use of com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion in project hmftools by hartwigmedical.
the class BachelorEligibility method fromMap.
static BachelorEligibility fromMap(final Map<String, Program> input) {
final BachelorEligibility result = new BachelorEligibility();
for (final Program program : input.values()) {
final Multimap<String, String> geneToEnsemblMap = HashMultimap.create();
program.getPanel().stream().map(ProgramPanel::getGene).flatMap(Collection::stream).forEach(g -> geneToEnsemblMap.put(g.getName(), g.getEnsembl()));
// NOTE: copy number and SVs are untested/unverified for now, but leave in support for them
// process copy number sections
final List<Predicate<GeneCopyNumber>> cnvPredicates = Lists.newArrayList();
for (final ProgramPanel panel : program.getPanel()) {
final List<GeneIdentifier> genes = panel.getGene();
if (panel.getEffect().contains(OtherEffect.HOMOZYGOUS_DELETION)) {
final Predicate<GeneCopyNumber> geneCopyNumberPredicate = cnv -> genes.stream().anyMatch(g -> g.getEnsembl().equals(cnv.transcriptID()));
// TODO: we are matching on transcript ID here but we only have canonical transcripts in our panel file
cnvPredicates.add(geneCopyNumberPredicate);
}
}
// process structural variant disruptions
final List<Predicate<HmfGenomeRegion>> disruptionPredicates = Lists.newArrayList();
for (final ProgramPanel panel : program.getPanel()) {
final List<GeneIdentifier> genes = panel.getGene();
if (panel.getEffect().contains(OtherEffect.GENE_DISRUPTION)) {
final Predicate<HmfGenomeRegion> disruptionPredicate = sv -> genes.stream().anyMatch(g -> g.getEnsembl().equals(sv.transcriptID()));
// TODO: we are matching on transcript ID here but we only have canonical transcripts in our panel file
disruptionPredicates.add(disruptionPredicate);
}
}
// process variants from vcf
final List<Predicate<VariantModel>> panelPredicates = Lists.newArrayList();
List<String> requiredEffects = Lists.newArrayList();
List<String> panelTranscripts = Lists.newArrayList();
for (final ProgramPanel panel : program.getPanel()) {
final List<GeneIdentifier> genes = panel.getGene();
// take up a collection of the effects to search for
requiredEffects = panel.getSnpEffect().stream().map(SnpEffect::value).collect(Collectors.toList());
panelTranscripts = genes.stream().map(GeneIdentifier::getEnsembl).collect(Collectors.toList());
final List<String> effects = requiredEffects;
final Predicate<VariantModel> panelPredicate = v -> genes.stream().anyMatch(p -> v.sampleAnnotations().stream().anyMatch(a -> a.featureID().equals(p.getEnsembl()) && effects.stream().anyMatch(x -> a.effects().contains(x))));
panelPredicates.add(panelPredicate);
// update query targets
for (final GeneIdentifier g : genes) {
final HmfGenomeRegion region = allTranscriptsMap.get(g.getEnsembl());
if (region == null) {
final HmfGenomeRegion namedRegion = allGenesMap.get(g.getName());
if (namedRegion == null) {
LOGGER.warn("Program {} gene {} non-canonical transcript {} couldn't find region, transcript will be skipped", program.getName(), g.getName(), g.getEnsembl());
// just skip this gene for now
} else {
result.variantLocationsToQuery.add(namedRegion);
}
} else {
result.variantLocationsToQuery.add(region);
}
}
}
final Predicate<VariantModel> inPanel = v -> panelPredicates.stream().anyMatch(p -> p.test(v));
final Predicate<VariantModel> inBlacklist = new BlacklistPredicate(geneToEnsemblMap.values(), program.getBlacklist());
final Predicate<VariantModel> inWhitelist = new WhitelistPredicate(geneToEnsemblMap, program.getWhitelist());
final Predicate<VariantModel> snvPredicate = v -> inPanel.test(v) ? !inBlacklist.test(v) : inWhitelist.test(v);
final Predicate<GeneCopyNumber> copyNumberPredicate = cnv -> cnvPredicates.stream().anyMatch(p -> p.test(cnv)) && cnv.minCopyNumber() < MAX_COPY_NUMBER_FOR_LOSS;
final Predicate<HmfGenomeRegion> disruptionPredicate = disruption -> disruptionPredicates.stream().anyMatch(p -> p.test(disruption));
BachelorProgram bachelorProgram = new BachelorProgram(program.getName(), snvPredicate, copyNumberPredicate, disruptionPredicate, requiredEffects, panelTranscripts);
result.programs.add(bachelorProgram);
}
return result;
}
use of com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion in project hmftools by hartwigmedical.
the class CanonicalTranscriptFactory method create.
@NotNull
public static List<CanonicalTranscript> create(@NotNull final Collection<HmfGenomeRegion> regions) {
final List<CanonicalTranscript> transcripts = Lists.newArrayList();
for (final HmfGenomeRegion region : regions) {
final CanonicalTranscript transcript = create(region);
transcripts.add(transcript);
}
return transcripts;
}
use of com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion in project hmftools by hartwigmedical.
the class GeneCopyNumberFactory method geneCopyNumbers.
@NotNull
public static List<GeneCopyNumber> geneCopyNumbers(@NotNull final List<HmfGenomeRegion> genes, @NotNull final List<PurpleCopyNumber> somaticCopyNumbers, @NotNull final List<PurpleCopyNumber> germlineDeletions, @NotNull final List<PurityAdjustedSomaticVariant> enrichedSomatics) {
final ListMultimap<String, PurityAdjustedSomaticVariant> variantMap = Multimaps.index(enrichedSomatics, SomaticVariant::gene);
final List<GeneCopyNumber> result = Lists.newArrayList();
for (HmfGenomeRegion gene : genes) {
final List<PurityAdjustedSomaticVariant> variants = variantMap.containsKey(gene.gene()) ? variantMap.get(gene.gene()) : Collections.EMPTY_LIST;
final GeneCopyNumberBuilder builder = new GeneCopyNumberBuilder(gene);
RegionZipper.zip(somaticCopyNumbers, gene.exome(), builder);
RegionZipper.zip(germlineDeletions, gene.exome(), builder);
variants.forEach(builder::somatic);
GeneCopyNumber geneCopyNumber = builder.build();
if (geneCopyNumber.totalRegions() > 0) {
result.add(geneCopyNumber);
}
}
return result;
}
use of com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion in project hmftools by hartwigmedical.
the class HmfGenePanelSupplierTest method loadedRegionsAreSortedCorrectly.
@Test
public void loadedRegionsAreSortedCorrectly() {
final SortedSetMultimap<String, HmfGenomeRegion> geneRegions = HmfGenePanelSupplier.allGeneMap();
for (final String chromosome : geneRegions.keySet()) {
long start = 0;
for (final HmfGenomeRegion hmfGenomeRegion : geneRegions.get(chromosome)) {
assertTrue(hmfGenomeRegion.start() >= start);
start = hmfGenomeRegion.start();
}
}
}
use of com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion in project hmftools by hartwigmedical.
the class CanonicalTranscriptFactoryTest method testPTEN.
@Test
public void testPTEN() {
final HmfGenomeRegion region = select("PTEN.tsv");
final CanonicalTranscript transcript = CanonicalTranscriptFactory.create(region);
assertTranscript(transcript, 9, 9, 9027, 403);
}
Aggregations