Search in sources :

Example 1 with Slicer

use of com.hartwig.hmftools.common.slicing.Slicer in project hmftools by hartwigmedical.

the class ConsequenceDeterminerTest method worksAsExpected.

@Test
public void worksAsExpected() {
    final SortedSetMultimap<String, GenomeRegion> regionMap = TreeMultimap.create();
    GenomeRegion testRegion = GenomeRegionFactory.create(CHROMOSOME, POSITION - 10, POSITION + 10);
    regionMap.put(testRegion.chromosome(), testRegion);
    final Slicer slicer = SlicerFactory.fromRegions(regionMap);
    final Map<String, HmfGenomeRegion> transcriptMap = Maps.newHashMap();
    transcriptMap.put(TRANSCRIPT, hmfRegion());
    final ConsequenceDeterminer determiner = new ConsequenceDeterminer(slicer, transcriptMap);
    final VariantConsequence rightConsequence = VariantConsequence.MISSENSE_VARIANT;
    final VariantConsequence wrongConsequence = VariantConsequence.OTHER;
    final ImmutableVariantAnnotation.Builder annotationBuilder = createVariantAnnotationBuilder().featureID(TRANSCRIPT).featureType(ConsequenceDeterminer.FEATURE_TYPE_TRANSCRIPT).gene(GENE).hgvsCoding(HGVS_CODING).hgvsProtein(HGVS_PROTEIN);
    final VariantAnnotation rightAnnotation = annotationBuilder.consequences(Lists.newArrayList(rightConsequence)).build();
    final VariantAnnotation wrongAnnotation = annotationBuilder.consequences(Lists.newArrayList(wrongConsequence)).build();
    final ImmutableSomaticVariantImpl.Builder variantBuilder = SomaticVariantTestBuilderFactory.create().chromosome(CHROMOSOME).ref(REF).alt(ALT).cosmicID(COSMIC_ID).totalReadCount(TOTAL_READ_COUNT).alleleReadCount(ALLELE_READ_COUNT);
    final SomaticVariant rightVariant = variantBuilder.position(POSITION).annotations(Lists.newArrayList(rightAnnotation)).build();
    final SomaticVariant wrongConsequenceVariant = variantBuilder.position(POSITION).annotations(Lists.newArrayList(wrongAnnotation)).build();
    final SomaticVariant wrongPositionVariant = variantBuilder.position(WRONG_POSITION).annotations(Lists.newArrayList(rightAnnotation)).build();
    final List<VariantReport> findings = determiner.run(Lists.newArrayList(rightVariant, wrongConsequenceVariant, wrongPositionVariant)).findings();
    assertEquals(1, findings.size());
    final VariantReport report = findings.get(0);
    assertEquals(GENE, report.gene());
    assertEquals(CHROMOSOME + ":" + POSITION, report.variant().chromosomePosition());
    assertEquals(REF, report.variant().ref());
    assertEquals(ALT, report.variant().alt());
    assertEquals(TRANSCRIPT + "." + TRANSCRIPT_VERSION, report.transcript());
    assertEquals(HGVS_CODING, report.hgvsCoding());
    assertEquals(HGVS_PROTEIN, report.hgvsProtein());
    assertEquals(rightConsequence.readableSequenceOntologyTerm(), report.consequence());
    assertEquals(COSMIC_ID, report.cosmicID());
    assertEquals(TOTAL_READ_COUNT, report.totalReadCount());
    assertEquals(ALLELE_READ_COUNT, report.alleleReadCount());
}
Also used : SomaticVariant(com.hartwig.hmftools.common.variant.SomaticVariant) Slicer(com.hartwig.hmftools.common.slicing.Slicer) ImmutableVariantAnnotation(com.hartwig.hmftools.common.variant.snpeff.ImmutableVariantAnnotation) VariantAnnotation(com.hartwig.hmftools.common.variant.snpeff.VariantAnnotation) VariantConsequence(com.hartwig.hmftools.common.variant.VariantConsequence) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) ImmutableHmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.ImmutableHmfGenomeRegion) GenomeRegion(com.hartwig.hmftools.common.region.GenomeRegion) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) ImmutableHmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.ImmutableHmfGenomeRegion) ImmutableSomaticVariantImpl(com.hartwig.hmftools.common.variant.ImmutableSomaticVariantImpl) ImmutableVariantAnnotation(com.hartwig.hmftools.common.variant.snpeff.ImmutableVariantAnnotation) Test(org.junit.Test)

Example 2 with Slicer

use of com.hartwig.hmftools.common.slicing.Slicer in project hmftools by hartwigmedical.

the class StrelkaPostProcessApplication method main.

public static void main(final String... args) throws ParseException, IOException {
    final Options options = createOptions();
    final CommandLine cmd = createCommandLine(options, args);
    final String highConfidenceBed = cmd.getOptionValue(HIGH_CONFIDENCE_BED);
    final String inputVcf = cmd.getOptionValue(INPUT_VCF);
    final String outputVcf = cmd.getOptionValue(OUTPUT_VCF);
    final String sampleName = cmd.getOptionValue(SAMPLE_NAME);
    final String tumorBam = cmd.getOptionValue(TUMOR_BAM);
    if (highConfidenceBed == null || inputVcf == null || outputVcf == null || sampleName == null || tumorBam == null) {
        final HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("Strelka Post Process", options);
        System.exit(1);
    }
    final Slicer highConfidenceSlicer = SlicerFactory.fromBedFile(highConfidenceBed);
    LOGGER.info("Starting strelka post process on " + inputVcf);
    processVariants(inputVcf, highConfidenceSlicer, outputVcf, sampleName, tumorBam);
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) Slicer(com.hartwig.hmftools.common.slicing.Slicer)

Example 3 with Slicer

use of com.hartwig.hmftools.common.slicing.Slicer in project hmftools by hartwigmedical.

the class BamSlicerApplication method getIntervalsFromBED.

@NotNull
private static QueryInterval[] getIntervalsFromBED(@NotNull final String bedPath, @NotNull final SAMFileHeader header) throws IOException {
    final Slicer bedSlicer = SlicerFactory.fromBedFile(bedPath);
    final List<QueryInterval> queryIntervals = Lists.newArrayList();
    for (final GenomeRegion region : bedSlicer.regions()) {
        queryIntervals.add(new QueryInterval(header.getSequenceIndex(region.chromosome()), (int) region.start(), (int) region.end()));
    }
    return QueryInterval.optimizeIntervals(queryIntervals.toArray(new QueryInterval[queryIntervals.size()]));
}
Also used : Slicer(com.hartwig.hmftools.common.slicing.Slicer) GenomeRegion(com.hartwig.hmftools.common.region.GenomeRegion) QueryInterval(htsjdk.samtools.QueryInterval) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Slicer (com.hartwig.hmftools.common.slicing.Slicer)3 GenomeRegion (com.hartwig.hmftools.common.region.GenomeRegion)2 HmfGenomeRegion (com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion)1 ImmutableHmfGenomeRegion (com.hartwig.hmftools.common.region.hmfslicer.ImmutableHmfGenomeRegion)1 ImmutableSomaticVariantImpl (com.hartwig.hmftools.common.variant.ImmutableSomaticVariantImpl)1 SomaticVariant (com.hartwig.hmftools.common.variant.SomaticVariant)1 VariantConsequence (com.hartwig.hmftools.common.variant.VariantConsequence)1 ImmutableVariantAnnotation (com.hartwig.hmftools.common.variant.snpeff.ImmutableVariantAnnotation)1 VariantAnnotation (com.hartwig.hmftools.common.variant.snpeff.VariantAnnotation)1 QueryInterval (htsjdk.samtools.QueryInterval)1 CommandLine (org.apache.commons.cli.CommandLine)1 HelpFormatter (org.apache.commons.cli.HelpFormatter)1 Options (org.apache.commons.cli.Options)1 NotNull (org.jetbrains.annotations.NotNull)1 Test (org.junit.Test)1