import jalview.api.FeatureColourI;
import jalview.api.FeatureSettingsModelI;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.GeneLoci;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
cdna.transferFeatures(gene.getFeatures().getPositionalFeatures(),
transcript.getDatasetSequence(), mapping, parentId);
+ mapTranscriptToChromosome(transcript, gene, mapping);
+
/*
* fetch and save cross-references
*/
}
/**
+ * If the gene has a mapping to chromosome coordinates, derive the transcript
+ * chromosome regions and save on the transcript sequence
+ *
+ * @param transcript
+ * @param gene
+ * @param mapping
+ * the mapping from gene to transcript positions
+ */
+ protected void mapTranscriptToChromosome(Sequence transcript,
+ SequenceI gene, MapList mapping)
+ {
+ GeneLoci loci = ((Sequence) gene).getGeneLoci();
+ if (loci == null)
+ {
+ return;
+ }
+
+ /*
+ * patch to ensure gene to chromosome mapping is complete
+ * (in case created before gene length was known)
+ */
+ MapList geneMapping = loci.getMapping();
+ if (geneMapping.getFromRanges().get(0)[1] == 0)
+ {
+ geneMapping.getFromRanges().get(0)[0] = gene.getStart();
+ geneMapping.getFromRanges().get(0)[1] = gene.getEnd();
+ }
+
+ List<int[]> exons = mapping.getFromRanges();
+ List<int[]> transcriptLoci = new ArrayList<>();
+
+ for (int[] exon : exons) {
+ transcriptLoci.add(geneMapping.locateInTo(exon[0], exon[1]));
+ }
+
+ List<int[]> transcriptRange = Arrays.asList(new int[] {
+ transcript.getStart(), transcript.getEnd() });
+ MapList mapList = new MapList(transcriptRange, transcriptLoci, 1, 1);
+ GeneLoci gl = new GeneLoci(loci.getSpecies(), loci.getReference(),
+ loci.getChromosome(), mapList, loci.isForwardStrand());
+
+ transcript.setGeneLoci(gl);
+ }
+
+ /**
* Returns the 'transcript_id' property of the sequence feature (or null)
*
* @param feature