JAL-3253 preliminary static fixes for JavaScript part 3 of 3
[jalview.git] / src / jalview / structure / StructureImportSettings.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.structure;
22
23 import jalview.bin.Jalview;
24 import jalview.datamodel.PDBEntry;
25 import jalview.datamodel.PDBEntry.Type;
26
27 /**
28  * bean holding settings for structure IO. TODO: tests for validation of values
29  * TODO: tests for race conditions (all fields are static, is that correct ?)
30  * 
31  * @author tcofoegbu
32  *
33  */
34 public class StructureImportSettings
35 {
36
37   private static StructureImportSettings getInstance()
38   {
39     Jalview j = Jalview.getInstance();
40     return (j.structureImportSettings == null
41             ? j.structureImportSettings = new StructureImportSettings()
42             : j.structureImportSettings);
43   }
44
45   /**
46    * set to true to add derived sequence annotations (temp factor read from
47    * file, or computed secondary structure) to the alignment
48    */
49   private boolean visibleChainAnnotation = false;
50
51   /**
52    * Set true to predict secondary structure (using JMol for protein, Annotate3D
53    * for RNA)
54    */
55   private boolean processSecStr = false;
56
57   /**
58    * Set true (with predictSecondaryStructure=true) to predict secondary
59    * structure using an external service (currently Annotate3D for RNA only)
60    */
61   private boolean externalSecondaryStructure = false;
62
63   private boolean showSeqFeatures = true;
64
65   public enum StructureParser
66   {
67     JMOL_PARSER, JALVIEW_PARSER
68   }
69
70   /**
71    * Determines the default file format for structure files to be downloaded
72    * from the PDB sequence fetcher. Possible options include: PDB|mmCIF
73    */
74   private PDBEntry.Type defaultStructureFileFormat = Type.PDB;
75
76   /**
77    * Determines the parser used for parsing PDB format file. Possible options
78    * are : JMolParser|JalveiwParser
79    */
80   private StructureParser defaultPDBFileParser = StructureParser.JMOL_PARSER;
81
82   public static void addSettings(boolean addAlignmentAnnotations,
83           boolean processSecStr, boolean externalSecStr)
84   {
85     StructureImportSettings s = getInstance();
86     s.visibleChainAnnotation = addAlignmentAnnotations;
87     s.processSecStr = processSecStr;
88     s.externalSecondaryStructure = externalSecStr;
89     s.showSeqFeatures = true;
90   }
91
92   public static boolean isVisibleChainAnnotation()
93   {
94     return getInstance().visibleChainAnnotation;
95   }
96
97   public static void setVisibleChainAnnotation(
98           boolean visibleChainAnnotation)
99   {
100     getInstance().visibleChainAnnotation = visibleChainAnnotation;
101   }
102
103   public static boolean isProcessSecondaryStructure()
104   {
105     return getInstance().processSecStr;
106   }
107
108   public static void setProcessSecondaryStructure(
109           boolean processSecondaryStructure)
110   {
111     getInstance().processSecStr = processSecondaryStructure;
112   }
113
114   public static boolean isExternalSecondaryStructure()
115   {
116     return getInstance().externalSecondaryStructure;
117   }
118
119   public static void setExternalSecondaryStructure(
120           boolean externalSecondaryStructure)
121   {
122     getInstance().externalSecondaryStructure = externalSecondaryStructure;
123   }
124
125   public static boolean isShowSeqFeatures()
126   {
127     return getInstance().showSeqFeatures;
128   }
129
130   public static void setShowSeqFeatures(boolean showSeqFeatures)
131   {
132     getInstance().showSeqFeatures = showSeqFeatures;
133   }
134
135   public static PDBEntry.Type getDefaultStructureFileFormat()
136   {
137     return getInstance().defaultStructureFileFormat;
138   }
139
140   public static void setDefaultStructureFileFormat(
141           String defaultStructureFileFormat)
142   {
143     getInstance().defaultStructureFileFormat = PDBEntry.Type
144             .valueOf(defaultStructureFileFormat.toUpperCase());
145   }
146
147   public static String getDefaultPDBFileParser()
148   {
149     return getInstance().defaultPDBFileParser.toString();
150   }
151
152   public static void setDefaultPDBFileParser(
153           StructureParser defaultPDBFileParser)
154   {
155     getInstance().defaultPDBFileParser = defaultPDBFileParser;
156   }
157
158   public static void setDefaultPDBFileParser(String defaultPDBFileParser)
159   {
160     getInstance().defaultPDBFileParser = StructureParser
161             .valueOf(defaultPDBFileParser.toUpperCase());
162   }
163
164 }