Exemplo n.º 1
0
  /**
   * Creates an empty GATKSAMRecord with the read's header, read group and mate information, but
   * empty (not-null) fields: - Cigar String - Read Bases - Base Qualities
   *
   * <p>Use this method if you want to create a new empty GATKSAMRecord based on another
   * GATKSAMRecord
   *
   * @param read a read to copy the header from
   * @return a read with no bases but safe for the GATK
   */
  public static GATKSAMRecord emptyRead(GATKSAMRecord read) {
    final GATKSAMRecord emptyRead = new GATKSAMRecord(read.getHeader());
    emptyRead.setReferenceIndex(read.getReferenceIndex());
    emptyRead.setAlignmentStart(0);
    emptyRead.setMappingQuality(0);
    // setting read indexing bin last
    emptyRead.setFlags(read.getFlags());
    emptyRead.setMateReferenceIndex(read.getMateReferenceIndex());
    emptyRead.setMateAlignmentStart(read.getMateAlignmentStart());
    emptyRead.setInferredInsertSize(read.getInferredInsertSize());

    emptyRead.setCigarString("");
    emptyRead.setReadBases(new byte[0]);
    emptyRead.setBaseQualities(new byte[0]);

    SAMReadGroupRecord samRG = read.getReadGroup();
    emptyRead.clearAttributes();
    if (samRG != null) {
      GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(samRG);
      emptyRead.setReadGroup(rg);
    }

    GATKBin.setReadIndexingBin(emptyRead, 0);

    return emptyRead;
  }
Exemplo n.º 2
0
  /**
   * is this base inside the adaptor of the read?
   *
   * <p>There are two cases to treat here:
   *
   * <p>1) Read is in the negative strand => Adaptor boundary is on the left tail 2) Read is in the
   * positive strand => Adaptor boundary is on the right tail
   *
   * <p>Note: We return false to all reads that are UNMAPPED or have an weird big insert size
   * (probably due to mismapping or bigger event)
   *
   * @param read the read to test
   * @param basePos base position in REFERENCE coordinates (not read coordinates)
   * @return whether or not the base is in the adaptor
   */
  public static boolean isBaseInsideAdaptor(final GATKSAMRecord read, long basePos) {
    Integer adaptorBoundary = getAdaptorBoundary(read);
    if (adaptorBoundary == null || read.getInferredInsertSize() > DEFAULT_ADAPTOR_SIZE)
      return false;

    return read.getReadNegativeStrandFlag()
        ? basePos <= adaptorBoundary
        : basePos >= adaptorBoundary;
  }