File: update_launching_script_and_config_file_for_Debian.patch

package info (click to toggle)
snpeff 5.2.f%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 701,384 kB
  • sloc: java: 62,547; perl: 2,279; sh: 1,185; python: 744; xml: 507; makefile: 50
file content (355 lines) | stat: -rw-r--r-- 15,625 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
Description: Alter the launching script, the config file and relevant Java
 files for a Debian install:
 - Simplify the paths to account for a Debian installation.
 - Use the default /etc/snpeff/snpEff.config file as configuration file if no
  file was given in the command line: it will be copied into
  ~/.snpEff/snpEff.config, which will be used as the configuration file is no
  other is given on the command line.
 - By default, put data in ~/.snpEff/data.
 - Correct bashisms in the launching script.
 - In Config.java, use per-user config file if available. Else use the file in
  /etc/snpeff. Else (which should normally just concern the unit tests), use
  default file which should be in the source tree.
 - Indicate path to effective config file in Java files.
Author: Pierre Gruet <pgt@debian.org>
Forwarded: not-needed
Last-Update: 2022-02-07

--- a/scripts/snpEff
+++ b/scripts/snpEff
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 #---------------------------------------------------------------------------------------------------
 #
@@ -13,13 +13,7 @@
 # Created by: Brad Chapman
 #---------------------------------------------------------------------------------------------------
 
-jardir="$(cd "$(dirname "$0")" && cd ".." && pwd -P)"
-
-java=java
-if [ -e "$JAVA_HOME/bin/java" ]
-then
-	java="$JAVA_HOME/bin/java"
-fi
+jardir=/usr/share/java
 
 default_jvm_mem_opts="-Xms1g -Xmx8g"
 jvm_mem_opts=""
@@ -39,12 +33,20 @@
     esac
 done
 
-if [ "$jvm_mem_opts" == "" ]; then
+if [ "$jvm_mem_opts" = "" ]; then
     jvm_mem_opts="$default_jvm_mem_opts"
 fi
-if [[ "$pass_args" != "" && ! "$pass_args" =~ "-c " ]]; then
-    pass_args="$pass_args -c ${jardir}/snpEff.config"
+if [ "$pass_args" != "" ] && ! echo "$pass_args" | grep "\-c " ; then
+    if [ ! -d ~/.snpEff ]; then
+        mkdir ~/.snpEff
+    fi
+
+    if [ -d ~/.snpEff -a ! -e ~/.snpEff/snpEff.config ]; then
+        cp /etc/snpeff/snpEff.config ~/.snpEff/snpEff.config
+    fi
+
+    pass_args="$pass_args -c $HOME/.snpEff/snpEff.config"
 fi
 
-exec $java $jvm_mem_opts $jvm_prop_opts -jar ${jardir}/snpEff.jar $pass_args
+exec java $jvm_mem_opts $jvm_prop_opts -jar ${jardir}/snpeff.jar $pass_args
 exit
--- a/config/snpEff.config
+++ b/config/snpEff.config
@@ -18,7 +18,7 @@
 # Also, a non-absolute path will be relative to config's file dir
 # 
 #---
-data.dir = ./data/
+data.dir = ~/.snpEff/data/
 
 #---
 # Database repository: A URL to the server where you can download databases (command: 'snpEff download dbName')
--- a/src/main/java/org/snpeff/PromoterSequences.java
+++ b/src/main/java/org/snpeff/PromoterSequences.java
@@ -63,7 +63,7 @@
 		genes = new HashSet<Gene>();
 
 		Log.info("Loading database");
-		String configFile = HOME + "/snpEff/snpEff.config";
+		String configFile = HOME + "/.snpEff/snpEff.config";
 		config = new Config(genomeName, configFile);
 		config.loadSnpEffectPredictor();
 		snpEffectPredictor = config.getSnpEffectPredictor();
--- a/src/main/java/org/snpeff/SnpEff.java
+++ b/src/main/java/org/snpeff/SnpEff.java
@@ -167,7 +167,7 @@
 
 	public SnpEff() {
 		genomeVer = ""; // Genome version
-		configFile = Config.DEFAULT_CONFIG_FILE; // Config file
+		configFile = Config.defaultConfigFile(); // Config file
 		verbose = false; // Be verbose
 		debug = false; // Debug mode
 		quiet = false; // Be quiet
--- a/src/main/java/org/snpeff/snpEffect/Config.java
+++ b/src/main/java/org/snpeff/snpEffect/Config.java
@@ -16,6 +16,8 @@
 public class Config implements Serializable, Iterable<String> {
 
     public static final String DEFAULT_CONFIG_FILE = "snpEff.config";
+    public static final String ETC_CONFIG_FILE = "/etc/snpeff/snpEff.config";
+    public static final String PREFERRED_CONFIG_FILE = Gpr.HOME + "/.snpEff/snpEff.config";
     public static final String DEFAULT_DATA_DIR = "./data";
     // Keys in properties file
     public static final String KEY_BUNDLE_SUFIX = ".bundle";
@@ -98,7 +100,7 @@
      * Create a config (uses DEFAULT_CONFIG_FILE)
      */
     public Config(String genomeVersion) {
-        init(genomeVersion, DEFAULT_CONFIG_FILE, null, null);
+        init(genomeVersion, defaultConfigFile(), null, null);
     }
 
     /**
@@ -201,6 +203,23 @@
         }
     }
 
+    /**
+     * If Debian-preferred config file is available, give it.
+     * else, if the config file in /etc/snpeff is available, give it.
+     * Else, default to DEFAULT_CONFIG_FILE.
+     */
+    public static String defaultConfigFile() {
+        File preferred = new File(PREFERRED_CONFIG_FILE);
+        File etcFile = new File(ETC_CONFIG_FILE);
+        if (preferred.exists()) {
+            return PREFERRED_CONFIG_FILE;
+        } else if (etcFile.exists()) {
+            return ETC_CONFIG_FILE;
+        } else {
+            return DEFAULT_CONFIG_FILE;
+        }
+    }
+
     /**
      * Get a list of URLs that can be used to download a database
      * Use compatible versions from 'getDatabaseCompatibilityVersions()'
--- a/src/main/java/org/snpeff/snpEffect/commandLine/SnpEffCmdProtein.java
+++ b/src/main/java/org/snpeff/snpEffect/commandLine/SnpEffCmdProtein.java
@@ -47,7 +47,7 @@
 	int totalOk = 0;
 	int totalWarnings = 0;
 	int totalNotFound = 0;
-	String configFile = Config.DEFAULT_CONFIG_FILE;
+	String configFile = Config.defaultConfigFile();
 	String proteinFile = "";
 	Map<String, String> proteinById; // Protein sequence by ID (transcript ID, protein ID, etc.)
 	AutoHashMap<String, List<Transcript>> trByChromo;
--- a/src/test/java/org/snpeff/snpEffect/testCases/integration/CompareEffects.java
+++ b/src/test/java/org/snpeff/snpEffect/testCases/integration/CompareEffects.java
@@ -37,13 +37,13 @@
 		genomeName = "test";
 		this.verbose = verbose;
 		this.snpEffectPredictor = snpEffectPredictor;
-		config = new Config("testCase", Config.DEFAULT_CONFIG_FILE);
+		config = new Config("testCase", Config.defaultConfigFile());
 	}
 
 	public CompareEffects(String genomeName, boolean verbose) {
 		this.genomeName = genomeName;
 		this.verbose = verbose;
-		config = new Config("testCase", Config.DEFAULT_CONFIG_FILE);
+		config = new Config("testCase", Config.defaultConfigFile());
 	}
 
 	/**
@@ -113,7 +113,7 @@
 
 	public void initSnpEffPredictor() {
 		// Create a config and force out snpPredictor for hg37 chromosome Y
-		config = new Config(genomeName, Config.DEFAULT_CONFIG_FILE);
+		config = new Config(genomeName, Config.defaultConfigFile());
 
 		if (snpEffectPredictor == null) {
 			config.loadSnpEffectPredictor();
--- a/src/test/java/org/snpeff/snpEffect/testCases/integration/CompareToEnsembl.java
+++ b/src/test/java/org/snpeff/snpEffect/testCases/integration/CompareToEnsembl.java
@@ -57,7 +57,7 @@
 	public CompareToEnsembl(String genomeName, boolean throwException) {
 		this.throwException = throwException;
 		if (verbose) Log.info("Loading predictor");
-		config = new Config(genomeName, Config.DEFAULT_CONFIG_FILE);
+		config = new Config(genomeName, Config.defaultConfigFile());
 		config.loadSnpEffectPredictor();
 		snpEffectPredictor = config.getSnpEffectPredictor();
 		genome = config.getGenome();
--- a/src/test/java/org/snpeff/snpEffect/testCases/integration/CreateSpliceSiteTestCase.java
+++ b/src/test/java/org/snpeff/snpEffect/testCases/integration/CreateSpliceSiteTestCase.java
@@ -33,7 +33,7 @@
 	 */
 	public void run() {
 		Log.debug("Loading config files");
-		Config config = new Config("testCase", Config.DEFAULT_CONFIG_FILE);
+		Config config = new Config("testCase", Config.defaultConfigFile());
 		config.loadSnpEffectPredictor();
 
 		for (Gene gint : config.getGenome().getGenes()) {
--- a/src/test/java/org/snpeff/snpEffect/testCases/integration/TestCasesHgvsBase.java
+++ b/src/test/java/org/snpeff/snpEffect/testCases/integration/TestCasesHgvsBase.java
@@ -75,7 +75,7 @@
      */
     protected void initSnpEffPredictor(boolean addUtrs, boolean onlyPlusStrand) {
         // Create a config and force out snpPredictor for hg37 chromosome Y
-        if (config == null) config = new Config("testCase", Config.DEFAULT_CONFIG_FILE);
+        if (config == null) config = new Config("testCase", Config.defaultConfigFile());
 
         // Initialize factory
         int maxGeneLen = 1000;
--- a/src/test/java/org/snpeff/snpEffect/testCases/integration/TestCasesIntegrationBase.java
+++ b/src/test/java/org/snpeff/snpEffect/testCases/integration/TestCasesIntegrationBase.java
@@ -95,7 +95,7 @@
         String expectedResult = Gpr.readFile(resultFile).trim();
 
         // Build
-        Config config = new Config(genome, Config.DEFAULT_CONFIG_FILE);
+        Config config = new Config(genome, Config.defaultConfigFile());
         SnpEffPredictorFactoryRefSeq factory = new SnpEffPredictorFactoryRefSeq(config);
         factory.setFileName(refSeqFile);
         factory.setVerbose(verbose);
@@ -118,7 +118,7 @@
      * Build a genome from a embl file and compare results to 'expected' results
      */
     public SnpEffectPredictor buildEmbl(String genome, String emblFile) {
-        Config config = new Config(genome, Config.DEFAULT_CONFIG_FILE);
+        Config config = new Config(genome, Config.defaultConfigFile());
         SnpEffPredictorFactoryEmbl sepEmbl = new SnpEffPredictorFactoryEmbl(config, emblFile);
         SnpEffectPredictor sep = sepEmbl.create();
         return sep;
@@ -132,7 +132,7 @@
      * Build a genome from a genbank file and compare results to 'expected' results
      */
     public SnpEffectPredictor buildGeneBank(String genome, String genBankFile, boolean circularCorrectlargeGap) {
-        Config config = new Config(genome, Config.DEFAULT_CONFIG_FILE);
+        Config config = new Config(genome, Config.defaultConfigFile());
         SnpEffPredictorFactoryGenBank sepfg = new SnpEffPredictorFactoryGenBank(config, genBankFile);
         sepfg.setVerbose(verbose);
         sepfg.setCircularCorrectLargeGap(circularCorrectlargeGap);
@@ -157,7 +157,7 @@
      */
     public SnpEffectPredictor buildGff3AndCompare(String genome, String gff3File, String resultFile, boolean readSeqs, boolean createRandSequences) {
         // Build
-        Config config = new Config(genome, Config.DEFAULT_CONFIG_FILE);
+        Config config = new Config(genome, Config.defaultConfigFile());
         SnpEffPredictorFactoryGff3 fgff3 = new SnpEffPredictorFactoryGff3(config);
         fgff3.setVerbose(verbose);
         if (gff3File != null) fgff3.setFileName(gff3File);
@@ -194,7 +194,7 @@
         String expectedResult = Gpr.readFile(resultFile).trim();
 
         // Build
-        Config config = new Config(genome, Config.DEFAULT_CONFIG_FILE);
+        Config config = new Config(genome, Config.defaultConfigFile());
         SnpEffPredictorFactoryGtf22 fgtf22 = new SnpEffPredictorFactoryGtf22(config);
         fgtf22.setFileName(gtf22);
         fgtf22.setVerbose(verbose);
--- a/src/test/java/org/snpeff/snpEffect/testCases/integration/TestCasesIntegrationExonFrame.java
+++ b/src/test/java/org/snpeff/snpEffect/testCases/integration/TestCasesIntegrationExonFrame.java
@@ -50,7 +50,7 @@
         //---
         // Load database and check some numbers
         //---
-        String configFile = Config.DEFAULT_CONFIG_FILE;
+        String configFile = Config.defaultConfigFile();
         Config config = new Config(genomeName, configFile);
         if (verbose) Log.info("Loading database");
         SnpEffectPredictor snpEffectPredictor = config.loadSnpEffectPredictor();
--- a/src/test/java/org/snpeff/snpEffect/testCases/integration/TestCasesIntegrationLof.java
+++ b/src/test/java/org/snpeff/snpEffect/testCases/integration/TestCasesIntegrationLof.java
@@ -281,7 +281,7 @@
 
 		// Load database
 		String genomeVer = "testHg3766Chr1";
-		config = new Config(genomeVer, Config.DEFAULT_CONFIG_FILE);
+		config = new Config(genomeVer, Config.defaultConfigFile());
 		config.loadSnpEffectPredictor();
 		config.setTreatAllAsProteinCoding(true); // For historical reasons...
 		config.getSnpEffectPredictor().buildForest();
--- a/src/test/java/org/snpeff/snpEffect/testCases/integration/TestCasesIntegrationNmd.java
+++ b/src/test/java/org/snpeff/snpEffect/testCases/integration/TestCasesIntegrationNmd.java
@@ -25,7 +25,7 @@
         // Load database
         String genomeVer = "testHg3766Chr1";
         Log.debug("Loading database '" + genomeVer + "'");
-        Config config = new Config(genomeVer, Config.DEFAULT_CONFIG_FILE);
+        Config config = new Config(genomeVer, Config.defaultConfigFile());
         config.setTreatAllAsProteinCoding(true); // For historical reasons...
         config.loadSnpEffectPredictor();
 
--- a/src/test/java/org/snpeff/snpEffect/testCases/integration/TestCasesIntegrationVariant.java
+++ b/src/test/java/org/snpeff/snpEffect/testCases/integration/TestCasesIntegrationVariant.java
@@ -225,7 +225,7 @@
     @Test
     public void test_25_exon_bases() {
         Log.debug("Test");
-        Config config = new Config("testCase", Config.DEFAULT_CONFIG_FILE);
+        Config config = new Config("testCase", Config.defaultConfigFile());
         config.loadSnpEffectPredictor();
 
         String fastaFile = path("testCase.fa");
@@ -283,7 +283,7 @@
         String gtfFile = path("ENSMUSG00000005763.gtf");
         String genome = "testMm37.61";
 
-        Config config = new Config(genome, Config.DEFAULT_CONFIG_FILE);
+        Config config = new Config(genome, Config.defaultConfigFile());
         SnpEffPredictorFactoryGtf22 fgtf22 = new SnpEffPredictorFactoryGtf22(config);
         fgtf22.setFileName(gtfFile);
         fgtf22.setReadSequences(false); // Don't read sequences
--- a/src/test/java/org/snpeff/snpEffect/testCases/unity/TestCasesBase.java
+++ b/src/test/java/org/snpeff/snpEffect/testCases/unity/TestCasesBase.java
@@ -254,7 +254,7 @@
     protected void initSnpEffPredictor(Gene[] genesToAdd) {
         // Create a config and force out snpPredictor
         if (config == null || config.getGenome() == null || !config.getGenome().getGenomeName().equals(genomeName)) {
-            config = new Config(genomeName, Config.DEFAULT_CONFIG_FILE);
+            config = new Config(genomeName, Config.defaultConfigFile());
         }
 
         // Initialize factory
--- a/src/test/java/org/snpeff/snpEffect/testCases/unity/TestCasesBaseApply.java
+++ b/src/test/java/org/snpeff/snpEffect/testCases/unity/TestCasesBaseApply.java
@@ -44,7 +44,7 @@
     protected void initSnpEffPredictor() {
         // Create a config and force out snpPredictor
         if (config == null || config.getGenome() == null || !config.getGenome().getGenomeName().equals(genomeName)) {
-            config = new Config(genomeName, Config.DEFAULT_CONFIG_FILE);
+            config = new Config(genomeName, Config.defaultConfigFile());
         }
 
         // Create predictor
--- a/src/test/java/org/snpeff/snpEffect/testCases/unity/TestCasesBuild.java
+++ b/src/test/java/org/snpeff/snpEffect/testCases/unity/TestCasesBuild.java
@@ -30,7 +30,7 @@
         };
 
         // Build
-        Config config = new Config(genome, Config.DEFAULT_CONFIG_FILE);
+        Config config = new Config(genome, Config.defaultConfigFile());
         SnpEffPredictorFactoryGff3 sefGff = new SnpEffPredictorFactoryGff3(config);
         sefGff.setFileName(gff);
         sefGff.setVerbose(verbose);
@@ -68,7 +68,7 @@
         };
 
         // Build
-        Config config = new Config(genome, Config.DEFAULT_CONFIG_FILE);
+        Config config = new Config(genome, Config.defaultConfigFile());
         SnpEffPredictorFactoryGff3 sefGff = new SnpEffPredictorFactoryGff3(config);
         sefGff.setFileName(gff);
         sefGff.setFastaFile(fasta);