Examples of Cigar


Examples of net.sf.samtools.Cigar

    String contigInfo = read.getStringAttribute("YA");
    if (contigInfo != null) {
      // Get assembled contig info.
      String[] fields = contigInfo.split(":");
      int contigPos = Integer.parseInt(fields[1]);
      Cigar contigCigar = TextCigarCodec.getSingleton().decode(fields[2]);
     
      // Check to see if contig contains indel at current locus
      elem = checkForIndelAtLocus(contigPos, contigCigar, refPos);
     
      if (elem != null) {
View Full Code Here

Examples of net.sf.samtools.Cigar

      // 0 based
      int startIdx = actualPos - contig.getAlignmentStart();
      endIdx = Math.min(startIdx + readLength*2, contig.getReadLength()-1);
//      int endIdx = Math.min(end - contig.getAlignmentStart(), startIdx+contig.getReadLength()-1); // inclusive
      String bases = contig.getReadString().substring(startIdx, endIdx+1);
      Cigar cigar = SAMRecordUtils.subset(contig.getCigar(), startIdx, endIdx);
     
      SAMRecord chunk = cloneRead(contig);
      // Using a static variable because contigs may overlap multiple regions and cause dupes
      chunk.setReadName(chunk.getReadName() + "_" + chunkIdx++);
      chunk.setAlignmentStart(actualPos + calcIndelOffset(startIdx, contig.getCigar()));
View Full Code Here

Examples of net.sf.samtools.Cigar

 
  private BaseInfo getBaseAtReferencePosition(SAMRecord read, int refPos) {
    boolean isNearEdge = false;
    boolean isIndel = false;
    int alignmentStart = read.getAlignmentStart();
    Cigar cigar = read.getCigar();
   
    char base = 'N';
   
    int readIdx = 0;
    int currRefPos = alignmentStart;
   
    for (CigarElement element : cigar.getCigarElements()) {
           
      if (element.getOperator() == CigarOperator.M) {
        readIdx += element.getLength();
        currRefPos += element.getLength();
       
View Full Code Here

Examples of net.sf.samtools.Cigar

       
//        System.out.println("o: " + origReadAltRef);
       
        if (origReadAltRef != null) {
          for (int i=indelPos; i>0; i--) {
            Cigar newCigar = shiftCigarLeft(read.getCigar(), i);
           
            String shiftedReadAltRef = c2r.getAlternateReference(read, newCigar);
           
            if ((shiftedReadAltRef != null) && (origReadAltRef.equals(shiftedReadAltRef))) {         
              SAMRecord newRead = cloneRead(read);
View Full Code Here

Examples of net.sf.samtools.Cigar

      throw new RuntimeException(e);
    }
  }
 
  protected Cigar shiftCigarLeft(Cigar cigar, int positionsToShift) {
    Cigar newCigar = new Cigar();
   
    for (int i=0; i<cigar.getCigarElements().size(); i++) {
      CigarElement elem = cigar.getCigarElement(i);
     
      if (isFirstNonSoftClippedElem(i, cigar)) {
        int newLen = elem.getLength() - positionsToShift;
       
        if (newLen > 0) {
          CigarElement newElem = new CigarElement(newLen, elem.getOperator());
          newCigar.add(newElem);
        }
      } else if (isLastNonSoftClippedElem(i, cigar)) {
        if (elem.getOperator() == CigarOperator.M) {
          CigarElement newElem = new CigarElement(elem.getLength() + positionsToShift, CigarOperator.M);
          newCigar.add(newElem);
        } else {
          CigarElement newElem = new CigarElement(positionsToShift, CigarOperator.M);
          newCigar.add(elem);
          newCigar.add(newElem);
        }
      } else {
        newCigar.add(elem);
      }
    }
   
    return newCigar;
  }
View Full Code Here

Examples of net.sf.samtools.Cigar

    Assert.assertEquals(read.getReadString(), "CCCCAGCC");
  }
 
  @Test (groups = "unit")
  public void testSubsetCigar_exact() {
    Cigar cigar = getCigar("100M");
    Cigar cigar2 = SAMRecordUtils.subset(cigar, 0, 99);
    Assert.assertEquals(cigar2.toString(), "100M");
  }
View Full Code Here

Examples of net.sf.samtools.Cigar

    Assert.assertEquals(cigar2.toString(), "100M");
  }
 
  @Test (groups = "unit")
  public void testSubsetCigar_lessThan1Elem() {
    Cigar cigar = getCigar("100M");
    Cigar cigar2 = SAMRecordUtils.subset(cigar, 0, 90);
    Assert.assertEquals(cigar2.toString(), "91M");
  }
View Full Code Here

Examples of net.sf.samtools.Cigar

    Assert.assertEquals(cigar2.toString(), "91M");
  }
 
  @Test (groups = "unit")
  public void testSubsetCigar_lessThan1Elem2() {
    Cigar cigar = getCigar("100M");
    Cigar cigar2 = SAMRecordUtils.subset(cigar, 10, 99);
    Assert.assertEquals(cigar2.toString(), "90M");
  }
View Full Code Here

Examples of net.sf.samtools.Cigar

    Assert.assertEquals(cigar2.toString(), "90M");
  }
 
  @Test (groups = "unit")
  public void testSubsetCigar_lessThan1Elem3() {
    Cigar cigar = getCigar("100M");
    Cigar cigar2 = SAMRecordUtils.subset(cigar, 10, 90);
    Assert.assertEquals(cigar2.toString(), "81M");
  }
View Full Code Here

Examples of net.sf.samtools.Cigar

    Assert.assertEquals(cigar2.toString(), "81M");
  }
 
  @Test (groups = "unit")
  public void testSubsetCigar_lessThanFirstElem() {
    Cigar cigar = getCigar("100M100I100M");
    Cigar cigar2 = SAMRecordUtils.subset(cigar, 10, 90);
    Assert.assertEquals(cigar2.toString(), "81M");
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.