Search in sources :

Example 1 with ChromosomeLength

use of com.hartwig.hmftools.common.chromosome.ChromosomeLength in project hmftools by hartwigmedical.

the class CountSupplier method fromBam.

@NotNull
public Multimap<Chromosome, CobaltCount> fromBam(@NotNull final String referenceBam, @NotNull final String tumorBam) throws IOException, ExecutionException, InterruptedException {
    final File tumorFile = new File(tumorBam);
    final File referenceFile = new File(referenceBam);
    final SamReaderFactory readerFactory = SamReaderFactory.make();
    final String chromosomeLengthFileName = ChromosomeLengthFile.generateFilename(outputDirectory, tumor);
    final List<ChromosomeLength> lengths;
    try (SamReader reader = readerFactory.open(tumorFile)) {
        lengths = ChromosomeLengthFactory.create(reader.getFileHeader());
    }
    ChromosomeLengthFile.write(chromosomeLengthFileName, lengths);
    LOGGER.info("Calculating Read Count from {}", tumorFile.toString());
    final List<Future<ChromosomeReadCount>> tumorFutures = createFutures(readerFactory, tumorFile, lengths);
    LOGGER.info("Calculating Read Count from {}", referenceFile.toString());
    final List<Future<ChromosomeReadCount>> referenceFutures = createFutures(readerFactory, referenceFile, lengths);
    final Multimap<String, ReadCount> tumorCounts = fromFutures(tumorFutures);
    final Multimap<String, ReadCount> referenceCounts = fromFutures(referenceFutures);
    LOGGER.info("Read Count Complete");
    return CobaltCountFactory.merge(referenceCounts, tumorCounts);
}
Also used : SamReader(htsjdk.samtools.SamReader) SamReaderFactory(htsjdk.samtools.SamReaderFactory) Future(java.util.concurrent.Future) File(java.io.File) CobaltCountFile(com.hartwig.hmftools.common.cobalt.CobaltCountFile) ChromosomeLengthFile(com.hartwig.hmftools.common.chromosome.ChromosomeLengthFile) CobaltRatioFile(com.hartwig.hmftools.common.cobalt.CobaltRatioFile) ReadCountFile(com.hartwig.hmftools.common.cobalt.ReadCountFile) ChromosomeLength(com.hartwig.hmftools.common.chromosome.ChromosomeLength) ReadCount(com.hartwig.hmftools.common.cobalt.ReadCount) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ChromosomeLength

use of com.hartwig.hmftools.common.chromosome.ChromosomeLength in project hmftools by hartwigmedical.

the class CountSupplier method createFutures.

@NotNull
private List<Future<ChromosomeReadCount>> createFutures(final SamReaderFactory readerFactory, final File file, final List<ChromosomeLength> lengths) {
    final List<Future<ChromosomeReadCount>> futures = Lists.newArrayList();
    for (ChromosomeLength chromosome : lengths) {
        final ChromosomeReadCount callable = new ChromosomeReadCount(file, readerFactory, chromosome.chromosome(), chromosome.length(), windowSize, minMappingQuality);
        futures.add(executorService.submit(callable));
    }
    return futures;
}
Also used : Future(java.util.concurrent.Future) ChromosomeLength(com.hartwig.hmftools.common.chromosome.ChromosomeLength) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ChromosomeLength (com.hartwig.hmftools.common.chromosome.ChromosomeLength)2 Future (java.util.concurrent.Future)2 NotNull (org.jetbrains.annotations.NotNull)2 ChromosomeLengthFile (com.hartwig.hmftools.common.chromosome.ChromosomeLengthFile)1 CobaltCountFile (com.hartwig.hmftools.common.cobalt.CobaltCountFile)1 CobaltRatioFile (com.hartwig.hmftools.common.cobalt.CobaltRatioFile)1 ReadCount (com.hartwig.hmftools.common.cobalt.ReadCount)1 ReadCountFile (com.hartwig.hmftools.common.cobalt.ReadCountFile)1 SamReader (htsjdk.samtools.SamReader)1 SamReaderFactory (htsjdk.samtools.SamReaderFactory)1 File (java.io.File)1