Merge branch 'JAL-1587_promotedisorder' into develop
authorJim Procter <jprocter@dundee.ac.uk>
Tue, 18 Nov 2014 09:57:09 +0000 (09:57 +0000)
committerJim Procter <jprocter@dundee.ac.uk>
Tue, 18 Nov 2014 09:57:09 +0000 (09:57 +0000)
1  2 
src/jalview/io/AppletFormatAdapter.java
src/jalview/io/FormatAdapter.java

@@@ -47,9 -47,7 +47,9 @@@ public class AppletFormatAdapte
     */
    public static final String[] READABLE_FORMATS = new String[]
            { "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "STH",
 -    "PDB", "JnetFile", "RNAML", PhylipFile.FILE_DESC }; // , "SimpleBLAST" };
 +      "PDB", "JnetFile", "RNAML", PhylipFile.FILE_DESC, "HTML" }; // ,
 +                                                                              // "SimpleBLAST"
 +                                                                              // };
  
    /**
     * List of valid format strings for use by callers of the formatSequences
@@@ -81,8 -79,7 +81,8 @@@
     */
    public static final String[] READABLE_EXTENSIONS = new String[]
            { "fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa",
 -    "jar,jvp", "sto,stk", "xml,rnaml", PhylipFile.FILE_EXT }; // ".blast"
 +      "jar,jvp", "sto,stk", "xml,rnaml", PhylipFile.FILE_EXT,
 + "html" }; // ".blast"
  
    /**
     * List of readable formats by application in order corresponding to
@@@ -90,7 -87,7 +90,7 @@@
     */
    public static final String[] READABLE_FNAMES = new String[]
            { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "Jalview",
 -    "Stockholm", "RNAML", PhylipFile.FILE_DESC };// ,
 +      "Stockholm", "RNAML", PhylipFile.FILE_DESC, "HTML" };// ,
  
    // "SimpleBLAST"
    // };
      for (int i = 0, iSize = els.length - 1; i < iSize; i++)
      {
        list.append(els[i]);
 -      list.append(",");
 +      list.append(", ");
      }
      list.append(" and " + els[els.length - 1] + ".");
      return list.toString();
  
    public static String CLASSLOADER = "ClassLoader";
  
+   /**
+    * add jalview-derived non-secondary structure annotation from PDB structure
+    */
+   boolean annotFromStructure = false;
+   /**
+    * add secondary structure from PDB data with built-in algorithms
+    */
+   boolean localSecondaryStruct = false;
+   /**
+    * process PDB data with web services
+    */
+   boolean serviceSecondaryStruct = false;
    AlignFile afile = null;
  
    String inFile;
        }
        else if (format.equals("PDB"))
        {
-         afile = new MCview.PDBfile(true,true,inFile, type);
+         afile = new MCview.PDBfile(annotFromStructure,
+                 localSecondaryStruct, serviceSecondaryStruct, inFile, type);
          // Uncomment to test Jmol data based PDB processing: JAL-1213
          // afile = new jalview.ext.jmol.PDBFileWithJmol(inFile, type);
        }
        {
          afile = new PhylipFile(inFile, type);
        }
 +      // else if (format.equals(HtmlFile.FILE_DESC))
 +      // {
 +      // afile = new HtmlFile(inFile, type);
 +      // }
        else if (format.equals("RNAML"))
        {
          afile = new RnamlFile(inFile, type);
        }
        else if (format.equals("PDB"))
        {
-         afile = new MCview.PDBfile(true,true,source);
+         afile = new MCview.PDBfile(annotFromStructure,
+                 localSecondaryStruct, serviceSecondaryStruct, source);
        }
        else if (format.equals("STH"))
        {
        {
          afile = new PhylipFile(source);
        }
 +      // else if (format.equals(HtmlFile.FILE_DESC))
 +      // {
 +      // afile = new HtmlFile(source);
 +      // }
        Alignment al = new Alignment(afile.getSeqsAsArray());
  
        afile.addAnnotations(al);
        {
          afile = new PhylipFile();
        }
 +      // else if (format.equalsIgnoreCase(HtmlFile.FILE_DESC))
 +      // {
 +      // afile = new HtmlFile();
 +      // }
        else if (format.equalsIgnoreCase("RNAML"))
        {
          afile = new RnamlFile();
@@@ -38,6 -38,26 +38,26 @@@ import jalview.datamodel.SequenceI
  public class FormatAdapter extends AppletFormatAdapter
  {
  
+   public FormatAdapter()
+   {
+     super();
+     if (jalview.bin.Cache.getDefault("STRUCT_FROM_PDB", true))
+     {
+       annotFromStructure = jalview.bin.Cache.getDefault("ADD_TEMPFACT_ANN",
+               true);
+       localSecondaryStruct = jalview.bin.Cache.getDefault("ADD_SS_ANN",
+             true);
+     serviceSecondaryStruct = jalview.bin.Cache.getDefault("USE_RNAVIEW",
+             true);
+     }
+     else
+     {
+       // disable all PDB annotation options
+       annotFromStructure = false;
+       localSecondaryStruct = false;
+       serviceSecondaryStruct = false;
+     }
+   }
    public String formatSequences(String format, SequenceI[] seqs,
            String[] omitHiddenColumns)
    {
      return this.formatSequences(format, alignment, suffix);
    }
  
 +  public Alignment readFile(String inFile, String type, String format)
 +          throws java.io.IOException
 +  {
 +    Alignment al;
 +    if (format.equals("HTML"))
 +    {
 +      afile = new HtmlFile(inFile, type);
 +      al = new Alignment(afile.getSeqsAsArray());
 +      afile.addAnnotations(al);
 +    }
 +    else
 +    {
 +      al = super.readFile(inFile, type, format);
 +    }
 +
 +    return al;
 +  }
 +
 +  public AlignmentI readFromFile(FileParse source, String format)
 +          throws java.io.IOException
 +  {
 +    Alignment al;
 +    if (format.equals("HTML"))
 +    {
 +      afile = new HtmlFile(source);
 +      al = new Alignment(afile.getSeqsAsArray());
 +      afile.addAnnotations(al);
 +    }
 +    else
 +    {
 +      al = (Alignment) super.readFromFile(source, format);
 +    }
 +    return al;
 +  }
 +
    /**
     * validate format is valid for IO in Application. This is basically the
     * AppletFormatAdapter.isValidFormat call with additional checks for