当前位置: 首页>>代码示例>>Java>>正文


Java SAMRecord.getAlignmentStart方法代码示例

本文整理汇总了Java中net.sf.samtools.SAMRecord.getAlignmentStart方法的典型用法代码示例。如果您正苦于以下问题:Java SAMRecord.getAlignmentStart方法的具体用法?Java SAMRecord.getAlignmentStart怎么用?Java SAMRecord.getAlignmentStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.samtools.SAMRecord的用法示例。


在下文中一共展示了SAMRecord.getAlignmentStart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processOneUnalignedRecord

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
/**
 * Converts a SAM record into a bed entry and outputs it straight away
 *
 * @param record
 */
private void processOneUnalignedRecord(SAMRecord record) {

    // output the alignment positions into a bed file
    int start = record.getAlignmentStart() - 1;
    int end = start + record.getReadLength();
    String out = record.getReferenceName() + "\t" + start + "\t" + end + "\n";

    synchronized (outunaligned) {
        try {
            outunaligned.write(out.getBytes());
        } catch (Exception ex) {
            System.out.println("Exception writing unaligned bed: " + ex.getMessage());
        }
    }

    // create a dummy thesaurus entry
    ThesaurusEntry entry = new ThesaurusEntry(record, ginfo);
    // complete it (need to fix alignment end manually, then use function to get anchors set right)
    entry.alignEnd = entry.originEnd;
    completeThesaurusEntry(entry, record);
    // set the origin chromosome to -1 to signal unaligned setup
    entry.originChrIndex = -1;
    outputThesaurusEntry(entry, outstreams.get(entry.getAlignChr()));

}
 
开发者ID:tkonopka,项目名称:GeneticThesaurus,代码行数:31,代码来源:ThesaurusWrite.java

示例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();
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);
  }
 
开发者ID:shaunmahony,项目名称:multigps-archive,代码行数:24,代码来源:SAMFileHitLoader.java

示例3: 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++;
  }
 
开发者ID:shaunmahony,项目名称:multigps-archive,代码行数:26,代码来源:SAMReader.java

示例4: getAlignedPairs

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
private static List<AlignedPair> getAlignedPairs(final SAMRecord record) {
    int q = 0, r = record.getAlignmentStart() - 1;
    List<AlignedPair> result = new ArrayList<AlignedPair>();
    for (final CigarElement e : record.getCigar().getCigarElements()) {
        final CigarOperator op = e.getOperator();
        for (int i = 0; i < e.getLength(); i++) {
            result.add(new AlignedPair(op.consumesReadBases() ? q++ : -1,
                    op.consumesReferenceBases() ? r++ : -1));
        }
    }
    return result;
}
 
开发者ID:cmccoy,项目名称:startreerenaissance,代码行数:13,代码来源:SAMBEASTUtils.java

示例5: alignmentOfRecord

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
/**
 * Create a BEAST-compatible alignment from a SAM record and reference bases.
 *
 * @param record Aligned read
 * @param rSeq   All reference sequence bases
 * @param onlyCertain Convert uncertain bases to 'N'?
 * @return An alignment, covering all bases of rSeq
 */
public static Alignment alignmentOfRecord(final SAMRecord record, final byte[] rSeq, final boolean onlyCertain) {
    StringBuilder rAln = new StringBuilder(), qAln = new StringBuilder();
    SimpleAlignment alignment = new SimpleAlignment();

    final byte[] qSeq = record.getReadBases();
    byte[] certainty = null;
    if (onlyCertain)
        certainty = record.getByteArrayAttribute("bq");


    for (int i = 0; i < record.getAlignmentStart() - 1; i++) {
        rAln.append((char) rSeq[i]);
        qAln.append('-');
    }
    for (AlignedPair p : getAlignedPairs(record)) {
        if (p.consumesReference()) {
            rAln.append((char) rSeq[p.getReferencePosition()]);
            if (p.consumesQuery()) {
                if(onlyCertain && certainty[p.getQueryPosition()] % 100 != 0)
                    qAln.append('N');
                else
                    qAln.append((char) qSeq[p.getQueryPosition()]);
            } else
                qAln.append('-');
        }
    }
    for (int i = qAln.length(); i < rSeq.length; i++) {
        rAln.append((char) rSeq[i]);
        qAln.append('-');
    }

    alignment.addSequence(new Sequence(new Taxon(record.getReferenceName()), rAln.toString()));
    alignment.addSequence(new Sequence(new Taxon(record.getReadName()), qAln.toString()));

    return alignment;
}
 
开发者ID:cmccoy,项目名称:startreerenaissance,代码行数:45,代码来源:SAMBEASTUtils.java

示例6: getAlignedPairs

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
/**
 * Get aligned pairs from a SAM record
 * <p/>
 * This mimics pysams AlignedRead.aligned_pairs
 *
 * @param record Aligned read
 * @return List of aligned (reference, query) indices
 */
public static List<AlignedPair> getAlignedPairs(final SAMRecord record) {
    Preconditions.checkNotNull(record);
    int q = 0, r = record.getAlignmentStart() - 1;
    List<AlignedPair> result = Lists.newArrayList();
    for (final CigarElement e : record.getCigar().getCigarElements()) {
        final CigarOperator op = e.getOperator();
        for (int i = 0; i < e.getLength(); i++) {
            result.add(new AlignedPair(op.consumesReadBases() ? q++ : -1,
                    op.consumesReferenceBases() ? r++ : -1));
        }
    }
    return result;
}
 
开发者ID:cmccoy,项目名称:startreerenaissance,代码行数:22,代码来源:SAMUtils.java

示例7: 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;
}
 
开发者ID:tkonopka,项目名称:GeneticThesaurus,代码行数:41,代码来源:ThesaurusEntry.java

示例8: 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();
}
 
开发者ID:tkonopka,项目名称:GeneticThesaurus,代码行数:18,代码来源:ThesaurusSAMRecord.java

示例9: 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();
}
 
开发者ID:REDetector,项目名称:RED,代码行数:13,代码来源:SequenceRead.java

示例10: 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++;
		}
	}
}
 
开发者ID:s-andrews,项目名称:BamQC,代码行数:30,代码来源:RpkmReference.java

示例11: 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;
}
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:38,代码来源:SAMPairedEndFileReader.java

示例12: 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;
}
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:34,代码来源:CountProbes.java

示例13: SAMFormatFullBED

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
public static Gene SAMFormatFullBED(SAMRecord sam){
	String chr=sam.getReferenceName();
   	int start=sam.getAlignmentStart()-1; //TODO: Do we need the -1, it is a left over from the method above.
   	Strand strand=sam.getReadNegativeStrandFlag() ? Strand.NEGATIVE : Strand.POSITIVE;
   	String cigar= sam.getCigarString(); //parse cigar and put the breaks into their component parts, in parallel keep track of the splices
   	Collection<Alignments> aligns=parseCigar(cigar, chr, start);
	Gene gene=new Gene( aligns);
	gene.setName(sam.getReadName());
	gene.setOrientation(strand);
	if(sam.getReadString() != null) {gene.setSequence(sam.getReadString()); }
   	return gene;
}
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:13,代码来源:AlignmentUtils.java

示例14: SingleEndAlignment

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
public SingleEndAlignment(SAMRecord read) {
  	super(read.getReferenceName(), read.getAlignmentStart()-1, read.getAlignmentStart()); //This is a dummy setup
  	parseCigar(read.getCigarString(), read.getReferenceName(), read.getAlignmentStart()-1);
  	long startT = System.nanoTime();
  	setName(read.getReadName());
long cTime = System.nanoTime() - startT;
cTime = Math.round(cTime/(double)1000000);
if(cTime > 50) {
	logger.debug("parse set read name  took " + cTime);
}

startT = System.nanoTime();
  	if (read.getReadNegativeStrandFlag()) 
  		setOrientation(Strand.NEGATIVE);
  	else
  		setOrientation(Strand.POSITIVE);
cTime = System.nanoTime() - startT;
cTime = Math.round(cTime/(double)1000000);
if(cTime > 50) {
	logger.debug("Set orientation took " + cTime);
}

  	startT = System.nanoTime();
  	try {
  		record = (SAMRecord) read.clone();
  	} catch (CloneNotSupportedException e) {
  		logger.warn("Caught exception on record " + read.getReadName());
  		e.printStackTrace();
  	}
  	//record=new WrapSamRecord(read);
  	assert(read.getAlignmentEnd() == getEnd()); // sanity check
cTime = System.nanoTime() - startT;
cTime = Math.round(cTime/(double)1000000);
if(cTime > 50) {
	logger.debug("Cloning object took " + cTime);
}
  }
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:38,代码来源:SingleEndAlignment.java

示例15: isCompatiblePair

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
private boolean isCompatiblePair(SAMRecord r1, SAMRecord r2) {
	if(r1.getReferenceName()==r2.getReferenceName()){
		if((r1.getAlignmentStart()==r2.getMateAlignmentStart())&& (r1.getMateAlignmentStart()==r2.getAlignmentStart())){
			if(r1.getMateNegativeStrandFlag()==r2.getReadNegativeStrandFlag() && r1.getReadNegativeStrandFlag()==r2.getMateNegativeStrandFlag()){
				if(r1.getMateReferenceName().equalsIgnoreCase(r2.getReferenceName()) && r2.getMateReferenceName().equalsIgnoreCase(r1.getReferenceName())){
					return true;
				}
			}
		}
	}
	return false;
}
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:13,代码来源:AlignmentPair.java


注:本文中的net.sf.samtools.SAMRecord.getAlignmentStart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。