JAL-629 implementation of --tempfac options
authorBen Soares <b.soares@dundee.ac.uk>
Mon, 5 Dec 2022 09:32:24 +0000 (09:32 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Mon, 5 Dec 2022 09:32:24 +0000 (09:32 +0000)
19 files changed:
resources/lang/Messages.properties
resources/lang/Messages_es.properties
src/jalview/analysis/AlignmentUtils.java
src/jalview/bin/ArgParser.java
src/jalview/bin/Commands.java
src/jalview/datamodel/AlignmentAnnotation.java
src/jalview/datamodel/annotations/AlphaFoldAnnotationRowBuilder.java
src/jalview/datamodel/annotations/AnnotationRowBuilder.java
src/jalview/ext/jmol/JmolParser.java
src/jalview/io/AlignFile.java
src/jalview/io/AppletFormatAdapter.java
src/jalview/io/FeaturesFile.java
src/jalview/io/FileLoader.java
src/jalview/io/FormatAdapter.java
src/jalview/io/StructureFile.java
src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java
src/jalview/ws/dbsources/EBIAlfaFold.java
src/mc_view/PDBChain.java
src/mc_view/PDBfile.java

index 30a154d..7f6e9a5 100644 (file)
@@ -1426,3 +1426,4 @@ label.memory_example_text = Maximum memory that would be used with these setting
 label.memory_example_tooltip = The memory allocated to Jalview is the smaller of the percentage of physical memory (default 90%) and the maximum absolute memory (default 32GB). If your computer's memory cannot be ascertained then the maximum absolute memory defaults to 8GB (if not customised).<br>Jalview will always try and reserve 512MB for the OS and at least 512MB for itself.
 warning.wrong_jvm_version_title = Wrong Java Version
 warning.wrong_jvm_version_message = The Java version being used (Java {0}) may lead to problems.\nThis installation of Jalview should be used with Java {1}.
 label.memory_example_tooltip = The memory allocated to Jalview is the smaller of the percentage of physical memory (default 90%) and the maximum absolute memory (default 32GB). If your computer's memory cannot be ascertained then the maximum absolute memory defaults to 8GB (if not customised).<br>Jalview will always try and reserve 512MB for the OS and at least 512MB for itself.
 warning.wrong_jvm_version_title = Wrong Java Version
 warning.wrong_jvm_version_message = The Java version being used (Java {0}) may lead to problems.\nThis installation of Jalview should be used with Java {1}.
+label.alphafold_reliability = Alphafold Reliability
index d0bfd65..13eb15e 100644 (file)
@@ -1411,4 +1411,4 @@ label.memory_example_text = Memoria m
 label.memory_example_tooltip = La memoria asignada a Jalview es el menor entre el porcentaje de memoria física (predeterminado 90%) y la memoria absoluta máxima (predeterminado 32 GB). Si no se puede determinar la memoria de su computadora, la memoria absoluta máxima predeterminada es de 8 GB (si no está personalizada).<br>Jalview siempre intentará reservar 512 MB para el sistema operativo y al menos 512 MB para sí mismo.
 warning.wrong_jvm_version_title = Versión incorrecta de Java
 warning.wrong_jvm_version_message = La versión de Java que se está utilizando (Java {0}) puede generar problemas.\nEsta instalación de Jalview debe usarse con Java {1}.
 label.memory_example_tooltip = La memoria asignada a Jalview es el menor entre el porcentaje de memoria física (predeterminado 90%) y la memoria absoluta máxima (predeterminado 32 GB). Si no se puede determinar la memoria de su computadora, la memoria absoluta máxima predeterminada es de 8 GB (si no está personalizada).<br>Jalview siempre intentará reservar 512 MB para el sistema operativo y al menos 512 MB para sí mismo.
 warning.wrong_jvm_version_title = Versión incorrecta de Java
 warning.wrong_jvm_version_message = La versión de Java que se está utilizando (Java {0}) puede generar problemas.\nEsta instalación de Jalview debe usarse con Java {1}.
-
+label.alphafold_reliability = Fiabilidad Alphafold
index a1a7fef..42c4b76 100644 (file)
@@ -184,10 +184,10 @@ public class AlignmentUtils
       // TODO use Character.toLowerCase to avoid creating String objects?
       char[] upstream = new String(ds
               .getSequence(s.getStart() - 1 - ustream_ds, s.getStart() - 1))
       // TODO use Character.toLowerCase to avoid creating String objects?
       char[] upstream = new String(ds
               .getSequence(s.getStart() - 1 - ustream_ds, s.getStart() - 1))
-                      .toLowerCase(Locale.ROOT).toCharArray();
+              .toLowerCase(Locale.ROOT).toCharArray();
       char[] downstream = new String(
               ds.getSequence(s_end - 1, s_end + dstream_ds))
       char[] downstream = new String(
               ds.getSequence(s_end - 1, s_end + dstream_ds))
-                      .toLowerCase(Locale.ROOT).toCharArray();
+              .toLowerCase(Locale.ROOT).toCharArray();
       char[] coreseq = s.getSequence();
       char[] nseq = new char[offset + upstream.length + downstream.length
               + coreseq.length];
       char[] coreseq = s.getSequence();
       char[] nseq = new char[offset + upstream.length + downstream.length
               + coreseq.length];
@@ -1581,6 +1581,21 @@ public class AlignmentUtils
     }
   }
 
     }
   }
 
+  public static AlignmentAnnotation getFirstSequenceAnnotationOfType(
+          AlignmentI al, int graphType)
+  {
+    AlignmentAnnotation[] anns = al.getAlignmentAnnotation();
+    if (anns != null)
+    {
+      for (AlignmentAnnotation aa : anns)
+      {
+        if (aa.sequenceRef != null && aa.graph == graphType)
+          return aa;
+      }
+    }
+    return null;
+  }
+
   /**
    * Returns true if either sequence has a cross-reference to the other
    * 
   /**
    * Returns true if either sequence has a cross-reference to the other
    * 
index be65a9b..bcd4498 100644 (file)
@@ -58,7 +58,7 @@ public class ArgParser
     ANNOTATION2, DISPLAY, GUI, NEWS, NOQUESTIONNAIRE, SORTBYTREE,
     USAGESTATS, OPEN, OPEN2, PROPS, QUESTIONNAIRE, SETPROP, TREE, VDOC,
     VSESS, OUTPUT, OUTPUTTYPE, SSANNOTATION, NOTEMPFAC, TEMPFAC,
     ANNOTATION2, DISPLAY, GUI, NEWS, NOQUESTIONNAIRE, SORTBYTREE,
     USAGESTATS, OPEN, OPEN2, PROPS, QUESTIONNAIRE, SETPROP, TREE, VDOC,
     VSESS, OUTPUT, OUTPUTTYPE, SSANNOTATION, NOTEMPFAC, TEMPFAC,
-    TEMPFAC_LABEL, TEMPFAC_DESC, TEMPFAC_SHADING, TITLE;
+    TEMPFAC_LABEL, TEMPFAC_DESC, TEMPFAC_SHADING, TITLE, PAEMATRIX, WRAP;
 
     static
     {
 
     static
     {
@@ -104,6 +104,8 @@ public class ArgParser
       TEMPFAC_DESC.setOptions(Opt.STRING, Opt.LINKED);
       TEMPFAC_SHADING.setOptions(Opt.STRING, Opt.LINKED);
       TITLE.setOptions(Opt.STRING, Opt.LINKED);
       TEMPFAC_DESC.setOptions(Opt.STRING, Opt.LINKED);
       TEMPFAC_SHADING.setOptions(Opt.STRING, Opt.LINKED);
       TITLE.setOptions(Opt.STRING, Opt.LINKED);
+      PAEMATRIX.setOptions(Opt.STRING, Opt.LINKED);
+      WRAP.setOptions(Opt.BOOLEAN, Opt.LINKED);
     }
 
     private final String[] argNames;
     }
 
     private final String[] argNames;
index 420e1d1..4ff82aa 100644 (file)
@@ -1,13 +1,19 @@
 package jalview.bin;
 
 import java.io.File;
 package jalview.bin;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import jalview.analysis.AlignmentUtils;
 import jalview.bin.ArgParser.Arg;
 import jalview.bin.ArgParser.ArgValues;
 import java.util.Map;
 
 import jalview.analysis.AlignmentUtils;
 import jalview.bin.ArgParser.Arg;
 import jalview.bin.ArgParser.ArgValues;
+import jalview.datamodel.AlignmentAnnotation;
 import jalview.gui.AlignFrame;
 import jalview.gui.Desktop;
 import jalview.io.AppletFormatAdapter;
 import jalview.gui.AlignFrame;
 import jalview.gui.Desktop;
 import jalview.io.AppletFormatAdapter;
@@ -19,6 +25,7 @@ import jalview.io.IdentifyFile;
 import jalview.util.HttpUtils;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
 import jalview.util.HttpUtils;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
+import jalview.ws.dbsources.EBIAlfaFold;
 
 public class Commands
 {
 
 public class Commands
 {
@@ -67,7 +74,6 @@ public class Commands
   protected void processLinked(String id)
   {
     Map<Arg, ArgValues> m = argParser.linkedArgs(id);
   protected void processLinked(String id)
   {
     Map<Arg, ArgValues> m = argParser.linkedArgs(id);
-    FileLoader fileLoader = new FileLoader(!headless);
 
     /*
     // script to execute after all loading is completed one way or another
 
     /*
     // script to execute after all loading is completed one way or another
@@ -90,7 +96,6 @@ public class Commands
       {
         if (openFile == null)
           continue OPEN;
       {
         if (openFile == null)
           continue OPEN;
-        Console.debug("********** id = " + id + ", openFile = " + openFile);
 
         if (first)
         {
 
         if (first)
         {
@@ -136,12 +141,55 @@ public class Commands
         af = afMap.get(id);
         if (af == null)
         {
         af = afMap.get(id);
         if (af == null)
         {
+          // get kind of temperature factor annotation
+          AlignmentAnnotation.TFType tempfacType = null;
+          if ((m.get(Arg.NOTEMPFAC) == null
+                  || !m.get(Arg.NOTEMPFAC).getBoolean())
+                  && m.get(Arg.TEMPFAC) != null)
+          {
+            try
+            {
+              tempfacType = AlignmentAnnotation.TFType
+                      .valueOf(m.get(Arg.TEMPFAC).getValue()
+                              .toUpperCase(Locale.ROOT));
+              Console.debug("Obtained Temperature Factor type of '"
+                      + tempfacType + "'");
+            } catch (IllegalArgumentException e)
+            {
+              StringBuilder sb = new StringBuilder().append("Cannot set --")
+                      .append(Arg.TEMPFAC.getName()).append(" to '")
+                      .append(tempfacType)
+                      .append("', ignoring.  Valid values are: ");
+              Iterator<AlignmentAnnotation.TFType> it = Arrays
+                      .stream(AlignmentAnnotation.TFType.values())
+                      .iterator();
+              while (it.hasNext())
+              {
+                sb.append(it.next().toString().toLowerCase(Locale.ROOT));
+                if (it.hasNext())
+                  sb.append(", ");
+              }
+              Console.warn(sb.toString());
+            }
+          }
+
           Console.debug(
                   "Opening '" + openFile + "' in new alignment frame");
           Console.debug(
                   "Opening '" + openFile + "' in new alignment frame");
-          af = fileLoader.LoadFileWaitTillLoaded(openFile, protocol,
-                  format);
+          FileLoader fileLoader = new FileLoader(!headless);
+          af = fileLoader.LoadFileWaitTillLoaded(openFile, protocol, format,
+                  tempfacType);
+
+          // wrap alignment?
+          if (m.get(Arg.WRAP) != null && m.get(Arg.WRAP).getBoolean())
+          {
+            af.getCurrentView().setWrapAlignment(true);
+          }
+
+          // change alignment frame title
           if (m.get(Arg.TITLE) != null)
             af.setTitle(m.get(Arg.TITLE).getValue());
           if (m.get(Arg.TITLE) != null)
             af.setTitle(m.get(Arg.TITLE).getValue());
+
+          // show secondary structure annotations?
           if (m.get(Arg.SSANNOTATION) != null
                   && !m.get(Arg.SSANNOTATION).getBoolean())
           {
           if (m.get(Arg.SSANNOTATION) != null
                   && !m.get(Arg.SSANNOTATION).getBoolean())
           {
@@ -151,19 +199,47 @@ public class Commands
                     Collections.singleton("Secondary Structure"), null,
                     false, false);
           }
                     Collections.singleton("Secondary Structure"), null,
                     false, false);
           }
+
+          // show temperature factor annotations?
           if (m.get(Arg.NOTEMPFAC) != null
                   && m.get(Arg.NOTEMPFAC).getBoolean())
           {
             // do this better (annotation types?)
           if (m.get(Arg.NOTEMPFAC) != null
                   && m.get(Arg.NOTEMPFAC).getBoolean())
           {
             // do this better (annotation types?)
+            List<String> hideThese = new ArrayList<>();
+            hideThese.add("Temperature Factor");
+            hideThese.add(MessageManager
+                    .getString("label.alphafold_reliability"));
             AlignmentUtils.showOrHideSequenceAnnotations(
             AlignmentUtils.showOrHideSequenceAnnotations(
-                    af.getCurrentView().getAlignment(),
-                    Collections.singleton("Temperature Factor"), null,
-                    false, false);
-            AlignmentUtils.showOrHideSequenceAnnotations(
-                    af.getCurrentView().getAlignment(),
-                    Collections.singleton("Alphafold Reliability"), null,
+                    af.getCurrentView().getAlignment(), hideThese, null,
                     false, false);
           }
                     false, false);
           }
+          else
+          {
+            if (m.get(Arg.TEMPFAC_LABEL) != null)
+            {
+              AlignmentAnnotation aa = AlignmentUtils
+                      .getFirstSequenceAnnotationOfType(
+                              af.getCurrentView().getAlignment(),
+                              AlignmentAnnotation.LINE_GRAPH);
+              Console.debug("***** Trying to change label from '"
+                      + (aa == null ? aa : aa.label) + "' to '"
+                      + m.get(Arg.TEMPFAC_LABEL).getValue() + "'");
+              if (aa != null)
+              {
+                aa.label = m.get(Arg.TEMPFAC_LABEL).getValue();
+              }
+            }
+          }
+
+          //
+
+          // load a pAE file?
+          if (m.get(Arg.PAEMATRIX) != null)
+          {
+            File paeFile = new File(m.get(Arg.PAEMATRIX).getValue());
+            EBIAlfaFold.addAlphaFoldPAE(af.getCurrentView().getAlignment(),
+                    paeFile);
+          }
 
           // store the AlignFrame for this id
           afMap.put(id, af);
 
           // store the AlignFrame for this id
           afMap.put(id, af);
index b6e48dc..636088b 100755 (executable)
@@ -43,6 +43,7 @@ import jalview.analysis.WUSSParseException;
  */
 public class AlignmentAnnotation
 {
  */
 public class AlignmentAnnotation
 {
+
   private static final String ANNOTATION_ID_PREFIX = "ann";
 
   /*
   private static final String ANNOTATION_ID_PREFIX = "ann";
 
   /*
@@ -95,6 +96,26 @@ public class AlignmentAnnotation
    */
   private long invalidrnastruc = -2;
 
    */
   private long invalidrnastruc = -2;
 
+  public static enum TFType
+  {
+    DEFAULT, PLDDT, DOSE;
+  }
+
+  /**
+   * the type of temperature factor plot (if it is one)
+   */
+  private TFType tfType = TFType.DEFAULT;
+
+  public void setTFType(TFType t)
+  {
+    tfType = t;
+  }
+
+  public TFType getTFType()
+  {
+    return tfType;
+  }
+
   /**
    * Updates the _rnasecstr field Determines the positions that base pair and
    * the positions of helices based on secondary structure from a Stockholm file
   /**
    * Updates the _rnasecstr field Determines the positions that base pair and
    * the positions of helices based on secondary structure from a Stockholm file
@@ -551,12 +572,12 @@ public class AlignmentAnnotation
                       : annotations[index + offset].displayCharacter == null
                               || annotations[index
                                       + offset].displayCharacter
                       : annotations[index + offset].displayCharacter == null
                               || annotations[index
                                       + offset].displayCharacter
-                                              .length() == 0
-                                                      ? annotations[index
-                                                              + offset].secondaryStructure
-                                                      : annotations[index
-                                                              + offset].displayCharacter
-                                                                      .charAt(0));
+                                      .length() == 0
+                                              ? annotations[index
+                                                      + offset].secondaryStructure
+                                              : annotations[index
+                                                      + offset].displayCharacter
+                                                      .charAt(0));
     }
 
     @Override
     }
 
     @Override
index a0befe0..fa48968 100644 (file)
@@ -1,15 +1,18 @@
 package jalview.datamodel.annotations;
 
 package jalview.datamodel.annotations;
 
+import jalview.datamodel.AlignmentAnnotation.TFType;
 import jalview.datamodel.Annotation;
 import jalview.datamodel.Annotation;
+import jalview.util.MessageManager;
 
 public class AlphaFoldAnnotationRowBuilder extends AnnotationRowBuilder
 {
   public AlphaFoldAnnotationRowBuilder()
   {
 
 public class AlphaFoldAnnotationRowBuilder extends AnnotationRowBuilder
 {
   public AlphaFoldAnnotationRowBuilder()
   {
-    super("Alphafold Reliability");
+    super(MessageManager.getString("label.alphafold_reliability"));
     min = 0;
     max = 100;
     hasMinMax = true;
     min = 0;
     max = 100;
     hasMinMax = true;
+    this.setTFType(TFType.PLDDT);
   }
 
   @Override
   }
 
   @Override
index 15f83e9..573b1a9 100644 (file)
@@ -1,5 +1,6 @@
 package jalview.datamodel.annotations;
 
 package jalview.datamodel.annotations;
 
+import jalview.datamodel.AlignmentAnnotation.TFType;
 import jalview.datamodel.Annotation;
 
 public class AnnotationRowBuilder
 import jalview.datamodel.Annotation;
 
 public class AnnotationRowBuilder
@@ -13,6 +14,21 @@ public class AnnotationRowBuilder
 
   boolean hasMinMax = false;
 
 
   boolean hasMinMax = false;
 
+  /**
+   * the type of temperature factor plot (if it is one)
+   */
+  private TFType tfType = TFType.DEFAULT;
+
+  public void setTFType(TFType t)
+  {
+    tfType = t;
+  }
+
+  public TFType getTFType()
+  {
+    return tfType;
+  }
+
   public String getName()
   {
     return name;
   public String getName()
   {
     return name;
@@ -80,6 +96,12 @@ public class AnnotationRowBuilder
     name = string;
   }
 
     name = string;
   }
 
+  public AnnotationRowBuilder(String name, float min, float max, TFType tft)
+  {
+    this(name, min, max);
+    setTFType(tft);
+  }
+
   public AnnotationRowBuilder(String name, float min, float max)
   {
     this(name);
   public AnnotationRowBuilder(String name, float min, float max)
   {
     this(name);
index 269fc31..9306388 100644 (file)
@@ -40,6 +40,7 @@ import com.stevesoft.pat.Regex;
 import jalview.bin.Console;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.bin.Console;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentAnnotation.TFType;
 import jalview.datamodel.Annotation;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
 import jalview.datamodel.Annotation;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
@@ -73,12 +74,19 @@ public class JmolParser extends StructureFile implements JmolStatusListener
   {
     // BH 2018 File or String for filename
     super(immediate, inFile, sourceType);
   {
     // BH 2018 File or String for filename
     super(immediate, inFile, sourceType);
+
   }
 
   public JmolParser(Object inFile, DataSourceType sourceType)
           throws IOException
   {
   }
 
   public JmolParser(Object inFile, DataSourceType sourceType)
           throws IOException
   {
-    super(inFile, sourceType);
+    this(inFile, sourceType, null);
+  }
+
+  public JmolParser(Object inFile, DataSourceType sourceType,
+          AlignmentAnnotation.TFType tempfacType) throws IOException
+  {
+    super(inFile, sourceType, tempfacType);
   }
 
   public JmolParser(FileParse fp) throws IOException
   }
 
   public JmolParser(FileParse fp) throws IOException
@@ -243,7 +251,8 @@ public class JmolParser extends StructureFile implements JmolStatusListener
         {
           AnnotationRowBuilder builder = null;
           String tempFString = null;
         {
           AnnotationRowBuilder builder = null;
           String tempFString = null;
-          if (isAlphafoldModel())
+          if (isAlphafoldModel()
+                  || this.getTemperatureFactorType() == AlignmentAnnotation.TFType.PLDDT)
           {
             builder = new AlphaFoldAnnotationRowBuilder();
           }
           {
             builder = new AlphaFoldAnnotationRowBuilder();
           }
index 3202ac9..889d72e 100755 (executable)
@@ -28,6 +28,7 @@ import java.util.List;
 import java.util.Vector;
 
 import jalview.datamodel.AlignmentAnnotation;
 import java.util.Vector;
 
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentAnnotation.TFType;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceGroup;
@@ -81,6 +82,13 @@ public abstract class AlignFile extends FileParse
 
   private boolean dataClosed = false;
 
 
   private boolean dataClosed = false;
 
+  private AlignmentAnnotation.TFType temperatureFactorType = null;
+
+  public AlignmentAnnotation.TFType getTemperatureFactorType()
+  {
+    return this.temperatureFactorType;
+  }
+
   /**
    * @return if doParse() was called at construction time
    */
   /**
    * @return if doParse() was called at construction time
    */
@@ -117,7 +125,13 @@ public abstract class AlignFile extends FileParse
   public AlignFile(Object dataObject, DataSourceType sourceType)
           throws IOException
   {
   public AlignFile(Object dataObject, DataSourceType sourceType)
           throws IOException
   {
-    this(true, dataObject, sourceType);
+    this(dataObject, sourceType, null);
+  }
+
+  public AlignFile(Object dataObject, DataSourceType sourceType,
+          AlignmentAnnotation.TFType tempfacType) throws IOException
+  {
+    this(true, dataObject, sourceType, tempfacType);
   }
 
   /**
   }
 
   /**
@@ -135,9 +149,16 @@ public abstract class AlignFile extends FileParse
   public AlignFile(boolean parseImmediately, Object dataObject,
           DataSourceType sourceType) throws IOException
   {
   public AlignFile(boolean parseImmediately, Object dataObject,
           DataSourceType sourceType) throws IOException
   {
+    this(parseImmediately, dataObject, sourceType, null);
+  }
+
+  public AlignFile(boolean parseImmediately, Object dataObject,
+          DataSourceType sourceType, AlignmentAnnotation.TFType tempfacType) throws IOException
+  {
     // BH allows File or String
     super(dataObject, sourceType);
     initData();
     // BH allows File or String
     super(dataObject, sourceType);
     initData();
+    this.temperatureFactorType = tempfacType;
     if (parseImmediately)
     {
       doParse();
     if (parseImmediately)
     {
       doParse();
index 5de14a4..8b1525c 100755 (executable)
  */
 package jalview.io;
 
  */
 package jalview.io;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
 import java.util.Locale;
 
 import jalview.api.AlignExportSettingsI;
 import jalview.api.AlignmentViewPanel;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
 import java.util.Locale;
 
 import jalview.api.AlignExportSettingsI;
 import jalview.api.AlignmentViewPanel;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentAnnotation.TFType;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentView;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentView;
-import jalview.datamodel.SeqDistanceContactMatrix;
 import jalview.datamodel.PDBEntry.Type;
 import jalview.datamodel.SequenceI;
 import jalview.ext.jmol.JmolParser;
 import jalview.structure.StructureImportSettings;
 import jalview.util.Platform;
 
 import jalview.datamodel.PDBEntry.Type;
 import jalview.datamodel.SequenceI;
 import jalview.ext.jmol.JmolParser;
 import jalview.structure.StructureImportSettings;
 import jalview.util.Platform;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
 /**
  * A low level class for alignment and feature IO with alignment formatting
  * methods used by both applet and application for generating flat alignment
 /**
  * A low level class for alignment and feature IO with alignment formatting
  * methods used by both applet and application for generating flat alignment
@@ -160,6 +159,13 @@ public class AppletFormatAdapter
           DataSourceType sourceType, FileFormatI fileFormat)
           throws IOException
   {
           DataSourceType sourceType, FileFormatI fileFormat)
           throws IOException
   {
+    return readFile(selectedFile, file, sourceType, fileFormat, null);
+  }
+
+  public AlignmentI readFile(File selectedFile, String file,
+          DataSourceType sourceType, FileFormatI fileFormat,
+          AlignmentAnnotation.TFType tempfacType) throws IOException
+  {
 
     this.selectedFile = selectedFile;
     if (selectedFile != null)
 
     this.selectedFile = selectedFile;
     if (selectedFile != null)
@@ -182,7 +188,8 @@ public class AppletFormatAdapter
         {
           // needs a File option
           alignFile = new JmolParser(
         {
           // needs a File option
           alignFile = new JmolParser(
-                  selectedFile == null ? inFile : selectedFile, sourceType);
+                  selectedFile == null ? inFile : selectedFile, sourceType,
+                  tempfacType);
         }
         else
         {
         }
         else
         {
index 745bce3..6332561 100755 (executable)
@@ -20,8 +20,6 @@
  */
 package jalview.io;
 
  */
 package jalview.io;
 
-import java.util.Locale;
-
 import java.awt.Color;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.awt.Color;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -30,6 +28,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.TreeMap;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.TreeMap;
index 4016e71..c7ade20 100755 (executable)
@@ -33,6 +33,8 @@ import jalview.api.FeaturesDisplayedI;
 import jalview.api.FeaturesSourceI;
 import jalview.bin.Cache;
 import jalview.bin.Jalview;
 import jalview.api.FeaturesSourceI;
 import jalview.bin.Cache;
 import jalview.bin.Jalview;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentAnnotation.TFType;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.PDBEntry;
@@ -73,6 +75,8 @@ public class FileLoader implements Runnable
 
   private File selectedFile;
 
 
   private File selectedFile;
 
+  private AlignmentAnnotation.TFType temperatureFactorType = null;
+
   /**
    * default constructor always raised errors in GUI dialog boxes
    */
   /**
    * default constructor always raised errors in GUI dialog boxes
    */
@@ -158,9 +162,26 @@ public class FileLoader implements Runnable
   public AlignFrame LoadFileWaitTillLoaded(String file,
           DataSourceType sourceType, FileFormatI format)
   {
   public AlignFrame LoadFileWaitTillLoaded(String file,
           DataSourceType sourceType, FileFormatI format)
   {
+    return LoadFileWaitTillLoaded(file, sourceType, format, null);
+  }
+
+  /**
+   * Load alignment from (file, protocol) of type format with specified
+   * temperature factor type and wait till loaded
+   * 
+   * @param file
+   * @param sourceType
+   * @param format
+   * @param tempfacType
+   * @return alignFrame constructed from file contents
+   */
+  public AlignFrame LoadFileWaitTillLoaded(String file,
+          DataSourceType sourceType, FileFormatI format, AlignmentAnnotation.TFType tempfacType)
+  {
     this.file = file;
     this.protocol = sourceType;
     this.format = format;
     this.file = file;
     this.protocol = sourceType;
     this.format = format;
+    this.temperatureFactorType = tempfacType;
     return _LoadFileWaitTillLoaded();
   }
 
     return _LoadFileWaitTillLoaded();
   }
 
@@ -272,6 +293,7 @@ public class FileLoader implements Runnable
             ? "Copied From Clipboard"
             : file;
     Runtime rt = Runtime.getRuntime();
             ? "Copied From Clipboard"
             : file;
     Runtime rt = Runtime.getRuntime();
+
     try
     {
       if (Desktop.instance != null)
     try
     {
       if (Desktop.instance != null)
@@ -378,12 +400,14 @@ public class FileLoader implements Runnable
             {
               if (selectedFile == null)
               {
             {
               if (selectedFile == null)
               {
-                al = fa.readFile(file, protocol, format);
+                al = fa.readFile(null, file, protocol, format,
+                        temperatureFactorType);
 
               }
               else
               {
 
               }
               else
               {
-                al = fa.readFile(selectedFile, protocol, format);
+                al = fa.readFile(selectedFile, null, protocol, format,
+                        temperatureFactorType);
               }
               source = fa.getAlignFile(); // keep reference for later if
 
               }
               source = fa.getAlignFile(); // keep reference for later if
 
index 735619f..0ca2b50 100755 (executable)
@@ -20,6 +20,8 @@
  */
 package jalview.io;
 
  */
 package jalview.io;
 
+import java.io.File;
+import java.io.IOException;
 import java.util.Locale;
 
 import jalview.api.AlignExportSettingsI;
 import java.util.Locale;
 
 import jalview.api.AlignExportSettingsI;
@@ -27,6 +29,7 @@ import jalview.api.AlignmentViewPanel;
 import jalview.bin.Cache;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.bin.Cache;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentAnnotation.TFType;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.Sequence;
@@ -34,9 +37,6 @@ import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.util.Comparison;
 
 import jalview.datamodel.SequenceI;
 import jalview.util.Comparison;
 
-import java.io.File;
-import java.io.IOException;
-
 /**
  * Additional formatting methods used by the application in a number of places.
  * 
 /**
  * Additional formatting methods used by the application in a number of places.
  * 
@@ -228,6 +228,16 @@ public class FormatAdapter extends AppletFormatAdapter
   }
 
   @Override
   }
 
   @Override
+  public AlignmentI readFile(File selectedFile, String file,
+          DataSourceType sourceType, FileFormatI fileFormat,
+          AlignmentAnnotation.TFType tempfacType) throws IOException
+  {
+    AlignmentI al = super.readFile(selectedFile, file, sourceType,
+            fileFormat, tempfacType);
+    return al;
+  }
+
+  @Override
   public AlignmentI readFile(String file, DataSourceType sourceType,
           FileFormatI fileFormat) throws IOException
   {
   public AlignmentI readFile(String file, DataSourceType sourceType,
           FileFormatI fileFormat) throws IOException
   {
index 6b623a1..c816f6d 100644 (file)
  */
 package jalview.io;
 
  */
 package jalview.io;
 
+import java.awt.Color;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.List;
+import java.util.Vector;
+
 import jalview.analysis.AlignSeq;
 import jalview.api.FeatureSettingsModelI;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.analysis.AlignSeq;
 import jalview.api.FeatureSettingsModelI;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentAnnotation.TFType;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.DBRefSource;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.DBRefSource;
@@ -31,13 +38,6 @@ import jalview.datamodel.PDBEntry;
 import jalview.datamodel.PDBEntry.Type;
 import jalview.datamodel.SequenceI;
 import jalview.structure.StructureImportSettings;
 import jalview.datamodel.PDBEntry.Type;
 import jalview.datamodel.SequenceI;
 import jalview.structure.StructureImportSettings;
-
-import java.awt.Color;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.util.List;
-import java.util.Vector;
-
 import mc_view.PDBChain;
 
 public abstract class StructureFile extends AlignFile
 import mc_view.PDBChain;
 
 public abstract class StructureFile extends AlignFile
@@ -71,7 +71,13 @@ public abstract class StructureFile extends AlignFile
   public StructureFile(Object inFile, DataSourceType sourceType)
           throws IOException
   {
   public StructureFile(Object inFile, DataSourceType sourceType)
           throws IOException
   {
-    super(inFile, sourceType);
+    this(inFile, sourceType, null);
+  }
+
+  public StructureFile(Object inFile, DataSourceType sourceType,
+          AlignmentAnnotation.TFType tempfacType) throws IOException
+  {
+    super(inFile, sourceType, tempfacType);
   }
 
   public StructureFile(FileParse fp) throws IOException
   }
 
   public StructureFile(FileParse fp) throws IOException
index 0ac3e00..3298a96 100644 (file)
@@ -30,7 +30,6 @@ public class PAEContactMatrix implements ContactMatrixI
 
   @SuppressWarnings("unchecked")
   public PAEContactMatrix(SequenceI _refSeq, Map<String, Object> pae_obj)
 
   @SuppressWarnings("unchecked")
   public PAEContactMatrix(SequenceI _refSeq, Map<String, Object> pae_obj)
-          throws Exception
   {
     refSeq = _refSeq;
     while (refSeq.getDatasetSequence() != null)
   {
     refSeq = _refSeq;
     while (refSeq.getDatasetSequence() != null)
@@ -184,6 +183,5 @@ public class PAEContactMatrix implements ContactMatrixI
   public String getAnnotLabel()
   {
     return "pAE Matrix";
   public String getAnnotLabel()
   {
     return "pAE Matrix";
-
   }
 }
   }
 }
index f98ae6d..5314207 100644 (file)
@@ -23,11 +23,15 @@ package jalview.ws.dbsources;
 
 import java.io.File;
 import java.io.FileInputStream;
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
+import org.json.simple.parser.ParseException;
+
 import com.stevesoft.pat.Regex;
 
 import jalview.api.FeatureSettingsModelI;
 import com.stevesoft.pat.Regex;
 
 import jalview.api.FeatureSettingsModelI;
@@ -217,14 +221,14 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy
    * @param retrievalUrl
    *          - URL of .mmcif from EBI-AlphaFold - will be used to generate the
    *          pAE URL automatically
    * @param retrievalUrl
    *          - URL of .mmcif from EBI-AlphaFold - will be used to generate the
    *          pAE URL automatically
+   * @throws IOException
    * @throws Exception
    */
   public static void retrieve_AlphaFold_pAE(String id,
    * @throws Exception
    */
   public static void retrieve_AlphaFold_pAE(String id,
-          AlignmentI pdbAlignment, String retrievalUrl) throws Exception
+          AlignmentI pdbAlignment, String retrievalUrl) throws IOException
   {
     // import PAE as contact matrix - assume this will work if there was a
     // model
   {
     // import PAE as contact matrix - assume this will work if there was a
     // model
-    File pae = File.createTempFile(id, "pae_json");
     String paeURL = getAlphaFoldPaeDownloadUrl(id, AF_VERSION);
 
     if (retrievalUrl != null)
     String paeURL = getAlphaFoldPaeDownloadUrl(id, AF_VERSION);
 
     if (retrievalUrl != null)
@@ -233,22 +237,49 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy
       paeURL = retrievalUrl.replace("model", "predicted_aligned_error")
               .replace(".cif", ".json");
     }
       paeURL = retrievalUrl.replace("model", "predicted_aligned_error")
               .replace(".cif", ".json");
     }
+
+    File pae = null;
+    try
+    {
+      pae = File.createTempFile(id == null ? "af_pae" : id, "pae_json");
+    } catch (IOException e)
+    {
+      e.printStackTrace();
+    }
     Console.debug("Downloading pae from " + paeURL + " to " + pae.toString()
             + "");
     Console.debug("Downloading pae from " + paeURL + " to " + pae.toString()
             + "");
+    UrlDownloadClient.download(paeURL, pae);
+    addAlphaFoldPAE(pdbAlignment, pae);
+  }
 
 
+  public static void addAlphaFoldPAE(AlignmentI pdbAlignment, File pae)
+  {
+    FileInputStream pae_input = null;
     try
     {
     try
     {
-      UrlDownloadClient.download(paeURL, pae);
-      FileInputStream pae_input = new FileInputStream(pae);
+      pae_input = new FileInputStream(pae);
+    } catch (FileNotFoundException e)
+    {
+      Console.error(
+              "Could not find pAE file '" + pae.getAbsolutePath() + "'", e);
+    }
 
 
+    try
+    {
       if (!importPaeJSONAsContactMatrix(pdbAlignment, pae_input))
       {
       if (!importPaeJSONAsContactMatrix(pdbAlignment, pae_input))
       {
-        Console.warn("Couln't import contact matrix from " + paeURL
-                + " (stored in " + pae.toString() + ")");
+        Console.warn("Could not import contact matrix from '"
+                + pae.getAbsolutePath() + "'");
       }
       }
-    } catch (Exception pae_ex)
+    } catch (IOException e1)
+    {
+      Console.error("Error when importing pAE file '"
+              + pae.getAbsolutePath() + "'", e1);
+    } catch (ParseException e2)
     {
     {
-      Console.error("Couldn't download PAE", pae_ex);
+      Console.error(
+              "Error when parsing pAE file '" + pae.getAbsolutePath() + "'",
+              e2);
     }
 
   }
     }
 
   }
@@ -260,10 +291,13 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy
    * @param pdbAlignment
    * @param pae_input
    * @return true if there was a pAE matrix added
    * @param pdbAlignment
    * @param pae_input
    * @return true if there was a pAE matrix added
+   * @throws ParseException
+   * @throws IOException
    * @throws Exception
    */
   public static boolean importPaeJSONAsContactMatrix(
    * @throws Exception
    */
   public static boolean importPaeJSONAsContactMatrix(
-          AlignmentI pdbAlignment, InputStream pae_input) throws Exception
+          AlignmentI pdbAlignment, InputStream pae_input)
+          throws IOException, ParseException
   {
 
     List<Object> pae_obj = (List<Object>) Platform.parseJSON(pae_input);
   {
 
     List<Object> pae_obj = (List<Object>) Platform.parseJSON(pae_input);
index 5413a3c..6d02630 100755 (executable)
@@ -536,6 +536,7 @@ public class PDBChain
                       ? tfacTemplate.getDescription()
                       : tfacTemplate.getName()) + " for " + pdbid + id,
               annots, min, max, AlignmentAnnotation.LINE_GRAPH);
                       ? tfacTemplate.getDescription()
                       : tfacTemplate.getName()) + " for " + pdbid + id,
               annots, min, max, AlignmentAnnotation.LINE_GRAPH);
+      tfactorann.setTFType(tfacTemplate.getTFType());
       tfactorann.setCalcId(getClass().getName());
 
       tfactorann.setSequenceRef(sequence);
       tfactorann.setCalcId(getClass().getName());
 
       tfactorann.setSequenceRef(sequence);
index 54bdca9..2a89e61 100755 (executable)
  */
 package mc_view;
 
  */
 package mc_view;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Vector;
+
+import jalview.bin.Console;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.DBRefSource;
 import jalview.datamodel.SequenceI;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.DBRefSource;
 import jalview.datamodel.SequenceI;
@@ -28,12 +35,6 @@ import jalview.io.FileParse;
 import jalview.io.StructureFile;
 import jalview.util.MessageManager;
 
 import jalview.io.StructureFile;
 import jalview.util.MessageManager;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Vector;
-
 public class PDBfile extends StructureFile
 {
   private static String CALC_ID_PREFIX = "JalviewPDB";
 public class PDBfile extends StructureFile
 {
   private static String CALC_ID_PREFIX = "JalviewPDB";
@@ -51,7 +52,9 @@ public class PDBfile extends StructureFile
           DataSourceType sourceType) throws IOException
   {
     super(false, dataObject, sourceType);
           DataSourceType sourceType) throws IOException
   {
     super(false, dataObject, sourceType);
+    Console.debug("***** PDBfile constructor");
     addSettings(addAlignmentAnnotations, predictSecStr, externalSecStr);
     addSettings(addAlignmentAnnotations, predictSecStr, externalSecStr);
+    Console.debug("***** About to doParse() 1");
     doParse();
   }
 
     doParse();
   }
 
@@ -60,6 +63,7 @@ public class PDBfile extends StructureFile
   {
     super(false, source);
     addSettings(addAlignmentAnnotations, predictSecStr, externalSecStr);
   {
     super(false, source);
     addSettings(addAlignmentAnnotations, predictSecStr, externalSecStr);
+    Console.debug("***** About to doParse() 2");
     doParse();
   }
 
     doParse();
   }