/** This method will process each argument and assign new variables */ public void processArgs(String[] args) { Pattern pat = Pattern.compile("-[a-z]"); File forExtraction = null; 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 'v': forExtraction = new File(args[++i]); break; case 'm': minimumSSC = Float.parseFloat(args[++i]); break; case 'a': minimumCount = Integer.parseInt(args[++i]); break; case 'r': minimumAbsFractionChange = Double.parseDouble(args[++i]); break; case 'n': maximumNormalAltFraction = Double.parseDouble(args[++i]); break; default: Misc.printErrAndExit("\nProblem, unknown option! " + mat.group()); } } catch (Exception e) { Misc.printErrAndExit( "\nSorry, something doesn't look right with this parameter: -" + test + "\n"); } } } System.out.println( "\n" + IO.fetchUSeqVersion() + " Arguments: " + Misc.stringArrayToString(args, " ") + "\n"); // pull vcf files if (forExtraction == null || forExtraction.exists() == false) Misc.printErrAndExit( "\nError: please enter a path to a vcf file or directory containing such.\n"); File[][] tot = new File[3][]; tot[0] = IO.extractFiles(forExtraction, ".vcf"); tot[1] = IO.extractFiles(forExtraction, ".vcf.gz"); tot[2] = IO.extractFiles(forExtraction, ".vcf.zip"); vcfFiles = IO.collapseFileArray(tot); if (vcfFiles == null || vcfFiles.length == 0 || vcfFiles[0].canRead() == false) Misc.printExit("\nError: cannot find your xxx.vcf(.zip/.gz OK) file(s)!\n"); }
/** 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(); }
/** This method will process each argument and assign new variables */ public void processArgs(String[] args) { Pattern pat = Pattern.compile("-[a-z]"); File forExtraction = null; File ucscDir = null; 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 'b': forExtraction = new File(args[++i]); break; case 'd': ucscDir = new File(args[++i]); break; case 'v': versionedGenome = args[++i]; break; case 'e': verbose = false; break; case 'f': forceConversion = true; break; case 'h': printDocs(); System.exit(0); break; default: USeqUtilities.printExit("\nProblem, unknown option! " + mat.group()); } } catch (Exception e) { USeqUtilities.printExit( "\nSorry, something doesn't look right with this parameter: -" + test + "\n"); } } } if (verbose) System.out.println( "\n" + IO.fetchUSeqVersion() + " Arguments: " + USeqUtilities.stringArrayToString(args, " ") + "\n"); // versioned genome? if (versionedGenome == null) USeqUtilities.printExit( "\nError: you must supply a genome version. Goto http://genome.ucsc.edu/cgi-" + "bin/hgGateway load your organism to find the associated genome version (e.g. H_sapiens_Mar_2006, H_sapiens_Feb_2009).\n"); // make files if (ucscDir == null || ucscDir.isDirectory() == false) USeqUtilities.printExit( "\nCannot find your directory containing the UCSC wig2BigWig and bed2BigBed apps -> " + ucscDir); bigWigToWig = new File(ucscDir, "bigWigToWig"); bigBedToBed = new File(ucscDir, "bigBedToBed"); // check files // if (bigWigToBedGraph.canExecute() == false) USeqUtilities.printExit("\nCannot find or execute // -> "+bigWigToBedGraph+"\n"); if (bigWigToWig.canExecute() == false) USeqUtilities.printExit("\nCannot find or execute -> " + bigWigToWig + "\n"); if (bigBedToBed.canExecute() == false) USeqUtilities.printExit("\nCannot find or execute -> " + bigBedToBed + "\n"); // pull ucsc files if (forExtraction == null || forExtraction.exists() == false) Misc.printExit( "\nError: please enter a bw or bb file or directory containing such to convert!\n"); File[][] tot = new File[2][]; tot[0] = USeqUtilities.fetchFilesRecursively(forExtraction, ".bw"); tot[1] = USeqUtilities.fetchFilesRecursively(forExtraction, ".bb"); ucscArchives = IO.collapseFileArray(tot); if (ucscArchives == null || ucscArchives.length == 0 || ucscArchives[0].canRead() == false) Misc.printExit("\nError: cannot find or read any xxx.bb or xxx.bw file(s)!\n"); }
/** This method will process each argument and assign new varibles */ public void processArgs(String[] args) { Pattern pat = Pattern.compile("-[a-z]"); String useqVersion = IO.fetchUSeqVersion(); System.err.println( "\n" + useqVersion + " Arguments: " + Misc.stringArrayToString(args, " ") + "\n"); File tabixDataDir = null; 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 'c': chrLengthFile = new File(args[++i]); break; case 'd': tabixDataDir = new File(args[++i]); break; case 'n': numberThreads = Integer.parseInt(args[++i]); break; case 'q': numberQueriesInChunk = Integer.parseInt(args[++i]); break; default: Misc.printErrAndExit("\nProblem, unknown option! " + mat.group()); } } catch (Exception e) { Misc.printErrAndExit( "\nSorry, something doesn't look right with this parameter: -" + test + "\n"); } } } if (chrLengthFile == null) Misc.printErrAndExit( "\nError: please provide a bed file of chromosome and their lengths, e.g. X 0 155270560\n"); if (tabixDataDir == null || tabixDataDir.isDirectory() == false) Misc.printErrAndExit( "\nError: please provide a directory containing tabix indexed xxx.vcf.gz and xxx.bed.gz files with their associated xxx.gz.tbi indexes"); // pull data sources vcfDataFiles = IO.fetchFilesRecursively(tabixDataDir, "vcf.gz"); bedDataFiles = IO.fetchFilesRecursively(tabixDataDir, "bed.gz"); mafDataFiles = IO.fetchFilesRecursively(tabixDataDir, "maf.txt.gz"); if (vcfDataFiles.length == 0 && bedDataFiles.length == 0 && mafDataFiles.length == 0) Misc.printErrAndExit( "\nError: failed to find any xxx.bed.gz, xxx.vcf.gz, or xxx.maf.txt.gz tabix files in your tabixDataDir -> " + tabixDataDir); // check for index lookForTabixIndex(vcfDataFiles); lookForTabixIndex(bedDataFiles); lookForTabixIndex(mafDataFiles); // threads to use int numAvail = Runtime.getRuntime().availableProcessors(); if (numberThreads < 1) numberThreads = numAvail - 1; System.err.println( numAvail + " Available processors, using " + numberThreads + " threaded loaders\n"); }