Search in sources :

Example 1 with Transcript

use of com.hartwig.hmftools.svannotation.annotations.Transcript in project hmftools by hartwigmedical.

the class GeneFusionData method from.

@NotNull
public static GeneFusionData from(@NotNull final GeneFusion fusion) {
    final Transcript upstream = fusion.upstreamLinkedAnnotation();
    final Transcript downstream = fusion.downstreamLinkedAnnotation();
    return ImmutableGeneFusionData.builder().geneStart(upstream.geneName()).geneStartEntrezIds(upstream.parent().entrezIds()).geneContextStart(exonDescription(upstream)).geneStartTranscript(upstream.transcriptId()).geneEnd(downstream.geneName()).geneEndEntrezIds(downstream.parent().entrezIds()).geneContextEnd(exonDescription(downstream)).geneEndTranscript(downstream.transcriptId()).copies(ploidyToCopiesString(fusionPloidy(fusion))).cosmicURL(fusion.cosmicURL()).build();
}
Also used : Transcript(com.hartwig.hmftools.svannotation.annotations.Transcript) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with Transcript

use of com.hartwig.hmftools.svannotation.annotations.Transcript in project hmftools by hartwigmedical.

the class MySQLAnnotator method annotateBreakend.

@NotNull
private List<GeneAnnotation> annotateBreakend(@NotNull EnrichedStructuralVariant variant, final boolean isStart, @NotNull String chromosome, final long position) {
    final List<GeneAnnotation> result = Lists.newArrayList();
    final Result<?> genes = queryGenesOnChromosomeAndPosition(chromosome, position);
    for (final Record gene : genes) {
        final UInteger geneId = gene.get(GENE.GENE_ID);
        final String geneName = gene.get(XREF.DISPLAY_LABEL);
        final String geneStableId = gene.get(GENE.STABLE_ID);
        final UInteger canonicalTranscriptId = gene.get(GENE.CANONICAL_TRANSCRIPT_ID);
        final int geneStrand = gene.get(GENE.SEQ_REGION_STRAND);
        final List<Integer> entrezIds = Arrays.stream(gene.get(ENTREZ_IDS, String.class).split(",")).map(Integer::parseInt).collect(Collectors.toList());
        final String karyotypeBand = gene.get(KARYOTYPE_BAND, String.class);
        final List<String> synonyms = context.select(XREF.DBPRIMARY_ACC).from(XREF).innerJoin(OBJECT_XREF).on(OBJECT_XREF.XREF_ID.eq(XREF.XREF_ID)).and(OBJECT_XREF.ENSEMBL_ID.eq(geneId)).and(OBJECT_XREF.ENSEMBL_OBJECT_TYPE.eq(ObjectXrefEnsemblObjectType.Gene)).fetch().stream().map(r -> r.get(XREF.DBPRIMARY_ACC)).collect(Collectors.toList());
        final GeneAnnotation geneAnnotation = new GeneAnnotation(variant, isStart, geneName, geneStableId, geneStrand, synonyms, entrezIds, karyotypeBand);
        final Result<?> transcripts = context.select(TRANSCRIPT.TRANSCRIPT_ID, TRANSCRIPT.STABLE_ID).from(TRANSCRIPT).where(TRANSCRIPT.GENE_ID.eq(geneId)).fetch();
        for (final Record transcriptRecord : transcripts) {
            Transcript transcript = buildTranscript(geneAnnotation, transcriptRecord, position, canonicalTranscriptId, geneStrand > 0);
            if (transcript != null) {
                geneAnnotation.addTranscript(transcript);
            }
        }
        if (!geneAnnotation.transcripts().isEmpty()) {
            result.add(geneAnnotation);
        }
    }
    return result;
}
Also used : UInteger(org.jooq.types.UInteger) EXON_TRANSCRIPT(org.ensembl.database.homo_sapiens_core.Tables.EXON_TRANSCRIPT) Arrays(java.util.Arrays) Connection(java.sql.Connection) DSL(org.jooq.impl.DSL) Xref(org.ensembl.database.homo_sapiens_core.tables.Xref) StructuralVariantAnnotation(com.hartwig.hmftools.svannotation.annotations.StructuralVariantAnnotation) SEQ_REGION(org.ensembl.database.homo_sapiens_core.Tables.SEQ_REGION) DSL.decode(org.jooq.impl.DSL.decode) ObjectXrefEnsemblObjectType(org.ensembl.database.homo_sapiens_core.enums.ObjectXrefEnsemblObjectType) TRANSCRIPT(org.ensembl.database.homo_sapiens_core.Tables.TRANSCRIPT) Condition(org.jooq.Condition) SQLException(java.sql.SQLException) Lists(com.google.common.collect.Lists) KARYOTYPE(org.ensembl.database.homo_sapiens_core.Tables.KARYOTYPE) UInteger(org.jooq.types.UInteger) GeneStatus(org.ensembl.database.homo_sapiens_core.enums.GeneStatus) DSLContext(org.jooq.DSLContext) SQLDialect(org.jooq.SQLDialect) EnrichedStructuralVariant(com.hartwig.hmftools.common.variant.structural.EnrichedStructuralVariant) Record(org.jooq.Record) GeneAnnotation(com.hartwig.hmftools.svannotation.annotations.GeneAnnotation) OBJECT_XREF(org.ensembl.database.homo_sapiens_core.Tables.OBJECT_XREF) Result(org.jooq.Result) Collectors(java.util.stream.Collectors) Transcript(com.hartwig.hmftools.svannotation.annotations.Transcript) XREF(org.ensembl.database.homo_sapiens_core.Tables.XREF) COORD_SYSTEM(org.ensembl.database.homo_sapiens_core.Tables.COORD_SYSTEM) Nullable(org.jetbrains.annotations.Nullable) EXON(org.ensembl.database.homo_sapiens_core.Tables.EXON) List(java.util.List) DSL.groupConcatDistinct(org.jooq.impl.DSL.groupConcatDistinct) GENE(org.ensembl.database.homo_sapiens_core.Tables.GENE) NotNull(org.jetbrains.annotations.NotNull) DriverManager(java.sql.DriverManager) GeneAnnotation(com.hartwig.hmftools.svannotation.annotations.GeneAnnotation) Transcript(com.hartwig.hmftools.svannotation.annotations.Transcript) UInteger(org.jooq.types.UInteger) Record(org.jooq.Record) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with Transcript

use of com.hartwig.hmftools.svannotation.annotations.Transcript in project hmftools by hartwigmedical.

the class GeneDisruptionData method from.

@NotNull
public static GeneDisruptionData from(@NotNull final GeneDisruption disruption) {
    final Transcript transcript = disruption.linkedAnnotation();
    final GeneAnnotation gene = transcript.parent();
    // TODO (KODU): Add upstream/downstream annotation
    // final boolean upstream = gene.variant().orientation(gene.isStart()) > 0;
    // + (upstream ? " Upstream" : " Downstream");
    final String geneContext = exonDescription(transcript);
    return ImmutableGeneDisruptionData.builder().chromosome(gene.variant().chromosome(gene.isStart())).gene(gene.geneName()).geneContext(geneContext).type(gene.variant().type().name()).copies(ploidyToCopiesString(gene.variant().ploidy())).chromosomeBand(gene.karyotypeBand()).build();
}
Also used : Transcript(com.hartwig.hmftools.svannotation.annotations.Transcript) GeneAnnotation(com.hartwig.hmftools.svannotation.annotations.GeneAnnotation) PatientReportFormat.ploidyToCopiesString(com.hartwig.hmftools.patientreporter.util.PatientReportFormat.ploidyToCopiesString) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with Transcript

use of com.hartwig.hmftools.svannotation.annotations.Transcript in project hmftools by hartwigmedical.

the class MySQLAnnotator method buildTranscript.

@Nullable
private Transcript buildTranscript(@NotNull GeneAnnotation parent, @NotNull Record transcript, long position, @NotNull UInteger canonicalTranscriptId, boolean isForwardStrand) {
    final UInteger transcriptId = transcript.get(TRANSCRIPT.TRANSCRIPT_ID);
    final boolean canonical = transcriptId.equals(canonicalTranscriptId);
    final String transcriptStableId = transcript.get(TRANSCRIPT.STABLE_ID);
    final Record exonLeft = context.select(EXON_TRANSCRIPT.RANK, EXON.PHASE, EXON.END_PHASE).from(EXON_TRANSCRIPT).innerJoin(EXON).on(EXON.EXON_ID.eq(EXON_TRANSCRIPT.EXON_ID)).where(EXON_TRANSCRIPT.TRANSCRIPT_ID.eq(transcriptId)).and(EXON.SEQ_REGION_START.le(UInteger.valueOf(position))).orderBy(EXON.SEQ_REGION_START.desc()).limit(1).fetchOne();
    final Record exonRight = context.select(EXON_TRANSCRIPT.RANK, EXON.PHASE, EXON.END_PHASE).from(EXON_TRANSCRIPT).innerJoin(EXON).on(EXON.EXON_ID.eq(EXON_TRANSCRIPT.EXON_ID)).where(EXON_TRANSCRIPT.TRANSCRIPT_ID.eq(transcriptId)).and(EXON.SEQ_REGION_END.ge(UInteger.valueOf(position))).orderBy(EXON.SEQ_REGION_END.asc()).limit(1).fetchOne();
    final int exonMax = context.select(EXON_TRANSCRIPT.RANK).from(EXON_TRANSCRIPT).where(EXON_TRANSCRIPT.TRANSCRIPT_ID.eq(transcriptId)).orderBy(EXON_TRANSCRIPT.RANK.desc()).limit(1).fetchOne().value1();
    final int exonUpstream;
    final int exonUpstreamPhase;
    final int exonDownstream;
    final int exonDownstreamPhase;
    if (isForwardStrand) {
        exonUpstream = exonLeft == null ? 0 : exonLeft.get(EXON_TRANSCRIPT.RANK);
        exonUpstreamPhase = exonLeft == null ? -1 : exonLeft.get(EXON.END_PHASE);
        exonDownstream = exonRight == null ? 0 : exonRight.get(EXON_TRANSCRIPT.RANK);
        exonDownstreamPhase = exonRight == null ? -1 : exonRight.get(EXON.PHASE);
    } else {
        exonDownstream = exonLeft == null ? 0 : exonLeft.get(EXON_TRANSCRIPT.RANK);
        exonDownstreamPhase = exonLeft == null ? -1 : exonLeft.get(EXON.PHASE);
        exonUpstream = exonRight == null ? 0 : exonRight.get(EXON_TRANSCRIPT.RANK);
        exonUpstreamPhase = exonRight == null ? -1 : exonRight.get(EXON.END_PHASE);
    }
    if (exonUpstream > 0 && exonDownstream == 0) {
        // NERA: past the last exon
        return null;
    } else {
        return new Transcript(parent, transcriptStableId, exonUpstream, exonUpstreamPhase, exonDownstream, exonDownstreamPhase, exonMax, canonical);
    }
}
Also used : Transcript(com.hartwig.hmftools.svannotation.annotations.Transcript) UInteger(org.jooq.types.UInteger) Record(org.jooq.Record) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with Transcript

use of com.hartwig.hmftools.svannotation.annotations.Transcript in project hmftools by hartwigmedical.

the class StructuralVariantAnalyzer method toReportableGeneFusions.

@NotNull
private List<GeneFusion> toReportableGeneFusions(@NotNull List<List<Pair<Transcript, Transcript>>> fusionsPerVariant) {
    final List<GeneFusion> result = Lists.newArrayList();
    for (final List<Pair<Transcript, Transcript>> fusions : fusionsPerVariant) {
        Optional<Pair<Transcript, Transcript>> reportableFusion = determineReportableFusion(fusions);
        for (final Pair<Transcript, Transcript> fusion : fusions) {
            final Transcript upstream = fusion.getLeft();
            final Transcript downstream = fusion.getRight();
            final CosmicFusionData cosmic = transcriptsMatchKnownFusion(upstream, downstream);
            final boolean promiscuousEnd = oneEndPromiscuous(upstream, downstream);
            final boolean reportable = reportableFusion.isPresent() && reportableFusion.get() == fusion && (cosmic != null || promiscuousEnd);
            final GeneFusion geneFusion = ImmutableGeneFusion.builder().reportable(reportable).upstreamLinkedAnnotation(upstream).downstreamLinkedAnnotation(downstream).cosmicURL(cosmic != null ? cosmic.cosmicURL() : "").build();
            result.add(geneFusion);
        }
    }
    return result;
}
Also used : Transcript(com.hartwig.hmftools.svannotation.annotations.Transcript) GeneFusion(com.hartwig.hmftools.svannotation.annotations.GeneFusion) ImmutableGeneFusion(com.hartwig.hmftools.svannotation.annotations.ImmutableGeneFusion) CosmicFusionData(com.hartwig.hmftools.common.cosmic.fusions.CosmicFusionData) Pair(org.apache.commons.lang3.tuple.Pair) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Transcript (com.hartwig.hmftools.svannotation.annotations.Transcript)8 NotNull (org.jetbrains.annotations.NotNull)6 GeneAnnotation (com.hartwig.hmftools.svannotation.annotations.GeneAnnotation)5 StructuralVariantAnnotation (com.hartwig.hmftools.svannotation.annotations.StructuralVariantAnnotation)4 GeneFusion (com.hartwig.hmftools.svannotation.annotations.GeneFusion)3 List (java.util.List)3 Pair (org.apache.commons.lang3.tuple.Pair)3 Nullable (org.jetbrains.annotations.Nullable)3 UInteger (org.jooq.types.UInteger)3 Lists (com.google.common.collect.Lists)2 CosmicFusionData (com.hartwig.hmftools.common.cosmic.fusions.CosmicFusionData)2 EnrichedStructuralVariant (com.hartwig.hmftools.common.variant.structural.EnrichedStructuralVariant)2 GeneDisruption (com.hartwig.hmftools.svannotation.annotations.GeneDisruption)2 ImmutableGeneFusion (com.hartwig.hmftools.svannotation.annotations.ImmutableGeneFusion)2 Collectors (java.util.stream.Collectors)2 Record (org.jooq.Record)2 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 Multimap (com.google.common.collect.Multimap)1 CosmicFusionModel (com.hartwig.hmftools.common.cosmic.fusions.CosmicFusionModel)1 HmfGenomeRegion (com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion)1