JAL-3691 automatic insertion of Locale.ROOT to toUpperCase() and toLowerCase() and...
[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 java.util.Locale;
24
25 import jalview.datamodel.PDBEntry;
26 import jalview.datamodel.PDBEntry.Type;
27
28 /**
29  * bean holding settings for structure IO. TODO: tests for validation of values
30  * TODO: tests for race conditions (all fields are static, is that correct ?)
31  * 
32  * @author tcofoegbu
33  *
34  */
35 public class StructureImportSettings
36 {
37   /**
38    * set to true to add derived sequence annotations (temp factor read from
39    * file, or computed secondary structure) to the alignment
40    */
41   private static boolean visibleChainAnnotation = false;
42
43   /**
44    * Set true to predict secondary structure (using JMol for protein, Annotate3D
45    * for RNA)
46    */
47   private static boolean processSecStr = false;
48
49   /**
50    * Set true (with predictSecondaryStructure=true) to predict secondary
51    * structure using an external service (currently Annotate3D for RNA only)
52    */
53   private static boolean externalSecondaryStructure = false;
54
55   private static boolean showSeqFeatures = true;
56
57   public enum StructureParser
58   {
59     JMOL_PARSER, JALVIEW_PARSER
60   }
61
62   /**
63    * Determines the default file format for structure files to be downloaded
64    * from the PDB sequence fetcher. Possible options include: PDB|mmCIF
65    */
66   private static PDBEntry.Type defaultStructureFileFormat = Type.PDB;
67
68   /**
69    * Determines the parser used for parsing PDB format file. Possible options
70    * are : JMolParser|JalveiwParser
71    */
72   private static StructureParser defaultPDBFileParser = StructureParser.JMOL_PARSER;
73
74   public static void addSettings(boolean addAlignmentAnnotations,
75           boolean processSecStr, boolean externalSecStr)
76   {
77     StructureImportSettings.visibleChainAnnotation = addAlignmentAnnotations;
78     StructureImportSettings.processSecStr = processSecStr;
79     StructureImportSettings.externalSecondaryStructure = externalSecStr;
80     StructureImportSettings.showSeqFeatures = true;
81   }
82
83   public static boolean isVisibleChainAnnotation()
84   {
85     return visibleChainAnnotation;
86   }
87
88   public static void setVisibleChainAnnotation(
89           boolean visibleChainAnnotation)
90   {
91     StructureImportSettings.visibleChainAnnotation = visibleChainAnnotation;
92   }
93
94   public static boolean isProcessSecondaryStructure()
95   {
96     return processSecStr;
97   }
98
99   public static void setProcessSecondaryStructure(
100           boolean processSecondaryStructure)
101   {
102     StructureImportSettings.processSecStr = processSecondaryStructure;
103   }
104
105   public static boolean isExternalSecondaryStructure()
106   {
107     return externalSecondaryStructure;
108   }
109
110   public static void setExternalSecondaryStructure(
111           boolean externalSecondaryStructure)
112   {
113     StructureImportSettings.externalSecondaryStructure = externalSecondaryStructure;
114   }
115
116   public static boolean isShowSeqFeatures()
117   {
118     return showSeqFeatures;
119   }
120
121   public static void setShowSeqFeatures(boolean showSeqFeatures)
122   {
123     StructureImportSettings.showSeqFeatures = showSeqFeatures;
124   }
125
126   public static PDBEntry.Type getDefaultStructureFileFormat()
127   {
128     return defaultStructureFileFormat;
129   }
130
131   public static void setDefaultStructureFileFormat(
132           String defaultStructureFileFormat)
133   {
134     StructureImportSettings.defaultStructureFileFormat = PDBEntry.Type
135             .valueOf(defaultStructureFileFormat.toUpperCase(Locale.ROOT));
136   }
137
138   public static String getDefaultPDBFileParser()
139   {
140     return defaultPDBFileParser.toString();
141   }
142
143   public static void setDefaultPDBFileParser(
144           StructureParser defaultPDBFileParser)
145   {
146     StructureImportSettings.defaultPDBFileParser = defaultPDBFileParser;
147   }
148
149   public static void setDefaultPDBFileParser(String defaultPDBFileParser)
150   {
151     StructureImportSettings.defaultPDBFileParser = StructureParser
152             .valueOf(defaultPDBFileParser.toUpperCase(Locale.ROOT));
153   }
154
155 }