JAL-4411 Record source metadata in derived/transferred annotation rows
authorRenia Correya <rcorreya001@dundee.ac.uk>
Thu, 27 Jun 2024 10:01:05 +0000 (11:01 +0100)
committerRenia Correya <rcorreya001@dundee.ac.uk>
Thu, 27 Jun 2024 10:01:05 +0000 (11:01 +0100)
Add secondary structure provider as a property in the annotation rows
when searched and added from 3d beacons.

src/jalview/analysis/AlignmentUtils.java
src/jalview/structure/StructureSelectionManager.java
src/jalview/util/Constants.java

index f69864f..3ca5bcb 100644 (file)
@@ -2986,6 +2986,13 @@ public class AlignmentUtils
       if (label.equals(aa.label))
       {
 
+        if (aa.getProperty(Constants.SS_PROVIDER_PROPERTY) != null) 
+        {
+          
+          return aa.getProperty(Constants.SS_PROVIDER_PROPERTY);
+          
+        }
+        
         // For JPred
         if (aa.label.equals(Constants.SS_ANNOTATION_FROM_JPRED_LABEL))
         {
index 9a9e2a2..36c8764 100644 (file)
@@ -56,6 +56,7 @@ import jalview.io.AppletFormatAdapter;
 import jalview.io.DataSourceType;
 import jalview.io.StructureFile;
 import jalview.structure.StructureImportSettings.TFType;
+import jalview.util.Constants;
 import jalview.util.MappingUtils;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
@@ -598,6 +599,7 @@ public class StructureSelectionManager
       }
 
       List<StructureMapping> seqToStrucMapping = new ArrayList<>();
+      String provider = null;
       if (isMapUsingSIFTs && seq.isProtein())
       {
         if (progress != null)
@@ -633,7 +635,6 @@ public class StructureSelectionManager
             maxChain.makeExactMapping(maxAlignseq, seq);
             maxChain.transferRESNUMFeatures(seq, "IEA:Jalview",
                     pdb.getId().toLowerCase(Locale.ROOT)); // FIXME: is
-            // this
             // "IEA:Jalview" ?
             maxChain.transferResidueAnnotation(nwMapping, sqmpping);
             ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0));
@@ -695,8 +696,42 @@ public class StructureSelectionManager
         StructureMapping nwMapping = getNWMappings(seq, pdbFile, maxChainId,
                 maxChain, pdb, maxAlignseq);
         seqToStrucMapping.add(nwMapping);
-        ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0));
+        ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0));  
       }
+      
+      //JAL-4392 TODO: Unable to match PDBProvider with Annotation without matching struct file path
+      String ssAnnotDescriptionInPDB = null;
+      String ssStructFilePathNameInPDB = pdb.getInFile(); //Structure file name in PDB data model
+      //Secondary structure annotations in pdb data model
+      AlignmentAnnotation[] ssAnnotationsInPDB = pdb.getSeqs().get(0).getAnnotation(Constants.SS_ANNOTATION_LABEL);
+      if(ssAnnotationsInPDB != null && ssAnnotationsInPDB.length>0) {
+        ssAnnotDescriptionInPDB = ssAnnotationsInPDB[0].description;
+      }
+      
+      //Match the PDB entry using file path in the pdb data model and get the provider
+      Vector<PDBEntry> pdbEntries = seq.getDatasetSequence().getAllPDBEntries();
+      for(PDBEntry pdbEntry : pdbEntries) {        
+        if(ssStructFilePathNameInPDB.startsWith(pdbEntry.getFile())) {
+          provider = pdbEntry.getProvider();
+          break;
+        }        
+      }
+      
+      //Add provider value as property to the ss annotation 
+      if(provider != null) {
+        AlignmentAnnotation[] ssAnnotList = ds.getAnnotation(Constants.SS_ANNOTATION_LABEL);
+        if(ssAnnotList != null) {
+          for(AlignmentAnnotation ssAnnot : ssAnnotList) {
+            //Match the annotation description with the annotation in pdb data object  
+            if(ssAnnot.getProperty(Constants.SS_PROVIDER_PROPERTY) == null 
+                    && ssAnnot.description.equals(ssAnnotDescriptionInPDB)) {
+              ssAnnot.setProperty(Constants.SS_PROVIDER_PROPERTY, provider);
+            }
+          }
+        }
+      }
+      
+      
       if (forStructureView)
       {
         for (StructureMapping sm : seqToStrucMapping)
index bced9c8..f8e4e4f 100644 (file)
@@ -46,4 +46,6 @@ public class Constants
       SECONDARY_STRUCTURE_LABELS.put(SS_ANNOTATION_FROM_JPRED_LABEL, "JPred");
       // Add other secondary structure labels here if needed
   } 
+  
+  public static final String SS_PROVIDER_PROPERTY = "SS_PROVIDER";
 }