Skip to content

Commit af06599

Browse files
committed
Fixed a mariaDB related bug. Further improved terminal output.
1 parent ff42a44 commit af06599

22 files changed

+565
-308
lines changed

java/src/build/Bmain.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,15 @@ private static void prtActions(String [] args) {
8282

8383
if (args.length==0) System.exit(0);
8484

85+
/**
8586
System.out.println("\nFor developments:");
8687
System.out.println(" 1 Load Gene annotation");
8788
System.out.println(" 2 Load Variants");
8889
System.out.println(" 3 Compute transcripts and proteins");
8990
System.out.println(" 4 Load Variant Coverage");
9091
System.out.println(" 9 Compute additional columns");
9192
System.out.println("10 Overview");
93+
**/
9294
System.exit(0);
9395
}
9496
/****************************************************
@@ -123,59 +125,55 @@ public static void buildArgs(int action, boolean prtCfg) {
123125
if (action==0) {
124126
LogTime.PrtDateMsg("+++Start building entire database+++");
125127
// Order of these 4 is important.
126-
new Genes(mDB, cfg); LogTime.PrtSpMsg(0, "--Finish Step 1");
128+
new Genes(mDB, cfg); LogTime.PrtSpMsg(0, "--Finish Step 1");
127129
new Variants(hostCfg.renew(),cfg); LogTime.PrtSpMsg(0, "--Finish Step 2");
128130
new VarAnno(hostCfg.renew(), cfg); LogTime.PrtSpMsg(0, "--Finish Step 3"); // may add cDNApos
129131
new GenTrans(hostCfg.renew(), cfg, project); LogTime.PrtSpMsg(0, "--Finish Step 4"); // else add here
130132
new VarCov(hostCfg.renew(), cfg, 0); LogTime.PrtSpMsg(0, "--Finish Step 5"); // needed here
131133

132134
new GeneAnno(hostCfg.renew(), cfg); LogTime.PrtSpMsg(0, "--Finish Step 6");
133135
if (cfg.hasExpDir())
134-
{new GeneCov(hostCfg.renew(), cfg); LogTime.PrtSpMsg(0, "--Step 6b");}
136+
{new GeneCov(hostCfg.renew(), cfg); LogTime.PrtSpMsg(0, "--Finish Step 6b");}
135137

136138
new ASE(hostCfg.renew()); LogTime.PrtSpMsg(0, "--Finish Step 7");
137139
new Compute(hostCfg.renew(), 0); LogTime.PrtSpMsg(0, "--Finish Step 8");
138-
new Overview(hostCfg.renew(), logDir); LogTime.PrtSpMsg(0, "--Finish Step 9");
139140
}
140141
// these only execute from buildAW (command line)
142+
// 5-8 and >20 are documented on help
141143
else if (action==1) new Genes(mDB, cfg);
142144
else if (action==2) new Variants(mDB, cfg);
143145
else if (action==3) {
144146
new GenTrans(mDB, cfg, project);
145147
new Compute(mDB, 1); // missense summary
146-
new Overview(mDB, logDir);
147148
}
148149
else if (action==4) {
149150
new VarCov(mDB,cfg, 0);
150151
new ASE(mDB);
151152
new Compute(mDB, 3); // copy ref:alt to trans S: columns
152-
new Overview(mDB, logDir);
153153
}
154+
154155
else if (action==5) {
155156
new VarAnno(mDB, cfg);
156157
new Compute(mDB, 1); // missense summary
157-
new Overview(mDB, logDir);
158158
}
159159
else if (action==6) new GeneAnno(mDB, cfg);
160-
161160
else if (action==7) new ASE(mDB);
162161
else if (action==8) { // add read counts
163162
new GeneCov(mDB, cfg);
164163
new ASE(mDB);
165164
new Compute(mDB, 2); // copy ref:alt to trans R: columns
166-
new Overview(mDB, logDir);
167165
}
168166
else if (action==9) new Compute(mDB, 0);
169-
else if (action==10) new Overview(mDB, logDir);
170-
171167
else if (action>20) { // update trans/gene SNP coverage counts
172168
Globals.READ_LEN = action;
173169
new VarCov(mDB, cfg, 1);
174170
new ASE(mDB);
175171
new Compute(mDB, 3);
176-
new Overview(mDB, logDir);
177172
}
178-
else if (action==12) Stats.prtStats(mDB);
173+
else if (action==12) {
174+
Stats.prtStats(mDB);
175+
System.exit(0);
176+
}
179177
else if (action==16) {
180178
new MakeDemo(mDB, cfg, 1);
181179
System.exit(0);
@@ -201,6 +199,8 @@ else if (action==16) {
201199
}
202200
}
203201
mDB.close(); // CASQ 7Sept19
202+
203+
new Overview(hostCfg.renew(), logDir); // CASZ 8Oct19 always do overview and do it here
204204
}
205205
catch (Exception e) {LogTime.PrtSpMsg(1, "ChgData not added");}
206206

java/src/build/Cfg.java

Lines changed: 62 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ public class Cfg {
2626
// all the files and directories that can be in AW.cfg
2727
private String gtfFile = null; // required
2828
private String ncbiFile = null; // optional
29-
private String genomeDir = null; // optional
29+
private String genomeDir = null; // optional
3030

31-
private String varDirFile = null; // required
31+
private String varDirFile = null; // required
32+
private String varCovDir = null; // required
3233
private String varAnnoDirFile = null; // optional
33-
private String varCovDir = null; // required
3434
private String geneCovDir = null; // optional
3535

3636
// return to file readers
@@ -63,7 +63,10 @@ public Cfg () {}
6363
public String getNCBI () {return ncbiFile;}
6464

6565
public Vector <String> getVarVec() { return varVec;}
66+
public String getVarDir() {return varDirFile;}
67+
6668
public Vector <String> getVarAnnoVec() { return varAnnoVec ;}
69+
public String getVarAnnoDir() {return varAnnoDirFile;}
6770

6871
public String getVarCovDir() { return varCovDir;}
6972
public Vector <String> getVarCovVec() { return varCovVec;}
@@ -278,25 +281,13 @@ private boolean fileExists(String file) {
278281
}
279282
return true;
280283
}
281-
private boolean dirExists(String file) {
282-
File f = new File(file);
283-
if (!f.exists())
284-
{
285-
LogTime.PrtError(file + " not found");
286-
return false;
287-
}
288-
if (!f.isDirectory()) {
289-
LogTime.PrtError(file + " must be a directory");
290-
return false;
291-
}
292-
return true;
293-
}
284+
294285
/****************************************************
295286
* XXX Validate all input from CFG file
296287
*/
297288
public boolean validate() {
298289
LogTime.PrtSpMsg(1, "Validate abbreviations");
299-
int cntErr=0;
290+
int cntErr=0, cntWarn=0;
300291
Vector <String> sAb = new Vector <String> ();
301292
for (String str1 : condVal1) {
302293
String [] tok1 = str1.split(":");
@@ -332,43 +323,81 @@ public boolean validate() {
332323
vd.setCond(sAb, tAb);
333324
LogTime.PrtSpMsg(1, "Checking files and directories");
334325

326+
// Variants defined
335327
if (varDirFile!=null) {
336328
varVec = vd.checkVariant(varDirFile);
337329
if (varVec==null || varVec.size()==0) cntErr++;
338330
}
339-
if (varCovDir!=null) {
331+
else {
332+
LogTime.PrtError("Variant call file or directory must exist ");
333+
cntErr++;
334+
}
335+
336+
// Variant coverage
337+
if (varCovDir!=null) {
340338
varCovVec = vd.checkVarCovDir(varCovDir);
341339
if (varCovVec==null || varCovVec.size()==0) cntErr++;
342340
}
343-
if (gtfFile!=null) {
344-
if (!vd.checkGTK(gtfFile)) cntErr++;
345-
}
346-
if (genomeDir!=null && !genomeDir.startsWith("#")) {
347-
genomeVec = vd.checkGenomeDir(genomeDir);
348-
if (genomeVec==null || genomeVec.size()==0) cntErr++;
349-
else remark += (remark.equals("")) ? "AAseqs" : "; AAseqs";
341+
else {
342+
LogTime.PrtError("Variant coverage directory must exist ");
343+
cntErr++;
350344
}
351-
if (varAnnoDirFile!=null && !varAnnoDirFile.startsWith("#")) {
345+
346+
//Variant effect (optional)
347+
if (varAnnoDirFile!=null && !varAnnoDirFile.startsWith("#")) {
352348
varAnnoVec = vd.checkVarAnno(varAnnoDirFile);
353-
if (varAnnoVec==null || varAnnoVec.size()==0) cntErr++;
349+
if (varAnnoVec==null || varAnnoVec.size()==0) cntWarn++;
354350
else {
355351
isSnpEFF = vd.isSnpEFF;
356352
isEVP = vd.isEVP;
357353
remark = (isEVP) ? "EVP" : "snpEFF";
358354
}
359355
}
356+
else LogTime.PrtSpMsg(2, "No variant effect file (optional)");
357+
358+
// Genome annotation file
359+
if (gtfFile!=null) {
360+
if (!vd.checkGTK(gtfFile)) cntErr++;
361+
}
362+
else {
363+
LogTime.PrtError("Genome annotation file must exist ");
364+
cntErr++;
365+
}
366+
367+
// Genome files
368+
if (genomeDir!=null && !genomeDir.startsWith("#")) {
369+
genomeVec = vd.checkGenomeDir(genomeDir);
370+
if (genomeVec==null || genomeVec.size()==0) cntErr++;
371+
else remark += (remark.equals("")) ? "AAseqs" : "; AAseqs";
372+
}
373+
else {
374+
LogTime.PrtError("Genome directory of sequence files must exist ");
375+
cntErr++;
376+
}
360377

378+
// NCBI (optional)
361379
if (ncbiFile!=null && !ncbiFile.startsWith("#")) {
362-
if (!vd.checkNCBI(ncbiFile)) cntErr++;
363-
else remark += (remark.equals("")) ? "NCBI" : "; NCBI";
380+
if (vd.checkNCBI(ncbiFile))
381+
remark += (remark.equals("")) ? "NCBI" : "; NCBI";
382+
else cntWarn++;
364383
}
384+
else LogTime.PrtSpMsg(2, "No NCBI functional annotation file (optional)");
385+
386+
// Counts (optional)
365387
if (geneCovDir!=null && !geneCovDir.startsWith("#")) {
366388
geneCovVec = vd.checkGeneCovDir(geneCovDir);
367-
if (geneCovVec==null || geneCovVec.size()==0) cntErr++;
368-
else remark += (remark.equals("")) ? "Reads" : "; Read";
389+
if (geneCovVec!=null && geneCovVec.size()>0)
390+
remark += (remark.equals("")) ? "Reads" : "; Read";
391+
else cntWarn++;
369392
}
370-
if (cntErr>0) return false;
371-
int cntWarn = vd.getWarn();
393+
else LogTime.PrtSpMsg(2, "No count files (optional)");
394+
395+
if (cntErr>0) {
396+
LogTime.PrtSpMsg(0, "Fatal errors: " + cntErr);
397+
return false;
398+
}
399+
400+
cntWarn += vd.getWarn();
372401
if (cntWarn>0) {
373402
if (!LogTime.yesNo(cntWarn + " warnings. Continue?")) return false;
374403
}

java/src/build/CfgFileValidate.java

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public int getWarn() {
2929
* Methods to check files and make sure they are the correct format
3030
*/
3131
public boolean checkGTK(String annoPath) {
32+
LogTime.PrtSpMsg(2, "Genome annotation file " + annoPath);
3233
if (!fileExists("Genome GTF file" , annoPath)) return false;
3334
if (!fileIsGTF("Genome GTF file" , annoPath)) return false;
3435
return true;
@@ -96,11 +97,11 @@ public Vector <String> checkVariant(String ford) {
9697
}
9798
Vector <String> varVec = new Vector <String> ();
9899
if (f.isFile()) {
99-
if (!fileIsVCF("Variant file " + ford, f)) return null;
100+
if (!fileIsVCF("Variant call file " + ford, f)) return null;
100101
varVec.add(f.getAbsolutePath());
101102
return varVec;
102103
}
103-
LogTime.PrtSpMsg(2, "Variant directory " + ford);
104+
LogTime.PrtSpMsg(2, "Variant call directory " + ford);
104105
for (File file : f.listFiles() )
105106
{
106107
if (file.isDirectory()) {
@@ -132,6 +133,7 @@ else if (varVec.size()==0) {
132133

133134
public Vector <String> checkVarCovDir(String dirName) {
134135
if (!dirExists("Variant coverage directory", dirName)) return null;
136+
135137
LogTime.PrtSpMsg(2, "Variant coverage directory " + dirName);
136138
Vector <String> varCovVec = dirOfLibs(dirName, ".bed");
137139
if (varCovVec==null) return null;
@@ -156,6 +158,8 @@ public Vector <String> checkVarCovDir(String dirName) {
156158
LogTime.PrtError("No good bed files in this directory ");
157159
return null;
158160
}
161+
LogTime.PrtSpMsg(3, "Good bed files " + varCovVec.size());
162+
159163
return varCovVec;
160164
}
161165
catch (Exception e) {ErrorReport.prtError(e, "checking variant count directory"); return null;}
@@ -175,18 +179,20 @@ public Vector <String> checkVarAnno(String ford) {
175179
return null;
176180
}
177181
Vector <String> varAnnoVec = new Vector <String> ();
178-
// one file
182+
// one file
179183
if (f.isFile()) {
184+
LogTime.PrtSpMsg(2, "One Variant effect file ");
180185
if (!ford.endsWith(".vcf")) {
181186
LogTime.PrtSpMsg(3, "Warning: no .vcf suffix " + ford);
182187
cntWarn++;
183188
}
184-
if (!checkVarAnnoFile(ford)) return null;
189+
if (!checkVarAnnoFile(ford))
190+
return null;
185191
varAnnoVec.add(f.getAbsolutePath());
186192
return varAnnoVec;
187193
}
188-
// directory of files
189-
LogTime.PrtSpMsg(2, "Variant annotation files " + ford);
194+
// directory of files
195+
LogTime.PrtSpMsg(2, "Variant effect files " + ford);
190196
for (File file : f.listFiles() )
191197
{
192198
if (file.isDirectory()) {
@@ -223,19 +229,22 @@ public Vector <String> checkVarAnno(String ford) {
223229
/// goes with above
224230
private boolean checkVarAnnoFile(String file) {
225231
try {
232+
LogTime.PrtSpMsg(3, "Variant file " + file);
226233
BufferedReader br = new BufferedReader(new FileReader(new File(file)));
227234
boolean hasGood=false;
228235
String line="";
229236
while ((line = br.readLine()) != null) {
230237
if (line.startsWith("## ENSEMBL VARIANT EFFECT PREDICTOR")) {
231238
isEVP = true;
232239
hasGood=true;
240+
LogTime.PrtSpMsg(4, "EVP file (ENSEMBL VARIANT EFFECT PREDICTOR)");
233241
break;
234242
}
235243
else if (line.startsWith("##SnpEffVersion")) {
236244
//if (!isVCF) LogTime.PrtSpMsg(3, file + " -- first line is not ##fileformat=VCF...");
237245
isSnpEFF=true;
238246
hasGood=true;
247+
LogTime.PrtSpMsg(4, "SnpEFF file (SnpEffVersion)");
239248
if (!line.contains("3.6b")) {
240249
LogTime.PrtSpMsg(3, "Warning: " + file + " -- if this file is not created with version >3.6b, it may not work ");
241250
LogTime.PrtSpMsg(4, line);
@@ -255,9 +264,9 @@ else if (line.startsWith("##SnpEffVersion")) {
255264
}
256265
/***************************************************************/
257266
public Vector <String> checkGeneCovDir(String dirName) {
258-
if (!dirExists("Transcript coverage directory ", dirName)) return null;
267+
if (!dirExists("Transcript count directory ", dirName)) return null;
259268

260-
LogTime.PrtSpMsg(2, "Transcript coverage directory " + dirName);
269+
LogTime.PrtSpMsg(2, "Transcript count directory " + dirName);
261270
Vector <String> covVec = dirOfLibs(dirName, ".xprs");
262271
if (covVec==null) return null;
263272

@@ -503,8 +512,9 @@ public boolean fileIsGTF(String msg, String file)
503512
}
504513
}
505514
if (!chrRoot.equals(""))
506-
LogTime.PrtWarn("Could not find root of seqname (e.g. chr, contig)");
515+
LogTime.PrtWarn("Could not find prefix of seqname (e.g. chr, contig)");
507516
}
517+
LogTime.PrtSpMsg(3, "Seqname prefix is '" + chrRoot + "'");
508518
return true;
509519
}
510520
catch(Exception e)
@@ -516,6 +526,7 @@ public boolean fileIsGTF(String msg, String file)
516526
catch(Exception e)
517527
{
518528
errmsg = "Could not read file";
529+
ErrorReport.prtError(e, errmsg);
519530
}
520531
LogTime.PrtError(msg + ": " + file);
521532
LogTime.PrtSpMsg(1, errmsg);

java/src/build/Pmain.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22

33
import build.panels.ConfigFrame;
44
import util.Globals;
5-
import database.HostCfg;
6-
import build.compute.Stats;
75

86
public class Pmain
97
{
10-
static public String dbSuffix = "mus"; // TODO - make dynamic
11-
128
public static void main(String[] args)
139
{
1410
System.out.println("\n" + Globals.TITLE);

0 commit comments

Comments
 (0)