Merge branch 'trailm' into trial_fixMakeCDSDBRefPropagation
[jalview.git] / src / jalview / analysis / AlignmentUtils.java
index c4e51b1..bed685a 100644 (file)
@@ -22,7 +22,6 @@ package jalview.analysis;
 
 import static jalview.io.gff.GffConstants.CLINICAL_SIGNIFICANCE;
 
-import jalview.api.DBRefEntryI;
 import jalview.datamodel.AlignedCodon;
 import jalview.datamodel.AlignedCodonFrame;
 import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping;
@@ -1682,6 +1681,10 @@ public class AlignmentUtils
            * its dataset sequence to the dataset
            */
           cdsSeq = makeCdsSequence(dnaSeq.getDatasetSequence(), aMapping);
+          // cdsSeq has a name constructed as CDS|<dbref>
+          // <dbref> will be either the accession for the coding sequence,
+          // marked in the /via/ dbref to the protein product accession
+          // or it will be the original nucleotide accession.
           SequenceI cdsSeqDss = cdsSeq.createDatasetSequence();
           cdsSeqs.add(cdsSeq);
           if (!dataset.getSequences().contains(cdsSeqDss))
@@ -1731,16 +1734,28 @@ public class AlignmentUtils
            * same source and accession, so need a different accession for
            * the CDS from the dna sequence
            */
-          DBRefEntryI dnaRef = dnaDss.getSourceDBRef();
-          if (dnaRef != null)
-          {
-            // assuming cds version same as dna ?!?
-            DBRefEntry proteinToCdsRef = new DBRefEntry(dnaRef.getSource(),
-                    dnaRef.getVersion(), cdsSeq.getName());
-            proteinToCdsRef.setMap(new Mapping(cdsSeqDss, cdsToProteinMap
-                    .getInverse()));
-            proteinProduct.addDBRef(proteinToCdsRef);
-          }
+          // specific use case:
+          // Genomic contig ENSCHR:1, contains coding regions for ENSG01,
+          // ENSG02, ENSG03, with transcripts and products similarly named.
+          // cannot add distinct dbrefs mapping location on ENSCHR:1 to ENSG01
+          // JBPNote: ?? can't actually create an example that demonstrates we
+          // need to
+          // synthesize an xref.
+          // TODO: merge conflicts from JAL-2154 branch and use PrimaryDBRefs()
+          // for (DBRefEntry primRef:dnaDss.getPrimaryDBRefs())
+          // {
+          // creates a complementary cross-reference to the source sequence's
+          // primary reference.
+
+          // // problem here is that the cross-reference is synthesized -
+          // cdsSeq.getName() may be like 'CDS|dnaaccession' or 'CDS|emblcdsacc'
+          // // assuming cds version same as dna ?!?
+          // DBRefEntry proteinToCdsRef = new DBRefEntry(dnaRef.getSource(),
+          // dnaRef.getVersion(), cdsSeq.getName());
+          // proteinToCdsRef.setMap(new Mapping(cdsSeqDss, cdsToProteinMap
+          // .getInverse()));
+          // proteinProduct.addDBRef(proteinToCdsRef);
+          // }
 
           /*
            * transfer any features on dna that overlap the CDS