JAL-2136 JAL-2137 Improved STRUCTMODEL annotation syntax to reinstated fasta file...
[jalview.git] / src / jalview / io / AnnotationFile.java
index c1ddeed..571ed79 100755 (executable)
@@ -1017,7 +1017,8 @@ public class AnnotationFile
         {
           boolean failedtoadd = true;
           // expect
-          // STRUCTMODEL <TemplateSeqId> <TemplateFileName> <Confidence> <%.I.D>
+          // STRUCTMODEL <TemplateSeqId> <ModelFile> <FastaMappingFile>
+          // <Confidence> <%.I.D>
           // <MatchStart> <MatchEnd> <Coverage> [<Other Information>]
           if (st.hasMoreTokens()) {
             refSeq = al.findName(refSeqId = st.nextToken());
@@ -1030,12 +1031,14 @@ public class AnnotationFile
             else
             {
               String tempId = st.nextToken();
+              String fastaMapping = st.nextToken();
               String confidence = 100 * Double.valueOf(st.nextToken()) + "";
               String pid = st.nextToken();
               String alignRange = st.nextToken() + "-" + st.nextToken();
               String otherInfo = st.hasMoreTokens() ? st.nextToken() : "";
               String coverage = "";
-              if (add_structmodel(al, refSeq, tempId, alignRange, coverage,
+              if (add_structmodel(al, refSeq, tempId, fastaMapping,
+                      alignRange, coverage,
                       confidence, pid, otherInfo))
               {
                 failedtoadd = false;
@@ -1045,7 +1048,7 @@ public class AnnotationFile
           if (failedtoadd)
           {
             System.err
-                    .println("Need <TemplateSeqId> <TemplateFileName> <Confidence> <%.I.D> <MatchStart> <MatchEnd> <Coverage> [<Other Information>] as tab separated fields after"
+                    .println("Need <TemplateSeqId> <ModelFile> <FastaMappingFile> <Confidence> <%.I.D> <MatchStart> <MatchEnd> <Coverage> [<Other Information>] as tab separated fields after"
                             + STRUCTMODEL
                             + ".\nNote: other information could be provided in html format ");
           } else {
@@ -1263,22 +1266,26 @@ public class AnnotationFile
    * @return true if model and sequence was added
    */
   private boolean add_structmodel(AlignmentI al, SequenceI refSeq,
-          String tempId, String aRange, String coverage, String confidence,
+          String modelFile, String fastaFile, String aRange,
+          String coverage, String confidence,
           String pid, String otherInfo)
   {
     String warningMessage = null;
     boolean added = false;
     try {
-      String pdbFile = baseUri + tempId;
-      PDBEntry phyre2PDBEntry = new PDBEntry(tempId, null, Type.FILE,
-              pdbFile);
-      refSeq.getDatasetSequence().addPDBId(phyre2PDBEntry);
+      String structureModelFile = resolveAbsolute(modelFile);
+      String fastaMappingFile = resolveAbsolute(fastaFile);
+      // System.out.println("Model File >> " + fastaMappingFile);
+      // System.out.println("Fasta File >> " + structureModelFile);
+      PDBEntry phyre2PDBEntry = new PDBEntry(modelFile, null, Type.FILE,
+              structureModelFile);
       String phyre2ModelDesc = generatePhyre2InfoHTMLTable(aRange,
               coverage, confidence, pid, otherInfo);
-      refSeq.setDescription(phyre2ModelDesc);
+      phyre2PDBEntry.setProperty("PHYRE2_MODEL_INFO", phyre2ModelDesc);
+      refSeq.getDatasetSequence().addPDBId(phyre2PDBEntry);
       StructureSelectionManager ssm = StructureSelectionManager
               .getStructureSelectionManager(Desktop.instance);
-      ssm.registerPhyre2Template(pdbFile);
+      ssm.registerPhyre2Template(structureModelFile, fastaMappingFile);
       added = true;
 
     } catch (Exception x)