use of org.ensembl.database.homo_sapiens_core.Tables.XREF 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;
}
use of org.ensembl.database.homo_sapiens_core.Tables.XREF in project hmftools by hartwigmedical.
the class MySQLAnnotator method queryGenesOnChromosomeAndPosition.
@NotNull
private Result<?> queryGenesOnChromosomeAndPosition(@NotNull String chromosome, long position) {
final int promoterDistance = 10000;
final byte zero = 0;
final Xref ENTREZ_XREF = XREF.as("entrez_xref");
return context.select(GENE.GENE_ID, XREF.DISPLAY_LABEL, GENE.STABLE_ID, GENE.CANONICAL_TRANSCRIPT_ID, GENE.SEQ_REGION_STRAND, groupConcatDistinct(ENTREZ_XREF.DBPRIMARY_ACC).separator(",").as(ENTREZ_IDS), groupConcatDistinct(KARYOTYPE.BAND).separator("-").as(KARYOTYPE_BAND)).from(GENE).innerJoin(SEQ_REGION).on(GENE.SEQ_REGION_ID.eq(SEQ_REGION.SEQ_REGION_ID)).and(SEQ_REGION.NAME.eq(chromosome)).and(SEQ_REGION.COORD_SYSTEM_ID.eq(coordSystemId)).innerJoin(KARYOTYPE).on(GENE.SEQ_REGION_ID.eq(KARYOTYPE.SEQ_REGION_ID)).innerJoin(OBJECT_XREF).on(GENE.GENE_ID.eq(OBJECT_XREF.ENSEMBL_ID)).and(OBJECT_XREF.ENSEMBL_OBJECT_TYPE.eq(ObjectXrefEnsemblObjectType.Gene)).innerJoin(ENTREZ_XREF).on(OBJECT_XREF.XREF_ID.eq(ENTREZ_XREF.XREF_ID)).and(ENTREZ_XREF.EXTERNAL_DB_ID.eq(UInteger.valueOf(1300))).innerJoin(XREF).on(XREF.XREF_ID.eq(GENE.DISPLAY_XREF_ID)).where(GENE.STATUS.eq(GeneStatus.KNOWN)).and(decode().when(GENE.SEQ_REGION_STRAND.gt(zero), decode().when(GENE.SEQ_REGION_START.ge(UInteger.valueOf(promoterDistance)), GENE.SEQ_REGION_START.sub(promoterDistance)).otherwise(GENE.SEQ_REGION_START)).otherwise(GENE.SEQ_REGION_START).le(UInteger.valueOf(position))).and(decode().when(GENE.SEQ_REGION_STRAND.lt(zero), GENE.SEQ_REGION_END.add(promoterDistance)).otherwise(GENE.SEQ_REGION_END).ge(UInteger.valueOf(position))).and(geneStartInKaryotypeBand().or(geneEndInKaryotypeBand())).groupBy(GENE.GENE_ID).fetch();
}
Aggregations