本文整理汇总了Java中net.sf.samtools.SAMRecord.setReferenceName方法的典型用法代码示例。如果您正苦于以下问题:Java SAMRecord.setReferenceName方法的具体用法?Java SAMRecord.setReferenceName怎么用?Java SAMRecord.setReferenceName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.samtools.SAMRecord
的用法示例。
在下文中一共展示了SAMRecord.setReferenceName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAlignmentOfRecord
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
@Test
public void testAlignmentOfRecord() throws Exception {
SAMRecord record = new SAMRecord(this.header);
record.setReadBases("TCCGTTAGTC".getBytes());
record.setReadName(queryName);
record.setCigarString("1S3M1I4M1S");
record.setReferenceIndex(0);
record.setReferenceName(this.referenceName);
record.setAlignmentStart(2);
assertEquals(referenceName, record.getReferenceName());
Alignment result = SAMBEASTUtils.alignmentOfRecord(record, this.reference);
assertEquals(2, result.getTaxonCount());
assertEquals(new String(reference), result.getAlignedSequenceString(0));
assertEquals("-CCGTAGT-", result.getAlignedSequenceString(1));
assertEquals(referenceName, result.getTaxonId(0));
assertEquals(queryName, result.getTaxonId(1));
}
示例2: createSAMRecord
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
/**
* Converts a blat psl entry into a SAM record.
*
* @param entry
* @param bases
* @param hh
* @param ns
*
* number of blat entries with the same score
*
* @param sd
*
* rank-dependent interpretation. For first rank, distance to next best
* match. For other ranks distance from first match.
*
* @param bs
*
* number of matches in best score
*
* @param matchrankA
*
* rank of this blat entry in a sorted list of entries (low rank means
* better alignment, modulo equal matching entries)
*
* @param matchrankB
*
* alternative rank (optimistic/pessimistic rank)
*
* @param readgroup
*
* @return
*/
private SAMRecord createSAMRecord(PslEntry entry, String bases, SAMFileHeader hh,
int ns, int sd, int bs, int matchrankA, int matchrankB, String readgroup) {
//System.out.println("in create pair");
SAMRecord sr = new SAMRecord(hh);
// set flags for a neutral read
sr.setFlags(0);
sr.setAlignmentStart(entry.Tstart + 1);
sr.setMateAlignmentStart(entry.Tstart + 1);
sr.setCigarString(entry.makeCigar());
sr.setReferenceName(entry.Tname);
sr.setReadName(entry.Qname);
sr.setMappingQuality(Math.min(254, entry.match));
if (entry.strand == '-') {
sr.setReadNegativeStrandFlag(true);
sr.setReadBases(SequenceComplementer.complement(bases.getBytes()));
} else {
sr.setReadNegativeStrandFlag(false);
sr.setReadBases(bases.getBytes());
}
sr.setBaseQualityString(makeBaseQuality(bases.length()));
sr.setAttribute("ns", ns);
sr.setAttribute("sd", sd);
sr.setAttribute("bs", bs);
sr.setAttribute("ra", matchrankA);
sr.setAttribute("rb", matchrankB);
sr.setAttribute("RG", readgroup);
return sr;
}
示例3: getSAMRecord
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
public SAMRecord getSAMRecord(SAMFileHeader hh) {
SAMRecord sr = new SAMRecord(hh);
// set flags for a neutral read
sr.setFlags(0);
sr.setReadName(getReadname());
sr.setBaseQualityString(makeBaseQuality(readsequence.length));
sr.setAttribute("RG", "thesalign");
sr.setNotPrimaryAlignmentFlag(!isPrimary());
sr.setAlignmentStart(alignpos + 1);
sr.setCigarString(readsequence.length + "M");
sr.setReferenceName(chrom);
sr.setMappingQuality(mappingquality);
if (negativestrand) {
sr.setReadNegativeStrandFlag(true);
sr.setReadBases(SequenceComplementer.complement(readsequence));
} else {
sr.setReadNegativeStrandFlag(false);
sr.setReadBases(readsequence);
}
// perhaps the read is unaligned (too many alignments to report)
if (unmapped) {
sr.setReadUnmappedFlag(unmapped);
}
return sr;
}
示例4: main
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
public static void main (String [] args) throws IOException {
ArgumentMap argMap = CLUtil.getParameters(args,USAGE , "default");
String alnFile = argMap.getInput();
String out = argMap.getOutput();
List<String> seqsToChange = new ArrayList<String>();
if(argMap.containsKey("seqsToFix")) {
seqsToChange = CLUtil.listFromArray(argMap.getMandatory("seqsToFix").split(","));
}
SAMFileReader reader = new SAMFileReader(new File(alnFile));
SAMFileWriterFactory samfwf = new SAMFileWriterFactory();
SAMFileHeader oldHeader = reader.getFileHeader();
SAMFileHeader header = oldHeader.clone();
header.setSortOrder(oldHeader.getSortOrder());
oldHeader.getAttributes();
for (Map.Entry<String, String> he : oldHeader.getAttributes()) {
header.setAttribute(he.getKey(), he.getValue());
}
header.addProgramRecord(new SAMProgramRecord("nextgen.core.programs.FixChromosomeNames -in " + alnFile + " -out " + out));
SAMSequenceDictionary ssd = header.getSequenceDictionary();
SAMSequenceDictionary newSSD = new SAMSequenceDictionary();
List<SAMSequenceRecord > sequences = ssd.getSequences();
for (SAMSequenceRecord s : sequences) {
if(seqsToChange.isEmpty() || seqsToChange.contains(s.getSequenceName())) {
SAMSequenceRecord ns = new SAMSequenceRecord("chr" + s.getSequenceName(), s.getSequenceLength());
ns.setAssembly(s.getAssembly());
ns.setSpecies(ns.getSpecies());
for (Map.Entry<String, String> e : s.getAttributes()) {
ns.setAttribute(e.getKey(), e.getValue());
}
newSSD.addSequence(ns);
} else {
newSSD.addSequence(s);
}
}
header.setSequenceDictionary(newSSD);
samfwf.setCreateIndex(true);
SAMFileWriter writer = samfwf.makeBAMWriter(header, true, new File(out)) ;
Iterator<SAMRecord> alnIt = reader.iterator();
while (alnIt.hasNext()) {
SAMRecord a = alnIt.next();
if(seqsToChange.isEmpty() || seqsToChange.contains(a.getReferenceName())) {
a.setReferenceName("chr"+a.getReferenceName());
a.setHeader(header);
}
writer.addAlignment(a);
}
reader.close();
writer.close();
}