Exemplo n.º 1
0
  /**
   * HACK TO CREATE GATKSAMRECORD BASED ONLY A SAMRECORD FOR TESTING PURPOSES ONLY
   *
   * @param read
   */
  public GATKSAMRecord(final SAMRecord read) {
    super(read.getHeader());
    super.setReferenceIndex(read.getReferenceIndex());
    super.setAlignmentStart(read.getAlignmentStart());
    super.setReadName(read.getReadName());
    super.setMappingQuality(read.getMappingQuality());
    // indexing bin done below
    super.setCigar(read.getCigar());
    super.setFlags(read.getFlags());
    super.setMateReferenceIndex(read.getMateReferenceIndex());
    super.setMateAlignmentStart(read.getMateAlignmentStart());
    super.setInferredInsertSize(read.getInferredInsertSize());
    SAMReadGroupRecord samRG = read.getReadGroup();
    SAMBinaryTagAndValue samAttr = GATKBin.getReadBinaryAttributes(read);
    if (samAttr == null) {
      clearAttributes();
    } else {
      setAttributes(samAttr);
    }
    if (samRG != null) {
      GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(samRG);
      setReadGroup(rg);
    }

    super.setFileSource(read.getFileSource());
    super.setReadName(read.getReadName());
    super.setCigarString(read.getCigarString());
    super.setReadBases(read.getReadBases());
    super.setBaseQualities(read.getBaseQualities());
    // From SAMRecord constructor: Do this after the above because setCigarString will clear it.
    GATKBin.setReadIndexingBin(this, GATKBin.getReadIndexingBin(read));
  }
Exemplo n.º 2
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;
  }