Skip to content

Commit d05b6ae

Browse files
committed
Merge pull request #1 from sbliven/pdbdir
Renaming CACHE_DIR to match its value (PDB_CACHE_DIR)
2 parents 49f69e7 + b122e60 commit d05b6ae

10 files changed

Lines changed: 56 additions & 99 deletions

File tree

biojava3-structure-gui/src/main/java/org/biojava/bio/structure/align/gui/ConfigPDBInstallPanel.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ public class ConfigPDBInstallPanel extends JPanel
5858
*/
5959
private static final long serialVersionUID = -1055193854675583808L;
6060

61-
/** the system property PDB_DIR can be used to configure the
62-
* default location for PDB files.
63-
*/
64-
public static final String PDB_DIR = "PDB_DIR";
65-
6661
JCheckBox pdbSplit;
6762
JCheckBox fromFtp;
6863
JComboBox fileType;
@@ -84,7 +79,7 @@ private ConfigPDBInstallPanel(){
8479

8580
pdbDir = new JTextField(20);
8681

87-
String conf = System.getProperty(PDB_DIR);
82+
String conf = System.getProperty(UserConfiguration.PDB_DIR);
8883
if ( conf != null){
8984
pdbDir.setText(conf);
9085
}

biojava3-structure-gui/src/main/java/org/biojava/bio/structure/align/webstart/WebStartMain.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.biojava.bio.structure.align.seq.SmithWaterman3Daligner;
4949
import org.biojava.bio.structure.align.util.AtomCache;
5050
import org.biojava.bio.structure.align.util.UserConfiguration;
51-
import org.biojava.bio.structure.gui.util.PDBDirPanel;
5251
import org.biojava.bio.structure.io.PDBFileReader;
5352

5453
public class WebStartMain
@@ -136,7 +135,7 @@ public void run() {
136135

137136
UserConfiguration config = getWebStartConfig();
138137

139-
System.setProperty(PDBDirPanel.PDB_DIR,config.getPdbFilePath());
138+
System.setProperty(UserConfiguration.PDB_DIR,config.getPdbFilePath());
140139
System.out.println("using PDB file path: " + config.getPdbFilePath());
141140

142141
AtomCache cache = new AtomCache(config);
@@ -265,7 +264,7 @@ public static UserConfiguration getWebStartConfig(){
265264
public static UserConfiguration getDefaultConfig(){
266265
userConfig = new UserConfiguration();
267266

268-
String pdbDir = System.getProperty(PDBDirPanel.PDB_DIR);
267+
String pdbDir = System.getProperty(UserConfiguration.PDB_DIR);
269268
if ( pdbDir != null) {
270269
userConfig.setPdbFilePath(pdbDir);
271270

@@ -294,7 +293,7 @@ public static UserConfiguration requestUserConfig(){
294293
//UserConfiguration config = new UserConfiguration();
295294
userConfig = new UserConfiguration();
296295

297-
String pdbDir = System.getProperty(PDBDirPanel.PDB_DIR);
296+
String pdbDir = System.getProperty(UserConfiguration.PDB_DIR);
298297
if ( pdbDir != null) {
299298
userConfig.setPdbFilePath(pdbDir);
300299
return userConfig;
@@ -324,7 +323,7 @@ public static UserConfiguration requestUserConfig(){
324323
System.err.println("did not provide directory, going on level higher! " + file.getAbsolutePath());
325324
file = file.getParentFile();
326325
}
327-
System.setProperty(PDBDirPanel.PDB_DIR, file.getAbsolutePath());
326+
System.setProperty(UserConfiguration.PDB_DIR, file.getAbsolutePath());
328327
userConfig.setPdbFilePath(file.getAbsolutePath());
329328

330329
return userConfig;

biojava3-structure-gui/src/main/java/org/biojava/bio/structure/gui/util/PDBDirPanel.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.io.File;
3030
import java.io.IOException;
3131
import java.util.logging.Logger;
32+
3233
import javax.swing.AbstractAction;
3334
import javax.swing.Action;
3435
import javax.swing.BorderFactory;
@@ -39,11 +40,11 @@
3940
import javax.swing.JPanel;
4041
import javax.swing.JTextField;
4142

42-
4343
import org.biojava.bio.structure.Chain;
4444
import org.biojava.bio.structure.Structure;
4545
import org.biojava.bio.structure.StructureException;
4646
import org.biojava.bio.structure.StructureImpl;
47+
import org.biojava.bio.structure.align.util.UserConfiguration;
4748
import org.biojava.bio.structure.io.PDBFileReader;
4849

4950
/** A class to define where a structure for the alignment is coming from
@@ -68,12 +69,6 @@ public class PDBDirPanel
6869
JTextField c1;
6970
JTextField c2;
7071

71-
/** the system property PDB_DIR can be used to configure the
72-
* default location for PDB files.
73-
*/
74-
public static final String PDB_DIR = "PDB_DIR";
75-
76-
7772
public static Logger logger = Logger.getLogger("org.biojava");
7873

7974
/** load the PDB files from a local directory
@@ -85,7 +80,7 @@ public PDBDirPanel() {
8580

8681
pdbDir = new JTextField(20);
8782

88-
String conf = System.getProperty(PDB_DIR);
83+
String conf = System.getProperty(UserConfiguration.PDB_DIR);
8984
if ( conf != null){
9085
pdbDir.setText(conf);
9186
}
@@ -97,12 +92,12 @@ public PDBDirPanel() {
9792

9893
f1 = new JTextField(pdbfSize);
9994
c1 = new JTextField(1);
100-
JPanel p1 = getPDBFilePanel(1,f1,c1);
95+
JPanel p1 = getPDBFilePanel(1,f1,c1);
10196
vBox.add(p1);
10297

10398
f2 = new JTextField(pdbfSize);
10499
c2 = new JTextField(1);
105-
JPanel p2 = getPDBFilePanel(2, f2,c2);
100+
JPanel p2 = getPDBFilePanel(2, f2,c2);
106101
vBox.add(p2);
107102

108103

@@ -127,14 +122,10 @@ private Structure fromPDB(JTextField f, JTextField c) throws StructureException{
127122

128123
// load them from the file system
129124

130-
PDBFileReader reader = new PDBFileReader();
131125

132126

133127
String dir = pdbDir.getText();
134-
if ( dir != null){
135-
System.setProperty(PDB_DIR, dir);
136-
}
137-
reader.setPath(dir);
128+
PDBFileReader reader = new PDBFileReader(dir);
138129

139130
if ( debug )
140131
System.out.println("dir: " + dir);

biojava3-structure/src/main/java/demo/DemoChangeChemCompProvider.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.biojava.bio.structure.Chain;
66
import org.biojava.bio.structure.Group;
77
import org.biojava.bio.structure.Structure;
8+
import org.biojava.bio.structure.align.util.UserConfiguration;
89
import org.biojava.bio.structure.io.FileParsingParameters;
910
import org.biojava.bio.structure.io.PDBFileReader;
1011
import org.biojava.bio.structure.io.mmcif.AllChemCompProvider;
@@ -44,7 +45,8 @@ public static void main(String[] args){
4445
// you can set the path to the local PDB installation either like this
4546
// reader.setPath(PDB_PATH);
4647
// or via
47-
//System.setProperty(AbstractUserArgumentProcessor.PDB_DIR,PDB_PATH);
48+
// by setting the PDB_PATH environmental variable or system property
49+
// when running the demo (e.g. -DPDB_DIR=/path/to/pdb)
4850

4951
if ( loadChemComp) {
5052

biojava3-structure/src/main/java/org/biojava/bio/structure/align/FarmJob.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.biojava.bio.structure.align.events.AlignmentProgressListener;
1111
import org.biojava.bio.structure.align.util.CliTools;
1212
import org.biojava.bio.structure.align.util.ConfigurationException;
13+
import org.biojava.bio.structure.align.util.UserConfiguration;
1314
import org.biojava.bio.structure.scop.CachedRemoteScopInstallation;
1415
import org.biojava.bio.structure.scop.ScopDatabase;
1516
import org.biojava.bio.structure.scop.ScopFactory;
@@ -138,14 +139,14 @@ public void run(){
138139
// set the system wide PDB path
139140

140141
String path = params.getPdbFilePath();
141-
System.setProperty(AbstractUserArgumentProcessor.PDB_DIR,path);
142+
System.setProperty(UserConfiguration.PDB_DIR,path);
142143

143144
String cachePath = params.getCacheFilePath();
144145
if ( cachePath != null && ! cachePath.equals(""))
145-
System.setProperty(AbstractUserArgumentProcessor.CACHE_DIR,cachePath);
146+
System.setProperty(UserConfiguration.PDB_CACHE_DIR,cachePath);
146147
else {
147148
// if not provided, we use pdbFilePath as the default CACHE path
148-
System.setProperty(AbstractUserArgumentProcessor.CACHE_DIR,path);
149+
System.setProperty(UserConfiguration.PDB_CACHE_DIR,path);
149150
}
150151
// declare SCOP to be locally cached, but fetching new stuff from remote
151152
ScopDatabase scop = new CachedRemoteScopInstallation(true);

biojava3-structure/src/main/java/org/biojava/bio/structure/align/ce/AbstractUserArgumentProcessor.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,6 @@ public abstract class AbstractUserArgumentProcessor implements UserArgumentProce
6565

6666
public static final List<String> mandatoryArgs= new ArrayList<String>();
6767

68-
/** the system property PDB_DIR can be used to configure the
69-
* default location for PDB files.
70-
*/
71-
public static final String PDB_DIR = "PDB_DIR";
72-
73-
74-
/** The system property PDB_CACHE_DIR can be used to configure the default location for various data related to working with PDB files, such as domain definitions.
75-
*
76-
*/
77-
public static final String CACHE_DIR = "PDB_CACHE_DIR";
78-
7968
protected AbstractUserArgumentProcessor(){
8069
params = new StartupParameters();
8170
}
@@ -127,11 +116,11 @@ public void process(String[] argv){
127116
}
128117

129118
if ( params.getPdbFilePath() != null){
130-
System.setProperty(PDB_DIR,params.getPdbFilePath());
119+
System.setProperty(UserConfiguration.PDB_DIR,params.getPdbFilePath());
131120
}
132121

133122
if ( params.getCacheFilePath() != null){
134-
System.setProperty(CACHE_DIR,params.getCacheFilePath());
123+
System.setProperty(UserConfiguration.PDB_CACHE_DIR,params.getCacheFilePath());
135124
}
136125

137126
if ( params.isShowMenu()){

biojava3-structure/src/main/java/org/biojava/bio/structure/align/util/UserConfiguration.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class UserConfiguration
4747
public static final String TMP_DIR = "java.io.tmpdir";
4848

4949
public static final String PDB_DIR = "PDB_DIR";
50-
public static final String CACHE_DIR = "PDB_CACHE_DIR";
50+
public static final String PDB_CACHE_DIR = "PDB_CACHE_DIR";
5151

5252
public static final String lineSplit = System.getProperty("file.separator");
5353

@@ -77,8 +77,8 @@ public class UserConfiguration
7777
* the system's temp directory is used.
7878
* </li>
7979
* <li>default cache location. This is the first specified of:
80-
* <ol><li>{@value #CACHE_DIR} system property (for instance, -D{@value #CACHE_DIR}=/tmp)</li>
81-
* <li>{@value #CACHE_DIR} environment variable</li>
80+
* <ol><li>{@value #PDB_CACHE_DIR} system property (for instance, -D{@value #PDB_CACHE_DIR}=/tmp)</li>
81+
* <li>{@value #PDB_CACHE_DIR} environment variable</li>
8282
* <li>the value set for {@value #PDB_DIR}</li>
8383
* </ol>
8484
* if the provided path is not a directory or is not writable then
@@ -162,7 +162,7 @@ private String initCacheFilePath() {
162162

163163
String path = null;
164164

165-
String propertyName = CACHE_DIR;
165+
String propertyName = PDB_CACHE_DIR;
166166

167167
String userProvidedDir = System.getProperty(propertyName);
168168

biojava3-structure/src/main/java/org/biojava/bio/structure/io/MMCIFFileReader.java

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -91,34 +91,18 @@ public static void main(String[] args) throws Exception {
9191
}
9292

9393
/**
94-
* Constructs a new MMCIFFileReader, initialising the extensions member variable.
95-
* The path is initialised in the same way as {@link UserConfiguration},
94+
* Constructs a new MMCIFFileReader, initializing the extensions member variable.
95+
* The path is initialized in the same way as {@link UserConfiguration},
9696
* i.e. to system property/environment variable {@link UserConfiguration#PDB_DIR}.
97-
* Both autoFetch and splitDir are initialised to false
97+
* Both autoFetch and splitDir are initialized to false
9898
*/
9999
public MMCIFFileReader(){
100-
extensions = new ArrayList<String>();
101-
extensions.add(".cif");
102-
extensions.add(".mmcif");
103-
extensions.add(".cif.gz");
104-
extensions.add(".mmcif.gz");
105-
106-
autoFetch = false;
107-
pdbDirectorySplit = false;
108-
109-
params = new FileParsingParameters();
110-
111-
112-
// initialising path from PDB_DIR property/environment variable
113-
UserConfiguration config = new UserConfiguration();
114-
path = new File(config.getPdbFilePath());
115-
logger.debug("Initialising from system property/environment variable to path: {}", path.toString());
116-
100+
this(null);
117101
}
118102

119103
/**
120-
* Constructs a new PDBFileReader, initialising the extensions member variable.
121-
* The path is initialised to the given path, both autoFetch and splitDir are initialised to false.
104+
* Constructs a new PDBFileReader, initializing the extensions member variable.
105+
* The path is initialized to the given path, both autoFetch and splitDir are initialized to false.
122106
*/
123107
public MMCIFFileReader(String path){
124108
extensions = new ArrayList<String>();
@@ -129,12 +113,17 @@ public MMCIFFileReader(String path){
129113

130114
autoFetch = false;
131115
pdbDirectorySplit = false;
132-
116+
133117
params = new FileParsingParameters();
134118

135-
119+
if( path == null) {
120+
UserConfiguration config = new UserConfiguration();
121+
path = config.getPdbFilePath();
122+
logger.debug("Initialising from system property/environment variable to path: {}", path.toString());
123+
} else {
124+
logger.debug("Initialising with path {}", path.toString());
125+
}
136126
this.path = new File(path);
137-
logger.debug("Initialising with path {}", path.toString());
138127
}
139128

140129
public void addExtension(String ext) {

biojava3-structure/src/main/java/org/biojava/bio/structure/io/PDBFileReader.java

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -261,35 +261,22 @@ public static void main(String[] args){
261261

262262

263263
/**
264-
* Constructs a new PDBFileReader, initialising the extensions member variable.
265-
* The path is initialised in the same way as {@link UserConfiguration},
264+
* Constructs a new PDBFileReader, initializing the extensions member variable.
265+
* The path is initialized in the same way as {@link UserConfiguration},
266266
* i.e. to system property/environment variable {@link UserConfiguration#PDB_DIR}.
267-
* Both autoFetch and splitDir are initialised to false
267+
* Both autoFetch and splitDir are initialized to false
268268
*/
269269
public PDBFileReader() {
270-
extensions = new ArrayList<String>();
271-
272-
extensions.add(".ent");
273-
extensions.add(".pdb");
274-
extensions.add(".ent.gz");
275-
extensions.add(".pdb.gz");
276-
extensions.add(".ent.Z");
277-
extensions.add(".pdb.Z");
278-
279-
autoFetch = false;
280-
pdbDirectorySplit = false;
281-
282-
params = new FileParsingParameters();
283-
284-
// initialising path from PDB_DIR property/environment variable
285-
UserConfiguration config = new UserConfiguration();
286-
path = new File(config.getPdbFilePath());
287-
logger.debug("Initialising from system property/environment variable to path: {}", path.toString());
270+
this(null);
288271
}
289272

290273
/**
291-
* Constructs a new PDBFileReader, initialising the extensions member variable.
292-
* The path is initialised to the given path, both autoFetch and splitDir are initialised to false.
274+
* Constructs a new PDBFileReader, initializing the extensions member variable.
275+
* The path is initialized to the given path, both autoFetch and splitDir are initialized to false.
276+
*
277+
* <p>If path is null, initialize using the system property/environment variable
278+
* {@link UserConfiguration#PDB_DIR}.
279+
* @param path Path to the PDB file directory
293280
*/
294281
public PDBFileReader(String path) {
295282
extensions = new ArrayList<String>();
@@ -301,14 +288,18 @@ public PDBFileReader(String path) {
301288
extensions.add(".ent.Z");
302289
extensions.add(".pdb.Z");
303290

304-
autoFetch = false;
291+
autoFetch = false;
305292
pdbDirectorySplit = false;
306293

307294
params = new FileParsingParameters();
308295

296+
if(path == null ) {
297+
path = new UserConfiguration().getPdbFilePath();
298+
logger.debug("Initializing from system property/environment variable to path: {}", path.toString());
299+
} else {
300+
logger.debug("Initialising with path {}", path.toString());
301+
}
309302
this.path = new File(path);
310-
logger.debug("Initialising with path {}", path.toString());
311-
312303
}
313304

314305

biojava3-structure/src/main/java/org/biojava/bio/structure/scop/ScopInstallation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public void nullifyComments() {
146146
/**
147147
* Create a new SCOP installation, downloading the file to "the right place".
148148
* This will first check for system properties or environmental variables
149-
* called {@link UserConfiguration#CACHE_DIR}, or else will use a temporary directory
149+
* called {@link UserConfiguration#PDB_CACHE_DIR}, or else will use a temporary directory
150150
*/
151151
public ScopInstallation() {
152152
this((new UserConfiguration()).getCacheFilePath());

0 commit comments

Comments
 (0)