use of com.hartwig.hmftools.common.cobalt.ReadCount 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);
}
Aggregations