本文整理汇总了Java中net.sf.samtools.SAMRecord.setMateAlignmentStart方法的典型用法代码示例。如果您正苦于以下问题:Java SAMRecord.setMateAlignmentStart方法的具体用法?Java SAMRecord.setMateAlignmentStart怎么用?Java SAMRecord.setMateAlignmentStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.samtools.SAMRecord
的用法示例。
在下文中一共展示了SAMRecord.setMateAlignmentStart方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toSAMRecord
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
@Override
public final SAMRecord toSAMRecord() {
SAMRecord record = firstMate.toSAMRecord();
record.setAttribute(PairedEndWriter.readStartFlag, Integer.valueOf(firstMate.getSAMStart()));
record.setAttribute(PairedEndWriter.readCigarFlag, firstMate.getCigarString());
record.setAttribute(PairedEndWriter.mateSequenceFlag, secondMate.getReadSequence());
record.setAttribute(PairedEndWriter.mateCigarFlag, secondMate.getCigarString());
record.setMateAlignmentStart(secondMate.getSAMStart());
// add by @zhuxp
record.setAlignmentStart(this.getAlignmentStart()+1);
// end of add (test version)
Annotation fragment = getReadAlignmentBlocks(null);
record.setCigarString(fragment.getLengthOnReference() + "M"); // NOTE: losing information about indels in the SingleEndAlignments
record.setInferredInsertSize(fragment.getLengthOnReference());
return record;
}
示例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: 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;
}
示例4: writeRemainder
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
private void writeRemainder(Map<String, AlignmentPair> tempCollection) {
if(tempCollection.size() > 0) {
logger.warn("WARNING Remainder: "+tempCollection.size()+" writing as single end reads");
}
for(String name: tempCollection.keySet()){
Pair<Collection<SAMRecord>> pair=tempCollection.get(name);
Collection<SAMRecord> records;
if(pair.hasValue1() && pair.hasValue2()){
//throw new IllegalStateException("There are samples in both pairs that are unaccounted for: "+name);
//
//logger.error("There are samples in both pairs that are unaccounted for: "+name);
Collection<SAMRecord> fragmentRecords = tempCollection.get(name).makePairs();
//write to output
writeAll(fragmentRecords);
}
else{
if(pair.hasValue1()){records=pair.getValue1();}
else{records=pair.getValue2();}
for(SAMRecord record: records) {
// If mate is unpaired, fix SAMRecord settings accordingly
// Why were the following changes added? This seems to break things. -Jesse
//record.setReferenceIndex(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX);
//record.setAlignmentStart(SAMRecord.NO_ALIGNMENT_START);
record.setMateReferenceIndex(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX);
record.setMateAlignmentStart(SAMRecord.NO_ALIGNMENT_START);
record.setMateNegativeStrandFlag(!record.getReadNegativeStrandFlag());
record.setMateUnmappedFlag(true);
record.setAttribute(SAMTag.MQ.name(), null);
record.setInferredInsertSize(0);
}
}
}
}
示例5: removeMate
import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
private void removeMate(SAMRecord first) {
first.setMateUnmappedFlag(true);
first.setMateAlignmentStart(0);
first.setMateNegativeStrandFlag(false);
first.setMateReferenceName("*");
}