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