private void buildXmlPropertiesFile() { System.out.println( "\nBuilding and checking your pipeline properties file -> " + truncPipePropFile); StringBuilder toPrint = new StringBuilder(); // walk through the prop file String[] prop = IO.loadFileIntoStringArray(truncPipePropFile); Pattern val = Pattern.compile("(<entry key.+>)([D|A|B].*)</entry>"); boolean missingFile = false; for (String s : prop) { // does it match a file needing prepending? Data/, Apps/, Bed/ Matcher mat = val.matcher(s); if (mat.matches()) { File test = new File(referenceDir, mat.group(2)); if (test.exists()) { System.out.println("Found\t" + test); toPrint.append(mat.group(1)); toPrint.append(test.toString()); toPrint.append("</entry>"); } else { System.out.println("Misssing\t" + test); missingFile = true; } } // threads? else if (s.contains("threads")) toPrint.append("<entry key=\"threads\">" + threads + "</entry>"); // nope just save it and add a line return else toPrint.append(s); toPrint.append("\n"); } // anything missing? if so exit if (missingFile) Misc.printErrAndExit( "\nFailed to find all of the files in your properties file, see above.\n"); // OK, write it out completePipelinePropFile = new File(outputDirectory, "pipelineProperties.xml"); if (IO.writeString(toPrint.toString(), completePipelinePropFile) == false) Misc.printErrAndExit("Problem writing -> " + truncPipePropFile); }
/** This method will process each argument and assign new varibles */ public void processArgs(String[] args) { Pattern pat = Pattern.compile("-[a-z]"); for (int i = 0; i < args.length; i++) { String lcArg = args[i].toLowerCase(); Matcher mat = pat.matcher(lcArg); if (mat.matches()) { char test = args[i].charAt(1); try { switch (test) { case 'f': fastas = IO.extractFiles(args[i + 1], "fasta"); i++; break; case 'n': numberOfBases = Integer.parseInt(args[i + 1]); i++; break; case 'i': indexDirectory = new File(args[i + 1]); i++; break; case 'h': printDocs(); System.exit(0); default: Misc.printExit("\nError: unknown option! " + mat.group()); } } catch (Exception e) { Misc.printExit( "\nSorry, something doesn't look right with this parameter: -" + test + "\n"); } } } // make index directory? if (indexDirectory == null) { indexDirectory = new File(fastas[0].getParentFile(), "IndexedSequences"); indexDirectory.mkdir(); } }
/** This method will process each argument and assign new variables */ public void processArgs(String[] args) { Pattern pat = Pattern.compile("-[a-z]"); System.out.println( "\n" + IO.fetchUSeqVersion() + " Arguments: " + Misc.stringArrayToString(args, " ") + "\n"); for (int i = 0; i < args.length; i++) { String lcArg = args[i].toLowerCase(); Matcher mat = pat.matcher(lcArg); if (mat.matches()) { char test = args[i].charAt(1); try { switch (test) { case 'o': jobId = args[++i]; break; case 's': sampleId = args[++i]; break; case 'm': submitter = args[++i]; break; case 'y': analysisType = args[++i]; break; case 'w': webRootForLinks = new File(args[++i]); break; case 'e': snpEffGenome = args[++i]; break; case 'i': minimumReadDepth = args[++i]; break; case 't': threads = args[++i]; break; case 'l': uploadVarsToNGSWeb = true; break; case 'j': pJar = new File(args[++i]); break; case 'p': truncPipePropFile = new File(args[++i]); break; case 'q': bedForCoverageQC = new File(args[++i]); break; case 'b': bedForVarCalling = new File(args[++i]); break; case 'r': fastaReference = new File(args[++i]); break; case 'u': unfilteredBam = new File(args[++i]); break; case 'f': finalBam = new File(args[++i]); break; case 'v': finalVcf = new File(args[++i]); break; case 'd': outputDirectory = new File(args[++i]); break; case 'c': referenceDir = new File(args[++i]); break; case 'h': printDocs(); System.exit(0); default: Misc.printErrAndExit("\nProblem, unknown option! " + mat.group()); } } catch (Exception e) { Misc.printErrAndExit( "\nSorry, something doesn't look right with this parameter: -" + test + "\n"); } } } // check output dir and if needed set sampleId if (outputDirectory != null) { outputDirectory.mkdirs(); if (sampleId.length() == 0) sampleId = outputDirectory.getName(); } // check root directory if needed if (webRootForLinks != null) { if (webRootForLinks.exists() == false) webRootForLinks.mkdirs(); // links dir? File links = new File(webRootForLinks, "links"); if (links.exists() == false) links.mkdirs(); } // look for required fields and files checkPrintFields(); checkPrintFiles(); checkForGzippedVcf(); }