本文整理汇总了Java中net.sf.samtools.SAMRecord.getAlignmentEnd方法的典型用法代码示例。如果您正苦于以下问题:Java SAMRecord.getAlignmentEnd方法的具体用法?Java SAMRecord.getAlignmentEnd怎么用?Java SAMRecord.getAlignmentEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.samtools.SAMRecord
的用法示例。
在下文中一共展示了SAMRecord.getAlignmentEnd方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRead
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
protected void processRead(Collection<SAMRecord> records) {
int mapcount = records.size();
if (mapcount == 0) {
return;
}
if (!useNonUnique && mapcount > 1) {
return;
}
float weight = 1 / ((float)mapcount);
Read currRead = new Read();
for (SAMRecord record : records) {
int start = record.getAlignmentStart();
int end = record.getAlignmentEnd();
ReadHit currHit = new ReadHit(
record.getReferenceName().replaceFirst("^chr", ""),
start, end,
record.getReadNegativeStrandFlag() ? '-' : '+',
weight);
currRead.addHit(currHit);
}currRead.setNumHits(mapcount);
addHits(currRead);
}
示例2: processRead
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
protected void processRead(Collection<SAMRecord> records) {
int mapcount = records.size();
if (mapcount == 0) {
return;
}
if (!useNonUnique && mapcount > 1) {
return;
}
float weight = 1 / ((float)mapcount);
Read currRead = new Read((int)totalWeight);
for (SAMRecord record : records) {
int start = record.getAlignmentStart();
int end = record.getAlignmentEnd();
ReadHit currHit = new ReadHit(gen, currID,
record.getReferenceName().replaceFirst("^chr", ""),
start, end,
record.getReadNegativeStrandFlag() ? '-' : '+',
weight);
currRead.addHit(currHit);
currID++;
}currRead.setNumHits(mapcount);
addHits(currRead);
totalWeight++;
}
示例3: ThesaurusEntry
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
/**
* Construct an entry by parsing a SAM record for a read.
*
* The read name should be of the format, e.g. T100;chr1:10001-10100 i.e.
* LABEL;CHROMOSOME;START-END
*
* Warning: this constructor will only set the following fields: originChr,
* originStart, originEnd, alignChr, alignStart, alignEnd. Other fields must
* be set via the separate set methods.
*
* @param record
*/
public ThesaurusEntry(SAMRecord record, GenomeInfo ginfo) {
this.ginfo = ginfo;
// parse the read name to get the origin location
String[] readelements = record.getReadName().split(";|:|-");
//originChr = readelements[1];
originChrIndex = ginfo.getChrIndex(readelements[1]);
originStart = Integer.parseInt(readelements[2]);
originEnd = Integer.parseInt(readelements[3]);
// get the alignment location
//alignChr = record.getReferenceName();
alignChrIndex = ginfo.getChrIndex(record.getReferenceName());
alignStart = record.getAlignmentStart();
alignEnd = record.getAlignmentEnd();
if (record.getReadNegativeStrandFlag()) {
alignStrand = '-';
} else {
alignStrand = '+';
}
anchors = new ArrayList<ThesaurusAnchor>(2);
// the anchor array will not be properly formed, i.e. any mismatches will not
// be recorded either in the anchors or in the penalty field.
ok = true;
}
示例4: ThesaurusSAMRecord
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
/**
* basic constructor that copies a SAMrecord and computes minimal things
*
* @param record
*/
public ThesaurusSAMRecord(SAMRecord record) {
this.record = record;
Cigar cigar = record.getCigar();
cigarsize = cigar.numCigarElements();
cigarelements = new CigarElement[cigarsize];
for (int i = 0; i < cigarsize; i++) {
cigarelements[i] = cigar.getCigarElement(i);
}
bases = record.getReadBases();
alignStart = record.getAlignmentStart();
alignEnd = record.getAlignmentEnd();
}
示例5: SequenceRead
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
public SequenceRead(SAMRecord record) {
super(record.getAlignmentStart(), record.getAlignmentEnd());
this.chr = record.getReferenceName();
if (record.getReadNegativeStrandFlag()) {
strand = Strand.NEGATIVE;
} else {
strand = Strand.POSITIVE;
}
this.readBases = record.getReadBases();
this.qualities = record.getBaseQualities();
this.alignmentBlocks = record.getAlignmentBlocks();
}
示例6: processSequence
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
@Override
public void processSequence(SAMRecord read) {
SAMFileHeader header = read.getHeader();
SAMSequenceDictionary samSequenceDictionary = header.getSequenceDictionary();
int referenceIndex = read.getReferenceIndex();
long alignmentStart = read.getAlignmentStart();
long alignmentEnd = read.getAlignmentEnd();
log.debug("header = " + header);
log.debug("referenceIndex = " + referenceIndex);
readNumber++;
if (referenceIndex > -1) {
if (!isBinNucleotidesSet) {
setBinNumber(samSequenceDictionary);
}
if (alignmentEnd > alignmentStart) {
long referenceStart = sequenceStarts.get(referenceIndex);
long alignmentStartAbsolute = alignmentStart + referenceStart;
long alignmentEndAbsolute = alignmentEnd + referenceStart;
recordCoverage(alignmentStartAbsolute, alignmentEndAbsolute);
}
else {
errorReads++;
}
}
}
示例7: convertToPairedEndFragment
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
public static SAMRecord convertToPairedEndFragment(SAMRecord rec) {
int insertSize = Math.abs(rec.getInferredInsertSize());
//TODO: possible to remove (insertSize > 0) clause? What does an insert size of 0 mean?
if (rec.getReadPairedFlag() && rec.getProperPairFlag() && !rec.getReadUnmappedFlag()
&& (insertSize <= MAX_INSERT) && (rec.getAlignmentStart() < rec.getMateAlignmentStart())
&& rec.getReferenceName() != "chrM") // current paired end representation doesn't do well with circular chromosomes
{
//We need to get the full fragment contained by read.getStart to pair.getEnd
int readEnd=rec.getAlignmentEnd();
int mateStart=rec.getMateAlignmentStart();
//int extension = insertSize - rec.getReadLength();
int extension=(mateStart-readEnd)+rec.getReadLength();
if (extension <= MAX_INSERT) {
String newRead = rec.getReadString() + StringUtils.repeat("N", extension);
rec.setReadString(newRead);
String newQual = StringUtils.repeat("A", newRead.length());
if(!rec.getBaseQualityString().equals("*")) newQual = rec.getBaseQualityString() + StringUtils.repeat("A", extension);
rec.setBaseQualityString(newQual);
String newCigar=newRead.length()+"M";
rec.setCigarString(newCigar);
// Change attributes to represent single read
rec.setMateReferenceName("*");
rec.setMateAlignmentStart(0);
rec.setFirstOfPairFlag(false);
rec.setMateNegativeStrandFlag(false);
rec.setMateUnmappedFlag(false);
rec.setProperPairFlag(false);
rec.setReadPairedFlag(false);
rec.setSecondOfPairFlag(false);
}
} else {
rec = null;
}
return rec;
}
示例8: readMapsToProbe
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
private boolean readMapsToProbe(SAMRecord read, SAMFileHeader header) {
if (read.getReadUnmappedFlag()) return false;
int left, right;
if (read.getReferenceName().contains("OriginalArray")) {
left = ORIGINAL_ARRAY_LEFT;
right = ORIGINAL_ARRAY_RIGHT;
} else if (read.getReferenceName().contains("MainArray")) {
left = MAIN_ARRAY_LEFT;
right = MAIN_ARRAY_RIGHT;
} else if (read.getReferenceName().contains("SimpleArray")) {
left = SIMPLE_ARRAY_LEFT;
right = SIMPLE_ARRAY_RIGHT;
} else if (read.getReferenceName().contains("140105")) {
left = ARRAY_140105;
right = ARRAY_140105;
} else if (read.getReferenceName().contains("Mouse")) {
left = MRNA_ARRAY_LEFT;
right = MRNA_ARRAY_RIGHT;
} else {
log.error("This reference name doesn't match: " + read.getReferenceName());
return false;
}
left = T7BASES + left;
right = header.getSequence(read.getReferenceIndex()).getSequenceLength() - right - T7BASES;
if ((read.getAlignmentStart() <= left - OVERLAP) || read.getAlignmentEnd() >= right + OVERLAP) {
return true;
}
return false;
}
示例9: purgeByDistance
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
/**
* Removes all pairs from the collection such that one of the mates is farther than the max insert size allowed
* @param tempCollection
*/
private Map<String, AlignmentPair> purgeByDistance(Map<String, AlignmentPair> tempCollection,int currentPosition) {
Map<String, AlignmentPair> newCollection = new TreeMap<String, AlignmentPair>();
for(String key : tempCollection.keySet()){
AlignmentPair pair=tempCollection.get(key);
boolean toAdd=true;
Iterator<SAMRecord> recordIter;
//For alignments where we are still waiting for the second one
if(!pair.hasValue1() || !pair.hasValue2()){
if(pair.hasValue1()){
recordIter=pair.getValue1().iterator();
}
else{recordIter=pair.getValue2().iterator();}
//pair.removeRecordsFartherThan(currentPosition);
while(recordIter.hasNext()) {
SAMRecord record = recordIter.next();
//if(we are farther than the current
if((currentPosition-record.getAlignmentEnd()) > maxAllowableInsert){
recordIter.remove();
if(pair.valuesAreEmpty())
toAdd=false;
}
}
}
if(toAdd)
newCollection.put(key, pair);
}
return newCollection;
}
示例10: getSingleEndRead
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
/**
* Gets a single end read.
*
* @param sections The tab split sections from the SAM file
* @param flag The binary flag field from the file
* @return The read which was read
* @throws SeqMonkException
*/
private SequenceReadWithChromosome getSingleEndRead (SAMRecord samRecord) throws SeqMonkException {
int strand;
int start;
int end;
start = samRecord.getAlignmentStart();
end = samRecord.getAlignmentEnd();
if (samRecord.getReadNegativeStrandFlag()) {
strand = Location.REVERSE;
}
else {
strand = Location.FORWARD;
}
if (extendBy > 0) {
if (strand == Location.FORWARD) {
end += extendBy;
}
else if (strand == Location.REVERSE) {
start -= extendBy;
}
}
ChromosomeWithOffset c;
try {
c = collection.genome().getChromosome(samRecord.getReferenceName());
}
catch (Exception iae) {
throw new SeqMonkException(iae.getLocalizedMessage());
}
start = c.position(start);
end = c.position(end);
// We also don't allow readings which are beyond the end of the chromosome
if (end > c.chromosome().length()) {
int overrun = end - c.chromosome().length();
throw new SeqMonkException("Reading position "+end+" was "+overrun+"bp beyond the end of chr"+c.chromosome().name()+" ("+c.chromosome().length()+")");
}
if (start < 1) {
throw new SeqMonkException("Reading position "+start+" was before the start of chr"+c.chromosome().name()+" ("+c.chromosome().length()+")");
}
// We can now make the new reading
SequenceReadWithChromosome read = new SequenceReadWithChromosome(c.chromosome(),SequenceRead.packPosition(start,end,strand));
return read;
}
示例11: getPairedEndRead
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
/**
* Gets a paired end read. This method assumes that it will only be passed reads which map
* to the reverse strand since these are the ones which contain enough information to
* unambiguously locate both ends of the pair.
*
* @param sections The tab split sections from the SAM file
* @param flag The binary flag field
* @return The read which was read
* @throws SeqMonkException
*/
private SequenceReadWithChromosome getPairedEndRead (SAMRecord samRecord) throws SeqMonkException {
int strand;
int start;
int end;
if (!samRecord.getReadNegativeStrandFlag()) {
throw new SeqMonkException("Read passed to parse pair was not on the negative strand");
}
if (samRecord.getMateNegativeStrandFlag()) {
throw new SeqMonkException("Ignored discordantly stranded read pair");
}
end = samRecord.getAlignmentEnd();
start = samRecord.getMateAlignmentStart();
if (start > end) {
throw new SeqMonkException("Ignored discordantly stranded read pair");
}
if (samRecord.getFirstOfPairFlag()) {
strand = Location.REVERSE;
}
else {
strand = Location.FORWARD;
}
if ((end - start)+1 > pairedEndDistance) {
throw new SeqMonkException("Distance between ends "+((end - start)+1)+" was larger than cutoff ("+pairedEndDistance+")");
}
ChromosomeWithOffset c;
try {
c = dataCollection().genome().getChromosome(samRecord.getReferenceName());
}
catch (Exception e) {
throw new SeqMonkException(e.getLocalizedMessage());
}
start = c.position(start);
end = c.position(end);
// We also don't allow readings which are beyond the end of the chromosome
if (end > c.chromosome().length()) {
int overrun = end - c.chromosome().length();
throw new SeqMonkException("Reading position "+end+" was "+overrun+"bp beyond the end of chr"+c.chromosome().name()+" ("+c.chromosome().length()+")");
}
if (start < 1) {
throw new SeqMonkException("Reading position "+start+" was before the start of chr"+c.chromosome().name()+" ("+c.chromosome().length()+")");
}
// We can now make the new reading
SequenceReadWithChromosome read = new SequenceReadWithChromosome(c.chromosome(),SequenceRead.packPosition(start,end,strand));
return read;
}