JAL-2154 JAL-2106 transfer primary refs to CDS for makeCDS
authorJim Procter <jprocter@issues.jalview.org>
Thu, 25 Aug 2016 19:52:43 +0000 (20:52 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Thu, 25 Aug 2016 19:52:43 +0000 (20:52 +0100)
src/jalview/analysis/AlignmentUtils.java

index bed685a..cc80384 100644 (file)
@@ -1734,28 +1734,41 @@ public class AlignmentUtils
            * same source and accession, so need a different accession for
            * the CDS from the dna sequence
            */
+          
           // 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);
-          // }
+          
+          for (DBRefEntry primRef : dnaDss.getPrimaryDBRefs())
+          {
+            // creates a complementary cross-reference to the source sequence's
+            // primary reference.
+
+            DBRefEntry cdsCrossRef = new DBRefEntry(primRef.getSource(),
+                    primRef.getSource() + ":" + primRef.getVersion(),
+                    primRef.getAccessionId());
+            cdsCrossRef
+                    .setMap(new Mapping(dnaDss, new MapList(dnaToCdsMap)));
+            cdsSeqDss.addDBRef(cdsCrossRef);
+
+            // 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(
+                    primRef.getSource(), primRef.getVersion(),
+                    cdsSeq.getName());
+            //
+            proteinToCdsRef.setMap(new Mapping(cdsSeqDss, cdsToProteinMap
+                    .getInverse()));
+            proteinProduct.addDBRef(proteinToCdsRef);
+          }
 
           /*
            * transfer any features on dna that overlap the CDS