From 962206377bc2e31dd731c1e37a38a228f0609988 Mon Sep 17 00:00:00 2001 From: Renia Correya Date: Thu, 27 Jun 2024 11:01:05 +0100 Subject: [PATCH] JAL-4411 Record source metadata in derived/transferred annotation rows Add secondary structure provider as a property in the annotation rows when searched and added from 3d beacons. --- src/jalview/analysis/AlignmentUtils.java | 7 ++++ .../structure/StructureSelectionManager.java | 39 +++++++++++++++++++- src/jalview/util/Constants.java | 2 + 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index f69864f..3ca5bcb 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -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)) { diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index 9a9e2a2..36c8764 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -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 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 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) diff --git a/src/jalview/util/Constants.java b/src/jalview/util/Constants.java index bced9c8..f8e4e4f 100644 --- a/src/jalview/util/Constants.java +++ b/src/jalview/util/Constants.java @@ -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"; } -- 1.7.10.2