Esempio n. 1
0
 @Override
 public boolean reallyFilterOut(final SAMRecord record) {
   return record.getDuplicateReadFlag();
 }
Esempio n. 2
0
  //
  //  Returns a downsampled set of reads for each sample.
  //
  private List<List<SAMRecord>> getReads(
      List<String> inputFiles, List<Feature> regions, ReAligner realigner) {

    int downsampleTarget = desiredNumberOfReads(regions);
    List<DownsampledReadList> readsList = new ArrayList<DownsampledReadList>();

    for (String input : inputFiles) {
      Set<String> readIds = new HashSet<String>();
      DownsampledReadList reads = new DownsampledReadList(downsampleTarget);
      readsList.add(reads);

      for (Feature region : regions) {
        SAMFileReader reader = new SAMFileReader(new File(input));
        reader.setValidationStringency(ValidationStringency.SILENT);

        Iterator<SAMRecord> iter;
        if (region != null) {
          iter =
              reader.queryOverlapping(
                  region.getSeqname(), (int) region.getStart(), (int) region.getEnd());
        } else {
          iter = reader.iterator();
        }

        while (iter.hasNext()) {

          SAMRecord read = iter.next();

          // Don't allow same read to be counted twice.
          if ((!realigner.isFiltered(read))
              && (!read.getDuplicateReadFlag())
              && (!read.getReadFailsVendorQualityCheckFlag())
              && (read.getMappingQuality() >= realigner.getMinMappingQuality()
                  || read.getReadUnmappedFlag())
              && (!readIds.contains(getIdentifier(read)))) {

            if (read.getReadString().length() > readLength) {
              reader.close();
              throw new IllegalArgumentException(
                  "Maximum read length of: "
                      + readLength
                      + " exceeded for: "
                      + read.getSAMString());
            }

            readIds.add(getIdentifier(read));

            reads.add(read);
          }
        }

        if (reads.getTotalReadCount() != reads.getReads().size()) {
          if (isDebug) {
            System.err.println(
                "downsampled: "
                    + regions.get(0).getDescriptor()
                    + ": "
                    + reads.getTotalReadCount()
                    + " -> "
                    + reads.getReads().size());
          }
        }

        reader.close();
      }
    }

    List<List<SAMRecord>> sampleReads = new ArrayList<List<SAMRecord>>();

    for (DownsampledReadList downsampledReads : readsList) {
      sampleReads.add(downsampledReads.getReads());
    }

    return sampleReads;
  }
Esempio n. 3
0
 /**
  * Returns true if we don't think this read is eligible for the BAQ calculation. Examples include
  * non-PF reads, duplicates, or unmapped reads. Used by baqRead to determine if a read should fall
  * through the calculation.
  *
  * @param read
  * @return
  */
 public boolean excludeReadFromBAQ(SAMRecord read) {
   // keeping mapped reads, regardless of pairing status, or primary alignment status.
   return read.getReadUnmappedFlag()
       || read.getReadFailsVendorQualityCheckFlag()
       || read.getDuplicateReadFlag();
 }