Exemplo n.º 1
0
  @Test
  public void testCountsFromLocusTraversal() {
    final GenomeAnalysisEngine engine = new GenomeAnalysisEngine();
    engine.setGenomeLocParser(genomeLocParser);

    final Collection<SAMReaderID> samFiles = new ArrayList<>();
    final SAMReaderID readerID = new SAMReaderID(testBAM, new Tags());
    samFiles.add(readerID);

    final SAMDataSource dataSource =
        new SAMDataSource(
            samFiles,
            new ThreadAllocation(),
            null,
            genomeLocParser,
            false,
            SAMFileReader.ValidationStringency.STRICT,
            null,
            null,
            new ValidationExclusion(),
            new ArrayList<ReadFilter>(),
            new ArrayList<ReadTransformer>(),
            false,
            (byte) 30,
            false,
            true);

    engine.setReadsDataSource(dataSource);
    final Set<String> samples = SampleUtils.getSAMFileSamples(dataSource.getHeader());

    final TraverseLociNano traverseLociNano = new TraverseLociNano(1);
    final DummyLocusWalker walker = new DummyLocusWalker();
    traverseLociNano.initialize(engine, walker, null);

    for (final Shard shard : dataSource.createShardIteratorOverAllReads(new LocusShardBalancer())) {
      final WindowMaker windowMaker =
          new WindowMaker(
              shard, genomeLocParser, dataSource.seek(shard), shard.getGenomeLocs(), samples);
      for (WindowMaker.WindowMakerIterator window : windowMaker) {
        final LocusShardDataProvider dataProvider =
            new LocusShardDataProvider(
                shard,
                shard.getReadProperties(),
                genomeLocParser,
                window.getLocus(),
                window,
                reference,
                new ArrayList<ReferenceOrderedDataSource>());
        traverseLociNano.traverse(walker, dataProvider, 0);
        dataProvider.close();
      }
      windowMaker.close();
    }

    // dataSource.close();
    Assert.assertEquals(
        engine.getCumulativeMetrics().getNumReadsSeen(), contigs.size() * numReadsPerContig);
    Assert.assertEquals(
        engine.getCumulativeMetrics().getNumIterations(), contigs.size() * numReadsPerContig);
  }
Exemplo n.º 2
0
  @Test
  public void testFilteredCounts() {
    final GenomeAnalysisEngine engine = new GenomeAnalysisEngine();
    engine.setGenomeLocParser(genomeLocParser);

    final Collection<SAMReaderID> samFiles = new ArrayList<>();
    final SAMReaderID readerID = new SAMReaderID(testBAM, new Tags());
    samFiles.add(readerID);

    final List<ReadFilter> filters = new ArrayList<>();
    filters.add(new EveryTenthReadFilter());

    final SAMDataSource dataSource =
        new SAMDataSource(
            samFiles,
            new ThreadAllocation(),
            null,
            genomeLocParser,
            false,
            SAMFileReader.ValidationStringency.STRICT,
            null,
            null,
            new ValidationExclusion(),
            filters,
            new ArrayList<ReadTransformer>(),
            false,
            (byte) 30,
            false,
            true);

    engine.setReadsDataSource(dataSource);

    final TraverseReadsNano traverseReadsNano = new TraverseReadsNano(1);
    final DummyReadWalker walker = new DummyReadWalker();
    traverseReadsNano.initialize(engine, walker, null);

    for (final Shard shard : dataSource.createShardIteratorOverAllReads(new ReadShardBalancer())) {
      final ReadShardDataProvider dataProvider =
          new ReadShardDataProvider(
              shard,
              engine.getGenomeLocParser(),
              dataSource.seek(shard),
              reference,
              new ArrayList<ReferenceOrderedDataSource>());
      traverseReadsNano.traverse(walker, dataProvider, 0);
      dataProvider.close();
    }

    Assert.assertEquals(
        (long)
            engine
                .getCumulativeMetrics()
                .getCountsByFilter()
                .get(EveryTenthReadFilter.class.getSimpleName()),
        contigs.size() * numReadsPerContig / 10);
  }
Exemplo n.º 3
0
  /**
   * this is the function that the inheriting class can expect to have called when the command line
   * system has initialized.
   *
   * @return the return code to exit the program with
   */
  protected int execute() throws Exception {
    engine.setParser(parser);
    argumentSources.add(this);

    Walker<?, ?> walker = engine.getWalkerByName(getAnalysisName());

    try {
      // Make sure a valid GATK user key is present, if required.
      authorizeGATKRun();

      engine.setArguments(getArgumentCollection());

      // File lists can require a bit of additional expansion.  Set these explicitly by the engine.
      engine.setSAMFileIDs(
          ListFileUtils.unpackBAMFileList(getArgumentCollection().samFiles, parser));

      engine.setWalker(walker);
      walker.setToolkit(engine);

      Collection<ReadFilter> filters = engine.createFilters();
      engine.setFilters(filters);

      // load the arguments into the walker / filters.
      // TODO: The fact that this extra load call exists here when all the parsing happens at the
      // engine
      // TODO: level indicates that we're doing something wrong.  Turn this around so that the GATK
      // can drive
      // TODO: argument processing.
      loadArgumentsIntoObject(walker);
      argumentSources.add(walker);

      Collection<RMDTriplet> rodBindings =
          ListFileUtils.unpackRODBindings(parser.getRodBindings(), parser);
      engine.setReferenceMetaDataFiles(rodBindings);

      for (ReadFilter filter : filters) {
        loadArgumentsIntoObject(filter);
        argumentSources.add(filter);
      }

      engine.execute();
      generateGATKRunReport(walker);
    } catch (Exception e) {
      generateGATKRunReport(walker, e);
      throw e;
    }

    // always return 0
    return 0;
  }
Exemplo n.º 4
0
  /**
   * GATK provides the walker as an argument source.
   *
   * @return List of walkers to load dynamically.
   */
  @Override
  protected Class[] getArgumentSources() {
    // No walker info?  No plugins.
    if (getAnalysisName() == null) return new Class[] {};

    Collection<Class> argumentSources = new ArrayList<Class>();

    Walker walker = engine.getWalkerByName(getAnalysisName());
    engine.setArguments(getArgumentCollection());
    engine.setWalker(walker);
    walker.setToolkit(engine);
    argumentSources.add(walker.getClass());

    Collection<ReadFilter> filters = engine.createFilters();
    for (ReadFilter filter : filters) argumentSources.add(filter.getClass());

    Class[] argumentSourcesAsArray = new Class[argumentSources.size()];
    return argumentSources.toArray(argumentSourcesAsArray);
  }
Exemplo n.º 5
0
 @Override
 protected String getArgumentSourceName(Class argumentSource) {
   return engine.getWalkerName((Class<Walker>) argumentSource);
 }