本文整理汇总了Java中htsjdk.samtools.SAMRecord.getReferenceIndex方法的典型用法代码示例。如果您正苦于以下问题:Java SAMRecord.getReferenceIndex方法的具体用法?Java SAMRecord.getReferenceIndex怎么用?Java SAMRecord.getReferenceIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.samtools.SAMRecord
的用法示例。
在下文中一共展示了SAMRecord.getReferenceIndex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calcBAQFromHMM
import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
public BAQCalculationResult calcBAQFromHMM(SAMRecord read, RefContentProvider refContentProvider) {
// start is alignment start - band width / 2 - size of first I element, if there is one. Stop is similar
int offset = getBandWidth() / 2;
long readStart = includeClippedBases ? read.getUnclippedStart() : read.getAlignmentStart();
long start = Math.max(readStart - offset - ReadUtils.getFirstInsertionOffset(read), 0);
long stop = (includeClippedBases ? read.getUnclippedEnd() : read.getAlignmentEnd()) + offset + ReadUtils.getLastInsertionOffset(read);
if ( stop > refContentProvider.getSamSequenceDictionary().getSequence(read.getReferenceName()).getSequenceLength() ) {
return null;
} else {
// now that we have the start and stop, get the reference sequence covering it
GenomeLoc locus = new GenomeLoc(read.getReferenceName(), read.getReferenceIndex(), (int)start, (int)stop);
byte[] refSeq = refContentProvider.getReferenceContext(locus).getBases();
return calcBAQFromHMM(read, refSeq, (int)(start - readStart));
}
}
示例2: transfer
import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
/**
* Write the record.
*
* @param alignment SAMRecord.
*/
public BasicSamRecord transfer(final SAMRecord alignment) {
String readName = alignment.getReadName();
int flags = alignment.getFlags();
int contigId = alignment.getReferenceIndex();
if (contigId == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX) {
contigId = FAKE_CONTIG_ID;
}
String contigName = alignment.getReferenceName();
int position = alignment.getAlignmentStart();
int mapQ = alignment.getMappingQuality();
String cigar = alignment.getCigarString();
int mateContigId = alignment.getMateReferenceIndex();
if (mateContigId == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX) {
mateContigId = FAKE_CONTIG_ID;
}
String mateContigName = alignment.getMateReferenceName();
int matePosition = alignment.getMateAlignmentStart();
int inferredSize = alignment.getInferredInsertSize();
byte[] sequence = alignment.getReadString().getBytes();
byte[] quality = alignment.getBaseQualityString().getBytes();
List<SAMRecord.SAMTagAndValue> attributes = alignment.getAttributes();
List<String> encodedTags = new ArrayList<>(attributes.size());
for (SAMRecord.SAMTagAndValue attribute : attributes) {
encodedTags.add(tagCodec.encode(attribute.tag, attribute.value));
}
// 在这里统一不压缩,压缩操作是由scala代码中的执行引擎统一调配的。
return BasicSamRecord.apply(false, readName, flags, contigId, contigName, position, mapQ,
cigar, mateContigId, mateContigName, matePosition, inferredSize,
sequence, quality, encodedTags);
}
示例3: createGenomeLoc
import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
/**
* Create a genome loc, given a read. If the read is unmapped, *and* yet the read has a contig and start position,
* then a GenomeLoc is returned for contig:start-start, otherwise an UNMAPPED GenomeLoc is returned.
*
* @param read the read from which to create a genome loc
* @return the GenomeLoc that was created
*/
public GenomeLoc createGenomeLoc(final SAMRecord read) {
if (read.getReadUnmappedFlag() && read.getReferenceIndex() == -1)
// read is unmapped and not placed anywhere on the genome
return GenomeLoc.UNMAPPED;
else {
// Use Math.max to ensure that end >= start (Picard assigns the end to reads that are entirely within an insertion as start-1)
final int end = read.getReadUnmappedFlag() ? read.getAlignmentStart() : Math.max(read.getAlignmentEnd(), read.getAlignmentStart());
return createGenomeLoc(read.getReferenceName(), read.getReferenceIndex(), read.getAlignmentStart(), end, false);
}
}
示例4: createGenomeLocUnclipped
import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
/**
* Create a genome loc, given a read using its unclipped alignment. If the read is unmapped, *and* yet the read has a contig and start position,
* then a GenomeLoc is returned for contig:start-start, otherwise an UNMAPPED GenomeLoc is returned.
*
* @param read the read from which to create a genome loc
* @return the GenomeLoc that was created
*/
public GenomeLoc createGenomeLocUnclipped(final SAMRecord read) {
if (read.getReadUnmappedFlag() && read.getReferenceIndex() == -1)
// read is unmapped and not placed anywhere on the genome
return GenomeLoc.UNMAPPED;
else {
// Use Math.max to ensure that end >= start (Picard assigns the end to reads that are entirely within an insertion as start-1)
final int end = read.getReadUnmappedFlag() ? read.getUnclippedEnd() : Math.max(read.getUnclippedEnd(), read.getUnclippedStart());
return createGenomeLoc(read.getReferenceName(), read.getReferenceIndex(), read.getUnclippedStart(), end, false);
}
}
示例5: isReadUnmapped
import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
/**
* Due to (unfortunate) multiple ways to indicate that read is unmapped allowed by SAM format
* specification, one may need this convenience shortcut. Checks both 'read unmapped' flag and
* alignment reference index/start.
*
* Our life would be so much easier if all sam files followed the specs. In reality,
* sam files (including those generated by maq or bwa) miss headers altogether. When
* reading such a SAM file, reference name is set, but since there is no sequence dictionary,
* null is always returned for referenceIndex. Let's be paranoid here, and make sure that
* we do not call the read "unmapped" when it has only reference name set with ref. index missing
* or vice versa.
*
* @param r a non-null record
* @return true if read is unmapped
*/
public static boolean isReadUnmapped(final SAMRecord r) {
if ( r == null )
throw new IllegalArgumentException("Read cannot be null");
return r.getReadUnmappedFlag() ||
!((r.getReferenceIndex() != null && r.getReferenceIndex() != SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX ||
r.getReferenceName() != null && !r.getReferenceName().equals(SAMRecord.NO_ALIGNMENT_REFERENCE_NAME)) &&
r.getAlignmentStart() != SAMRecord.NO_ALIGNMENT_START);
}