bugged
stringlengths 6
599k
| fixed
stringlengths 10
599k
| __index_level_0__
int64 0
1.13M
|
|---|---|---|
public void handleEvent(Event event) { ApplicationDowntimeHistory downtimeHistory = getDowntimeHistory(event.getApplicationConfig()); assert downtimeHistory != null; if(event instanceof ApplicationUpEvent){ // application must have went down earlier downtimeHistory.applicationCameUp(event.getTime()); }else if(event instanceof ApplicationDownEvent){ downtimeHistory.applicationWentDown(event.getTime()); recordDowntime(event.getApplicationConfig().getApplicationId(), downtimeHistory.getDowntimeBegin(), event.getTime()); } }
|
public void handleEvent(Event event) { ApplicationDowntimeHistory downtimeHistory = getDowntimeHistory(event.getApplicationConfig()); assert downtimeHistory != null; if(event instanceof ApplicationUpEvent){ // application must have went down earlier downtimeHistory.applicationCameUp(event.getTime()); }else if(event instanceof ApplicationDownEvent){ downtimeHistory.applicationWentDown(event.getTime()); recordDowntime(event.getApplicationConfig().getApplicationId(), downtimeHistory.getDowntimeBegin(), event.getTime()); } }
| 1,112,250
|
private void argHandler(String[] args){ argHandlerMessages = new Vector(); int maxDistance = -1; //this means that user didn't specify any output type if it doesn't get changed below blockOutputType = -1; double hapThresh = -1; double minimumMAF=-1; double spacingThresh = -1; double minimumGenoPercent = -1; double hwCutoff = -1; double missingCutoff = -1; int maxMendel = -1; boolean assocTDT = false; boolean assocCC = false; permutationCount = 0; tagging = Tagger.NONE; maxNumTags = Tagger.DEFAULT_MAXNUMTAGS; findTags = true; double cutHighCI = -1; double cutLowCI = -1; double mafThresh = -1; double recHighCI = -1; double informFrac = -1; double fourGameteCutoff = -1; double spineDP = -1; for(int i =0; i < args.length; i++) { if(args[i].equalsIgnoreCase("-help") || args[i].equalsIgnoreCase("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equalsIgnoreCase("-n") || args[i].equalsIgnoreCase("-nogui")) { nogui = true; } else if(args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-logfile")){ i++; if (i >= args.length || args[i].charAt(0) == '-'){ logName = "haploview.log"; i--; }else{ logName = args[i]; } } else if(args[i].equalsIgnoreCase("-p") || args[i].equalsIgnoreCase("-pedfile")) { i++; if( i>=args.length || (args[i].charAt(0) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(pedFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-pcloadletter")){ die("PC LOADLETTER?! What the fuck does that mean?!"); } else if (args[i].equalsIgnoreCase("-skipcheck") || args[i].equalsIgnoreCase("--skipcheck")){ skipCheck = true; } else if (args[i].equalsIgnoreCase("-excludeMarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ die("-excludeMarkers requires a list of markers"); } else { StringTokenizer str = new StringTokenizer(args[i],","); try { StringBuffer sb = new StringBuffer(); if (!quietMode) sb.append("Excluding markers: "); while(str.hasMoreTokens()) { String token = str.nextToken(); if(token.indexOf("..") != -1) { int lastIndex = token.indexOf(".."); int rangeStart = Integer.parseInt(token.substring(0,lastIndex)); int rangeEnd = Integer.parseInt(token.substring(lastIndex+2,token.length())); for(int j=rangeStart;j<=rangeEnd;j++) { if (!quietMode) sb.append(j+" "); excludedMarkers.add(new Integer(j)); } } else { if (!quietMode) sb.append(token+" "); excludedMarkers.add(new Integer(token)); } } argHandlerMessages.add(sb.toString()); } catch(NumberFormatException nfe) { die("-excludeMarkers argument should be of the format: 1,3,5..8,12"); } } } else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-haps")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapsFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-i") || args[i].equalsIgnoreCase("-info")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(infoFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-hapmap")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapmapFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpdata")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpdataFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap data file listed will be used"); } phasedhmpdataFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpsample")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpsampleFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap sample file listed will be used"); } phasedhmpsampleFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmplegend")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmplegendFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap legend file listed will be used"); } phasedhmplegendFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhapmapdl")){ phasedhapmapDownload = true; } else if (args[i].equalsIgnoreCase("-plink")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last PLINK file listed will be used"); } plinkFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-map")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last map file listed will be used"); } mapFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-k") || args[i].equalsIgnoreCase("-blocks")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; blockOutputType = BLOX_CUSTOM; }else{ die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-png")){ outputPNG = true; } else if (args[i].equalsIgnoreCase("-smallpng") || args[i].equalsIgnoreCase("-compressedPNG")){ outputCompressedPNG = true; } else if (args[i].equalsIgnoreCase("-track")){ i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ trackFileName = args[i]; }else{ die("-track requires a filename"); } } else if(args[i].equalsIgnoreCase("-o") || args[i].equalsIgnoreCase("-output") || args[i].equalsIgnoreCase("-blockoutput")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(blockOutputType != -1){ die("Only one block output type argument is allowed."); } if(args[i].equalsIgnoreCase("SFS") || args[i].equalsIgnoreCase("GAB")){ blockOutputType = BLOX_GABRIEL; } else if(args[i].equalsIgnoreCase("GAM")){ blockOutputType = BLOX_4GAM; } else if(args[i].equalsIgnoreCase("MJD") || args[i].equalsIgnoreCase("SPI")){ blockOutputType = BLOX_SPINE; } else if(args[i].equalsIgnoreCase("ALL")) { blockOutputType = BLOX_ALL; } } else { //defaults to SFS output blockOutputType = BLOX_GABRIEL; i--; } } else if(args[i].equalsIgnoreCase("-d") || args[i].equalsIgnoreCase("--dprime") || args[i].equalsIgnoreCase("-dprime")) { outputDprime = true; } else if (args[i].equalsIgnoreCase("-c") || args[i].equalsIgnoreCase("-check")){ outputCheck = true; } else if (args[i].equalsIgnoreCase("-indcheck")){ individualCheck = true; } else if (args[i].equalsIgnoreCase("-mendel")){ mendel = true; } else if (args[i].equalsIgnoreCase("-malehets")){ malehets = true; } else if(args[i].equalsIgnoreCase("-m") || args[i].equalsIgnoreCase("-maxdistance")) { i++; maxDistance = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-batch")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(batchFileName != null){ argHandlerMessages.add("multiple " + args[i-1] + " arguments found. only last batch file listed will be used"); } batchFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-hapthresh")) { i++; hapThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-spacing")) { i++; spacingThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-minMAF")) { i++; minimumMAF = getDoubleArg(args,i,0,0.5); } else if(args[i].equalsIgnoreCase("-minGeno") || args[i].equalsIgnoreCase("-minGenoPercent")) { i++; minimumGenoPercent = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-hwcutoff")) { i++; hwCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-maxMendel") ) { i++; maxMendel = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-missingcutoff")) { i++; missingCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-assoctdt")) { assocTDT = true; } else if(args[i].equalsIgnoreCase("-assoccc")) { assocCC = true; } else if(args[i].equalsIgnoreCase("-randomcc")){ assocCC = true; randomizeAffection = true; } else if(args[i].equalsIgnoreCase("-ldcolorscheme")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(args[i].equalsIgnoreCase("default")){ Options.setLDColorScheme(STD_SCHEME); } else if(args[i].equalsIgnoreCase("RSQ")){ Options.setLDColorScheme(RSQ_SCHEME); } else if(args[i].equalsIgnoreCase("DPALT") ){ Options.setLDColorScheme(WMF_SCHEME); } else if(args[i].equalsIgnoreCase("GAB")) { Options.setLDColorScheme(GAB_SCHEME); } else if(args[i].equalsIgnoreCase("GAM")) { Options.setLDColorScheme(GAM_SCHEME); } else if(args[i].equalsIgnoreCase("GOLD")) { Options.setLDColorScheme(GOLD_SCHEME); } } else { //defaults to STD color scheme Options.setLDColorScheme(STD_SCHEME); i--; } } else if(args[i].equalsIgnoreCase("-blockCutHighCI")) { i++; cutHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockCutLowCI")) { i++; cutLowCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockMafThresh")) { i++; mafThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockRecHighCI")) { i++; recHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockInformFrac")) { i++; informFrac = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-block4GamCut")) { i++; fourGameteCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockSpineDP")) { i++; spineDP = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-permtests")) { i++; doPermutationTest = true; permutationCount = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-customassoc")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ customAssocTestsFileName = args[i]; }else{ die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-aggressiveTagging")) { tagging = Tagger.AGGRESSIVE_TRIPLE; } else if (args[i].equalsIgnoreCase("-pairwiseTagging")){ tagging = Tagger.PAIRWISE_ONLY; } else if (args[i].equalsIgnoreCase("-printalltags")){ Options.setPrintAllTags(true); } else if(args[i].equalsIgnoreCase("-maxNumTags")){ i++; maxNumTags = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-tagrSqCutoff")) { i++; tagRSquaredCutOff = getDoubleArg(args,i,0,1); } else if (args[i].equalsIgnoreCase("-dontaddtags")){ findTags = false; } else if(args[i].equalsIgnoreCase("-tagLODCutoff")) { i++; Options.setTaggerLODCutoff(getDoubleArg(args,i,0,100000)); } else if(args[i].equalsIgnoreCase("-includeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die(args[i-1] + " requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceIncludeTags = new Vector(); while(str.hasMoreTokens()) { forceIncludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-includeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceIncludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-excludeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die("-excludeTags requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceExcludeTags = new Vector(); while(str.hasMoreTokens()) { forceExcludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-excludeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceExcludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-captureAlleles")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { captureAllelesFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-designScores")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { designScoresFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-mintagdistance")){ i++; minTagDistance = args[i]; } else if(args[i].equalsIgnoreCase("-chromosome") || args[i].equalsIgnoreCase("-chr")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { chromosomeArg =args[i]; }else { die(args[i-1] + " requires a chromosome name"); } if(!(chromosomeArg.equalsIgnoreCase("X")) && !(chromosomeArg.equalsIgnoreCase("Y"))){ try{ if (Integer.parseInt(chromosomeArg) > 22){ die("-chromosome requires a chromsome name of 1-22, X, or Y"); } }catch(NumberFormatException nfe){ die("-chromosome requires a chromsome name of 1-22, X, or Y"); } } } else if(args[i].equalsIgnoreCase("-population")){ i++; if(!(i>=args.length) && !(args[i].charAt(0)== '-')) { populationArg = args[i]; }else { die(args[i-1] + "requires a population name"); } } else if(args[i].equalsIgnoreCase("-startpos")){ i++; startPos = args[i]; } else if(args[i].equalsIgnoreCase("-endPos")){ i++; endPos = args[i]; } else if(args[i].equalsIgnoreCase("-release")){ i++; release = args[i]; } else if(args[i].equalsIgnoreCase("-q") || args[i].equalsIgnoreCase("-quiet")) { quietMode = true; } else if(args[i].equalsIgnoreCase("-gzip")){ Options.setGzip(true); } else { die("invalid parameter specified: " + args[i]); } } if (logName != null){ logString = "*****************************************************\n" + TITLE_STRING + "\tJava Version: " + JAVA_VERSION + "\n*****************************************************\n\n\n" + "Arguments:\t"; for (int i = 0; i < args.length; i++){ logString = logString + args[i] + "\t"; } logString = logString + "\n\n"; } int countOptions = 0; if(pedFileName != null) { countOptions++; } if(hapsFileName != null) { countOptions++; } if(hapmapFileName != null) { countOptions++; } if(phasedhmpdataFileName != null) { countOptions++; if(phasedhmpsampleFileName == null){ die("You must specify a sample file for phased hapmap input."); }else if(phasedhmplegendFileName == null){ die("You must specify a legend file for phased hapmap input."); } } if(phasedhapmapDownload) { countOptions++; } if(plinkFileName != null){ countOptions++; if(mapFileName == null){ die("You must specify a map file for plink format input."); } } if(batchFileName != null) { countOptions++; } if(countOptions > 1) { die("Only one genotype input file may be specified on the command line."); } else if(countOptions == 0 && nogui) { die("You must specify a genotype input file."); } //mess with vars, set defaults, etc if(skipCheck) { argHandlerMessages.add("Skipping genotype file check"); } if(maxDistance == -1){ maxDistance = MAXDIST_DEFAULT; }else{ argHandlerMessages.add("Max LD comparison distance = " +maxDistance + "kb"); } Options.setMaxDistance(maxDistance); if(hapThresh != -1) { Options.setHaplotypeDisplayThreshold(hapThresh); argHandlerMessages.add("Haplotype display threshold = " + hapThresh); } if(minimumMAF != -1) { CheckData.mafCut = minimumMAF; argHandlerMessages.add("Minimum MAF = " + minimumMAF); } if(minimumGenoPercent != -1) { CheckData.failedGenoCut = (int)(minimumGenoPercent*100); argHandlerMessages.add("Minimum SNP genotype % = " + minimumGenoPercent); } if(hwCutoff != -1) { CheckData.hwCut = hwCutoff; argHandlerMessages.add("Hardy Weinberg equilibrium p-value cutoff = " + hwCutoff); } if(maxMendel != -1) { CheckData.numMendErrCut = maxMendel; argHandlerMessages.add("Maximum number of Mendel errors = "+maxMendel); } if(spacingThresh != -1) { Options.setSpacingThreshold(spacingThresh); argHandlerMessages.add("LD display spacing value = "+spacingThresh); } if(missingCutoff != -1) { Options.setMissingThreshold(missingCutoff); argHandlerMessages.add("Maximum amount of missing data allowed per individual = "+missingCutoff); } if(cutHighCI != -1) { FindBlocks.cutHighCI = cutHighCI; } if(cutLowCI != -1) { FindBlocks.cutLowCI = cutLowCI; } if(mafThresh != -1) { FindBlocks.mafThresh = mafThresh; } if(recHighCI != -1) { FindBlocks.recHighCI = recHighCI; } if(informFrac != -1) { FindBlocks.informFrac = informFrac; } if(fourGameteCutoff != -1) { FindBlocks.fourGameteCutoff = fourGameteCutoff; } if(spineDP != -1) { FindBlocks.spineDP = spineDP; } if(assocTDT) { Options.setAssocTest(ASSOC_TRIO); }else if(assocCC) { Options.setAssocTest(ASSOC_CC); } if (Options.getAssocTest() != ASSOC_NONE && infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when performing association tests."); } if(doPermutationTest) { if(!assocCC && !assocTDT) { die("An association test type must be specified for permutation tests to be performed."); } } if(customAssocTestsFileName != null) { if(!assocCC && !assocTDT) { die("An association test type must be specified when using a custom association test file."); } if(infoFileName == null) { die("A marker info file must be specified when using a custom association test file."); } } if(tagging != Tagger.NONE) { if(infoFileName == null && hapmapFileName == null && batchFileName == null && phasedhmpdataFileName == null && !phasedhapmapDownload) { die("A marker info file must be specified when tagging."); } if(forceExcludeTags == null) { forceExcludeTags = new Vector(); } else if (forceExcludeFileName != null) { die("-excludeTags and -excludeTagsFile cannot both be used"); } if(forceExcludeFileName != null) { File excludeFile = new File(forceExcludeFileName); forceExcludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(excludeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceExcludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -excludeTagsFile."); } } if(forceIncludeTags == null ) { forceIncludeTags = new Vector(); } else if (forceIncludeFileName != null) { die("-includeTags and -includeTagsFile cannot both be used"); } if(forceIncludeFileName != null) { File includeFile = new File(forceIncludeFileName); forceIncludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(includeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceIncludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -includeTagsFile."); } } if (captureAllelesFileName != null) { File captureFile = new File(captureAllelesFileName); captureAlleleTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(captureFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ line = line.trim(); captureAlleleTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (designScoresFileName != null) { File designFile = new File(designScoresFileName); designScores = new Hashtable(1,1); try { BufferedReader br = new BufferedReader(new FileReader(designFile)); String line; int lines = 0; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ StringTokenizer st = new StringTokenizer(line); int length = st.countTokens(); if (length != 2){ die("Invalid formatting on line " + lines); } String marker = st.nextToken(); Double score = new Double(st.nextToken()); designScores.put(marker,score); } lines++; } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (minTagDistance != null) { try{ if (Integer.parseInt(minTagDistance) < 0){ die("minimum tag distance cannot be negative"); } }catch(NumberFormatException nfe){ die("minimum tag distance must be a positive integer"); } Options.setTaggerMinDistance(Integer.parseInt(minTagDistance)); } //check that there isn't any overlap between include/exclude lists Vector tempInclude = (Vector) forceIncludeTags.clone(); tempInclude.retainAll(forceExcludeTags); if(tempInclude.size() > 0) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < tempInclude.size(); i++) { String s = (String) tempInclude.elementAt(i); sb.append(s).append(","); } die("The following markers appear in both the include and exclude lists: " + sb.toString()); } if(tagRSquaredCutOff != -1) { Options.setTaggerRsqCutoff(tagRSquaredCutOff); } } else if(forceExcludeTags != null || forceIncludeTags != null || tagRSquaredCutOff != -1) { die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without a tagging option"); } if(chromosomeArg != null && hapmapFileName != null) { argHandlerMessages.add("-chromosome flag ignored when loading hapmap file"); chromosomeArg = null; } if(chromosomeArg != null) { Chromosome.setDataChrom("chr" + chromosomeArg); } if (phasedhapmapDownload){ if (chromosomeArg == null){ die("-phasedhapmapdl requires a chromosome specification"); }else if (!(populationArg.equalsIgnoreCase("CEU") || populationArg.equalsIgnoreCase("YRI") || populationArg.equalsIgnoreCase("CHB+JPT"))){ die("-phasedhapmapdl requires a population specification of CEU, YRI, or CHB+JPT"); } if (Integer.parseInt(chromosomeArg) < 1 && Integer.parseInt(chromosomeArg) > 22){ if (!(chromosomeArg.equalsIgnoreCase("X")) && !(chromosomeArg.equalsIgnoreCase("Y"))){ die("-chromosome must be betweeen 1 and 22, X, or Y"); } } try{ if (Integer.parseInt(startPos) > Integer.parseInt(endPos)){ die("-endpos must be greater then -startpos"); } }catch(NumberFormatException nfe){ die("-startpos and -endpos must be integer values"); } if (release == null){ release = "21"; } if (!(release.equals("21")) && !(release.startsWith("16"))){ die("release must be either 16a or 21"); } } }
|
private void argHandler(String[] args){ argHandlerMessages = new Vector(); int maxDistance = -1; //this means that user didn't specify any output type if it doesn't get changed below blockOutputType = -1; double hapThresh = -1; double minimumMAF=-1; double spacingThresh = -1; double minimumGenoPercent = -1; double hwCutoff = -1; double missingCutoff = -1; int maxMendel = -1; boolean assocTDT = false; boolean assocCC = false; permutationCount = 0; tagging = Tagger.NONE; maxNumTags = Tagger.DEFAULT_MAXNUMTAGS; findTags = true; double cutHighCI = -1; double cutLowCI = -1; double mafThresh = -1; double recHighCI = -1; double informFrac = -1; double fourGameteCutoff = -1; double spineDP = -1; for(int i =0; i < args.length; i++) { if(args[i].equalsIgnoreCase("-help") || args[i].equalsIgnoreCase("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equalsIgnoreCase("-n") || args[i].equalsIgnoreCase("-nogui")) { nogui = true; } else if(args[i].equalsIgnoreCase("-log")){ i++; if (i >= args.length || args[i].charAt(0) == '-'){ logName = "haploview.log"; i--; }else{ logName = args[i]; } } else if(args[i].equalsIgnoreCase("-p") || args[i].equalsIgnoreCase("-pedfile")) { i++; if( i>=args.length || (args[i].charAt(0) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(pedFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-pcloadletter")){ die("PC LOADLETTER?! What the fuck does that mean?!"); } else if (args[i].equalsIgnoreCase("-skipcheck") || args[i].equalsIgnoreCase("--skipcheck")){ skipCheck = true; } else if (args[i].equalsIgnoreCase("-excludeMarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ die("-excludeMarkers requires a list of markers"); } else { StringTokenizer str = new StringTokenizer(args[i],","); try { StringBuffer sb = new StringBuffer(); if (!quietMode) sb.append("Excluding markers: "); while(str.hasMoreTokens()) { String token = str.nextToken(); if(token.indexOf("..") != -1) { int lastIndex = token.indexOf(".."); int rangeStart = Integer.parseInt(token.substring(0,lastIndex)); int rangeEnd = Integer.parseInt(token.substring(lastIndex+2,token.length())); for(int j=rangeStart;j<=rangeEnd;j++) { if (!quietMode) sb.append(j+" "); excludedMarkers.add(new Integer(j)); } } else { if (!quietMode) sb.append(token+" "); excludedMarkers.add(new Integer(token)); } } argHandlerMessages.add(sb.toString()); } catch(NumberFormatException nfe) { die("-excludeMarkers argument should be of the format: 1,3,5..8,12"); } } } else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-haps")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapsFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-i") || args[i].equalsIgnoreCase("-info")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(infoFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-hapmap")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapmapFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpdata")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpdataFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap data file listed will be used"); } phasedhmpdataFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpsample")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpsampleFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap sample file listed will be used"); } phasedhmpsampleFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmplegend")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmplegendFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap legend file listed will be used"); } phasedhmplegendFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhapmapdl")){ phasedhapmapDownload = true; } else if (args[i].equalsIgnoreCase("-plink")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last PLINK file listed will be used"); } plinkFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-map")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last map file listed will be used"); } mapFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-k") || args[i].equalsIgnoreCase("-blocks")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; blockOutputType = BLOX_CUSTOM; }else{ die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-png")){ outputPNG = true; } else if (args[i].equalsIgnoreCase("-smallpng") || args[i].equalsIgnoreCase("-compressedPNG")){ outputCompressedPNG = true; } else if (args[i].equalsIgnoreCase("-track")){ i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ trackFileName = args[i]; }else{ die("-track requires a filename"); } } else if(args[i].equalsIgnoreCase("-o") || args[i].equalsIgnoreCase("-output") || args[i].equalsIgnoreCase("-blockoutput")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(blockOutputType != -1){ die("Only one block output type argument is allowed."); } if(args[i].equalsIgnoreCase("SFS") || args[i].equalsIgnoreCase("GAB")){ blockOutputType = BLOX_GABRIEL; } else if(args[i].equalsIgnoreCase("GAM")){ blockOutputType = BLOX_4GAM; } else if(args[i].equalsIgnoreCase("MJD") || args[i].equalsIgnoreCase("SPI")){ blockOutputType = BLOX_SPINE; } else if(args[i].equalsIgnoreCase("ALL")) { blockOutputType = BLOX_ALL; } } else { //defaults to SFS output blockOutputType = BLOX_GABRIEL; i--; } } else if(args[i].equalsIgnoreCase("-d") || args[i].equalsIgnoreCase("--dprime") || args[i].equalsIgnoreCase("-dprime")) { outputDprime = true; } else if (args[i].equalsIgnoreCase("-c") || args[i].equalsIgnoreCase("-check")){ outputCheck = true; } else if (args[i].equalsIgnoreCase("-indcheck")){ individualCheck = true; } else if (args[i].equalsIgnoreCase("-mendel")){ mendel = true; } else if (args[i].equalsIgnoreCase("-malehets")){ malehets = true; } else if(args[i].equalsIgnoreCase("-m") || args[i].equalsIgnoreCase("-maxdistance")) { i++; maxDistance = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-batch")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(batchFileName != null){ argHandlerMessages.add("multiple " + args[i-1] + " arguments found. only last batch file listed will be used"); } batchFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-hapthresh")) { i++; hapThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-spacing")) { i++; spacingThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-minMAF")) { i++; minimumMAF = getDoubleArg(args,i,0,0.5); } else if(args[i].equalsIgnoreCase("-minGeno") || args[i].equalsIgnoreCase("-minGenoPercent")) { i++; minimumGenoPercent = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-hwcutoff")) { i++; hwCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-maxMendel") ) { i++; maxMendel = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-missingcutoff")) { i++; missingCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-assoctdt")) { assocTDT = true; } else if(args[i].equalsIgnoreCase("-assoccc")) { assocCC = true; } else if(args[i].equalsIgnoreCase("-randomcc")){ assocCC = true; randomizeAffection = true; } else if(args[i].equalsIgnoreCase("-ldcolorscheme")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(args[i].equalsIgnoreCase("default")){ Options.setLDColorScheme(STD_SCHEME); } else if(args[i].equalsIgnoreCase("RSQ")){ Options.setLDColorScheme(RSQ_SCHEME); } else if(args[i].equalsIgnoreCase("DPALT") ){ Options.setLDColorScheme(WMF_SCHEME); } else if(args[i].equalsIgnoreCase("GAB")) { Options.setLDColorScheme(GAB_SCHEME); } else if(args[i].equalsIgnoreCase("GAM")) { Options.setLDColorScheme(GAM_SCHEME); } else if(args[i].equalsIgnoreCase("GOLD")) { Options.setLDColorScheme(GOLD_SCHEME); } } else { //defaults to STD color scheme Options.setLDColorScheme(STD_SCHEME); i--; } } else if(args[i].equalsIgnoreCase("-blockCutHighCI")) { i++; cutHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockCutLowCI")) { i++; cutLowCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockMafThresh")) { i++; mafThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockRecHighCI")) { i++; recHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockInformFrac")) { i++; informFrac = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-block4GamCut")) { i++; fourGameteCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockSpineDP")) { i++; spineDP = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-permtests")) { i++; doPermutationTest = true; permutationCount = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-customassoc")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ customAssocTestsFileName = args[i]; }else{ die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-aggressiveTagging")) { tagging = Tagger.AGGRESSIVE_TRIPLE; } else if (args[i].equalsIgnoreCase("-pairwiseTagging")){ tagging = Tagger.PAIRWISE_ONLY; } else if (args[i].equalsIgnoreCase("-printalltags")){ Options.setPrintAllTags(true); } else if(args[i].equalsIgnoreCase("-maxNumTags")){ i++; maxNumTags = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-tagrSqCutoff")) { i++; tagRSquaredCutOff = getDoubleArg(args,i,0,1); } else if (args[i].equalsIgnoreCase("-dontaddtags")){ findTags = false; } else if(args[i].equalsIgnoreCase("-tagLODCutoff")) { i++; Options.setTaggerLODCutoff(getDoubleArg(args,i,0,100000)); } else if(args[i].equalsIgnoreCase("-includeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die(args[i-1] + " requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceIncludeTags = new Vector(); while(str.hasMoreTokens()) { forceIncludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-includeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceIncludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-excludeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die("-excludeTags requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceExcludeTags = new Vector(); while(str.hasMoreTokens()) { forceExcludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-excludeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceExcludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-captureAlleles")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { captureAllelesFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-designScores")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { designScoresFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-mintagdistance")){ i++; minTagDistance = args[i]; } else if(args[i].equalsIgnoreCase("-chromosome") || args[i].equalsIgnoreCase("-chr")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { chromosomeArg =args[i]; }else { die(args[i-1] + " requires a chromosome name"); } if(!(chromosomeArg.equalsIgnoreCase("X")) && !(chromosomeArg.equalsIgnoreCase("Y"))){ try{ if (Integer.parseInt(chromosomeArg) > 22){ die("-chromosome requires a chromsome name of 1-22, X, or Y"); } }catch(NumberFormatException nfe){ die("-chromosome requires a chromsome name of 1-22, X, or Y"); } } } else if(args[i].equalsIgnoreCase("-population")){ i++; if(!(i>=args.length) && !(args[i].charAt(0)== '-')) { populationArg = args[i]; }else { die(args[i-1] + "requires a population name"); } } else if(args[i].equalsIgnoreCase("-startpos")){ i++; startPos = args[i]; } else if(args[i].equalsIgnoreCase("-endPos")){ i++; endPos = args[i]; } else if(args[i].equalsIgnoreCase("-release")){ i++; release = args[i]; } else if(args[i].equalsIgnoreCase("-q") || args[i].equalsIgnoreCase("-quiet")) { quietMode = true; } else if(args[i].equalsIgnoreCase("-gzip")){ Options.setGzip(true); } else { die("invalid parameter specified: " + args[i]); } } if (logName != null){ logString = "*****************************************************\n" + TITLE_STRING + "\tJava Version: " + JAVA_VERSION + "\n*****************************************************\n\n\n" + "Arguments:\t"; for (int i = 0; i < args.length; i++){ logString = logString + args[i] + "\t"; } logString = logString + "\n\n"; } int countOptions = 0; if(pedFileName != null) { countOptions++; } if(hapsFileName != null) { countOptions++; } if(hapmapFileName != null) { countOptions++; } if(phasedhmpdataFileName != null) { countOptions++; if(phasedhmpsampleFileName == null){ die("You must specify a sample file for phased hapmap input."); }else if(phasedhmplegendFileName == null){ die("You must specify a legend file for phased hapmap input."); } } if(phasedhapmapDownload) { countOptions++; } if(plinkFileName != null){ countOptions++; if(mapFileName == null){ die("You must specify a map file for plink format input."); } } if(batchFileName != null) { countOptions++; } if(countOptions > 1) { die("Only one genotype input file may be specified on the command line."); } else if(countOptions == 0 && nogui) { die("You must specify a genotype input file."); } //mess with vars, set defaults, etc if(skipCheck) { argHandlerMessages.add("Skipping genotype file check"); } if(maxDistance == -1){ maxDistance = MAXDIST_DEFAULT; }else{ argHandlerMessages.add("Max LD comparison distance = " +maxDistance + "kb"); } Options.setMaxDistance(maxDistance); if(hapThresh != -1) { Options.setHaplotypeDisplayThreshold(hapThresh); argHandlerMessages.add("Haplotype display threshold = " + hapThresh); } if(minimumMAF != -1) { CheckData.mafCut = minimumMAF; argHandlerMessages.add("Minimum MAF = " + minimumMAF); } if(minimumGenoPercent != -1) { CheckData.failedGenoCut = (int)(minimumGenoPercent*100); argHandlerMessages.add("Minimum SNP genotype % = " + minimumGenoPercent); } if(hwCutoff != -1) { CheckData.hwCut = hwCutoff; argHandlerMessages.add("Hardy Weinberg equilibrium p-value cutoff = " + hwCutoff); } if(maxMendel != -1) { CheckData.numMendErrCut = maxMendel; argHandlerMessages.add("Maximum number of Mendel errors = "+maxMendel); } if(spacingThresh != -1) { Options.setSpacingThreshold(spacingThresh); argHandlerMessages.add("LD display spacing value = "+spacingThresh); } if(missingCutoff != -1) { Options.setMissingThreshold(missingCutoff); argHandlerMessages.add("Maximum amount of missing data allowed per individual = "+missingCutoff); } if(cutHighCI != -1) { FindBlocks.cutHighCI = cutHighCI; } if(cutLowCI != -1) { FindBlocks.cutLowCI = cutLowCI; } if(mafThresh != -1) { FindBlocks.mafThresh = mafThresh; } if(recHighCI != -1) { FindBlocks.recHighCI = recHighCI; } if(informFrac != -1) { FindBlocks.informFrac = informFrac; } if(fourGameteCutoff != -1) { FindBlocks.fourGameteCutoff = fourGameteCutoff; } if(spineDP != -1) { FindBlocks.spineDP = spineDP; } if(assocTDT) { Options.setAssocTest(ASSOC_TRIO); }else if(assocCC) { Options.setAssocTest(ASSOC_CC); } if (Options.getAssocTest() != ASSOC_NONE && infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when performing association tests."); } if(doPermutationTest) { if(!assocCC && !assocTDT) { die("An association test type must be specified for permutation tests to be performed."); } } if(customAssocTestsFileName != null) { if(!assocCC && !assocTDT) { die("An association test type must be specified when using a custom association test file."); } if(infoFileName == null) { die("A marker info file must be specified when using a custom association test file."); } } if(tagging != Tagger.NONE) { if(infoFileName == null && hapmapFileName == null && batchFileName == null && phasedhmpdataFileName == null && !phasedhapmapDownload) { die("A marker info file must be specified when tagging."); } if(forceExcludeTags == null) { forceExcludeTags = new Vector(); } else if (forceExcludeFileName != null) { die("-excludeTags and -excludeTagsFile cannot both be used"); } if(forceExcludeFileName != null) { File excludeFile = new File(forceExcludeFileName); forceExcludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(excludeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceExcludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -excludeTagsFile."); } } if(forceIncludeTags == null ) { forceIncludeTags = new Vector(); } else if (forceIncludeFileName != null) { die("-includeTags and -includeTagsFile cannot both be used"); } if(forceIncludeFileName != null) { File includeFile = new File(forceIncludeFileName); forceIncludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(includeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceIncludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -includeTagsFile."); } } if (captureAllelesFileName != null) { File captureFile = new File(captureAllelesFileName); captureAlleleTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(captureFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ line = line.trim(); captureAlleleTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (designScoresFileName != null) { File designFile = new File(designScoresFileName); designScores = new Hashtable(1,1); try { BufferedReader br = new BufferedReader(new FileReader(designFile)); String line; int lines = 0; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ StringTokenizer st = new StringTokenizer(line); int length = st.countTokens(); if (length != 2){ die("Invalid formatting on line " + lines); } String marker = st.nextToken(); Double score = new Double(st.nextToken()); designScores.put(marker,score); } lines++; } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (minTagDistance != null) { try{ if (Integer.parseInt(minTagDistance) < 0){ die("minimum tag distance cannot be negative"); } }catch(NumberFormatException nfe){ die("minimum tag distance must be a positive integer"); } Options.setTaggerMinDistance(Integer.parseInt(minTagDistance)); } //check that there isn't any overlap between include/exclude lists Vector tempInclude = (Vector) forceIncludeTags.clone(); tempInclude.retainAll(forceExcludeTags); if(tempInclude.size() > 0) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < tempInclude.size(); i++) { String s = (String) tempInclude.elementAt(i); sb.append(s).append(","); } die("The following markers appear in both the include and exclude lists: " + sb.toString()); } if(tagRSquaredCutOff != -1) { Options.setTaggerRsqCutoff(tagRSquaredCutOff); } } else if(forceExcludeTags != null || forceIncludeTags != null || tagRSquaredCutOff != -1) { die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without a tagging option"); } if(chromosomeArg != null && hapmapFileName != null) { argHandlerMessages.add("-chromosome flag ignored when loading hapmap file"); chromosomeArg = null; } if(chromosomeArg != null) { Chromosome.setDataChrom("chr" + chromosomeArg); } if (phasedhapmapDownload){ if (chromosomeArg == null){ die("-phasedhapmapdl requires a chromosome specification"); }else if (!(populationArg.equalsIgnoreCase("CEU") || populationArg.equalsIgnoreCase("YRI") || populationArg.equalsIgnoreCase("CHB+JPT"))){ die("-phasedhapmapdl requires a population specification of CEU, YRI, or CHB+JPT"); } if (Integer.parseInt(chromosomeArg) < 1 && Integer.parseInt(chromosomeArg) > 22){ if (!(chromosomeArg.equalsIgnoreCase("X")) && !(chromosomeArg.equalsIgnoreCase("Y"))){ die("-chromosome must be betweeen 1 and 22, X, or Y"); } } try{ if (Integer.parseInt(startPos) > Integer.parseInt(endPos)){ die("-endpos must be greater then -startpos"); } }catch(NumberFormatException nfe){ die("-startpos and -endpos must be integer values"); } if (release == null){ release = "21"; } if (!(release.equals("21")) && !(release.startsWith("16"))){ die("release must be either 16a or 21"); } } }
| 1,112,251
|
private void processTextOnly(){ String fileName; int fileType; if(hapsFileName != null) { fileName = hapsFileName; fileType = HAPS_FILE; } else if (pedFileName != null){ fileName = pedFileName; fileType = PED_FILE; } else if (phasedhmpdataFileName != null){ fileName = phasedhmpdataFileName; fileType = PHASED_FILE; phasedHapMapInfo = new String[]{phasedhmpdataFileName, phasedhmpsampleFileName, phasedhmplegendFileName, "", ""}; } else if (phasedhapmapDownload){ fileName = "Chromosome" + chromosomeArg + populationArg; fileType = PHASEDHMPDL_FILE; phasedHapMapInfo = new String[]{fileName, populationArg, startPos, endPos, chromosomeArg, release}; }else{ fileName = hapmapFileName; fileType = HMP_FILE; } processFile(fileName,fileType,infoFileName); }
|
private void processTextOnly(){ String fileName; int fileType; if(hapsFileName != null) { fileName = hapsFileName; fileType = HAPS_FILE; } else if (pedFileName != null){ fileName = pedFileName; fileType = PED_FILE; } else if (phasedhmpdataFileName != null){ fileName = phasedhmpdataFileName; fileType = PHASED_FILE; phasedHapMapInfo = new String[]{phasedhmpdataFileName, phasedhmpsampleFileName, phasedhmplegendFileName, chromosomeArg, ""}; } else if (phasedhapmapDownload){ fileName = "Chromosome" + chromosomeArg + populationArg; fileType = PHASEDHMPDL_FILE; phasedHapMapInfo = new String[]{fileName, populationArg, startPos, endPos, chromosomeArg, release}; }else{ fileName = hapmapFileName; fileType = HMP_FILE; } processFile(fileName,fileType,infoFileName); }
| 1,112,253
|
public void doTag(XMLOutput output) throws Exception { // run the body first to configure any nested DataType instances getBody().run(context, output); AntTagSupport parentTag = (AntTagSupport) findAncestorWithClass( AntTagSupport.class); if ( parentTag == null ) { // ignore, as all it can be is a top-level datatype with // an id which has -already- added it to the project thanks // to the setAttribute() call. return; } Object targetObj = parentTag.getObject(); DataType dataType = getDataType(); if ( targetObj == null ) { // ignore, as all it can be is a top-level datatype with // an id which has -already- added it to the project thanks // to the setAttribute() call. return; } if( parentTag instanceof DynaBeanTagSupport ) { DynaBean dynaBean = ((DynaBeanTagSupport)parent).getDynaBean(); DynaClass dynaClass = dynaBean.getDynaClass(); DynaProperty dynaProperty = dynaClass.getDynaProperty(name); if ( dynaProperty != null ) { // lets set the bean property try { dynaBean.set( name, dataType ); return; } catch (Exception e) { // ignore, maybe something else will work. } } } if ( targetObj instanceof Path && dataType instanceof Path ) { ((Path)targetObj).append( (Path)dataType ); return; } IntrospectionHelper ih = IntrospectionHelper.getHelper( targetObj.getClass() ); try { ih.storeElement( getAntProject(), targetObj, dataType, getName() ); } catch (Exception e) { String dataTypeName = dataType.getClass().getName(); String baseName = dataTypeName.substring( dataTypeName.lastIndexOf( "." ) + 1 ); String methName = "add" + baseName; Method m = MethodUtils.getAccessibleMethod( targetObj.getClass(), methName, dataType.getClass() ); if ( m == null ) { String lname = baseName.toLowerCase(); methName = "add" + lname.substring( 0, 1 ).toUpperCase() + lname.substring( 1 ); m = MethodUtils.getAccessibleMethod( targetObj.getClass(), methName, dataType.getClass() ); } if ( m != null ) { try { m.invoke( targetObj, new Object[] { dataType } ); return; } catch (Exception i) { i.printStackTrace(); } } } }
|
public void doTag(XMLOutput output) throws Exception { // run the body first to configure any nested DataType instances invokeBody(output); AntTagSupport parentTag = (AntTagSupport) findAncestorWithClass( AntTagSupport.class); if ( parentTag == null ) { // ignore, as all it can be is a top-level datatype with // an id which has -already- added it to the project thanks // to the setAttribute() call. return; } Object targetObj = parentTag.getObject(); DataType dataType = getDataType(); if ( targetObj == null ) { // ignore, as all it can be is a top-level datatype with // an id which has -already- added it to the project thanks // to the setAttribute() call. return; } if( parentTag instanceof DynaBeanTagSupport ) { DynaBean dynaBean = ((DynaBeanTagSupport)parent).getDynaBean(); DynaClass dynaClass = dynaBean.getDynaClass(); DynaProperty dynaProperty = dynaClass.getDynaProperty(name); if ( dynaProperty != null ) { // lets set the bean property try { dynaBean.set( name, dataType ); return; } catch (Exception e) { // ignore, maybe something else will work. } } } if ( targetObj instanceof Path && dataType instanceof Path ) { ((Path)targetObj).append( (Path)dataType ); return; } IntrospectionHelper ih = IntrospectionHelper.getHelper( targetObj.getClass() ); try { ih.storeElement( getAntProject(), targetObj, dataType, getName() ); } catch (Exception e) { String dataTypeName = dataType.getClass().getName(); String baseName = dataTypeName.substring( dataTypeName.lastIndexOf( "." ) + 1 ); String methName = "add" + baseName; Method m = MethodUtils.getAccessibleMethod( targetObj.getClass(), methName, dataType.getClass() ); if ( m == null ) { String lname = baseName.toLowerCase(); methName = "add" + lname.substring( 0, 1 ).toUpperCase() + lname.substring( 1 ); m = MethodUtils.getAccessibleMethod( targetObj.getClass(), methName, dataType.getClass() ); } if ( m != null ) { try { m.invoke( targetObj, new Object[] { dataType } ); return; } catch (Exception i) { i.printStackTrace(); } } } }
| 1,112,254
|
private User buildUser(ActionForm form){ UserForm userForm = (UserForm)form; User user = UserManager.getInstance().getUser(userForm.getUsername()); assert user != null; List<Role> roles = new ArrayList<Role>(1); roles.add(new Role(userForm.getRole())); user.setRoles(roles); if(!userForm.getPassword().equals(UserForm.FORM_PASSWORD)){ String hashedPassword = Crypto.hash(userForm.getPassword()); user.setPassword(hashedPassword); } user.setStatus(userForm.getStatus()); return user; }
|
private User buildUser(ActionForm form){ UserForm userForm = (UserForm)form; User user = UserManager.getInstance().getUser(userForm.getUsername()); assert user != null; List<Role> roles = new ArrayList<Role>(1); String[] rolesString = userForm.getRole(); for(int ctr=0; ctr < rolesString.length; ctr++){ roles.add(new Role(rolesString[ctr])); } user.setRoles(roles); if(!userForm.getPassword().equals(UserForm.FORM_PASSWORD)){ String hashedPassword = Crypto.hash(userForm.getPassword()); user.setPassword(hashedPassword); } user.setStatus(userForm.getStatus()); return user; }
| 1,112,255
|
public Vector linkageToChrom(File infile, int type) throws IllegalArgumentException, HaploViewException, PedFileException, IOException{ Vector pedFileStrings = new Vector(); Vector hapsDataStrings = new Vector(); BufferedReader reader = new BufferedReader(new FileReader(infile)); String line; while((line = reader.readLine())!=null){ if (line.length() == 0){ //skip blank lines continue; } if (line.startsWith("#@")){ hapsDataStrings.add(line.substring(2)); continue; } if (line.startsWith("#")){ //skip comments continue; } pedFileStrings.add(line); } pedFile = new PedFile(); if (type == PED_FILE){ pedFile.parseLinkage(pedFileStrings); }else{ pedFile.parseHapMap(pedFileStrings, hapsDataStrings); } Vector result = pedFile.check(); Vector indList = pedFile.getUnrelatedIndividuals(); Vector indsInTrio = new Vector(); int numMarkers = 0; numSingletons = 0; numTrios = 0; numPeds = pedFile.getNumFamilies(); Individual currentInd; Family currentFamily; Vector chrom = new Vector(); //first time through we deal with trios. for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.get(x); boolean haploid = ((currentInd.getGender() == 1) && Chromosome.getDataChrom().equalsIgnoreCase("chrx")); currentFamily = pedFile.getFamily(currentInd.getFamilyID()); if (currentFamily.containsMember(currentInd.getMomID()) && currentFamily.containsMember(currentInd.getDadID())){ //if indiv has both parents Individual mom = currentFamily.getMember(currentInd.getMomID()); Individual dad = currentFamily.getMember(currentInd.getDadID()); if (indList.contains(mom) && indList.contains(dad)){ numMarkers = currentInd.getNumMarkers(); byte[] dadT = new byte[numMarkers]; byte[] dadU = new byte[numMarkers]; byte[] momT = new byte[numMarkers]; byte[] momU = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte kid1, kid2; if (currentInd.getZeroed(i)){ kid1 = 0; kid2 = 0; }else{ kid1 = currentInd.getAllele(i,0); kid2 = currentInd.getAllele(i,1); } byte mom1,mom2; if (currentFamily.getMember(currentInd.getMomID()).getZeroed(i)){ mom1 = 0; mom2 = 0; }else{ mom1 = (currentFamily.getMember(currentInd.getMomID())).getAllele(i,0); mom2 = (currentFamily.getMember(currentInd.getMomID())).getAllele(i,1); } byte dad1,dad2; if (currentFamily.getMember(currentInd.getDadID()).getZeroed(i)){ dad1 = 0; dad2 = 0; }else{ dad1 = (currentFamily.getMember(currentInd.getDadID())).getAllele(i,0); dad2 = (currentFamily.getMember(currentInd.getDadID())).getAllele(i,1); } if(haploid) { if(kid1 == 0) { //kid missing dadU[i] = dad1; if (mom1 == mom2) { momT[i] = mom1; momU[i] = mom1; } else if (mom1 != 0 && mom2 != 0){ momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } } else { dadU[i] = dad1; if (mom1 == 0) { momT[i] = kid1; momU[i] = 0; } else if (mom1 == kid1) { momT[i] = mom1; momU[i] = mom2; } else { momT[i] = mom2; momU[i] = mom1; } } }else { if (kid1 == 0 || kid2 == 0) { //kid missing if (dad1 == dad2) { dadT[i] = dad1; dadU[i] = dad1; } else if (dad1 != 0 && dad2 != 0) { dadT[i] = (byte)(4+dad1); dadU[i] = (byte)(4+dad2); } if (mom1 == mom2) { momT[i] = mom1; momU[i] = mom1; } else if (mom1 != 0 && mom2 != 0){ momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadT[i] = kid1; dadU[i] = 0; } else if (dad1 == kid1) { dadT[i] = dad1; dadU[i] = dad2; } else { dadT[i] = dad2; dadU[i] = dad1; } if (mom1 == 0) { momT[i] = kid1; momU[i] = 0; } else if (mom1 == kid1) { momT[i] = mom1; momU[i] = mom2; } else { momT[i] = mom2; momU[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadT[i] = 0; dadU[i] = 0; momT[i] = 0; momU[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadT[i] = 0; dadU[i] = 0; momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadT[i] = (byte)(4+dad1); dadU[i] = (byte)(4+dad2); momT[i] = 0; momU[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momT[i] = mom1; momU[i] = mom1; dadU[i] = 0; if (kid1 == mom1) { dadT[i] = kid2; } else { dadT[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadT[i] = dad1; dadU[i] = dad1; momU[i] = 0; if (kid1 == dad1) { momT[i] = kid2; } else { momT[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadT[i] = dad1; dadU[i] = dad2; if (kid1 == dad1) { momT[i] = kid2; momU[i] = kid1; } else { momT[i] = kid1; momU[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momT[i] = mom1; momU[i] = mom2; if (kid1 == mom1) { dadT[i] = kid2; dadU[i] = kid1; } else { dadT[i] = kid1; dadU[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadT[i] = dad1; dadU[i] = dad1; momT[i] = mom1; momU[i] = mom1; } else { //everybody het dadT[i] = (byte)(4+dad1); dadU[i] = (byte)(4+dad2); momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } } } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momT, mom.getAffectedStatus(),currentInd.getAffectedStatus())); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momU, mom.getAffectedStatus(),currentInd.getAffectedStatus())); if(haploid) { chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadU, dad.getAffectedStatus(),currentInd.getAffectedStatus())); ((Chromosome)chrom.lastElement()).setHaploid(true); }else if(Chromosome.getDataChrom().equalsIgnoreCase("chrx")){ chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadT, dad.getAffectedStatus(), currentInd.getAffectedStatus())); ((Chromosome)chrom.lastElement()).setHaploid(true); }else { chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadU, dad.getAffectedStatus(),currentInd.getAffectedStatus())); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadT, dad.getAffectedStatus(), currentInd.getAffectedStatus())); } numTrios++; indsInTrio.add(mom); indsInTrio.add(dad); indsInTrio.add(currentInd); } } } for (int x=0; x<indList.size(); x++){ currentInd = (Individual)indList.get(x); boolean haploid = ((currentInd.getGender() == 1) && Chromosome.getDataChrom().equalsIgnoreCase("chrx")); if (!indsInTrio.contains(currentInd)){ //ind has no parents or kids -- he's a singleton numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte thisMarkerA, thisMarkerB; if (currentInd.getZeroed(i)){ thisMarkerA = 0; thisMarkerB = 0; }else{ thisMarkerA = currentInd.getAllele(i,0); thisMarkerB = currentInd.getAllele(i,1); } if (thisMarkerA == thisMarkerB || thisMarkerA == 0 || thisMarkerB == 0){ chrom1[i] = thisMarkerA; chrom2[i] = thisMarkerB; }else{ chrom1[i] = (byte)(4+thisMarkerA); chrom2[i] = (byte)(4+thisMarkerB); } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1, currentInd.getAffectedStatus(), -1)); if(!haploid){ chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2,currentInd.getAffectedStatus(), -1)); }else{ ((Chromosome)chrom.lastElement()).setHaploid(true); } numSingletons++; } } chromosomes = chrom; //wipe clean any existing marker info so we know we're starting with a new file Chromosome.markers = null; return result; }
|
public Vector linkageToChrom(File infile, int type) throws IllegalArgumentException, HaploViewException, PedFileException, IOException{ Vector pedFileStrings = new Vector(); Vector hapsDataStrings = new Vector(); BufferedReader reader = new BufferedReader(new FileReader(infile)); String line; while((line = reader.readLine())!=null){ if (line.length() == 0){ //skip blank lines continue; } if (line.startsWith("#@")){ hapsDataStrings.add(line.substring(2)); continue; } if (line.startsWith("#")){ //skip comments continue; } pedFileStrings.add(line); } pedFile = new PedFile(); if (type == PED_FILE){ pedFile.parseLinkage(pedFileStrings); }else{ pedFile.parseHapMap(pedFileStrings, hapsDataStrings); } Vector result = pedFile.check(); Vector indList = pedFile.getUnrelatedIndividuals(); Vector indsInTrio = new Vector(); int numMarkers = 0; numSingletons = 0; numTrios = 0; numPeds = pedFile.getNumFamilies(); Individual currentInd; Family currentFamily; Vector chrom = new Vector(); //first time through we deal with trios. for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.get(x); boolean haploid = ((currentInd.getGender() == 1) && Chromosome.getDataChrom().equalsIgnoreCase("chrx")); currentFamily = pedFile.getFamily(currentInd.getFamilyID()); if (currentFamily.containsMember(currentInd.getMomID()) && currentFamily.containsMember(currentInd.getDadID())){ //if indiv has both parents Individual mom = currentFamily.getMember(currentInd.getMomID()); Individual dad = currentFamily.getMember(currentInd.getDadID()); if (indList.contains(mom) && indList.contains(dad)){ numMarkers = currentInd.getNumMarkers(); byte[] dadT = new byte[numMarkers]; byte[] dadU = new byte[numMarkers]; byte[] momT = new byte[numMarkers]; byte[] momU = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte kid1, kid2; if (currentInd.getZeroed(i)){ kid1 = 0; kid2 = 0; }else{ kid1 = currentInd.getAllele(i,0); kid2 = currentInd.getAllele(i,1); } byte mom1,mom2; if (currentFamily.getMember(currentInd.getMomID()).getZeroed(i)){ mom1 = 0; mom2 = 0; }else{ mom1 = (currentFamily.getMember(currentInd.getMomID())).getAllele(i,0); mom2 = (currentFamily.getMember(currentInd.getMomID())).getAllele(i,1); } byte dad1,dad2; if (currentFamily.getMember(currentInd.getDadID()).getZeroed(i)){ dad1 = 0; dad2 = 0; }else{ dad1 = (currentFamily.getMember(currentInd.getDadID())).getAllele(i,0); dad2 = (currentFamily.getMember(currentInd.getDadID())).getAllele(i,1); } if(haploid) { if(kid1 == 0) { //kid missing dadU[i] = dad1; if (mom1 == mom2) { momT[i] = mom1; momU[i] = mom1; } else if (mom1 != 0 && mom2 != 0){ momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } } else { dadU[i] = dad1; if (mom1 == 0) { momT[i] = kid1; momU[i] = 0; } else if (mom1 == kid1) { momT[i] = mom1; momU[i] = mom2; } else { momT[i] = mom2; momU[i] = mom1; } } }else { if (kid1 == 0 || kid2 == 0) { //kid missing if (dad1 == dad2) { dadT[i] = dad1; dadU[i] = dad1; } else if (dad1 != 0 && dad2 != 0) { dadT[i] = (byte)(4+dad1); dadU[i] = (byte)(4+dad2); } if (mom1 == mom2) { momT[i] = mom1; momU[i] = mom1; } else if (mom1 != 0 && mom2 != 0){ momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadT[i] = kid1; dadU[i] = 0; } else if (dad1 == kid1) { dadT[i] = dad1; dadU[i] = dad2; } else { dadT[i] = dad2; dadU[i] = dad1; } if (mom1 == 0) { momT[i] = kid1; momU[i] = 0; } else if (mom1 == kid1) { momT[i] = mom1; momU[i] = mom2; } else { momT[i] = mom2; momU[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadT[i] = 0; dadU[i] = 0; momT[i] = 0; momU[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadT[i] = 0; dadU[i] = 0; momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadT[i] = (byte)(4+dad1); dadU[i] = (byte)(4+dad2); momT[i] = 0; momU[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momT[i] = mom1; momU[i] = mom1; dadU[i] = 0; if (kid1 == mom1) { dadT[i] = kid2; } else { dadT[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadT[i] = dad1; dadU[i] = dad1; momU[i] = 0; if (kid1 == dad1) { momT[i] = kid2; } else { momT[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadT[i] = dad1; dadU[i] = dad2; if (kid1 == dad1) { momT[i] = kid2; momU[i] = kid1; } else { momT[i] = kid1; momU[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momT[i] = mom1; momU[i] = mom2; if (kid1 == mom1) { dadT[i] = kid2; dadU[i] = kid1; } else { dadT[i] = kid1; dadU[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadT[i] = dad1; dadU[i] = dad1; momT[i] = mom1; momU[i] = mom1; } else { //everybody het dadT[i] = (byte)(4+dad1); dadU[i] = (byte)(4+dad2); momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } } } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momT, mom.getAffectedStatus(),currentInd.getAffectedStatus())); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momU, mom.getAffectedStatus(),currentInd.getAffectedStatus())); if(haploid) { chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadU, dad.getAffectedStatus(),currentInd.getAffectedStatus())); ((Chromosome)chrom.lastElement()).setHaploid(true); }else if(Chromosome.getDataChrom().equalsIgnoreCase("chrx")){ chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadT, dad.getAffectedStatus(), currentInd.getAffectedStatus())); ((Chromosome)chrom.lastElement()).setHaploid(true); }else { chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadU, dad.getAffectedStatus(),currentInd.getAffectedStatus())); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadT, dad.getAffectedStatus(), currentInd.getAffectedStatus())); } numTrios++; indsInTrio.add(mom); indsInTrio.add(dad); indsInTrio.add(currentInd); } } } for (int x=0; x<indList.size(); x++){ currentInd = (Individual)indList.get(x); boolean haploid = ((currentInd.getGender() == 1) && Chromosome.getDataChrom().equalsIgnoreCase("chrx")); if (!indsInTrio.contains(currentInd)){ //ind has no parents or kids -- he's a singleton numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte thisMarkerA, thisMarkerB; if (currentInd.getZeroed(i)){ thisMarkerA = 0; thisMarkerB = 0; }else{ thisMarkerA = currentInd.getAllele(i,0); thisMarkerB = currentInd.getAllele(i,1); } if (thisMarkerA == thisMarkerB || thisMarkerA == 0 || thisMarkerB == 0){ chrom1[i] = thisMarkerA; chrom2[i] = thisMarkerB; }else{ chrom1[i] = (byte)(4+thisMarkerA); chrom2[i] = (byte)(4+thisMarkerB); } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1, currentInd.getAffectedStatus(), -1)); if(!haploid){ chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2,currentInd.getAffectedStatus(), -1)); }else{ ((Chromosome)chrom.lastElement()).setHaploid(true); } numSingletons++; } } chromosomes = chrom; //wipe clean any existing marker info so we know we're starting with a new file Chromosome.markers = null; return result; }
| 1,112,256
|
public void dbChildrenInserted(SQLObjectEvent e) { logger.debug("dbchildrenadd. source="+e.getSource()); if (!SwingUtilities.isEventDispatchThread()) return; if (logger.isDebugEnabled()) { if (e.getSQLSource() instanceof SQLRelationship) { SQLRelationship r = (SQLRelationship) e.getSQLSource(); logger.debug("dbChildrenInserted SQLObjectEvent: "+e +"; pk path="+Arrays.asList(getPkPathToRelationship(r)) +"; fk path="+Arrays.asList(getFkPathToRelationship(r))); } else { logger.debug("dbChildrenInserted SQLObjectEvent: "+e +"; tree path="+Arrays.asList(getPathToNode(e.getSQLSource()))); } } try { SQLObject[] newEventSources = e.getChildren(); for (int i = 0; i < newEventSources.length; i++) { ArchitectUtils.listenToHierarchy(this, newEventSources[i]); } } catch (ArchitectException ex) { logger.error("Error listening to added object", ex); } // relationships have two parents (pktable and fktable) so we need to fire two TMEs if (e.getSQLSource() instanceof SQLRelationship) { TreeModelEvent tme = new TreeModelEvent (this, getPkPathToRelationship((SQLRelationship) e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesInserted(tme); tme = new TreeModelEvent (this, getFkPathToRelationship((SQLRelationship) e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesInserted(tme); } else { TreeModelEvent tme = new TreeModelEvent (this, getPathToNode(e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesInserted(tme); } }
|
public void dbChildrenInserted(SQLObjectEvent e) { logger.debug("dbchildrenadd. source="+e.getSource()); if (!SwingUtilities.isEventDispatchThread()) return; if (logger.isDebugEnabled()) { if (e.getSQLSource() instanceof SQLRelationship) { SQLRelationship r = (SQLRelationship) e.getSQLSource(); logger.debug("dbChildrenInserted SQLObjectEvent: "+e +"; pk path="+Arrays.asList(getPkPathToRelationship(r)) +"; fk path="+Arrays.asList(getFkPathToRelationship(r))); } else { logger.debug("dbChildrenInserted SQLObjectEvent: "+e +"; tree path="+Arrays.asList(getPathToNode(e.getSQLSource()))); } } try { SQLObject[] newEventSources = e.getChildren(); for (int i = 0; i < newEventSources.length; i++) { ArchitectUtils.listenToHierarchy(this, newEventSources[i]); } } catch (ArchitectException ex) { logger.error("Error listening to added object", ex); } // relationships have two parents (pktable and fktable) so we need to fire two TMEs if (e.getSQLSource() instanceof SQLRelationship) { TreeModelEvent tme = new TreeModelEvent (this, getPkPathToRelationship((SQLRelationship) e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesInserted(tme); tme = new TreeModelEvent (this, getFkPathToRelationship((SQLRelationship) e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesInserted(tme); } else { TreeModelEvent tme = new TreeModelEvent (this, getPathToNode(e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesInserted(tme); } }
| 1,112,257
|
public void dbChildrenRemoved(SQLObjectEvent e) { logger.debug("dbchildrenremove. source="+e.getSource()); if (!SwingUtilities.isEventDispatchThread()) return; if (logger.isDebugEnabled()) logger.debug("dbChildrenRemoved SQLObjectEvent: "+e); try { SQLObject[] oldEventSources = e.getChildren(); for (int i = 0; i < oldEventSources.length; i++) { ArchitectUtils.unlistenToHierarchy(this, oldEventSources[i]); } } catch (ArchitectException ex) { logger.error("Error unlistening to removed object", ex); } if (e.getSQLSource() instanceof SQLRelationship) { TreeModelEvent tme = new TreeModelEvent (this, getPkPathToRelationship((SQLRelationship) e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesRemoved(tme); tme = new TreeModelEvent (this, getFkPathToRelationship((SQLRelationship) e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesRemoved(tme); } else { TreeModelEvent tme = new TreeModelEvent (this, getPathToNode(e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesRemoved(tme); } }
|
public void dbChildrenRemoved(SQLObjectEvent e) { logger.debug("dbchildrenremove. source="+e.getSource()); if (!SwingUtilities.isEventDispatchThread()) return; if (logger.isDebugEnabled()) logger.debug("dbChildrenRemoved SQLObjectEvent: "+e); try { SQLObject[] oldEventSources = e.getChildren(); for (int i = 0; i < oldEventSources.length; i++) { ArchitectUtils.unlistenToHierarchy(this, oldEventSources[i]); } } catch (ArchitectException ex) { logger.error("Error unlistening to removed object", ex); } if (e.getSQLSource() instanceof SQLRelationship) { TreeModelEvent tme = new TreeModelEvent (this, getPkPathToRelationship((SQLRelationship) e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesRemoved(tme); tme = new TreeModelEvent (this, getFkPathToRelationship((SQLRelationship) e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesRemoved(tme); } else { TreeModelEvent tme = new TreeModelEvent (this, getPathToNode(e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesRemoved(tme); } }
| 1,112,259
|
public void dbObjectChanged(SQLObjectEvent e) { logger.debug("dbObjectChanged. source="+e.getSource()); if (!SwingUtilities.isEventDispatchThread()) return; if (logger.isDebugEnabled()) logger.debug("dbObjectChanged SQLObjectEvent: "+e); if (e.getPropertyName().equals("name") && !e.getNewValue().equals(e.getSQLSource().getName()) ) { logger.error("Name change event has wrong new value. new="+e.getNewValue()+"; real="+e.getSQLSource().getName()); } SQLObject source = e.getSQLSource(); if (source instanceof SQLRelationship) { SQLRelationship r = (SQLRelationship) source; fireTreeNodesChanged(new TreeModelEvent(this, getPkPathToRelationship(r))); fireTreeNodesChanged(new TreeModelEvent(this, getFkPathToRelationship(r))); } else { fireTreeNodesChanged(new TreeModelEvent(this, getPathToNode(source))); } }
|
public void dbObjectChanged(SQLObjectEvent e) { logger.debug("dbObjectChanged. source="+e.getSource()); if ((!SwingUtilities.isEventDispatchThread()) && (!testMode)) { logger.debug("Not refiring because this is not the EDT."); return; } if (logger.isDebugEnabled()) logger.debug("dbObjectChanged SQLObjectEvent: "+e); if (e.getPropertyName().equals("name") && !e.getNewValue().equals(e.getSQLSource().getName()) ) { logger.error("Name change event has wrong new value. new="+e.getNewValue()+"; real="+e.getSQLSource().getName()); } SQLObject source = e.getSQLSource(); if (source instanceof SQLRelationship) { SQLRelationship r = (SQLRelationship) source; fireTreeNodesChanged(new TreeModelEvent(this, getPkPathToRelationship(r))); fireTreeNodesChanged(new TreeModelEvent(this, getFkPathToRelationship(r))); } else { fireTreeNodesChanged(new TreeModelEvent(this, getPathToNode(source))); } }
| 1,112,261
|
public void dbStructureChanged(SQLObjectEvent e) { logger.debug("dbStructureChanged. source="+e.getSource()); if (!SwingUtilities.isEventDispatchThread()) return; try { ArchitectUtils.listenToHierarchy(this, e.getSQLSource()); TreeModelEvent tme = new TreeModelEvent(this, getPathToNode(e.getSQLSource())); fireTreeStructureChanged(tme); } catch (ArchitectException ex) { logger.error("Couldn't listen to hierarchy rooted at "+e.getSQLSource(), ex); } }
|
public void dbStructureChanged(SQLObjectEvent e) { logger.debug("dbStructureChanged. source="+e.getSource()); try { ArchitectUtils.listenToHierarchy(this, e.getSQLSource()); TreeModelEvent tme = new TreeModelEvent(this, getPathToNode(e.getSQLSource())); fireTreeStructureChanged(tme); } catch (ArchitectException ex) { logger.error("Couldn't listen to hierarchy rooted at "+e.getSQLSource(), ex); } }
| 1,112,262
|
public void dbStructureChanged(SQLObjectEvent e) { logger.debug("dbStructureChanged. source="+e.getSource()); if (!SwingUtilities.isEventDispatchThread()) return; try { ArchitectUtils.listenToHierarchy(this, e.getSQLSource()); TreeModelEvent tme = new TreeModelEvent(this, getPathToNode(e.getSQLSource())); fireTreeStructureChanged(tme); } catch (ArchitectException ex) { logger.error("Couldn't listen to hierarchy rooted at "+e.getSQLSource(), ex); } }
|
public void dbStructureChanged(SQLObjectEvent e) { logger.debug("dbStructureChanged. source="+e.getSource()); if (!SwingUtilities.isEventDispatchThread()) return; try { ArchitectUtils.listenToHierarchy(this, e.getSQLSource()); TreeModelEvent tme = new TreeModelEvent(this, getPathToNode(e.getSQLSource())); fireTreeStructureChanged(tme); } catch (ArchitectException ex) { logger.error("Couldn't listen to hierarchy rooted at "+e.getSQLSource(), ex); } }
| 1,112,263
|
public SQLObject[] getFkPathToRelationship(SQLRelationship rel) { SQLObject[] pathToFkTable = getPathToNode(rel.getFkTable()); SQLObject[] path = new SQLObject[pathToFkTable.length + 1]; System.arraycopy(pathToFkTable, 0, path, 0, pathToFkTable.length); path[path.length - 1] = rel; return path; }
|
public SQLObject[] getFkPathToRelationship(SQLRelationship rel) { SQLObject[] pathToFkTable = getPathToNode(rel.getFkTable()); SQLObject[] path = new SQLObject[pathToFkTable.length + 2]; System.arraycopy(pathToFkTable, 0, path, 0, pathToFkTable.length); path[path.length - 1] = rel; return path; }
| 1,112,265
|
public SQLObject[] getPkPathToRelationship(SQLRelationship rel) { SQLObject[] pathToPkTable = getPathToNode(rel.getPkTable()); SQLObject[] path = new SQLObject[pathToPkTable.length + 1]; System.arraycopy(pathToPkTable, 0, path, 0, pathToPkTable.length); path[path.length - 1] = rel; return path; }
|
public SQLObject[] getPkPathToRelationship(SQLRelationship rel) { SQLObject[] pathToPkTable = getPathToNode(rel.getPkTable()); SQLObject[] path = new SQLObject[pathToPkTable.length + 2]; System.arraycopy(pathToPkTable, 0, path, 0, pathToPkTable.length); path[path.length - 1] = rel; return path; }
| 1,112,267
|
public SQLObject[] getPkPathToRelationship(SQLRelationship rel) { SQLObject[] pathToPkTable = getPathToNode(rel.getPkTable()); SQLObject[] path = new SQLObject[pathToPkTable.length + 1]; System.arraycopy(pathToPkTable, 0, path, 0, pathToPkTable.length); path[path.length - 1] = rel; return path; }
|
public SQLObject[] getPkPathToRelationship(SQLRelationship rel) { SQLObject[] pathToPkTable = getPathToNode(rel.getPkTable()); SQLObject[] path = new SQLObject[pathToPkTable.length + 1]; System.arraycopy(pathToPkTable, 0, path, 0, pathToPkTable.length); path[path.length - 2] = rel.getPkTable().getExportedKeysFolder(); path[path.length - 1] = rel; return path; }
| 1,112,268
|
public Dimension getPreferredSize(JComponent jc) { TablePane c = (TablePane) jc; SQLTable table = c.getModel(); if (table == null) return null; int height = 0; int width = 0; try { Insets insets = c.getInsets(); java.util.List columnList = table.getColumns(); int cols = columnList.size(); Font font = c.getFont(); if (font == null) { logger.error("getPreferredSize(): Null font in TablePane "+c); logger.error("getPreferredSize(): TablePane's parent is "+c.getParent()); return null; } FontMetrics metrics = c.getFontMetrics(font); int fontHeight = metrics.getHeight(); height = insets.top + fontHeight + gap + c.getMargin().top + cols*fontHeight + boxLineThickness*2 + c.getMargin().bottom + insets.bottom; width = minimumWidth; logger.debug("starting width is: " + width); Iterator columnIt = table.getColumns().iterator(); while (columnIt.hasNext()) { String theColumn = columnIt.next().toString(); width = Math.max(width, metrics.stringWidth(theColumn)); logger.debug("new width is: " + width); } width += insets.left + c.getMargin().left + boxLineThickness*2 + c.getMargin().right + insets.right; } catch (ArchitectException e) { logger.warn("BasicTablePaneUI.getPreferredSize failed due to", e); width = 100; height = 100; } return new Dimension(width, height); }
|
public Dimension getPreferredSize(JComponent jc) { TablePane c = (TablePane) jc; SQLTable table = c.getModel(); if (table == null) return null; int height = 0; int width = 0; try { Insets insets = c.getInsets(); java.util.List columnList = table.getColumns(); int cols = columnList.size(); Font font = c.getFont(); if (font == null) { logger.error("getPreferredSize(): Null font in TablePane "+c); logger.error("getPreferredSize(): TablePane's parent is "+c.getParent()); return null; } FontMetrics metrics = c.getFontMetrics(font); int fontHeight = metrics.getHeight(); height = insets.top + fontHeight + gap + c.getMargin().top + cols*fontHeight + boxLineThickness*2 + c.getMargin().bottom + insets.bottom; width = minimumWidth; logger.debug("starting width is: " + width); Iterator columnIt = table.getColumns().iterator(); while (columnIt.hasNext()) { String theColumn = columnIt.next().toString(); width = Math.max(width, metrics.stringWidth(theColumn)); logger.debug("new width is: " + width); } width += insets.left + c.getMargin().left + boxLineThickness*2 + c.getMargin().right + insets.right; } catch (ArchitectException e) { logger.warn("BasicTablePaneUI.getPreferredSize failed due to", e); width = 100; height = 100; } return new Dimension(width, height); }
| 1,112,269
|
public Dimension getPreferredSize(JComponent jc) { TablePane c = (TablePane) jc; SQLTable table = c.getModel(); if (table == null) return null; int height = 0; int width = 0; try { Insets insets = c.getInsets(); java.util.List columnList = table.getColumns(); int cols = columnList.size(); Font font = c.getFont(); if (font == null) { logger.error("getPreferredSize(): Null font in TablePane "+c); logger.error("getPreferredSize(): TablePane's parent is "+c.getParent()); return null; } FontMetrics metrics = c.getFontMetrics(font); int fontHeight = metrics.getHeight(); height = insets.top + fontHeight + gap + c.getMargin().top + cols*fontHeight + boxLineThickness*2 + c.getMargin().bottom + insets.bottom; width = minimumWidth; logger.debug("starting width is: " + width); Iterator columnIt = table.getColumns().iterator(); while (columnIt.hasNext()) { String theColumn = columnIt.next().toString(); width = Math.max(width, metrics.stringWidth(theColumn)); logger.debug("new width is: " + width); } width += insets.left + c.getMargin().left + boxLineThickness*2 + c.getMargin().right + insets.right; } catch (ArchitectException e) { logger.warn("BasicTablePaneUI.getPreferredSize failed due to", e); width = 100; height = 100; } return new Dimension(width, height); }
|
public Dimension getPreferredSize(JComponent jc) { TablePane c = (TablePane) jc; SQLTable table = c.getModel(); if (table == null) return null; int height = 0; int width = 0; try { Insets insets = c.getInsets(); java.util.List columnList = table.getColumns(); int cols = columnList.size(); Font font = c.getFont(); if (font == null) { logger.error("getPreferredSize(): Null font in TablePane "+c); logger.error("getPreferredSize(): TablePane's parent is "+c.getParent()); return null; } FontMetrics metrics = c.getFontMetrics(font); int fontHeight = metrics.getHeight(); height = insets.top + fontHeight + gap + c.getMargin().top + cols*fontHeight + boxLineThickness*2 + c.getMargin().bottom + insets.bottom; width = minimumWidth; logger.debug("starting width is: " + width); Iterator columnIt = table.getColumns().iterator(); while (columnIt.hasNext()) { String theColumn = columnIt.next().toString(); width = Math.max(width, (int) font.getStringBounds(theColumn, frc).getWidth()); logger.debug("new width is: " + width); } width += insets.left + c.getMargin().left + boxLineThickness*2 + c.getMargin().right + insets.right; } catch (ArchitectException e) { logger.warn("BasicTablePaneUI.getPreferredSize failed due to", e); width = 100; height = 100; } return new Dimension(width, height); }
| 1,112,270
|
public String draw(DashboardContext context) { StringBuffer output = new StringBuffer(); // wrap wih div tag output.append("<div id=\"" + getId() + "\">"); output.append(component.draw(context)); output.append("</div>"); // append script String appId = context.getWebContext().getApplicationConfig().getApplicationId(); output.append("\n<script>"); output.append("self.setTimeout(\"refreshDBComponent("); output.append("''"); output.append(getId()); output.append("'', "); output.append(refreshInterval + ", " + appId + ")\", " + refreshInterval + ");"); output.append("</script>"); return output.toString(); }
|
public String draw(DashboardContext context) { StringBuffer output = new StringBuffer(); // wrap wih div tag output.append(component.draw(context)); output.append("</div>"); // append script String appId = context.getWebContext().getApplicationConfig().getApplicationId(); output.append("\n<script>"); output.append("self.setTimeout(\"refreshDBComponent("); output.append("''"); output.append(getId()); output.append("'', "); output.append(refreshInterval + ", " + appId + ")\", " + refreshInterval + ");"); output.append("</script>"); return output.toString(); }
| 1,112,272
|
public String draw(DashboardContext context) { StringBuffer output = new StringBuffer(); // wrap wih div tag output.append("<div id=\"" + getId() + "\">"); output.append(component.draw(context)); output.append("</div>"); // append script String appId = context.getWebContext().getApplicationConfig().getApplicationId(); output.append("\n<script>"); output.append("self.setTimeout(\"refreshDBComponent("); output.append("''"); output.append(getId()); output.append("'', "); output.append(refreshInterval + ", " + appId + ")\", " + refreshInterval + ");"); output.append("</script>"); return output.toString(); }
|
public String draw(DashboardContext context) { StringBuffer output = new StringBuffer(); // wrap wih div tag output.append("<div id=\"" + getId() + "\">"); output.append(component.draw(context)); // append script String appId = context.getWebContext().getApplicationConfig().getApplicationId(); output.append("\n<script>"); output.append("self.setTimeout(\"refreshDBComponent("); output.append("''"); output.append(getId()); output.append("'', "); output.append(refreshInterval + ", " + appId + ")\", " + refreshInterval + ");"); output.append("</script>"); return output.toString(); }
| 1,112,273
|
private void sqlScriptGenerator(Map<DiffType, AttributeSet> styles, List<DiffChunk<SQLObject>> diff, DDLGenerator gen) throws ArchitectDiffException, SQLException, ArchitectException, BadLocationException, InstantiationException, IllegalAccessException { for (DiffChunk<SQLObject> chunk : diff) { if (chunk.getType() == DiffType.KEY_CHANGED) { if(chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); boolean hasKey = false; for (SQLColumn c : t.getColumns()) { if (c.isPrimaryKey()) { hasKey=true; break; } } if (hasKey) { gen.addPrimaryKey(t,t.getPrimaryKeyName()); } else { gen.dropPrimaryKey(t,t.getPrimaryKeyName()); } } }else if (chunk.getType() == DiffType.LEFTONLY) { if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.dropTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.dropColumn(c,c.getParentTable()); } else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.dropRelationship(r); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.RIGHTONLY){ if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.writeTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.addColumn(c,c.getParentTable()); }else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.addRelationship(r); }else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.MODIFIED) { if (chunk.getData() instanceof SQLColumn) { SQLColumn c = (SQLColumn) chunk.getData(); gen.modifyColumn(c); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else { } } }
|
private void sqlScriptGenerator(Map<DiffType, AttributeSet> styles, List<DiffChunk<SQLObject>> diff, DDLGenerator gen) throws ArchitectDiffException, SQLException, ArchitectException, BadLocationException, InstantiationException, IllegalAccessException { for (DiffChunk<SQLObject> chunk : diff) { if (chunk.getType() == DiffType.KEY_CHANGED) { if(chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); boolean hasKey = false; for (SQLColumn c : t.getColumns()) { if (c.isPrimaryKey()) { hasKey=true; break; } } if (hasKey) { gen.addPrimaryKey(t); } else { gen.dropPrimaryKey(t,t.getPrimaryKeyName()); } } }else if (chunk.getType() == DiffType.LEFTONLY) { if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.dropTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.dropColumn(c,c.getParentTable()); } else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.dropRelationship(r); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.RIGHTONLY){ if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.writeTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.addColumn(c,c.getParentTable()); }else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.addRelationship(r); }else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.MODIFIED) { if (chunk.getData() instanceof SQLColumn) { SQLColumn c = (SQLColumn) chunk.getData(); gen.modifyColumn(c); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else { } } }
| 1,112,280
|
private void sqlScriptGenerator(Map<DiffType, AttributeSet> styles, List<DiffChunk<SQLObject>> diff, DDLGenerator gen) throws ArchitectDiffException, SQLException, ArchitectException, BadLocationException, InstantiationException, IllegalAccessException { for (DiffChunk<SQLObject> chunk : diff) { if (chunk.getType() == DiffType.KEY_CHANGED) { if(chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); boolean hasKey = false; for (SQLColumn c : t.getColumns()) { if (c.isPrimaryKey()) { hasKey=true; break; } } if (hasKey) { gen.addPrimaryKey(t,t.getPrimaryKeyName()); } else { gen.dropPrimaryKey(t,t.getPrimaryKeyName()); } } }else if (chunk.getType() == DiffType.LEFTONLY) { if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.dropTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.dropColumn(c,c.getParentTable()); } else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.dropRelationship(r); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.RIGHTONLY){ if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.writeTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.addColumn(c,c.getParentTable()); }else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.addRelationship(r); }else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.MODIFIED) { if (chunk.getData() instanceof SQLColumn) { SQLColumn c = (SQLColumn) chunk.getData(); gen.modifyColumn(c); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else { } } }
|
private void sqlScriptGenerator(Map<DiffType, AttributeSet> styles, List<DiffChunk<SQLObject>> diff, DDLGenerator gen) throws ArchitectDiffException, SQLException, ArchitectException, BadLocationException, InstantiationException, IllegalAccessException { for (DiffChunk<SQLObject> chunk : diff) { if (chunk.getType() == DiffType.KEY_CHANGED) { if(chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); boolean hasKey = false; for (SQLColumn c : t.getColumns()) { if (c.isPrimaryKey()) { hasKey=true; break; } } if (hasKey) { gen.addPrimaryKey(t,t.getPrimaryKeyName()); } else { gen.dropPrimaryKey(t); } } }else if (chunk.getType() == DiffType.LEFTONLY) { if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.dropTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.dropColumn(c,c.getParentTable()); } else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.dropRelationship(r); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.RIGHTONLY){ if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.writeTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.addColumn(c,c.getParentTable()); }else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.addRelationship(r); }else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.MODIFIED) { if (chunk.getData() instanceof SQLColumn) { SQLColumn c = (SQLColumn) chunk.getData(); gen.modifyColumn(c); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else { } } }
| 1,112,281
|
private void sqlScriptGenerator(Map<DiffType, AttributeSet> styles, List<DiffChunk<SQLObject>> diff, DDLGenerator gen) throws ArchitectDiffException, SQLException, ArchitectException, BadLocationException, InstantiationException, IllegalAccessException { for (DiffChunk<SQLObject> chunk : diff) { if (chunk.getType() == DiffType.KEY_CHANGED) { if(chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); boolean hasKey = false; for (SQLColumn c : t.getColumns()) { if (c.isPrimaryKey()) { hasKey=true; break; } } if (hasKey) { gen.addPrimaryKey(t,t.getPrimaryKeyName()); } else { gen.dropPrimaryKey(t,t.getPrimaryKeyName()); } } }else if (chunk.getType() == DiffType.LEFTONLY) { if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.dropTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.dropColumn(c,c.getParentTable()); } else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.dropRelationship(r); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.RIGHTONLY){ if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.writeTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.addColumn(c,c.getParentTable()); }else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.addRelationship(r); }else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.MODIFIED) { if (chunk.getData() instanceof SQLColumn) { SQLColumn c = (SQLColumn) chunk.getData(); gen.modifyColumn(c); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else { } } }
|
private void sqlScriptGenerator(Map<DiffType, AttributeSet> styles, List<DiffChunk<SQLObject>> diff, DDLGenerator gen) throws ArchitectDiffException, SQLException, ArchitectException, BadLocationException, InstantiationException, IllegalAccessException { for (DiffChunk<SQLObject> chunk : diff) { if (chunk.getType() == DiffType.KEY_CHANGED) { if(chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); boolean hasKey = false; for (SQLColumn c : t.getColumns()) { if (c.isPrimaryKey()) { hasKey=true; break; } } if (hasKey) { gen.addPrimaryKey(t,t.getPrimaryKeyName()); } else { gen.dropPrimaryKey(t,t.getPrimaryKeyName()); } } }else if (chunk.getType() == DiffType.LEFTONLY) { if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.dropTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.dropColumn(c); } else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.dropRelationship(r); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.RIGHTONLY){ if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.writeTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.addColumn(c,c.getParentTable()); }else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.addRelationship(r); }else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.MODIFIED) { if (chunk.getData() instanceof SQLColumn) { SQLColumn c = (SQLColumn) chunk.getData(); gen.modifyColumn(c); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else { } } }
| 1,112,282
|
private void sqlScriptGenerator(Map<DiffType, AttributeSet> styles, List<DiffChunk<SQLObject>> diff, DDLGenerator gen) throws ArchitectDiffException, SQLException, ArchitectException, BadLocationException, InstantiationException, IllegalAccessException { for (DiffChunk<SQLObject> chunk : diff) { if (chunk.getType() == DiffType.KEY_CHANGED) { if(chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); boolean hasKey = false; for (SQLColumn c : t.getColumns()) { if (c.isPrimaryKey()) { hasKey=true; break; } } if (hasKey) { gen.addPrimaryKey(t,t.getPrimaryKeyName()); } else { gen.dropPrimaryKey(t,t.getPrimaryKeyName()); } } }else if (chunk.getType() == DiffType.LEFTONLY) { if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.dropTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.dropColumn(c,c.getParentTable()); } else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.dropRelationship(r); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.RIGHTONLY){ if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.writeTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.addColumn(c,c.getParentTable()); }else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.addRelationship(r); }else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.MODIFIED) { if (chunk.getData() instanceof SQLColumn) { SQLColumn c = (SQLColumn) chunk.getData(); gen.modifyColumn(c); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else { } } }
|
private void sqlScriptGenerator(Map<DiffType, AttributeSet> styles, List<DiffChunk<SQLObject>> diff, DDLGenerator gen) throws ArchitectDiffException, SQLException, ArchitectException, BadLocationException, InstantiationException, IllegalAccessException { for (DiffChunk<SQLObject> chunk : diff) { if (chunk.getType() == DiffType.KEY_CHANGED) { if(chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); boolean hasKey = false; for (SQLColumn c : t.getColumns()) { if (c.isPrimaryKey()) { hasKey=true; break; } } if (hasKey) { gen.addPrimaryKey(t,t.getPrimaryKeyName()); } else { gen.dropPrimaryKey(t,t.getPrimaryKeyName()); } } }else if (chunk.getType() == DiffType.LEFTONLY) { if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.dropTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.dropColumn(c,c.getParentTable()); } else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.dropRelationship(r); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.RIGHTONLY){ if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.writeTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.addColumn(c); }else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.addRelationship(r); }else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.MODIFIED) { if (chunk.getData() instanceof SQLColumn) { SQLColumn c = (SQLColumn) chunk.getData(); gen.modifyColumn(c); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else { } } }
| 1,112,283
|
public void actionPerformed(ActionEvent evt) { // update the progress bar logger.debug("updating progress bar..."); try { Integer jobSize = monitorable.getJobSize(); if (bar != null) { if (monitorable.hasStarted()) { if (jobSize == null) { bar.setIndeterminate(true); } else { bar.setIndeterminate(false); bar.setMaximum(jobSize.intValue()); } bar.setVisible(true); bar.setValue(monitorable.getProgress()); bar.setIndeterminate(false); } } if (label != null) { label.setVisible(true); } if (pm != null) { // using ProgressMonitor if (monitorable.hasStarted()) { if (jobSize != null) { pm.setMaximum(jobSize.intValue()); } pm.setProgress(monitorable.getProgress()); logger.debug("progress: " + monitorable.getProgress()); pm.setNote(monitorable.getMessage()); } } } catch (ArchitectException e) { logger.error("Couldn't update progress bar (Monitorable threw an exception)", e); } finally { try { logger.debug("monitorable.isFinished():" + monitorable.isFinished()); if (monitorable.isFinished()) { if (label != null) { label.setText(""); } if (bar != null) { bar.setValue(0); } if (pm != null) { logger.debug("pm done, max was: " + pm.getMaximum()); pm.close(); } // fire a taskTerminationEvent fireTaskFinished(); logger.debug("trying to stop timer thread..."); timer.stop(); logger.debug("did the timer thread stop???"); } } catch (ArchitectException e1) { logger.error("Couldn't tell if Monitorable was finished (it threw an exception)", e1); } } }
|
public void actionPerformed(ActionEvent evt) { // update the progress bar logger.debug("updating progress bar..."); try { Integer jobSize = monitorable.getJobSize(); if (bar != null) { if (monitorable.hasStarted()) { if (jobSize == null) { bar.setIndeterminate(true); } else { bar.setIndeterminate(false); bar.setMaximum(jobSize.intValue()); } bar.setVisible(true); bar.setValue(monitorable.getProgress()); bar.setIndeterminate(false); } } if (label != null) { label.setVisible(true); } if (pm != null) { // using ProgressMonitor if (monitorable.hasStarted()) { if (jobSize != null) { pm.setMaximum(jobSize.intValue()); } pm.setProgress(monitorable.getProgress()); logger.debug("progress: " + monitorable.getProgress()); pm.setNote(monitorable.getMessage()); } } } catch (ArchitectException e) { logger.error("Couldn't update progress bar (Monitorable threw an exception)", e); } finally { try { logger.debug("monitorable.isFinished():" + monitorable.isFinished()); if (monitorable.isFinished()) { if (label != null) { label.setText(""); } if (bar != null) { bar.setValue(0); } if (pm != null) { logger.debug("pm done, max was: " + pm.getMaximum()); pm.close(); } // fire a taskTerminationEvent fireTaskFinished(); logger.debug("trying to stop timer thread..."); timer.stop(); logger.debug("did the timer thread stop???"); } } catch (ArchitectException e1) { logger.error("Couldn't tell if Monitorable was finished (it threw an exception)", e1); } } }
| 1,112,284
|
public Vector calcTDT(Vector chromosomes) { int numChroms; Chromosome chromT, chromU,chromTemp; String ped,ind; Vector temp; numChroms = chromosomes.size(); temp = (Vector)chromosomes.clone(); chromosomes = temp; int numMarkers = Chromosome.getSize(); for(int k=0;k<numMarkers;k++){ this.results.add(new TDTResult(Chromosome.getMarker(k))); } for(int i=0;i<chromosomes.size()-3;i++){ Chromosome chrom1T = (Chromosome)chromosomes.get(i); i++; Chromosome chrom1U = (Chromosome)chromosomes.get(i); i++; Chromosome chrom2T = (Chromosome)chromosomes.get(i); i++; Chromosome chrom2U = (Chromosome)chromosomes.get(i); //System.out.println("ind1T: " + chrom1T.getPed() + "\t" + chrom1T.getIndividual() ); //System.out.println("ind1U: " + chrom1U.getPed() + "\t" + chrom1U.getIndividual() ); //System.out.println("ind2T: " + chrom2T.getPed() + "\t" + chrom2T.getIndividual() ); //System.out.println("ind2U: " + chrom2U.getPed() + "\t" + chrom2U.getIndividual() ); for(int j=0;j<numMarkers;j++){ byte allele1T = chrom1T.getGenotype(j); byte allele1U = chrom1U.getGenotype(j); byte allele2T = chrom2T.getGenotype(j); byte allele2U = chrom2U.getGenotype(j); TDTResult curRes = (TDTResult)results.get(j); //System.out.println("marker "+ j + ":\t " + allele1T + "\t" + allele1U + "\t" + allele2T + "\t" + allele2U); curRes.tallyInd(allele1T,allele1U); curRes.tallyInd(allele2T,allele2U); } } for(int i=0;i<this.results.size();i++){ TDTResult tempRes = (TDTResult)this.results.get(i); int[][] counts = tempRes.counts; System.out.println( counts[0][0] + "\t" + counts[1][1] + "\t" + counts[0][1] + "\t" + counts[1][0]); } return this.results; }
|
public Vector calcTDT(Vector chromosomes) { int numChroms; Chromosome chromT, chromU,chromTemp; String ped,ind; Vector temp; numChroms = chromosomes.size(); temp = (Vector)chromosomes.clone(); chromosomes = temp; int numMarkers = Chromosome.getSize(); for(int k=0;k<numMarkers;k++){ this.results.add(new TDTResult(Chromosome.getMarker(k))); } for(int i=0;i<chromosomes.size()-3;i++){ Chromosome chrom1T = (Chromosome)chromosomes.get(i); i++; Chromosome chrom1U = (Chromosome)chromosomes.get(i); i++; Chromosome chrom2T = (Chromosome)chromosomes.get(i); i++; Chromosome chrom2U = (Chromosome)chromosomes.get(i); //System.out.println("ind1T: " + chrom1T.getPed() + "\t" + chrom1T.getIndividual() ); //System.out.println("ind1U: " + chrom1U.getPed() + "\t" + chrom1U.getIndividual() ); //System.out.println("ind2T: " + chrom2T.getPed() + "\t" + chrom2T.getIndividual() ); //System.out.println("ind2U: " + chrom2U.getPed() + "\t" + chrom2U.getIndividual() ); for(int j=0;j<numMarkers;j++){ byte allele1T = chrom1T.getGenotype(j); byte allele1U = chrom1U.getGenotype(j); byte allele2T = chrom2T.getGenotype(j); byte allele2U = chrom2U.getGenotype(j); TDTResult curRes = (TDTResult)results.get(j); //System.out.println("marker "+ j + ":\t " + allele1T + "\t" + allele1U + "\t" + allele2T + "\t" + allele2U); curRes.tallyInd(allele1T,allele1U); curRes.tallyInd(allele2T,allele2U); } } for(int i=0;i<this.results.size();i++){ TDTResult tempRes = (TDTResult)this.results.get(i); int[][] counts = tempRes.counts; } return this.results; }
| 1,112,285
|
public SQLCatalog(SQLDatabase parent, String name) { this.parent = parent; this.catalogName = name; this.children = new LinkedList(); }
|
public SQLCatalog(SQLDatabase parent, String name) { this.parent = parent; this.catalogName = name; this.children = new LinkedList(); }
| 1,112,286
|
public Test_ThumbnailView() { testRefImageDir = new File( "/home/harri/projects/photovault/tests/images/photovault/swingui/TestThumbnailView/" ); testRefImageDir.mkdirs(); }
|
public Test_ThumbnailView() { super(); testRefImageDir = new File( "tests/images/photovault/swingui/TestThumbnailView/" ); testRefImageDir.mkdirs(); }
| 1,112,287
|
protected void setUp() { // Create a frame with the test instance name as the title frame = new JFrame(getName()); pane = (JPanel)frame.getContentPane(); pane.setLayout(new FlowLayout()); pane.setBorder(new EmptyBorder(50, 50, 50, 50)); tester = ComponentTester.getTester(ThumbnailView.class); File f = new File(testImgDir, "test1.jpg" ); try { photo = PhotoInfo.addToDB( f ); } catch( PhotoNotFoundException e ) { fail( "error creating photo" ); } photo.setShootingPlace( "TESSTPLACE" ); }
|
public void setUp() { super.setUp(); // Create a frame with the test instance name as the title frame = new JFrame(getName()); pane = (JPanel)frame.getContentPane(); pane.setLayout(new FlowLayout()); pane.setBorder(new EmptyBorder(50, 50, 50, 50)); tester = ComponentTester.getTester(ThumbnailView.class); File f = new File(testImgDir, "test1.jpg" ); try { photo = PhotoInfo.addToDB( f ); } catch( PhotoNotFoundException e ) { fail( "error creating photo" ); } photo.setShootingPlace( "TESSTPLACE" ); }
| 1,112,288
|
public void doTag(XMLOutput output) throws Exception { output.write("output - ignored body"); }
|
public void doTag(XMLOutput output) throws JellyTagException { output.write("output - ignored body"); }
| 1,112,289
|
public void doTag(XMLOutput output) throws Exception { output.write("output - ignored body"); }
|
public void doTag(XMLOutput output) throws Exception { try { output.write("output - ignored body"); } catch (SAXException e) { throw new JellyTagException(e); } }
| 1,112,290
|
public void testComplexUnionPlan3() throws Exception { UnionQueryAnalyzer uqa = new UnionQueryAnalyzer(StorableTestBasic.class, TestIndexedQueryAnalyzer.RepoAccess.INSTANCE); Filter<StorableTestBasic> filter = Filter.filterFor (StorableTestBasic.class, "stringProp = ? | stringProp = ?"); filter = filter.bind(); UnionQueryAnalyzer.Result result = uqa.analyze(filter, null); boolean a = result.getTotalOrdering() == OrderingList.get(StorableTestBasic.class, "+doubleProp", "+stringProp"); boolean b = result.getTotalOrdering() == OrderingList.get(StorableTestBasic.class, "+stringProp", "+doubleProp"); assertTrue(a || b); QueryExecutor<StorableTestBasic> exec = result.createExecutor(); assertEquals(filter, exec.getFilter()); a = exec.getOrdering() == OrderingList.get(StorableTestBasic.class, "+doubleProp", "+stringProp"); b = exec.getOrdering() == OrderingList.get(StorableTestBasic.class, "+stringProp", "+doubleProp"); assertTrue(a || b); List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults(); assertEquals(2, subResults.size()); StringBuffer buf = new StringBuffer(); exec.printPlan(buf, 0, null); String plan = buf.toString(); String expexted = "union\n" + " index scan: com.amazon.carbonado.stored.StorableTestBasic\n" + " ...index: {properties=[+stringProp, +doubleProp], unique=true}\n" + " ...identity filter: stringProp = ?\n" + " index scan: com.amazon.carbonado.stored.StorableTestBasic\n" + " ...index: {properties=[+stringProp, +doubleProp], unique=true}\n" + " ...identity filter: stringProp = ?[2]\n"; // Test test will fail if the format of the plan changes. assertEquals(expexted, plan); }
|
public void testComplexUnionPlan3() throws Exception { UnionQueryAnalyzer uqa = new UnionQueryAnalyzer(StorableTestBasic.class, TestIndexedQueryAnalyzer.RepoAccess.INSTANCE); Filter<StorableTestBasic> filter = Filter.filterFor (StorableTestBasic.class, "stringProp = ? | stringProp = ?"); filter = filter.bind(); UnionQueryAnalyzer.Result result = uqa.analyze(filter, null); boolean a = result.getTotalOrdering() == OrderingList.get(StorableTestBasic.class, "+doubleProp", "+stringProp"); boolean b = result.getTotalOrdering() == OrderingList.get(StorableTestBasic.class, "+stringProp", "+doubleProp"); assertTrue(a || b); QueryExecutor<StorableTestBasic> exec = result.createExecutor(); assertEquals(filter, exec.getFilter()); a = exec.getOrdering() == OrderingList.get(StorableTestBasic.class, "+doubleProp", "+stringProp"); b = exec.getOrdering() == OrderingList.get(StorableTestBasic.class, "+stringProp", "+doubleProp"); assertTrue(a || b); List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults(); assertEquals(2, subResults.size()); StringBuffer buf = new StringBuffer(); exec.printPlan(buf, 0, null); String plan = buf.toString(); String expexted = "union\n" + " index scan: com.amazon.carbonado.stored.StorableTestBasic\n" + " ...index: {properties=[+stringProp, +doubleProp], unique=true}\n" + " ...identity filter: stringProp = ?\n" + " index scan: com.amazon.carbonado.stored.StorableTestBasic\n" + " ...index: {properties=[+stringProp, +doubleProp], unique=true}\n" + " ...identity filter: stringProp = ?[2]\n"; // Test test will fail if the format of the plan changes. assertEquals(expexted, plan); }
| 1,112,291
|
public void testComplexUnionPlan3() throws Exception { UnionQueryAnalyzer uqa = new UnionQueryAnalyzer(StorableTestBasic.class, TestIndexedQueryAnalyzer.RepoAccess.INSTANCE); Filter<StorableTestBasic> filter = Filter.filterFor (StorableTestBasic.class, "stringProp = ? | stringProp = ?"); filter = filter.bind(); UnionQueryAnalyzer.Result result = uqa.analyze(filter, null); boolean a = result.getTotalOrdering() == OrderingList.get(StorableTestBasic.class, "+doubleProp", "+stringProp"); boolean b = result.getTotalOrdering() == OrderingList.get(StorableTestBasic.class, "+stringProp", "+doubleProp"); assertTrue(a || b); QueryExecutor<StorableTestBasic> exec = result.createExecutor(); assertEquals(filter, exec.getFilter()); a = exec.getOrdering() == OrderingList.get(StorableTestBasic.class, "+doubleProp", "+stringProp"); b = exec.getOrdering() == OrderingList.get(StorableTestBasic.class, "+stringProp", "+doubleProp"); assertTrue(a || b); List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults(); assertEquals(2, subResults.size()); StringBuffer buf = new StringBuffer(); exec.printPlan(buf, 0, null); String plan = buf.toString(); String expexted = "union\n" + " index scan: com.amazon.carbonado.stored.StorableTestBasic\n" + " ...index: {properties=[+stringProp, +doubleProp], unique=true}\n" + " ...identity filter: stringProp = ?\n" + " index scan: com.amazon.carbonado.stored.StorableTestBasic\n" + " ...index: {properties=[+stringProp, +doubleProp], unique=true}\n" + " ...identity filter: stringProp = ?[2]\n"; // Test test will fail if the format of the plan changes. assertEquals(expexted, plan); }
|
public void testComplexUnionPlan3() throws Exception { UnionQueryAnalyzer uqa = new UnionQueryAnalyzer(StorableTestBasic.class, TestIndexedQueryAnalyzer.RepoAccess.INSTANCE); Filter<StorableTestBasic> filter = Filter.filterFor (StorableTestBasic.class, "stringProp = ? | stringProp = ?"); filter = filter.bind(); UnionQueryAnalyzer.Result result = uqa.analyze(filter, null); boolean a = result.getTotalOrdering() == OrderingList.get(StorableTestBasic.class, "+doubleProp", "+stringProp"); boolean b = result.getTotalOrdering() == OrderingList.get(StorableTestBasic.class, "+stringProp", "+doubleProp"); assertTrue(a || b); QueryExecutor<StorableTestBasic> exec = result.createExecutor(); assertEquals(filter, exec.getFilter()); a = exec.getOrdering() == OrderingList.get(StorableTestBasic.class, "+doubleProp", "+stringProp"); b = exec.getOrdering() == OrderingList.get(StorableTestBasic.class, "+stringProp", "+doubleProp"); assertTrue(a || b); List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults(); assertEquals(2, subResults.size()); StringBuffer buf = new StringBuffer(); exec.printPlan(buf, 0, null); String plan = buf.toString(); String expexted = "union\n" + " index scan: com.amazon.carbonado.stored.StorableTestBasic\n" + " ...index: {properties=[+stringProp, +doubleProp], unique=true}\n" + " ...identity filter: stringProp = ?\n" + " index scan: com.amazon.carbonado.stored.StorableTestBasic\n" + " ...index: {properties=[+stringProp, +doubleProp], unique=true}\n" + " ...identity filter: stringProp = ?[2]\n"; // Test test will fail if the format of the plan changes. assertEquals(expexted, plan); }
| 1,112,292
|
public void save(ProgressMonitor pm) throws IOException, ArchitectException { // write to temp file and then rename (this preserves old project file // when there's problems) if (file.exists() && !file.canWrite()) { // write problems with architect file will muck up the save process throw new ArchitectException("problem saving project -- " + "cannot write to architect file: " + file.getAbsolutePath()); } File backupFile = new File (file.getParent(), file.getName()+"~"); File tempFile = new File (file.getParent(),"tmp___" + file.getName()); out = new PrintWriter(new BufferedWriter(new FileWriter(tempFile))); objectIdMap = new HashMap(); dbcsIdMap = new HashMap(); indent = 0; progress = 0; boolean saveOk = false; // use this to determine if save process worked this.pm = pm; if (pm != null) { pm.setMinimum(0); int pmMax = countSourceTables((SQLObject) sourceDatabases.getModel().getRoot()) + playPen.getPPComponentCount() * 2; logger.debug("Setting progress monitor maximum to "+pmMax); pm.setMaximum(pmMax); pm.setProgress(progress); pm.setMillisToDecideToPopup(0); } try { println("<?xml version=\"1.0\"?>"); println("<architect-project version=\"0.1\">"); indent++; println("<project-name>"+name+"</project-name>"); saveDataSources(); saveSourceDatabases(); saveTargetDatabase(); saveDDLGenerator(); savePlayPen(); indent--; println("</architect-project>"); setModified(false); saveOk = true; } finally { if (out != null) out.close(); out = null; if (pm != null) pm.close(); pm = null; } // do the rename dance if (saveOk) { boolean fstatus = false; fstatus = backupFile.delete(); logger.debug("deleting backup~ file: " + fstatus); fstatus = file.renameTo(backupFile); logger.debug("renaming current file to backupFile: " + fstatus); fstatus = tempFile.renameTo(file); logger.debug("renaming tempFile to current file: " + fstatus); } }
|
public void save(ProgressMonitor pm) throws IOException, ArchitectException { // write to temp file and then rename (this preserves old project file // when there's problems) if (file.exists() && !file.canWrite()) { // write problems with architect file will muck up the save process throw new ArchitectException("problem saving project -- " + "cannot write to architect file: " + file.getAbsolutePath()); } File backupFile = new File (file.getParent(), file.getName()+"~"); File tempFile = new File (file.getParent(),"tmp___" + file.getName()); out = new PrintWriter(new BufferedWriter(new FileWriter(tempFile))); objectIdMap = new HashMap(); dbcsIdMap = new HashMap(); indent = 0; progress = 0; boolean saveOk = false; // use this to determine if save process worked this.pm = pm; if (pm != null) { pm.setMinimum(0); int pmMax = countSourceTables((SQLObject) sourceDatabases.getModel().getRoot()) + playPen.getPPComponentCount() * 2; logger.debug("Setting progress monitor maximum to "+pmMax); pm.setMaximum(pmMax); pm.setProgress(progress); pm.setMillisToDecideToPopup(0); } try { println("<?xml version=\"1.0\"?>"); println("<architect-project version=\"0.1\">"); indent++; println("<project-name>"+name+"</project-name>"); saveDataSources(); saveSourceDatabases(); saveTargetDatabase(); saveDDLGenerator(); savePlayPen(); indent--; println("</architect-project>"); setModified(false); saveOk = true; } finally { if (out != null) out.close(); out = null; if (pm != null) pm.close(); pm = null; } // do the rename dance if (saveOk) { boolean fstatus = false; fstatus = backupFile.delete(); logger.debug("deleting backup~ file: " + fstatus); fstatus = file.renameTo(backupFile); logger.debug("renaming current file to backupFile: " + fstatus); fstatus = tempFile.renameTo(file); logger.debug("renaming tempFile to current file: " + fstatus); } }
| 1,112,293
|
public void exportPhoto( File file, int width, int height ) { ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are no instances, nothing can be exported log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); AffineTransform xform = photovault.image. ImageXform.getFittingXform( width, height, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_BILINEAR ); BufferedImage exportImage = atOp.filter( origImage, null ); // Save it try { ImageIO.write( exportImage, "jpg", file ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } }
|
public void exportPhoto( File file, int width, int height ) { ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are no instances, nothing can be exported log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); AffineTransform xform = photovault.image. ImageXform.getFittingXform( width, height, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_BILINEAR ); BufferedImage exportImage = atOp.filter( origImage, null ); // Save it try { ImageIO.write( exportImage, "jpg", file ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } }
| 1,112,294
|
public void parseHapMap(Vector rawLines) throws PedFileException { int colNum = -1; int numLines = rawLines.size(); Individual ind; this.order = new Vector(); //sort first Vector lines = new Vector(); Hashtable sortHelp = new Hashtable(numLines-1,1.0f); long[] pos = new long[numLines-1]; lines.add(rawLines.get(0)); for (int k = 1; k < numLines; k++){ StringTokenizer st = new StringTokenizer((String) rawLines.get(k)); //strip off 1st 3 cols st.nextToken();st.nextToken();st.nextToken(); pos[k-1] = new Long(st.nextToken()).longValue(); sortHelp.put(new Long(pos[k-1]),rawLines.get(k)); } Arrays.sort(pos); for (int i = 0; i < pos.length; i++){ lines.add(sortHelp.get(new Long(pos[i]))); } //enumerate indivs StringTokenizer st = new StringTokenizer((String)lines.get(0), "\n\t\" \""); int numMetaColumns = 0; boolean doneMeta = false; while(!doneMeta && st.hasMoreTokens()){ String thisfield = st.nextToken(); numMetaColumns++; //so currently the first person ID always starts with NA (Coriell ID) but //todo: will this be true with AA samples etc? if (thisfield.startsWith("NA")){ doneMeta = true; } } numMetaColumns--; st = new StringTokenizer((String)lines.get(0), "\n\t\" \""); for (int i = 0; i < numMetaColumns; i++){ st.nextToken(); } StringTokenizer dt; while (st.hasMoreTokens()){ ind = new Individual(numLines); String name = st.nextToken(); String details = (String)hapMapTranslate.get(name); if (details == null){ throw new PedFileException("Hapmap data format error: " + name); } dt = new StringTokenizer(details, "\n\t\" \""); ind.setFamilyID(dt.nextToken().trim()); ind.setIndividualID(dt.nextToken().trim()); ind.setDadID(dt.nextToken().trim()); ind.setMomID(dt.nextToken().trim()); try { ind.setGender(Integer.parseInt(dt.nextToken().trim())); ind.setAffectedStatus(Integer.parseInt(dt.nextToken().trim())); }catch(NumberFormatException nfe) { throw new PedFileException("File error: invalid gender or affected status for indiv " + name); } ind.setIsTyped(true); //check if the family exists already in the Hashtable Family fam = (Family)this.families.get(ind.getFamilyID()); if(fam == null){ //it doesnt exist, so create a new Family object fam = new Family(ind.getFamilyID()); } fam.addMember(ind); this.families.put(ind.getFamilyID(),fam); String[] indFamID = new String[2]; indFamID[0] = ind.getFamilyID(); indFamID[1] = ind.getIndividualID(); this.order.add(ind); } //start at k=1 to skip header which we just processed above. hminfo = new String[numLines-1][]; for(int k=1;k<numLines;k++){ StringTokenizer tokenizer = new StringTokenizer((String)lines.get(k)); //reading the first line if(colNum < 0){ //only check column number count for the first line colNum = tokenizer.countTokens(); } if(colNum != tokenizer.countTokens()) { //this line has a different number of columns //should send some sort of error message //TODO: add something which stores number of markers for all lines and checks that they're consistent throw new PedFileException("Line number mismatch in input file. line " + (k+1)); } if(tokenizer.hasMoreTokens()){ hminfo[k-1] = new String[2]; for (int skip = 0; skip < numMetaColumns; skip++){ //meta-data crap String s = tokenizer.nextToken().trim(); //get marker name, chrom and pos if (skip == 0){ hminfo[k-1][0] = s; } if (skip == 2){ if (Chromosome.dataChrom != null){ if (!Chromosome.dataChrom.equals(s)){ throw new PedFileException("Hapmap file format error on line " + (k+1)+ ":\n There appear to be multiple chromosomes in the file."); } }else{ Chromosome.dataChrom = s; } } if (skip == 3){ hminfo[k-1][1] = s; } } int index = 0; while(tokenizer.hasMoreTokens()){ ind = ((Family)families.get(((String[])order.elementAt(index))[0])).getMember( ((String[])order.elementAt(index))[1]); String alleles = tokenizer.nextToken(); int allele1=0, allele2=0; if (alleles.substring(0,1).equals("A")){ allele1 = 1; }else if (alleles.substring(0,1).equals("C")){ allele1 = 2; }else if (alleles.substring(0,1).equals("G")){ allele1 = 3; }else if (alleles.substring(0,1).equals("T")){ allele1 = 4; } if (alleles.substring(1,2).equals("A")){ allele2 = 1; }else if (alleles.substring(1,2).equals("C")){ allele2 = 2; }else if (alleles.substring(1,2).equals("G")){ allele2 = 3; }else if (alleles.substring(1,2).equals("T")){ allele2 = 4; } byte[] markers = new byte[2]; markers[0] = (byte)allele1; markers[1]= (byte)allele2; ind.addMarker(markers); index++; } } } }
|
public void parseHapMap(Vector rawLines) throws PedFileException { int colNum = -1; int numLines = rawLines.size(); Individual ind; this.order = new Vector(); //sort first Vector lines = new Vector(); Hashtable sortHelp = new Hashtable(numLines-1,1.0f); long[] pos = new long[numLines-1]; lines.add(rawLines.get(0)); for (int k = 1; k < numLines; k++){ StringTokenizer st = new StringTokenizer((String) rawLines.get(k)); //strip off 1st 3 cols st.nextToken();st.nextToken();st.nextToken(); pos[k-1] = new Long(st.nextToken()).longValue(); sortHelp.put(new Long(pos[k-1]),rawLines.get(k)); } Arrays.sort(pos); for (int i = 0; i < pos.length; i++){ lines.add(sortHelp.get(new Long(pos[i]))); } //enumerate indivs StringTokenizer st = new StringTokenizer((String)lines.get(0), "\n\t\" \""); int numMetaColumns = 0; boolean doneMeta = false; while(!doneMeta && st.hasMoreTokens()){ String thisfield = st.nextToken(); numMetaColumns++; //so currently the first person ID always starts with NA (Coriell ID) but //todo: will this be true with AA samples etc? if (thisfield.startsWith("NA")){ doneMeta = true; } } numMetaColumns--; st = new StringTokenizer((String)lines.get(0), "\n\t\" \""); for (int i = 0; i < numMetaColumns; i++){ st.nextToken(); } StringTokenizer dt; while (st.hasMoreTokens()){ ind = new Individual(numLines); String name = st.nextToken(); String details = (String)hapMapTranslate.get(name); if (details == null){ throw new PedFileException("Hapmap data format error: " + name); } dt = new StringTokenizer(details, "\n\t\" \""); ind.setFamilyID(dt.nextToken().trim()); ind.setIndividualID(dt.nextToken().trim()); ind.setDadID(dt.nextToken().trim()); ind.setMomID(dt.nextToken().trim()); try { ind.setGender(Integer.parseInt(dt.nextToken().trim())); ind.setAffectedStatus(Integer.parseInt(dt.nextToken().trim())); }catch(NumberFormatException nfe) { throw new PedFileException("File error: invalid gender or affected status for indiv " + name); } ind.setIsTyped(true); //check if the family exists already in the Hashtable Family fam = (Family)this.families.get(ind.getFamilyID()); if(fam == null){ //it doesnt exist, so create a new Family object fam = new Family(ind.getFamilyID()); } fam.addMember(ind); this.families.put(ind.getFamilyID(),fam); String[] indFamID = new String[2]; indFamID[0] = ind.getFamilyID(); indFamID[1] = ind.getIndividualID(); this.order.add(ind); } //start at k=1 to skip header which we just processed above. hminfo = new String[numLines-1][]; for(int k=1;k<numLines;k++){ StringTokenizer tokenizer = new StringTokenizer((String)lines.get(k)); //reading the first line if(colNum < 0){ //only check column number count for the first line colNum = tokenizer.countTokens(); } if(colNum != tokenizer.countTokens()) { //this line has a different number of columns //should send some sort of error message //TODO: add something which stores number of markers for all lines and checks that they're consistent throw new PedFileException("Line number mismatch in input file. line " + (k+1)); } if(tokenizer.hasMoreTokens()){ hminfo[k-1] = new String[2]; for (int skip = 0; skip < numMetaColumns; skip++){ //meta-data crap String s = tokenizer.nextToken().trim(); //get marker name, chrom and pos if (skip == 0){ hminfo[k-1][0] = s; } if (skip == 2){ if (Chromosome.dataChrom != null){ if (!Chromosome.dataChrom.equals(s)){ throw new PedFileException("Hapmap file format error on line " + (k+1)+ ":\n There appear to be multiple chromosomes in the file."); } }else{ Chromosome.dataChrom = s; } } if (skip == 3){ hminfo[k-1][1] = s; } } int index = 0; while(tokenizer.hasMoreTokens()){ ind = ((Family)families.get(((String[])order.elementAt(index))[0])).getMember( ((String[])order.elementAt(index))[1]); String alleles = tokenizer.nextToken(); int allele1=0, allele2=0; if (alleles.substring(0,1).equals("A")){ allele1 = 1; }else if (alleles.substring(0,1).equals("C")){ allele1 = 2; }else if (alleles.substring(0,1).equals("G")){ allele1 = 3; }else if (alleles.substring(0,1).equals("T")){ allele1 = 4; } if (alleles.substring(1,2).equals("A")){ allele2 = 1; }else if (alleles.substring(1,2).equals("C")){ allele2 = 2; }else if (alleles.substring(1,2).equals("G")){ allele2 = 3; }else if (alleles.substring(1,2).equals("T")){ allele2 = 4; } byte[] markers = new byte[2]; markers[0] = (byte)allele1; markers[1]= (byte)allele2; ind.addMarker(markers); index++; } } } }
| 1,112,297
|
public void mouseClicked(MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK) { int clickX = e.getX(); int clickY = e.getY(); if (showWM && wmInteriorRect.contains(clickX,clickY)){ //convert a click on the worldmap to a point on the big picture int bigClickX = (((clickX - getVisibleRect().x - (worldmap.getWidth()-wmInteriorRect.width)/2) * chartSize.width) / wmInteriorRect.width)-getVisibleRect().width/2; int bigClickY = (((clickY - getVisibleRect().y - (worldmap.getHeight() - wmInteriorRect.height)/2 - (getVisibleRect().height-worldmap.getHeight())) * chartSize.height) / wmInteriorRect.height) - getVisibleRect().height/2; //if the clicks are near the edges, correct values if (bigClickX > chartSize.width - getVisibleRect().width){ bigClickX = chartSize.width - getVisibleRect().width; } if (bigClickX < 0){ bigClickX = 0; } if (bigClickY > chartSize.height - getVisibleRect().height){ bigClickY = chartSize.height - getVisibleRect().height; } if (bigClickY < 0){ bigClickY = 0; } ((JViewport)getParent()).setViewPosition(new Point(bigClickX,bigClickY)); }else{ theHV.changeBlocks(BLOX_CUSTOM); Rectangle2D blockselector = new Rectangle2D.Double(clickXShift-boxRadius,clickYShift - boxRadius, alignedPositions[alignedPositions.length-1], boxSize); if(blockselector.contains(clickX,clickY)){ int whichMarker = getPreciseMarkerAt(clickX - clickXShift); if (whichMarker > -1){ if (theData.isInBlock[whichMarker]){ theData.removeFromBlock(whichMarker); repaint(); } else if (whichMarker > 0 && whichMarker < Chromosome.realIndex.length){ theData.addMarkerIntoSurroundingBlock(whichMarker); } } } } } }
|
public void mouseClicked(MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK) { int clickX = e.getX(); int clickY = e.getY(); if (showWM && wmInteriorRect.contains(clickX,clickY)){ //convert a click on the worldmap to a point on the big picture int bigClickX = (((clickX - getVisibleRect().x - (worldmap.getWidth()-wmInteriorRect.width)/2) * chartSize.width) / wmInteriorRect.width)-getVisibleRect().width/2; int bigClickY = (((clickY - getVisibleRect().y - (worldmap.getHeight() - wmInteriorRect.height)/2 - (getVisibleRect().height-worldmap.getHeight())) * chartSize.height) / wmInteriorRect.height) - getVisibleRect().height/2; //if the clicks are near the edges, correct values if (bigClickX > chartSize.width - getVisibleRect().width){ bigClickX = chartSize.width - getVisibleRect().width; } if (bigClickX < 0){ bigClickX = 0; } if (bigClickY > chartSize.height - getVisibleRect().height){ bigClickY = chartSize.height - getVisibleRect().height; } if (bigClickY < 0){ bigClickY = 0; } ((JViewport)getParent()).setViewPosition(new Point(bigClickX,bigClickY)); }else{ theHV.changeBlocks(BLOX_CUSTOM); Rectangle2D blockselector = new Rectangle2D.Double(clickXShift-boxRadius,clickYShift - boxRadius, alignedPositions[alignedPositions.length-1] + boxSize, boxSize); if(blockselector.contains(clickX,clickY)){ int whichMarker = getPreciseMarkerAt(clickX - clickXShift); if (whichMarker > -1){ if (theData.isInBlock[whichMarker]){ theData.removeFromBlock(whichMarker); repaint(); } else if (whichMarker > 0 && whichMarker < Chromosome.realIndex.length){ theData.addMarkerIntoSurroundingBlock(whichMarker); } } } } } }
| 1,112,298
|
public void paintComponent(Graphics graphics) { if (filteredHaplos == null){ super.paintComponent(graphics); return; } Graphics2D g = (Graphics2D) graphics; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //System.out.println(getSize()); Dimension size = getSize(); Dimension pref = getPreferredSize(); g.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); //g.drawRect(0, 0, pref.width, pref.height); final BasicStroke thinStroke = new BasicStroke(0.5f); final BasicStroke thickStroke = new BasicStroke(2.0f); // width of one letter of the haplotype block //int letterWidth = haploMetrics.charWidth('G'); //int percentWidth = pctMetrics.stringWidth(".000"); //final int verticalOffset = 43; // room for tags and diamonds int left = BORDER; int top = BORDER; //verticalOffset; //int totalWidth = 0; // percentages for each haplotype NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); nf.setMinimumIntegerDigits(0); nf.setMaximumIntegerDigits(0); // multi reading, between the columns NumberFormat nfMulti = NumberFormat.getInstance(); nfMulti.setMinimumFractionDigits(2); nfMulti.setMaximumFractionDigits(2); nfMulti.setMinimumIntegerDigits(0); nfMulti.setMaximumIntegerDigits(0); int[][] lookupPos = new int[filteredHaplos.length][]; for (int p = 0; p < lookupPos.length; p++) { lookupPos[p] = new int[filteredHaplos[p].length]; for (int q = 0; q < lookupPos[p].length; q++){ lookupPos[p][filteredHaplos[p][q].getListOrder()] = q; } } // set number formatter to pad with appropriate number of zeroes NumberFormat nfMarker = NumberFormat.getInstance(); int markerCount = Chromosome.getSize(); // the +0.0000001 is because there is // some suckage where log(1000) / log(10) isn't actually 3 int markerDigits = (int) (0.0000001 + Math.log(markerCount) / Math.log(10)) + 1; nfMarker.setMinimumIntegerDigits(markerDigits); nfMarker.setMaximumIntegerDigits(markerDigits); //int tagShapeX[] = new int[3]; //int tagShapeY[] = new int[3]; //Polygon tagShape; int textRight = 0; // gets updated for scooting over // i = 0 to number of columns - 1 for (int i = 0; i < filteredHaplos.length; i++) { int[] markerNums = filteredHaplos[i][0].getMarkers(); boolean[] tags = filteredHaplos[i][0].getTags(); //int headerX = x; for (int z = 0; z < markerNums.length; z++) { //int tagMiddle = tagMetrics.getAscent() / 2; //int tagLeft = x + z*letterWidth + tagMiddle; //g.translate(tagLeft, 20); // if tag snp, draw little triangle pooper if (tags[z]) { g.drawImage(tagImage, left + z*CHAR_WIDTH, top + markerDigits*MARKER_CHAR_WIDTH + -(CHAR_HEIGHT - TAG_SPAN), null); } //g.rotate(-Math.PI / 2.0); //g.drawLine(0, 0, 0, 0); //g.setColor(Color.black); //g.drawString(nfMarker.format(markerNums[z]), 0, tagMiddle); char markerChars[] = nfMarker.format(Chromosome.realIndex[markerNums[z]]+1).toCharArray(); for (int m = 0; m < markerDigits; m++) { g.drawImage(markerNumImages[markerChars[m] - '0'], left + z*CHAR_WIDTH + (1 + CHAR_WIDTH - MARKER_CHAR_HEIGHT)/2, top + (markerDigits-m-1)*MARKER_CHAR_WIDTH, null); } // undo the transform.. no push/pop.. arrgh //g.rotate(Math.PI / 2.0); //g.translate(-tagLeft, -20); } // y position of the first image for the haplotype letter // top + the size of the marker digits + the size of the tag + // the character height centered in the row's height int above = top + markerDigits*MARKER_CHAR_WIDTH + TAG_SPAN + (ROW_HEIGHT - CHAR_HEIGHT) / 2; for (int j = 0; j < filteredHaplos[i].length; j++){ int curHapNum = lookupPos[i][j]; //String theHap = new String(); //String thePercentage = new String(); int[] theGeno = filteredHaplos[i][curHapNum].getGeno(); //getGeno(); // j is the row of haplotype for (int k = 0; k < theGeno.length; k++) { // theGeno[k] will be 1,2,3,4 (acgt) or 8 (for bad) g.drawImage(charImages[theGeno[k] - 1], left + k*CHAR_WIDTH, above + j*ROW_HEIGHT, null); } //draw the percentage value in non mono font double percent = filteredHaplos[i][curHapNum].getPercentage(); //thePercentage = " " + nf.format(percent); char percentChars[] = nf.format(percent).toCharArray(); // perhaps need an exceptional case for 1.0 being the percent for (int m = 0; m < percentChars.length; m++) { g.drawImage(grayNumImages[(m == 0) ? 10 : percentChars[m]-'0'], left + theGeno.length*CHAR_WIDTH + m*CHAR_WIDTH, above + j*ROW_HEIGHT, null); } // 4 is the number of chars in .999 for the percent textRight = left + theGeno.length*CHAR_WIDTH + 4*CHAR_WIDTH; g.setColor(Color.black); if (i < filteredHaplos.length - 1) { //draw crossovers for (int crossCount = 0; crossCount < filteredHaplos[i+1].length; crossCount++) { double crossVal = filteredHaplos[i][curHapNum].getCrossover(crossCount); //draw thin and thick lines int crossValue = (int) (crossVal*100); if (crossValue > thinThresh) { g.setStroke(crossValue > thickThresh ? thickStroke : thinStroke); int connectTo = filteredHaplos[i+1][crossCount].getListOrder(); g.drawLine(textRight + LINE_LEFT, above + j*ROW_HEIGHT + ROW_HEIGHT/2, textRight + LINE_RIGHT, above + connectTo*ROW_HEIGHT + ROW_HEIGHT/2); } } } } left = textRight; // add the multilocus d prime if appropriate if (i < filteredHaplos.length - 1) { //put the numbers in the right place vertically int depth; if (filteredHaplos[i].length > filteredHaplos[i+1].length){ depth = filteredHaplos[i].length; }else{ depth = filteredHaplos[i+1].length; } char multiChars[] = nfMulti.format(multidprimeArray[i]).toCharArray(); for (int m = 0; m < 3; m++) { // 7*CHAR_WIDTH/2 = CHAR_WIDTH*3.5 to center it better // since the . char is right-aligned, and visually off g.drawImage(blackNumImages[(m == 0) ? 10 : multiChars[m]-'0'], left + (LINE_SPAN - 7*CHAR_WIDTH/2)/2 + m*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); } //int multiX = x + totalWidth + 3; //g.drawString(nfMulti.format(multidprimeArray[i]), // multiX+2, windowY - 3); } left += LINE_SPAN; //x += (totalWidth + 40); //y = verticalOffset; //left = textRight + LINE_SPAN; } }
|
public void paintComponent(Graphics graphics) { if (filteredHaplos == null){ super.paintComponent(graphics); return; } Graphics2D g = (Graphics2D) graphics; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //System.out.println(getSize()); Dimension size = getSize(); Dimension pref = getPreferredSize(); g.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); //g.drawRect(0, 0, pref.width, pref.height); final BasicStroke thinStroke = new BasicStroke(0.5f); final BasicStroke thickStroke = new BasicStroke(2.0f); // width of one letter of the haplotype block //int letterWidth = haploMetrics.charWidth('G'); //int percentWidth = pctMetrics.stringWidth(".000"); //final int verticalOffset = 43; // room for tags and diamonds int left = BORDER; int top = BORDER; //verticalOffset; //int totalWidth = 0; // percentages for each haplotype NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); nf.setMinimumIntegerDigits(0); nf.setMaximumIntegerDigits(0); // multi reading, between the columns NumberFormat nfMulti = NumberFormat.getInstance(); nfMulti.setMinimumFractionDigits(2); nfMulti.setMaximumFractionDigits(2); nfMulti.setMinimumIntegerDigits(0); nfMulti.setMaximumIntegerDigits(0); int[][] lookupPos = new int[filteredHaplos.length][]; for (int p = 0; p < lookupPos.length; p++) { lookupPos[p] = new int[filteredHaplos[p].length]; for (int q = 0; q < lookupPos[p].length; q++){ lookupPos[p][filteredHaplos[p][q].getListOrder()] = q; } } // set number formatter to pad with appropriate number of zeroes NumberFormat nfMarker = NumberFormat.getInstance(); int markerCount = Chromosome.getSize(); // the +0.0000001 is because there is // some suckage where log(1000) / log(10) isn't actually 3 int markerDigits = (int) (0.0000001 + Math.log(markerCount) / Math.log(10)) + 1; nfMarker.setMinimumIntegerDigits(markerDigits); nfMarker.setMaximumIntegerDigits(markerDigits); //int tagShapeX[] = new int[3]; //int tagShapeY[] = new int[3]; //Polygon tagShape; int textRight = 0; // gets updated for scooting over // i = 0 to number of columns - 1 for (int i = 0; i < filteredHaplos.length; i++) { int[] markerNums = filteredHaplos[i][0].getMarkers(); boolean[] tags = filteredHaplos[i][0].getTags(); //int headerX = x; for (int z = 0; z < markerNums.length; z++) { //int tagMiddle = tagMetrics.getAscent() / 2; //int tagLeft = x + z*letterWidth + tagMiddle; //g.translate(tagLeft, 20); // if tag snp, draw little triangle pooper if (tags[z]) { g.drawImage(tagImage, left + z*CHAR_WIDTH, top + markerDigits*MARKER_CHAR_WIDTH + -(CHAR_HEIGHT - TAG_SPAN), null); } //g.rotate(-Math.PI / 2.0); //g.drawLine(0, 0, 0, 0); //g.setColor(Color.black); //g.drawString(nfMarker.format(markerNums[z]), 0, tagMiddle); char markerChars[] = nfMarker.format(Chromosome.realIndex[markerNums[z]]+1).toCharArray(); for (int m = 0; m < markerDigits; m++) { g.drawImage(markerNumImages[markerChars[m] - '0'], left + z*CHAR_WIDTH + (1 + CHAR_WIDTH - MARKER_CHAR_HEIGHT)/2, top + (markerDigits-m-1)*MARKER_CHAR_WIDTH, null); } // undo the transform.. no push/pop.. arrgh //g.rotate(Math.PI / 2.0); //g.translate(-tagLeft, -20); } // y position of the first image for the haplotype letter // top + the size of the marker digits + the size of the tag + // the character height centered in the row's height int above = top + markerDigits*MARKER_CHAR_WIDTH + TAG_SPAN + (ROW_HEIGHT - CHAR_HEIGHT) / 2; for (int j = 0; j < filteredHaplos[i].length; j++){ int curHapNum = lookupPos[i][j]; //String theHap = new String(); //String thePercentage = new String(); int[] theGeno = filteredHaplos[i][curHapNum].getGeno(); //getGeno(); // j is the row of haplotype for (int k = 0; k < theGeno.length; k++) { // theGeno[k] will be 1,2,3,4 (acgt) or 8 (for bad) g.drawImage(charImages[theGeno[k] - 1], left + k*CHAR_WIDTH, above + j*ROW_HEIGHT, null); } //draw the percentage value in non mono font double percent = filteredHaplos[i][curHapNum].getPercentage(); //thePercentage = " " + nf.format(percent); char percentChars[] = nf.format(percent).toCharArray(); // perhaps need an exceptional case for 1.0 being the percent for (int m = 0; m < percentChars.length; m++) { g.drawImage(grayNumImages[(m == 0) ? 10 : percentChars[m]-'0'], left + theGeno.length*CHAR_WIDTH + m*CHAR_WIDTH, above + j*ROW_HEIGHT, null); } // 4 is the number of chars in .999 for the percent textRight = left + theGeno.length*CHAR_WIDTH + 4*CHAR_WIDTH; g.setColor(Color.black); if (i < filteredHaplos.length - 1) { //draw crossovers for (int crossCount = 0; crossCount < filteredHaplos[i+1].length; crossCount++) { double crossVal = filteredHaplos[i][curHapNum].getCrossover(crossCount); //draw thin and thick lines int crossValue = (int) (crossVal*100); if (crossValue > thinThresh) { g.setStroke(crossValue > thickThresh ? thickStroke : thinStroke); int connectTo = filteredHaplos[i+1][crossCount].getListOrder(); g.drawLine(textRight + LINE_LEFT, above + j*ROW_HEIGHT + ROW_HEIGHT/2, textRight + LINE_RIGHT, above + connectTo*ROW_HEIGHT + ROW_HEIGHT/2); } } } } left = textRight; // add the multilocus d prime if appropriate if (i < filteredHaplos.length - 1) { //put the numbers in the right place vertically int depth; if (filteredHaplos[i].length > filteredHaplos[i+1].length){ depth = filteredHaplos[i].length; }else{ depth = filteredHaplos[i+1].length; } char multiChars[] = nfMulti.format(multidprimeArray[i]).toCharArray(); for (int m = 0; m < 3; m++) { // 7*CHAR_WIDTH/2 = CHAR_WIDTH*3.5 to center it better // since the . char is right-aligned, and visually off g.drawImage(blackNumImages[(m == 0) ? 10 : multiChars[m]-'0'], left + (LINE_SPAN - 7*CHAR_WIDTH/2)/2 + m*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); } //int multiX = x + totalWidth + 3; //g.drawString(nfMulti.format(multidprimeArray[i]), // multiX+2, windowY - 3); } left += LINE_SPAN; //x += (totalWidth + 40); //y = verticalOffset; //left = textRight + LINE_SPAN; } }
| 1,112,299
|
public static void main(String[] args) throws Exception { try { if (args.length <= 0) { System.out.println("Usage: Jelly scriptFile [outputFile]"); return; } Jelly jelly = new Jelly(); jelly.setScript(args[0]); // later we might wanna add some command line arguments // checking stuff using commons-cli to specify the output file // and input file via command line arguments final XMLOutput output = (args.length > 1) ? XMLOutput.createXMLOutput(new FileWriter(args[1])) : XMLOutput.createXMLOutput(System.out); Script script = jelly.compileScript(); // add the system properties and the command line arguments JellyContext context = jelly.getJellyContext(); context.setVariable("args", args); script.run(context, output); // now lets wait for all threads to close Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { output.close(); } catch (Exception e) { // ignore errors } } } ); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause != null) { cause.printStackTrace(); } else { e.printStackTrace(); } } }
|
public static void main(String[] args) throws Exception { try { if (args.length <= 0) { System.out.println("Usage: jelly [scriptFile] [-script scriptFile -o outputFile -Dsysprop=syspropval]"); return; } Jelly jelly = new Jelly(); jelly.setScript(args[0]); // later we might wanna add some command line arguments // checking stuff using commons-cli to specify the output file // and input file via command line arguments final XMLOutput output = (args.length > 1) ? XMLOutput.createXMLOutput(new FileWriter(args[1])) : XMLOutput.createXMLOutput(System.out); Script script = jelly.compileScript(); // add the system properties and the command line arguments JellyContext context = jelly.getJellyContext(); context.setVariable("args", args); script.run(context, output); // now lets wait for all threads to close Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { output.close(); } catch (Exception e) { // ignore errors } } } ); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause != null) { cause.printStackTrace(); } else { e.printStackTrace(); } } }
| 1,112,300
|
public static void main(String[] args) throws Exception { try { if (args.length <= 0) { System.out.println("Usage: Jelly scriptFile [outputFile]"); return; } Jelly jelly = new Jelly(); jelly.setScript(args[0]); // later we might wanna add some command line arguments // checking stuff using commons-cli to specify the output file // and input file via command line arguments final XMLOutput output = (args.length > 1) ? XMLOutput.createXMLOutput(new FileWriter(args[1])) : XMLOutput.createXMLOutput(System.out); Script script = jelly.compileScript(); // add the system properties and the command line arguments JellyContext context = jelly.getJellyContext(); context.setVariable("args", args); script.run(context, output); // now lets wait for all threads to close Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { output.close(); } catch (Exception e) { // ignore errors } } } ); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause != null) { cause.printStackTrace(); } else { e.printStackTrace(); } } }
|
public static void main(String[] args) throws Exception { try { if (args.length <= 0) { System.out.println("Usage: Jelly scriptFile [outputFile]"); return; } Jelly jelly = new Jelly(); jelly.setScript(args[0]); // later we might wanna add some command line arguments // checking stuff using commons-cli to specify the output file // and input file via command line arguments final XMLOutput output = (args.length > 1) ? XMLOutput.createXMLOutput(new FileWriter(args[1])) : XMLOutput.createXMLOutput(System.out); Script script = jelly.compileScript(); // add the system properties and the command line arguments JellyContext context = jelly.getJellyContext(); context.setVariable("args", args); script.run(context, output); // now lets wait for all threads to close Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { output.close(); } catch (Exception e) { // ignore errors } } } ); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause != null) { cause.printStackTrace(); } else { e.printStackTrace(); } } }
| 1,112,301
|
protected void setUp() throws Exception { super.setUp(); SQLDatabase mydb = new SQLDatabase(db.getDataSource()); Connection con = mydb.getConnection(); /* * Setting up a clean db for each of the tests */ Statement stmt = con.createStatement(); try { stmt.executeUpdate("DROP TABLE REGRESSION_TEST1"); stmt.executeUpdate("DROP TABLE REGRESSION_TEST2"); } catch (SQLException sqle ){ System.out.println("+++ TestSQLDatabase exception should be for dropping a non-existant table"); sqle.printStackTrace(); } stmt.executeUpdate("CREATE TABLE REGRESSION_TEST1 (t1_c1 numeric(10))"); stmt.executeUpdate("CREATE TABLE REGRESSION_TEST2 (t2_c1 char(10))"); stmt.close(); mydb.disconnect(); }
|
protected void setUp() throws Exception { super.setUp(); SQLDatabase mydb = new SQLDatabase(db.getDataSource()); Connection con = mydb.getConnection(); /* * Setting up a clean db for each of the tests */ Statement stmt = con.createStatement(); try { stmt.executeUpdate("DROP TABLE REGRESSION_TEST1"); stmt.executeUpdate("DROP TABLE REGRESSION_TEST2"); } catch (SQLException sqle ){ System.out.println("+++ TestSQLDatabase exception should be for dropping a non-existant table"); sqle.printStackTrace(); } stmt.executeUpdate("CREATE TABLE REGRESSION_TEST1 (t1_c1 numeric(10))"); stmt.executeUpdate("CREATE TABLE REGRESSION_TEST2 (t2_c1 char(10))"); stmt.close(); mydb.disconnect(); }
| 1,112,305
|
protected QueryExecutor<UserAddress> addressExecutor() throws Exception { Storage<UserAddress> addressStorage = mRepository.storageFor(UserAddress.class); QueryExecutor<UserAddress> addressExecutor = new ScanQueryExecutor<UserAddress>(addressStorage.query()); addressExecutor = new FilteredQueryExecutor<UserAddress> (addressExecutor, Filter.filterFor(UserAddress.class, "state = ?")); StorableProperty<UserAddress> prop = StorableIntrospector .examine(UserAddress.class).getAllProperties().get("country"); List<OrderedProperty<UserAddress>> orderings = new ArrayList<OrderedProperty<UserAddress>>(); orderings.add(OrderedProperty.get(prop, null)); addressExecutor = new ArraySortedQueryExecutor<UserAddress> (addressExecutor, null, orderings); return addressExecutor; }
|
protected QueryExecutor<UserAddress> addressExecutor() throws Exception { Storage<UserAddress> addressStorage = mRepository.storageFor(UserAddress.class); QueryExecutor<UserAddress> addressExecutor = new ScanQueryExecutor<UserAddress>(addressStorage.query()); addressExecutor = new FilteredQueryExecutor<UserAddress> (addressExecutor, Filter.filterFor(UserAddress.class, "state = ?")); StorableProperty<UserAddress> prop = StorableIntrospector .examine(UserAddress.class).getAllProperties().get("country"); List<OrderedProperty<UserAddress>> orderings = new ArrayList<OrderedProperty<UserAddress>>(); orderings.add(OrderedProperty.get(prop, Direction.ASCENDING)); addressExecutor = new ArraySortedQueryExecutor<UserAddress> (addressExecutor, null, orderings); return addressExecutor; }
| 1,112,306
|
public void testJoin() throws Exception { QueryExecutor<UserAddress> addressExecutor = addressExecutor(); QueryExecutor<UserInfo> userExecutor = new JoinedQueryExecutor<UserAddress, UserInfo> (mRepository, UserInfo.class, "address", addressExecutor); assertEquals("address.state = ?", userExecutor.getFilter().toString()); assertEquals("address.country", userExecutor.getOrdering().get(0).toString()); // Create some addresses Storage<UserAddress> addressStorage = mRepository.storageFor(UserAddress.class); UserAddress addr = addressStorage.prepare(); addr.setAddressID(1); addr.setLine1("4567, 123 Street"); addr.setCity("Springfield"); addr.setState("IL"); addr.setCountry("USA"); addr.insert(); addr = addressStorage.prepare(); addr.setAddressID(2); addr.setLine1("1111 Apt 1, 1st Ave"); addr.setCity("Somewhere"); addr.setState("AA"); addr.setCountry("USA"); addr.setNeighborAddressID(1); addr.insert(); addr = addressStorage.prepare(); addr.setAddressID(3); addr.setLine1("9999"); addr.setCity("Chicago"); addr.setState("IL"); addr.setCountry("USA"); addr.insert(); // Create some users Storage<UserInfo> userStorage = mRepository.storageFor(UserInfo.class); UserInfo user = userStorage.prepare(); user.setUserID(1); user.setStateID(1); user.setFirstName("Bob"); user.setLastName("Loblaw"); user.setAddressID(1); user.insert(); user = userStorage.prepare(); user.setUserID(2); user.setStateID(1); user.setFirstName("Deb"); user.setLastName("Loblaw"); user.setAddressID(1); user.insert(); user = userStorage.prepare(); user.setUserID(3); user.setStateID(1); user.setFirstName("No"); user.setLastName("Body"); user.setAddressID(2); user.insert(); // Now do a basic join, finding everyone in IL. FilterValues<UserInfo> values = Filter .filterFor(UserInfo.class, "address.state = ?").initialFilterValues().with("IL"); Cursor<UserInfo> cursor = userExecutor.fetch(values); assertTrue(cursor.hasNext()); assertEquals(1, cursor.next().getUserID()); assertEquals(2, cursor.next().getUserID()); assertFalse(cursor.hasNext()); cursor.close(); assertEquals(2L, userExecutor.count(values)); // Now do a multi join, finding everyone with an explicit neighbor in IL. userExecutor = new JoinedQueryExecutor<UserAddress, UserInfo> (mRepository, UserInfo.class, "address.neighbor", addressExecutor); assertEquals("address.neighbor.state = ?", userExecutor.getFilter().toString()); assertEquals("address.neighbor.country", userExecutor.getOrdering().get(0).toString()); values = Filter .filterFor(UserInfo.class, "address.neighbor.state = ?") .initialFilterValues().with("IL"); cursor = userExecutor.fetch(values); assertTrue(cursor.hasNext()); assertEquals(3, cursor.next().getUserID()); assertFalse(cursor.hasNext()); cursor.close(); assertEquals(1L, userExecutor.count(values)); }
|
public void testJoin() throws Exception { QueryExecutor<UserAddress> addressExecutor = addressExecutor(); QueryExecutor<UserInfo> userExecutor = new JoinedQueryExecutor<UserAddress, UserInfo> (mRepository, UserInfo.class, "address", addressExecutor); assertEquals("address.state = ?", userExecutor.getFilter().toString()); assertEquals("+address.country", userExecutor.getOrdering().get(0).toString()); // Create some addresses Storage<UserAddress> addressStorage = mRepository.storageFor(UserAddress.class); UserAddress addr = addressStorage.prepare(); addr.setAddressID(1); addr.setLine1("4567, 123 Street"); addr.setCity("Springfield"); addr.setState("IL"); addr.setCountry("USA"); addr.insert(); addr = addressStorage.prepare(); addr.setAddressID(2); addr.setLine1("1111 Apt 1, 1st Ave"); addr.setCity("Somewhere"); addr.setState("AA"); addr.setCountry("USA"); addr.setNeighborAddressID(1); addr.insert(); addr = addressStorage.prepare(); addr.setAddressID(3); addr.setLine1("9999"); addr.setCity("Chicago"); addr.setState("IL"); addr.setCountry("USA"); addr.insert(); // Create some users Storage<UserInfo> userStorage = mRepository.storageFor(UserInfo.class); UserInfo user = userStorage.prepare(); user.setUserID(1); user.setStateID(1); user.setFirstName("Bob"); user.setLastName("Loblaw"); user.setAddressID(1); user.insert(); user = userStorage.prepare(); user.setUserID(2); user.setStateID(1); user.setFirstName("Deb"); user.setLastName("Loblaw"); user.setAddressID(1); user.insert(); user = userStorage.prepare(); user.setUserID(3); user.setStateID(1); user.setFirstName("No"); user.setLastName("Body"); user.setAddressID(2); user.insert(); // Now do a basic join, finding everyone in IL. FilterValues<UserInfo> values = Filter .filterFor(UserInfo.class, "address.state = ?").initialFilterValues().with("IL"); Cursor<UserInfo> cursor = userExecutor.fetch(values); assertTrue(cursor.hasNext()); assertEquals(1, cursor.next().getUserID()); assertEquals(2, cursor.next().getUserID()); assertFalse(cursor.hasNext()); cursor.close(); assertEquals(2L, userExecutor.count(values)); // Now do a multi join, finding everyone with an explicit neighbor in IL. userExecutor = new JoinedQueryExecutor<UserAddress, UserInfo> (mRepository, UserInfo.class, "address.neighbor", addressExecutor); assertEquals("address.neighbor.state = ?", userExecutor.getFilter().toString()); assertEquals("address.neighbor.country", userExecutor.getOrdering().get(0).toString()); values = Filter .filterFor(UserInfo.class, "address.neighbor.state = ?") .initialFilterValues().with("IL"); cursor = userExecutor.fetch(values); assertTrue(cursor.hasNext()); assertEquals(3, cursor.next().getUserID()); assertFalse(cursor.hasNext()); cursor.close(); assertEquals(1L, userExecutor.count(values)); }
| 1,112,307
|
public void testJoin() throws Exception { QueryExecutor<UserAddress> addressExecutor = addressExecutor(); QueryExecutor<UserInfo> userExecutor = new JoinedQueryExecutor<UserAddress, UserInfo> (mRepository, UserInfo.class, "address", addressExecutor); assertEquals("address.state = ?", userExecutor.getFilter().toString()); assertEquals("address.country", userExecutor.getOrdering().get(0).toString()); // Create some addresses Storage<UserAddress> addressStorage = mRepository.storageFor(UserAddress.class); UserAddress addr = addressStorage.prepare(); addr.setAddressID(1); addr.setLine1("4567, 123 Street"); addr.setCity("Springfield"); addr.setState("IL"); addr.setCountry("USA"); addr.insert(); addr = addressStorage.prepare(); addr.setAddressID(2); addr.setLine1("1111 Apt 1, 1st Ave"); addr.setCity("Somewhere"); addr.setState("AA"); addr.setCountry("USA"); addr.setNeighborAddressID(1); addr.insert(); addr = addressStorage.prepare(); addr.setAddressID(3); addr.setLine1("9999"); addr.setCity("Chicago"); addr.setState("IL"); addr.setCountry("USA"); addr.insert(); // Create some users Storage<UserInfo> userStorage = mRepository.storageFor(UserInfo.class); UserInfo user = userStorage.prepare(); user.setUserID(1); user.setStateID(1); user.setFirstName("Bob"); user.setLastName("Loblaw"); user.setAddressID(1); user.insert(); user = userStorage.prepare(); user.setUserID(2); user.setStateID(1); user.setFirstName("Deb"); user.setLastName("Loblaw"); user.setAddressID(1); user.insert(); user = userStorage.prepare(); user.setUserID(3); user.setStateID(1); user.setFirstName("No"); user.setLastName("Body"); user.setAddressID(2); user.insert(); // Now do a basic join, finding everyone in IL. FilterValues<UserInfo> values = Filter .filterFor(UserInfo.class, "address.state = ?").initialFilterValues().with("IL"); Cursor<UserInfo> cursor = userExecutor.fetch(values); assertTrue(cursor.hasNext()); assertEquals(1, cursor.next().getUserID()); assertEquals(2, cursor.next().getUserID()); assertFalse(cursor.hasNext()); cursor.close(); assertEquals(2L, userExecutor.count(values)); // Now do a multi join, finding everyone with an explicit neighbor in IL. userExecutor = new JoinedQueryExecutor<UserAddress, UserInfo> (mRepository, UserInfo.class, "address.neighbor", addressExecutor); assertEquals("address.neighbor.state = ?", userExecutor.getFilter().toString()); assertEquals("address.neighbor.country", userExecutor.getOrdering().get(0).toString()); values = Filter .filterFor(UserInfo.class, "address.neighbor.state = ?") .initialFilterValues().with("IL"); cursor = userExecutor.fetch(values); assertTrue(cursor.hasNext()); assertEquals(3, cursor.next().getUserID()); assertFalse(cursor.hasNext()); cursor.close(); assertEquals(1L, userExecutor.count(values)); }
|
public void testJoin() throws Exception { QueryExecutor<UserAddress> addressExecutor = addressExecutor(); QueryExecutor<UserInfo> userExecutor = new JoinedQueryExecutor<UserAddress, UserInfo> (mRepository, UserInfo.class, "address", addressExecutor); assertEquals("address.state = ?", userExecutor.getFilter().toString()); assertEquals("address.country", userExecutor.getOrdering().get(0).toString()); // Create some addresses Storage<UserAddress> addressStorage = mRepository.storageFor(UserAddress.class); UserAddress addr = addressStorage.prepare(); addr.setAddressID(1); addr.setLine1("4567, 123 Street"); addr.setCity("Springfield"); addr.setState("IL"); addr.setCountry("USA"); addr.insert(); addr = addressStorage.prepare(); addr.setAddressID(2); addr.setLine1("1111 Apt 1, 1st Ave"); addr.setCity("Somewhere"); addr.setState("AA"); addr.setCountry("USA"); addr.setNeighborAddressID(1); addr.insert(); addr = addressStorage.prepare(); addr.setAddressID(3); addr.setLine1("9999"); addr.setCity("Chicago"); addr.setState("IL"); addr.setCountry("USA"); addr.insert(); // Create some users Storage<UserInfo> userStorage = mRepository.storageFor(UserInfo.class); UserInfo user = userStorage.prepare(); user.setUserID(1); user.setStateID(1); user.setFirstName("Bob"); user.setLastName("Loblaw"); user.setAddressID(1); user.insert(); user = userStorage.prepare(); user.setUserID(2); user.setStateID(1); user.setFirstName("Deb"); user.setLastName("Loblaw"); user.setAddressID(1); user.insert(); user = userStorage.prepare(); user.setUserID(3); user.setStateID(1); user.setFirstName("No"); user.setLastName("Body"); user.setAddressID(2); user.insert(); // Now do a basic join, finding everyone in IL. FilterValues<UserInfo> values = Filter .filterFor(UserInfo.class, "address.state = ?").initialFilterValues().with("IL"); Cursor<UserInfo> cursor = userExecutor.fetch(values); assertTrue(cursor.hasNext()); assertEquals(1, cursor.next().getUserID()); assertEquals(2, cursor.next().getUserID()); assertFalse(cursor.hasNext()); cursor.close(); assertEquals(2L, userExecutor.count(values)); // Now do a multi join, finding everyone with an explicit neighbor in IL. userExecutor = new JoinedQueryExecutor<UserAddress, UserInfo> (mRepository, UserInfo.class, "address.neighbor", addressExecutor); assertEquals("address.neighbor.state = ?", userExecutor.getFilter().toString()); assertEquals("+address.neighbor.country", userExecutor.getOrdering().get(0).toString()); values = Filter .filterFor(UserInfo.class, "address.neighbor.state = ?") .initialFilterValues().with("IL"); cursor = userExecutor.fetch(values); assertTrue(cursor.hasNext()); assertEquals(3, cursor.next().getUserID()); assertFalse(cursor.hasNext()); cursor.close(); assertEquals(1L, userExecutor.count(values)); }
| 1,112,308
|
public void run(Context context, XMLOutput output) throws Exception { if ( value != null ) { String text = value.evaluateAsString( context ); if ( text != null ) { output.write( text ); } } }
|
public void run(Context context, XMLOutput output) throws Exception { if ( value != null ) { String text = value.evaluateAsString( context ); if ( text != null ) { output.write( text ); } } }
| 1,112,309
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if(command.equals("Show CC counts")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_COUNTS); jtt.repaint(); } else if (command.equals("Show CC ratios")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_RATIOS); jtt.repaint(); } }
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if(command.equals("Show CC counts")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_HAP_COUNTS); jtt.repaint(); } else if (command.equals("Show CC ratios")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_RATIOS); jtt.repaint(); } }
| 1,112,310
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if(command.equals("Show CC counts")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_COUNTS); jtt.repaint(); } else if (command.equals("Show CC ratios")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_RATIOS); jtt.repaint(); } }
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if(command.equals("Show CC counts")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_COUNTS); jtt.repaint(); } else if (command.equals("Show CC frequencies")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_RATIOS); jtt.repaint(); } }
| 1,112,311
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if(command.equals("Show CC counts")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_COUNTS); jtt.repaint(); } else if (command.equals("Show CC ratios")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_RATIOS); jtt.repaint(); } }
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if(command.equals("Show CC counts")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_COUNTS); jtt.repaint(); } else if (command.equals("Show CC ratios")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_HAP_RATIOS); jtt.repaint(); } }
| 1,112,312
|
public void saveDprimeToText(String[][] dPrimeTable, File dumpDprimeFile, boolean info, Vector markerinfo) throws IOException{ FileWriter saveDprimeWriter = new FileWriter(dumpDprimeFile); if (info){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; for (int i = 0; i < dPrimeTable.length; i++){ for (int j = 0; j < dPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = ((SNP)markerinfo.elementAt(j)).getPosition() - ((SNP)markerinfo.elementAt(i)).getPosition(); saveDprimeWriter.write(i + "\t" + j + "\t" + dPrimeTable[i][j] + "\t" + dist + "\n"); } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); for (int i = 0; i < dPrimeTable.length; i++){ for (int j = 0; j < dPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ saveDprimeWriter.write(i + "\t" + j + "\t" + dPrimeTable[i][j] + "\n"); } } } } saveDprimeWriter.close(); }
|
public void saveDprimeToText(String[][] dPrimeTable, File dumpDprimeFile, boolean info, Vector markerinfo) throws IOException{ FileWriter saveDprimeWriter = new FileWriter(dumpDprimeFile); if (info){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; for (int i = 0; i < dPrimeTable.length; i++){ for (int j = 0; j < dPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = ((SNP)markerinfo.elementAt(j)).getPosition() - ((SNP)markerinfo.elementAt(i)).getPosition(); saveDprimeWriter.write((i+1) + "\t" + (j+1) + "\t" + dPrimeTable[i][j] + "\t" + dist + "\n"); } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); for (int i = 0; i < dPrimeTable.length; i++){ for (int j = 0; j < dPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ saveDprimeWriter.write(i + "\t" + j + "\t" + dPrimeTable[i][j] + "\n"); } } } } saveDprimeWriter.close(); }
| 1,112,313
|
public void saveDprimeToText(String[][] dPrimeTable, File dumpDprimeFile, boolean info, Vector markerinfo) throws IOException{ FileWriter saveDprimeWriter = new FileWriter(dumpDprimeFile); if (info){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; for (int i = 0; i < dPrimeTable.length; i++){ for (int j = 0; j < dPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = ((SNP)markerinfo.elementAt(j)).getPosition() - ((SNP)markerinfo.elementAt(i)).getPosition(); saveDprimeWriter.write(i + "\t" + j + "\t" + dPrimeTable[i][j] + "\t" + dist + "\n"); } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); for (int i = 0; i < dPrimeTable.length; i++){ for (int j = 0; j < dPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ saveDprimeWriter.write(i + "\t" + j + "\t" + dPrimeTable[i][j] + "\n"); } } } } saveDprimeWriter.close(); }
|
public void saveDprimeToText(String[][] dPrimeTable, File dumpDprimeFile, boolean info, Vector markerinfo) throws IOException{ FileWriter saveDprimeWriter = new FileWriter(dumpDprimeFile); if (info){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; for (int i = 0; i < dPrimeTable.length; i++){ for (int j = 0; j < dPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = ((SNP)markerinfo.elementAt(j)).getPosition() - ((SNP)markerinfo.elementAt(i)).getPosition(); saveDprimeWriter.write(i + "\t" + j + "\t" + dPrimeTable[i][j] + "\t" + dist + "\n"); } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); for (int i = 0; i < dPrimeTable.length; i++){ for (int j = 0; j < dPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ saveDprimeWriter.write((i+1) + "\t" + (j+1) + "\t" + dPrimeTable[i][j] + "\n"); } } } } saveDprimeWriter.close(); }
| 1,112,314
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals("Filter")){ doFilters(); }else if (command.equals("top filter")){ numResults = Integer.parseInt(topField.getText()); doTopFilter(); }else if (command.equals("Reset Filters")){ clearFilters(); }else if (command.equals("Load Additional Results")){ HaploView.fc.setSelectedFile(new File("")); int returned = HaploView.fc.showOpenDialog(this); if (returned != JFileChooser.APPROVE_OPTION) return; File file = HaploView.fc.getSelectedFile(); String fullName = file.getParent()+File.separator+file.getName(); String[] inputs = {null,null,fullName}; hv.readWGA(inputs); }else if (command.equals("Go to Selected Region")){ gotoRegion(); } }
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals("Filter")){ doFilters(); }else if (command.equals("top filter")){ numResults = Integer.parseInt(topField.getText()); doTopFilter(); }else if (command.equals("Reset Filters")){ clearFilters(); }else if (command.equals("Load Additional Results")){ HaploView.fc.setSelectedFile(new File("")); int returned = HaploView.fc.showOpenDialog(this); if (returned != JFileChooser.APPROVE_OPTION) return; File file = HaploView.fc.getSelectedFile(); String fullName = file.getParent()+File.separator+file.getName(); String[] inputs = {null,null,fullName,null}; hv.readWGA(inputs); }else if (command.equals("Go to Selected Region")){ gotoRegion(); } }
| 1,112,315
|
public void doTag(XMLOutput output) throws Exception { connection = MessengerManager.get( name ); if ( var != null ) { context.setVariable( var, connection ); } getBody().run(context, output); }
|
public void doTag(XMLOutput output) throws Exception { connection = MessengerManager.get( name ); if ( var != null ) { context.setVariable( var, connection ); } invokeBody(output); }
| 1,112,317
|
private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; String hapmapFileName = ""; String blockFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; boolean outputCheck=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } //todo: fix ignoremarkers /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha") || args[i].equals("-l")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equals("-a")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-a requires a filename"); System.exit(1); } else{ if(!hapmapFileName.equals("")){ System.out.println("multiple -a arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equals("-k")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; outputType = BLOX_CUSTOM; }else{ System.out.println("-k requires a filename"); System.exit(1); } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one output argument is allowed"); System.exit(1); } if(args[i].equals("SFS") || args[i].equals("GAB")){ outputType = BLOX_GABRIEL; } else if(args[i].equals("GAM")){ outputType = BLOX_4GAM; } else if(args[i].equals("MJD") || args[i].equals("SPI")){ outputType = BLOX_SPINE; } else if(args[i].equals("ALL")) { outputType = BLOX_ALL; } } else { //defaults to SFS output outputType = BLOX_GABRIEL; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = true; } else if (args[i].equals("-c")){ outputCheck = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("") || !hapmapFileName.equals("")) && !outputDprime && !outputCheck) { outputType = BLOX_GABRIEL; if(nogui && !quietMode) { System.out.println("No output type specified. Default of Gabriel will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_hapmapfile = hapmapFileName; arg_blockfile = blockFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; arg_check = outputCheck; }
|
private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; String hapmapFileName = ""; String blockFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; boolean outputCheck=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } //todo: fix ignoremarkers /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha") || args[i].equals("-l")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equals("-a")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-a requires a filename"); System.exit(1); } else{ if(!hapmapFileName.equals("")){ System.out.println("multiple -a arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equals("-k")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; outputType = BLOX_CUSTOM; }else{ System.out.println("-k requires a filename"); System.exit(1); } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one output argument is allowed"); System.exit(1); } if(args[i].equals("SFS") || args[i].equals("GAB")){ outputType = BLOX_GABRIEL; } else if(args[i].equals("GAM")){ outputType = BLOX_4GAM; } else if(args[i].equals("MJD") || args[i].equals("SPI")){ outputType = BLOX_SPINE; } else if(args[i].equals("ALL")) { outputType = BLOX_ALL; } } else { //defaults to SFS output outputType = BLOX_GABRIEL; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = true; } else if (args[i].equals("-c")){ outputCheck = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("") || !hapmapFileName.equals("")) && !outputDprime && !outputCheck && !outputPNG && !outputSmallPNG) { outputType = BLOX_GABRIEL; if(nogui && !quietMode) { System.out.println("No output type specified. Default of Gabriel will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_hapmapfile = hapmapFileName; arg_blockfile = blockFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; arg_check = outputCheck; }
| 1,112,319
|
private void processFile(String fileName,int fileType,String infoFileName){ System.out.println(TITLE_STRING); try { int outputType; long maxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; outputType = this.arg_output; textData = new HaploData(0); Vector result = null; if(fileType == 0){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == 1) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ result = textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile result = textData.linkageToChrom(inputFile,4,arg_skipCheck); } File infoFile; if(infoFileName.equals("")) { infoFile = null; }else{ infoFile = new File(infoFileName); } if (result != null){ textData.prepareMarkerInput(infoFile,maxDistance,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,maxDistance,null); } if(!arg_quiet && infoFile != null){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; if(this.arg_showCheck && result != null) { CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(null); } if(this.arg_check && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(new File (fileName + ".CHECK")); } Vector cust = new Vector(); if(outputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; switch(outputType){ case BLOX_GABRIEL: OutputFile = new File(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = new File(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = new File(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = new File(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(arg_blockfile); cust = textData.readBlocks(blocksFile); break; default: OutputFile = new File(fileName + ".GABRIELblocks"); break; } //this handles output type ALL int start = 0; int stop = Chromosome.getFilteredSize(); if(outputType == BLOX_ALL) { OutputFile = new File(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType, cust); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getFilteredSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getFilteredSize()); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } }
|
private void processFile(String fileName,int fileType,String infoFileName){ System.out.println(TITLE_STRING); try { int outputType; long maxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; outputType = this.arg_output; textData = new HaploData(0); Vector result = null; if(fileType == 0){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == 1) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ result = textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile result = textData.linkageToChrom(inputFile,4,arg_skipCheck); } File infoFile; if(infoFileName.equals("")) { infoFile = null; }else{ infoFile = new File(infoFileName); } if (result != null){ textData.prepareMarkerInput(infoFile,maxDistance,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,maxDistance,null); } if(!arg_quiet && infoFile != null){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; if(this.arg_showCheck && result != null) { CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(null); } if(this.arg_check && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(new File (fileName + ".CHECK")); } Vector cust = new Vector(); if(outputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; switch(outputType){ case BLOX_GABRIEL: OutputFile = new File(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = new File(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = new File(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = new File(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(arg_blockfile); cust = textData.readBlocks(blocksFile); break; default: OutputFile = new File(fileName + ".GABRIELblocks"); break; } //this handles output type ALL int start = 0; int stop = Chromosome.getFilteredSize(); if(outputType == BLOX_ALL) { OutputFile = new File(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType, cust); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getFilteredSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getFilteredSize()); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } }
| 1,112,321
|
private void processFile(String fileName,int fileType,String infoFileName){ System.out.println(TITLE_STRING); try { int outputType; long maxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; outputType = this.arg_output; textData = new HaploData(0); Vector result = null; if(fileType == 0){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == 1) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ result = textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile result = textData.linkageToChrom(inputFile,4,arg_skipCheck); } File infoFile; if(infoFileName.equals("")) { infoFile = null; }else{ infoFile = new File(infoFileName); } if (result != null){ textData.prepareMarkerInput(infoFile,maxDistance,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,maxDistance,null); } if(!arg_quiet && infoFile != null){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; if(this.arg_showCheck && result != null) { CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(null); } if(this.arg_check && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(new File (fileName + ".CHECK")); } Vector cust = new Vector(); if(outputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; switch(outputType){ case BLOX_GABRIEL: OutputFile = new File(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = new File(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = new File(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = new File(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(arg_blockfile); cust = textData.readBlocks(blocksFile); break; default: OutputFile = new File(fileName + ".GABRIELblocks"); break; } //this handles output type ALL int start = 0; int stop = Chromosome.getFilteredSize(); if(outputType == BLOX_ALL) { OutputFile = new File(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType, cust); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getFilteredSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getFilteredSize()); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } }
|
private void processFile(String fileName,int fileType,String infoFileName){ System.out.println(TITLE_STRING); try { int outputType; long maxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; outputType = this.arg_output; textData = new HaploData(0); Vector result = null; if(fileType == 0){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == 1) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ result = textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile result = textData.linkageToChrom(inputFile,4,arg_skipCheck); } File infoFile; if(infoFileName.equals("")) { infoFile = null; }else{ infoFile = new File(infoFileName); } if (result != null){ textData.prepareMarkerInput(infoFile,maxDistance,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,maxDistance,null); } if(!arg_quiet && infoFile != null){ System.out.println("Using marker file " + infoFile.getName()); } if(this.arg_showCheck && result != null) { CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(null); } if(this.arg_check && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(new File (fileName + ".CHECK")); } Vector cust = new Vector(); if(outputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; switch(outputType){ case BLOX_GABRIEL: OutputFile = new File(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = new File(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = new File(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = new File(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(arg_blockfile); cust = textData.readBlocks(blocksFile); break; default: OutputFile = new File(fileName + ".GABRIELblocks"); break; } //this handles output type ALL int start = 0; int stop = Chromosome.getFilteredSize(); if(outputType == BLOX_ALL) { OutputFile = new File(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType, cust); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getFilteredSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getFilteredSize()); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } }
| 1,112,322
|
public void paintComponent(Graphics graphics) { if (filteredHaplos == null){ super.paintComponent(graphics); return; } Graphics2D g = (Graphics2D) graphics; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //System.out.println(getSize()); Dimension size = getSize(); Dimension pref = getPreferredSize(); g.setColor(this.getBackground()); g.fillRect(0,0,pref.width, pref.height); if (!forExport){ g.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } //g.drawRect(0, 0, pref.width, pref.height); final BasicStroke thinStroke = new BasicStroke(0.5f); final BasicStroke thickStroke = new BasicStroke(2.0f); // width of one letter of the haplotype block //int letterWidth = haploMetrics.charWidth('G'); //int percentWidth = pctMetrics.stringWidth(".000"); //final int verticalOffset = 43; // room for tags and diamonds int left = BORDER; int top = BORDER; //verticalOffset; //int totalWidth = 0; // percentages for each haplotype NumberFormat nf = NumberFormat.getInstance(Locale.US); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); nf.setMinimumIntegerDigits(0); nf.setMaximumIntegerDigits(0); // multi reading, between the columns NumberFormat nfMulti = NumberFormat.getInstance(Locale.US); nfMulti.setMinimumFractionDigits(2); nfMulti.setMaximumFractionDigits(2); nfMulti.setMinimumIntegerDigits(0); nfMulti.setMaximumIntegerDigits(0); int[][] lookupPos = new int[filteredHaplos.length][]; for (int p = 0; p < lookupPos.length; p++) { lookupPos[p] = new int[filteredHaplos[p].length]; for (int q = 0; q < lookupPos[p].length; q++){ lookupPos[p][filteredHaplos[p][q].getListOrder()] = q; } } // set number formatter to pad with appropriate number of zeroes NumberFormat nfMarker = NumberFormat.getInstance(Locale.US); int markerCount = Chromosome.getSize(); // the +0.0000001 is because there is // some suckage where log(1000) / log(10) isn't actually 3 int markerDigits = (int) (0.0000001 + Math.log(markerCount) / Math.log(10)) + 1; nfMarker.setMinimumIntegerDigits(markerDigits); nfMarker.setMaximumIntegerDigits(markerDigits); //int tagShapeX[] = new int[3]; //int tagShapeY[] = new int[3]; //Polygon tagShape; int textRight = 0; // gets updated for scooting over // i = 0 to number of columns - 1 for (int i = 0; i < filteredHaplos.length; i++) { int[] markerNums = filteredHaplos[i][0].getMarkers(); boolean[] tags = filteredHaplos[i][0].getTags(); //int headerX = x; for (int z = 0; z < markerNums.length; z++) { //int tagMiddle = tagMetrics.getAscent() / 2; //int tagLeft = x + z*letterWidth + tagMiddle; //g.translate(tagLeft, 20); // if tag snp, draw little triangle pooper if (tags[z]) { g.drawImage(tagImage, left + z*CHAR_WIDTH, top + markerDigits*MARKER_CHAR_WIDTH + -(CHAR_HEIGHT - TAG_SPAN), null); } //g.rotate(-Math.PI / 2.0); //g.drawLine(0, 0, 0, 0); //g.setColor(Color.black); //g.drawString(nfMarker.format(markerNums[z]), 0, tagMiddle); char markerChars[] = nfMarker.format(Chromosome.realIndex[markerNums[z]]+1).toCharArray(); for (int m = 0; m < markerDigits; m++) { g.drawImage(markerNumImages[markerChars[m] - '0'], left + z*CHAR_WIDTH + (1 + CHAR_WIDTH - MARKER_CHAR_HEIGHT)/2, top + (markerDigits-m-1)*MARKER_CHAR_WIDTH, null); } // undo the transform.. no push/pop.. arrgh //g.rotate(Math.PI / 2.0); //g.translate(-tagLeft, -20); } // y position of the first image for the haplotype letter // top + the size of the marker digits + the size of the tag + // the character height centered in the row's height int above = top + markerDigits*MARKER_CHAR_WIDTH + TAG_SPAN + (ROW_HEIGHT - CHAR_HEIGHT) / 2; //figure out which allele is the major allele double[][] alleleCounts = new double[filteredHaplos[i][0].getGeno().length][9]; //zero this out for (int j = 0; j < alleleCounts.length; j++){ for (int k = 0; k < alleleCounts[j].length; k++){ alleleCounts[j][k] = 0; } } for (int j = 0; j < filteredHaplos[i].length; j++){ int curHapNum = lookupPos[i][j]; int[] theGeno = filteredHaplos[i][curHapNum].getGeno(); double theFreq = filteredHaplos[i][curHapNum].getPercentage(); for (int k = 0; k < theGeno.length; k++){ alleleCounts[k][theGeno[k]] += theFreq; } } int[] majorAllele = new int[filteredHaplos[i][0].getGeno().length]; for (int k = 0; k < majorAllele.length; k++){ double maj = 0; for (int z = 0; z < alleleCounts[k].length; z++){ if (alleleCounts[k][z] > maj){ majorAllele[k] = z; maj = alleleCounts[k][z]; } } } for (int j = 0; j < filteredHaplos[i].length; j++){ int curHapNum = lookupPos[i][j]; //String theHap = new String(); //String thePercentage = new String(); int[] theGeno = filteredHaplos[i][curHapNum].getGeno(); //getGeno(); // j is the row of haplotype for (int k = 0; k < theGeno.length; k++) { // theGeno[k] will be 1,2,3,4 (acgt) or 8 (for bad) if (alleleDisp == 0){ g.drawImage(charImages[theGeno[k] - 1], left + k*CHAR_WIDTH, above + j*ROW_HEIGHT, null); }else if (alleleDisp == 1){ g.drawImage(blackNumImages[theGeno[k]], left + k*CHAR_WIDTH, above + j*ROW_HEIGHT, null); }else{ if (theGeno[k] == majorAllele[k]){ g.setColor(dullRed); }else{ g.setColor(dullBlue); } g.fillRect(left + k*CHAR_WIDTH, above + j*ROW_HEIGHT + (ROW_HEIGHT - CHAR_WIDTH)/2, CHAR_WIDTH, CHAR_WIDTH); } } //draw the percentage value in non mono font double percent = filteredHaplos[i][curHapNum].getPercentage(); //thePercentage = " " + nf.format(percent); char percentChars[] = nf.format(percent).toCharArray(); // perhaps need an exceptional case for 1.0 being the percent for (int m = 0; m < percentChars.length; m++) { g.drawImage(grayNumImages[(m == 0) ? 10 : percentChars[m]-'0'], left + theGeno.length*CHAR_WIDTH + m*CHAR_WIDTH, above + j*ROW_HEIGHT, null); } // 4 is the number of chars in .999 for the percent textRight = left + theGeno.length*CHAR_WIDTH + 4*CHAR_WIDTH; g.setColor(Color.black); if (i < filteredHaplos.length - 1) { //draw crossovers for (int crossCount = 0; crossCount < filteredHaplos[i+1].length; crossCount++) { double crossVal = filteredHaplos[i][curHapNum].getCrossover(crossCount); //draw thin and thick lines int crossValue = (int) (crossVal*100); if (crossValue > thinThresh) { g.setStroke(crossValue > thickThresh ? thickStroke : thinStroke); int connectTo = filteredHaplos[i+1][crossCount].getListOrder(); g.drawLine(textRight + LINE_LEFT, above + j*ROW_HEIGHT + ROW_HEIGHT/2, textRight + LINE_RIGHT, above + connectTo*ROW_HEIGHT + ROW_HEIGHT/2); } } } } left = textRight; // add the multilocus d prime if appropriate if (i < filteredHaplos.length - 1) { //put the numbers in the right place vertically int depth; if (filteredHaplos[i].length > filteredHaplos[i+1].length){ depth = filteredHaplos[i].length; }else{ depth = filteredHaplos[i+1].length; } char multiChars[] = nfMulti.format(multidprimeArray[i]).toCharArray(); if (multidprimeArray[i] > 0.99){ //draw 1.0 vals specially g.drawImage(blackNumImages[1], left + (LINE_SPAN - 7*CHAR_WIDTH/2)/2 + CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); g.drawImage(blackNumImages[10], left + (LINE_SPAN - 9*CHAR_WIDTH/2)/2 + 2*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); g.drawImage(blackNumImages[0], left + (LINE_SPAN - 9*CHAR_WIDTH/2)/2 + 3*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); }else{ for (int m = 0; m < 3; m++) { g.drawImage(blackNumImages[(m == 0) ? 10 : multiChars[m]-'0'], left + (LINE_SPAN - 7*CHAR_WIDTH/2)/2 + m*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); } } } left += LINE_SPAN; } }
|
public void paintComponent(Graphics graphics) { if (filteredHaplos == null){ super.paintComponent(graphics); return; } Graphics2D g = (Graphics2D) graphics; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //System.out.println(getSize()); Dimension size = getSize(); Dimension pref = getPreferredSize(); g.setColor(this.getBackground()); g.fillRect(0,0,pref.width, pref.height); if (!forExport){ g.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } //g.drawRect(0, 0, pref.width, pref.height); final BasicStroke thinStroke = new BasicStroke(0.5f); final BasicStroke thickStroke = new BasicStroke(2.0f); // width of one letter of the haplotype block //int letterWidth = haploMetrics.charWidth('G'); //int percentWidth = pctMetrics.stringWidth(".000"); //final int verticalOffset = 43; // room for tags and diamonds int left = BORDER; int top = BORDER; //verticalOffset; //int totalWidth = 0; // percentages for each haplotype NumberFormat nf = NumberFormat.getInstance(Locale.US); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); nf.setMinimumIntegerDigits(0); nf.setMaximumIntegerDigits(0); // multi reading, between the columns NumberFormat nfMulti = NumberFormat.getInstance(Locale.US); nfMulti.setMinimumFractionDigits(2); nfMulti.setMaximumFractionDigits(2); nfMulti.setMinimumIntegerDigits(0); nfMulti.setMaximumIntegerDigits(0); int[][] lookupPos = new int[filteredHaplos.length][]; for (int p = 0; p < lookupPos.length; p++) { lookupPos[p] = new int[filteredHaplos[p].length]; for (int q = 0; q < lookupPos[p].length; q++){ lookupPos[p][filteredHaplos[p][q].getListOrder()] = q; } } // set number formatter to pad with appropriate number of zeroes NumberFormat nfMarker = NumberFormat.getInstance(Locale.US); int markerCount = Chromosome.getSize(); // the +0.0000001 is because there is // some suckage where log(1000) / log(10) isn't actually 3 int markerDigits = (int) (0.0000001 + Math.log(markerCount) / Math.log(10)) + 1; nfMarker.setMinimumIntegerDigits(markerDigits); nfMarker.setMaximumIntegerDigits(markerDigits); //int tagShapeX[] = new int[3]; //int tagShapeY[] = new int[3]; //Polygon tagShape; int textRight = 0; // gets updated for scooting over // i = 0 to number of columns - 1 for (int i = 0; i < filteredHaplos.length; i++) { int[] markerNums = filteredHaplos[i][0].getMarkers(); boolean[] tags = filteredHaplos[i][0].getTags(); //int headerX = x; for (int z = 0; z < markerNums.length; z++) { //int tagMiddle = tagMetrics.getAscent() / 2; //int tagLeft = x + z*letterWidth + tagMiddle; //g.translate(tagLeft, 20); // if tag snp, draw little triangle pooper if (tags[z]) { g.drawImage(tagImage, left + z*CHAR_WIDTH, top + markerDigits*MARKER_CHAR_WIDTH + -(CHAR_HEIGHT - TAG_SPAN), null); } //g.rotate(-Math.PI / 2.0); //g.drawLine(0, 0, 0, 0); //g.setColor(Color.black); //g.drawString(nfMarker.format(markerNums[z]), 0, tagMiddle); char markerChars[] = nfMarker.format(Chromosome.realIndex[markerNums[z]]+1).toCharArray(); for (int m = 0; m < markerDigits; m++) { g.drawImage(markerNumImages[markerChars[m] - '0'], left + z*CHAR_WIDTH + (1 + CHAR_WIDTH - MARKER_CHAR_HEIGHT)/2, top + (markerDigits-m-1)*MARKER_CHAR_WIDTH, null); } // undo the transform.. no push/pop.. arrgh //g.rotate(Math.PI / 2.0); //g.translate(-tagLeft, -20); } // y position of the first image for the haplotype letter // top + the size of the marker digits + the size of the tag + // the character height centered in the row's height int above = top + markerDigits*MARKER_CHAR_WIDTH + TAG_SPAN + (ROW_HEIGHT - CHAR_HEIGHT) / 2; //figure out which allele is the major allele double[][] alleleCounts = new double[filteredHaplos[i][0].getGeno().length][9]; //zero this out for (int j = 0; j < alleleCounts.length; j++){ for (int k = 0; k < alleleCounts[j].length; k++){ alleleCounts[j][k] = 0; } } for (int j = 0; j < filteredHaplos[i].length; j++){ int curHapNum = lookupPos[i][j]; int[] theGeno = filteredHaplos[i][curHapNum].getGeno(); double theFreq = filteredHaplos[i][curHapNum].getPercentage(); for (int k = 0; k < theGeno.length; k++){ alleleCounts[k][theGeno[k]] += theFreq; } } int[] majorAllele = new int[filteredHaplos[i][0].getGeno().length]; for (int k = 0; k < majorAllele.length; k++){ double maj = 0; for (int z = 0; z < alleleCounts[k].length; z++){ if (alleleCounts[k][z] > maj){ majorAllele[k] = z; maj = alleleCounts[k][z]; } } } for (int j = 0; j < filteredHaplos[i].length; j++){ int curHapNum = lookupPos[i][j]; //String theHap = new String(); //String thePercentage = new String(); int[] theGeno = filteredHaplos[i][curHapNum].getGeno(); //getGeno(); // j is the row of haplotype for (int k = 0; k < theGeno.length; k++) { // theGeno[k] will be 1,2,3,4 (acgt) or 8 (for bad) if (alleleDisp == 0){ g.drawImage(charImages[theGeno[k] - 1], left + k*CHAR_WIDTH, above + j*ROW_HEIGHT, null); }else if (alleleDisp == 1){ g.drawImage(blackNumImages[theGeno[k]], left + k*CHAR_WIDTH, above + j*ROW_HEIGHT, null); }else{ if (theGeno[k] == majorAllele[k]){ g.setColor(dullRed); }else{ g.setColor(dullBlue); } g.fillRect(left + k*CHAR_WIDTH, above + j*ROW_HEIGHT + (ROW_HEIGHT - CHAR_WIDTH)/2, CHAR_WIDTH, CHAR_WIDTH); } } //draw the percentage value in non mono font double percent = filteredHaplos[i][curHapNum].getPercentage(); //thePercentage = " " + nf.format(percent); char percentChars[] = nf.format(percent).toCharArray(); // perhaps need an exceptional case for 1.0 being the percent for (int m = 0; m < percentChars.length; m++) { g.drawImage(grayNumImages[(m == 0) ? 10 : percentChars[m]-'0'], left + theGeno.length*CHAR_WIDTH + m*CHAR_WIDTH, above + j*ROW_HEIGHT, null); } // 4 is the number of chars in .999 for the percent textRight = left + theGeno.length*CHAR_WIDTH + 4*CHAR_WIDTH; g.setColor(Color.black); if (i < filteredHaplos.length - 1) { //draw crossovers for (int crossCount = 0; crossCount < filteredHaplos[i+1].length; crossCount++) { double crossVal = filteredHaplos[i][curHapNum].getCrossover(crossCount); //draw thin and thick lines int crossValue = (int) (crossVal*100); if (crossValue > thinThresh) { g.setStroke(crossValue > thickThresh ? thickStroke : thinStroke); int connectTo = filteredHaplos[i+1][crossCount].getListOrder(); g.drawLine(textRight + LINE_LEFT, above + j*ROW_HEIGHT + ROW_HEIGHT/2, textRight + LINE_RIGHT, above + connectTo*ROW_HEIGHT + ROW_HEIGHT/2); } } } } left = textRight; // add the multilocus d prime if appropriate if (i < filteredHaplos.length - 1) { //put the numbers in the right place vertically int depth; if (filteredHaplos[i].length > filteredHaplos[i+1].length){ depth = filteredHaplos[i].length; }else{ depth = filteredHaplos[i+1].length; } char multiChars[] = nfMulti.format(multidprimeArray[i]).toCharArray(); if (multidprimeArray[i] > 0.99){ //draw 1.0 vals specially g.drawImage(blackNumImages[1], left + (LINE_SPAN - 7*CHAR_WIDTH/2)/2 + CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); g.drawImage(blackNumImages[10], left + (LINE_SPAN - 9*CHAR_WIDTH/2)/2 + 2*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); g.drawImage(blackNumImages[0], left + (LINE_SPAN - 9*CHAR_WIDTH/2)/2 + 3*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); }else{ for (int m = 0; m < 3; m++) { g.drawImage(blackNumImages[(m == 0) ? 10 : multiChars[m]-'0'], left + (LINE_SPAN - 7*CHAR_WIDTH/2)/2 + m*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); } } } left += LINE_SPAN; } }
| 1,112,324
|
public void run(Context context, XMLOutput output) throws Exception { if ( trim && ! hasTrimmed ) { trimBody(); hasTrimmed = true; } if ( log.isDebugEnabled() ) { log.debug( "Running body: " + getBody() ); } getBody().run( context, output ); }
|
public void run(JellyContext context, XMLOutput output) throws Exception { if ( trim && ! hasTrimmed ) { trimBody(); hasTrimmed = true; } if ( log.isDebugEnabled() ) { log.debug( "Running body: " + getBody() ); } getBody().run( context, output ); }
| 1,112,325
|
public static boolean initODMG( String user, String passwd, String dbName ) { getODMGImplementation(); db = odmg.newDatabase(); boolean success = false; try { log.debug( "Opening database" ); db.open( dbName + "#" + user + "#" + passwd, Database.OPEN_READ_WRITE ); log.debug( "Success!!!" ); } catch ( Exception e ) { log.error( "Failed to get connection" ); } // Test the connection by fetching something try { PhotoFolder folder = PhotoFolder.getRoot(); if ( folder != null ) { success = true; } else { log.error( "Could not open database connection" ); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } } } catch ( Throwable t ) { log.error( "Could not open database connection" ); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } } return ( success ); }
|
public static boolean initODMG( String user, String passwd, String dbName ) { getODMGImplementation(); db = odmg.newDatabase(); boolean success = false; log.error( t.getMessage() ); t.printStackTrace(); try { log.debug( "Opening database" ); db.open( dbName + "#" + user + "#" + passwd, Database.OPEN_READ_WRITE ); log.debug( "Success!!!" ); } catch ( Exception e ) { log.error( "Failed to get connection" ); } // Test the connection by fetching something log.error( t.getMessage() ); t.printStackTrace(); try { PhotoFolder folder = PhotoFolder.getRoot(); if ( folder != null ) { success = true; } else { log.error( "Could not open database connection" ); log.error( t.getMessage() ); t.printStackTrace(); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } } } catch ( Throwable t ) { log.error( "Could not open database connection" ); log.error( t.getMessage() ); t.printStackTrace(); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } } return ( success ); }
| 1,112,326
|
public Vector linkageToChrom(File infile, int type) throws IllegalArgumentException, HaploViewException, PedFileException, IOException{ //okay, for now we're going to assume the ped file has no header Vector pedFileStrings = new Vector(); BufferedReader reader = new BufferedReader(new FileReader(infile)); String line; while((line = reader.readLine())!=null){ if (line.length() == 0){ //skip blank lines continue; } if (line.startsWith("#")){ //skip comments continue; } pedFileStrings.add(line); } pedFile = new PedFile(); if (type == PED){ pedFile.parseLinkage(pedFileStrings); }else{ pedFile.parseHapMap(pedFileStrings); } Vector result = pedFile.check(); Vector indList = pedFile.getOrder(); int numMarkers = 0; numSingletons = 0; numTrios = 0; numPeds = pedFile.getNumFamilies(); Individual currentInd; Family currentFamily; Vector usedParents = new Vector(); Vector chrom = new Vector(); Vector chromTrios = new Vector(); for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.elementAt(x); currentFamily = pedFile.getFamily(currentInd.getFamilyID()); byte[] zeroArray = {0,0}; if(!currentInd.hasEitherParent()){ if (!currentInd.hasKids()){ //ind has no parents or kids -- he's a singleton numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (currentInd.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = currentInd.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1, currentInd.getAffectedStatus())); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2,currentInd.getAffectedStatus())); numSingletons++; } }else if (currentInd.hasBothParents()){ //if indiv has both parents Individual mom = currentFamily.getMember(currentInd.getMomID()); Individual dad = currentFamily.getMember(currentInd.getDadID()); //but doesn't have grandparents (i.e. is the kid in a founding trio) //and his parents haven't already been counted if (!(mom.hasBothParents() || dad.hasBothParents()) && !(usedParents.contains(mom) || usedParents.contains(dad))){ //we note that we've used these founders so we won't re use them if more of their kids //are in the file usedParents.add(mom); usedParents.add(dad); numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (currentInd.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = currentInd.getMarker(i); } byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; if (currentFamily.getMember(currentInd.getMomID()).getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); } byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; if (currentFamily.getMember(currentInd.getDadID()).getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); } byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { //kid missing if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else if (dad1 != 0 && dad2 != 0) { dadTb[i] = 0; dadUb[i] = 0; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else if (mom1 != 0 && mom2 != 0){ momTb[i] = 0; momUb[i] = 0; } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadTb[i] = 0; dadUb[i] = 0; momTb[i] = (byte)(4+mom1); momUb[i] = (byte)(4+mom2); } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadTb[i] = (byte)(4+dad1); dadUb[i] = (byte)(4+dad2); momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { //everybody het dadTb[i] = (byte)(4+dad1); dadUb[i] = (byte)(4+dad2); momTb[i] = (byte)(4+mom1); momUb[i] = (byte)(4+mom2); } } } chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadTb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadUb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momTb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momUb, currentInd.getAffectedStatus())); numTrios++; }else if (mom.hasBothParents() && !dad.hasBothParents() && !usedParents.contains(dad)){ //in this case dad is a founder so we toss him in as a singleton. //this only happens in the bizarre case where we have grandparents on one side //of a family but not the other usedParents.add(dad); numMarkers = dad.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (dad.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = dad.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(dad.getFamilyID(),dad.getIndividualID(),chrom1,dad.getAffectedStatus())); chrom.add(new Chromosome(dad.getFamilyID(),dad.getIndividualID(),chrom2,dad.getAffectedStatus())); numSingletons++; }else if (dad.hasBothParents() && !mom.hasBothParents() && !usedParents.contains(mom)){ //in this case mom is a founder so we toss here in as a singleton //rarely occurs, see above usedParents.add(mom); numMarkers = mom.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (mom.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = mom.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(mom.getFamilyID(),mom.getIndividualID(),chrom1,mom.getAffectedStatus())); chrom.add(new Chromosome(mom.getFamilyID(),mom.getIndividualID(),chrom2,mom.getAffectedStatus())); numSingletons++; } } } chromTrios.addAll(chrom); chromosomes = chromTrios; //wipe clean any existing marker info so we know we're starting with a new file Chromosome.markers = null; return result; }
|
public Vector linkageToChrom(File infile, int type) throws IllegalArgumentException, HaploViewException, PedFileException, IOException{ //okay, for now we're going to assume the ped file has no header Vector pedFileStrings = new Vector(); BufferedReader reader = new BufferedReader(new FileReader(infile)); String line; while((line = reader.readLine())!=null){ if (line.length() == 0){ //skip blank lines continue; } if (line.startsWith("#")){ //skip comments continue; } pedFileStrings.add(line); } pedFile = new PedFile(); if (type == PED){ pedFile.parseLinkage(pedFileStrings); }else{ pedFile.parseHapMap(pedFileStrings); } Vector result = pedFile.check(); Vector indList = pedFile.getOrder(); int numMarkers = 0; numSingletons = 0; numTrios = 0; numPeds = pedFile.getNumFamilies(); Individual currentInd; Family currentFamily; Vector usedParents = new Vector(); Vector chrom = new Vector(); Vector chromTrios = new Vector(); for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.elementAt(x); currentFamily = pedFile.getFamily(currentInd.getFamilyID()); byte[] zeroArray = {0,0}; if(!currentInd.hasEitherParent()){ if (!currentInd.hasKids()){ //ind has no parents or kids -- he's a singleton numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (currentInd.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = currentInd.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1, currentInd.getAffectedStatus())); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2,currentInd.getAffectedStatus())); numSingletons++; } }else if (currentInd.hasBothParents()){ //if indiv has both parents Individual mom = currentFamily.getMember(currentInd.getMomID()); Individual dad = currentFamily.getMember(currentInd.getDadID()); //but doesn't have grandparents (i.e. is the kid in a founding trio) //and his parents haven't already been counted if (!(mom.hasBothParents() || dad.hasBothParents()) && !(usedParents.contains(mom) || usedParents.contains(dad))){ //we note that we've used these founders so we won't re use them if more of their kids //are in the file usedParents.add(mom); usedParents.add(dad); numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (currentInd.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = currentInd.getMarker(i); } byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; if (currentFamily.getMember(currentInd.getMomID()).getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); } byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; if (currentFamily.getMember(currentInd.getDadID()).getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); } byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { //kid missing if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else if (dad1 != 0 && dad2 != 0) { dadTb[i] = 0; dadUb[i] = 0; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else if (mom1 != 0 && mom2 != 0){ momTb[i] = 0; momUb[i] = 0; } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadTb[i] = 0; dadUb[i] = 0; momTb[i] = (byte)(4+mom1); momUb[i] = (byte)(4+mom2); } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadTb[i] = (byte)(4+dad1); dadUb[i] = (byte)(4+dad2); momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { //everybody het dadTb[i] = (byte)(4+dad1); dadUb[i] = (byte)(4+dad2); momTb[i] = (byte)(4+mom1); momUb[i] = (byte)(4+mom2); } } } chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadTb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadUb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momTb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momUb, currentInd.getAffectedStatus())); numTrios++; }else if (mom.hasBothParents() && !dad.hasBothParents() && !usedParents.contains(dad)){ //in this case dad is a founder so we toss him in as a singleton. //this only happens in the bizarre case where we have grandparents on one side //of a family but not the other usedParents.add(dad); numMarkers = dad.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (dad.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = dad.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(dad.getFamilyID(),dad.getIndividualID(),chrom1,dad.getAffectedStatus())); chrom.add(new Chromosome(dad.getFamilyID(),dad.getIndividualID(),chrom2,dad.getAffectedStatus())); numSingletons++; }else if (dad.hasBothParents() && !mom.hasBothParents() && !usedParents.contains(mom)){ //in this case mom is a founder so we toss here in as a singleton //rarely occurs, see above usedParents.add(mom); numMarkers = mom.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (mom.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = mom.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(mom.getFamilyID(),mom.getIndividualID(),chrom1,mom.getAffectedStatus())); chrom.add(new Chromosome(mom.getFamilyID(),mom.getIndividualID(),chrom2,mom.getAffectedStatus())); numSingletons++; } } } chromTrios.addAll(chrom); chromosomes = chromTrios; //wipe clean any existing marker info so we know we're starting with a new file Chromosome.markers = null; return result; }
| 1,112,328
|
public Vector linkageToChrom(File infile, int type) throws IllegalArgumentException, HaploViewException, PedFileException, IOException{ //okay, for now we're going to assume the ped file has no header Vector pedFileStrings = new Vector(); BufferedReader reader = new BufferedReader(new FileReader(infile)); String line; while((line = reader.readLine())!=null){ if (line.length() == 0){ //skip blank lines continue; } if (line.startsWith("#")){ //skip comments continue; } pedFileStrings.add(line); } pedFile = new PedFile(); if (type == PED){ pedFile.parseLinkage(pedFileStrings); }else{ pedFile.parseHapMap(pedFileStrings); } Vector result = pedFile.check(); Vector indList = pedFile.getOrder(); int numMarkers = 0; numSingletons = 0; numTrios = 0; numPeds = pedFile.getNumFamilies(); Individual currentInd; Family currentFamily; Vector usedParents = new Vector(); Vector chrom = new Vector(); Vector chromTrios = new Vector(); for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.elementAt(x); currentFamily = pedFile.getFamily(currentInd.getFamilyID()); byte[] zeroArray = {0,0}; if(!currentInd.hasEitherParent()){ if (!currentInd.hasKids()){ //ind has no parents or kids -- he's a singleton numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (currentInd.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = currentInd.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1, currentInd.getAffectedStatus())); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2,currentInd.getAffectedStatus())); numSingletons++; } }else if (currentInd.hasBothParents()){ //if indiv has both parents Individual mom = currentFamily.getMember(currentInd.getMomID()); Individual dad = currentFamily.getMember(currentInd.getDadID()); //but doesn't have grandparents (i.e. is the kid in a founding trio) //and his parents haven't already been counted if (!(mom.hasBothParents() || dad.hasBothParents()) && !(usedParents.contains(mom) || usedParents.contains(dad))){ //we note that we've used these founders so we won't re use them if more of their kids //are in the file usedParents.add(mom); usedParents.add(dad); numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (currentInd.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = currentInd.getMarker(i); } byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; if (currentFamily.getMember(currentInd.getMomID()).getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); } byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; if (currentFamily.getMember(currentInd.getDadID()).getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); } byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { //kid missing if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else if (dad1 != 0 && dad2 != 0) { dadTb[i] = 0; dadUb[i] = 0; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else if (mom1 != 0 && mom2 != 0){ momTb[i] = 0; momUb[i] = 0; } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadTb[i] = 0; dadUb[i] = 0; momTb[i] = (byte)(4+mom1); momUb[i] = (byte)(4+mom2); } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadTb[i] = (byte)(4+dad1); dadUb[i] = (byte)(4+dad2); momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { //everybody het dadTb[i] = (byte)(4+dad1); dadUb[i] = (byte)(4+dad2); momTb[i] = (byte)(4+mom1); momUb[i] = (byte)(4+mom2); } } } chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadTb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadUb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momTb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momUb, currentInd.getAffectedStatus())); numTrios++; }else if (mom.hasBothParents() && !dad.hasBothParents() && !usedParents.contains(dad)){ //in this case dad is a founder so we toss him in as a singleton. //this only happens in the bizarre case where we have grandparents on one side //of a family but not the other usedParents.add(dad); numMarkers = dad.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (dad.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = dad.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(dad.getFamilyID(),dad.getIndividualID(),chrom1,dad.getAffectedStatus())); chrom.add(new Chromosome(dad.getFamilyID(),dad.getIndividualID(),chrom2,dad.getAffectedStatus())); numSingletons++; }else if (dad.hasBothParents() && !mom.hasBothParents() && !usedParents.contains(mom)){ //in this case mom is a founder so we toss here in as a singleton //rarely occurs, see above usedParents.add(mom); numMarkers = mom.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (mom.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = mom.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(mom.getFamilyID(),mom.getIndividualID(),chrom1,mom.getAffectedStatus())); chrom.add(new Chromosome(mom.getFamilyID(),mom.getIndividualID(),chrom2,mom.getAffectedStatus())); numSingletons++; } } } chromTrios.addAll(chrom); chromosomes = chromTrios; //wipe clean any existing marker info so we know we're starting with a new file Chromosome.markers = null; return result; }
|
public Vector linkageToChrom(File infile, int type) throws IllegalArgumentException, HaploViewException, PedFileException, IOException{ //okay, for now we're going to assume the ped file has no header Vector pedFileStrings = new Vector(); BufferedReader reader = new BufferedReader(new FileReader(infile)); String line; while((line = reader.readLine())!=null){ if (line.length() == 0){ //skip blank lines continue; } if (line.startsWith("#")){ //skip comments continue; } pedFileStrings.add(line); } pedFile = new PedFile(); if (type == PED){ pedFile.parseLinkage(pedFileStrings); }else{ pedFile.parseHapMap(pedFileStrings); } Vector result = pedFile.check(); Vector indList = pedFile.getOrder(); int numMarkers = 0; numSingletons = 0; numTrios = 0; numPeds = pedFile.getNumFamilies(); Individual currentInd; Family currentFamily; Vector usedParents = new Vector(); Vector chrom = new Vector(); Vector chromTrios = new Vector(); for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.elementAt(x); currentFamily = pedFile.getFamily(currentInd.getFamilyID()); byte[] zeroArray = {0,0}; if(!currentInd.hasEitherParent()){ if (!currentInd.hasKids()){ //ind has no parents or kids -- he's a singleton numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (currentInd.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = currentInd.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1, currentInd.getAffectedStatus())); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2,currentInd.getAffectedStatus())); numSingletons++; } }else if (currentInd.hasBothParents()){ //if indiv has both parents Individual mom = currentFamily.getMember(currentInd.getMomID()); Individual dad = currentFamily.getMember(currentInd.getDadID()); //but doesn't have grandparents (i.e. is the kid in a founding trio) //and his parents haven't already been counted if (!(mom.hasBothParents() || dad.hasBothParents()) && !(usedParents.contains(mom) || usedParents.contains(dad))){ //we note that we've used these founders so we won't re use them if more of their kids //are in the file usedParents.add(mom); usedParents.add(dad); numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (currentInd.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = currentInd.getMarker(i); } byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; if (currentFamily.getMember(currentInd.getMomID()).getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); } byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; if (currentFamily.getMember(currentInd.getDadID()).getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); } byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { //kid missing if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else if (dad1 != 0 && dad2 != 0) { dadTb[i] = 0; dadUb[i] = 0; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else if (mom1 != 0 && mom2 != 0){ momTb[i] = 0; momUb[i] = 0; } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadTb[i] = 0; dadUb[i] = 0; momTb[i] = (byte)(4+mom1); momUb[i] = (byte)(4+mom2); } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadTb[i] = (byte)(4+dad1); dadUb[i] = (byte)(4+dad2); momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { //everybody het dadTb[i] = (byte)(4+dad1); dadUb[i] = (byte)(4+dad2); momTb[i] = (byte)(4+mom1); momUb[i] = (byte)(4+mom2); } } } chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadTb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadUb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momTb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momUb, currentInd.getAffectedStatus())); numTrios++; }else if (mom.hasBothParents() && !dad.hasBothParents() && !usedParents.contains(dad)){ //in this case dad is a founder so we toss him in as a singleton. //this only happens in the bizarre case where we have grandparents on one side //of a family but not the other usedParents.add(dad); numMarkers = dad.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (dad.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = dad.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(dad.getFamilyID(),dad.getIndividualID(),chrom1,dad.getAffectedStatus())); chrom.add(new Chromosome(dad.getFamilyID(),dad.getIndividualID(),chrom2,dad.getAffectedStatus())); numSingletons++; }else if (dad.hasBothParents() && !mom.hasBothParents() && !usedParents.contains(mom)){ //in this case mom is a founder so we toss here in as a singleton //rarely occurs, see above usedParents.add(mom); numMarkers = mom.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (mom.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = mom.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(mom.getFamilyID(),mom.getIndividualID(),chrom1,mom.getAffectedStatus())); chrom.add(new Chromosome(mom.getFamilyID(),mom.getIndividualID(),chrom2,mom.getAffectedStatus())); numSingletons++; } } } chromTrios.addAll(chrom); chromosomes = chromTrios; //wipe clean any existing marker info so we know we're starting with a new file Chromosome.markers = null; return result; }
| 1,112,329
|
public void doTag(final XMLOutput output) throws Exception { getGoal(getName()).addPreActionCallback( new PreActionCallback() { public void firePreAction(Goal goal) throws Exception { // lets run the body log.debug( "Running pre action: " + getName() ); getBody().run( context, output); } } ); }
|
public void doTag(final XMLOutput output) throws Exception { getGoal(getName()).addPreActionCallback( new PreActionCallback() { public void firePreAction(Goal goal) throws Exception { // lets run the body log.debug( "Running pre action: " + getName() ); invokeBody( output); } } ); }
| 1,112,330
|
public void firePreAction(Goal goal) throws Exception { // lets run the body log.debug( "Running pre action: " + getName() ); getBody().run( context, output); }
|
public void firePreAction(Goal goal) throws Exception { // lets run the body log.debug( "Running pre action: " + getName() ); invokeBody( output); }
| 1,112,331
|
private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; String hapmapFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; boolean outputCheck=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println("HaploView command line options\n" + "-h, -help print this message\n" + "-n command line output only\n" + "-q quiet mode- doesnt print any warnings or information to screen\n" + "-p <pedfile> specify an input file in pedigree file format\n" + " pedfile specific options (nogui mode only): \n" + " --showcheck displays the results of the various pedigree integrity checks\n" + " --skipcheck skips the various pedfile checks\n" + //TODO: fix ignoremarkers //" --ignoremarkers <markers> ignores the specified markers.<markers> is a comma\n" + //" seperated list of markers. eg. 1,5,7,19,25\n" + "-a <hapmapfile> specify an input file in HapMap format\n" + "-l <hapsfile> specify an input file in .haps format\n" + "-i <infofile> specify a marker info file\n" + "-b <batchfile> batch mode. batchfile should contain a list of files either all genotype or alternating genotype/info\n" + "-d outputs dprime to <inputfile>.DPRIME\n" + "-c outputs marker checks to <inputfile>.CHECK\n" + " note: -d and -c default to no blocks output. use -o to also output blocks\n" + "-o <GAB,GAM,SPI,ALL> output type. Gabriel, 4 gamete, spine output or all 3. default is Gabriel.\n" + "-m <distance> maximum comparison distance in kilobases (integer). default is 500"); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha") || args[i].equals("-l")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equals("-a")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-a requires a filename"); System.exit(1); } else{ if(!hapmapFileName.equals("")){ System.out.println("multiple -a arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one -o argument is allowed"); System.exit(1); } if(args[i].equals("SFS") || args[i].equals("GAB")){ outputType = BLOX_GABRIEL; } else if(args[i].equals("GAM")){ outputType = BLOX_4GAM; } else if(args[i].equals("MJD") || args[i].equals("SPI")){ outputType = BLOX_SPINE; } else if(args[i].equals("ALL")) { outputType = BLOX_ALL; } } else { //defaults to SFS output outputType = BLOX_GABRIEL; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = true; } else if (args[i].equals("-c")){ outputCheck = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("") || !hapmapFileName.equals("")) && !outputDprime && !outputCheck) { outputType = BLOX_GABRIEL; if(nogui && !quietMode) { System.out.println("No output type specified. Default of SFS will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_hapmapfile = hapmapFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; arg_check = outputCheck; }
|
private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; String hapmapFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; boolean outputCheck=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println("HaploView command line options\n" + "-h, -help print this message\n" + "-n command line output only\n" + "-q quiet mode- doesnt print any warnings or information to screen\n" + "-p <pedfile> specify an input file in pedigree file format\n" + " pedfile specific options (nogui mode only): \n" + " --showcheck displays the results of the various pedigree integrity checks\n" + " --skipcheck skips the various pedfile checks\n" + //TODO: fix ignoremarkers //" --ignoremarkers <markers> ignores the specified markers.<markers> is a comma\n" + //" seperated list of markers. eg. 1,5,7,19,25\n" + "-a <hapmapfile> specify an input file in HapMap format\n" + "-l <hapsfile> specify an input file in .haps format\n" + "-i <infofile> specify a marker info file\n" + "-b <batchfile> batch mode. batchfile should contain a list of files either all genotype or alternating genotype/info\n" + "-d outputs dprime to <inputfile>.DPRIME\n" + "-c outputs marker checks to <inputfile>.CHECK\n" + " note: -d and -c default to no blocks output. use -o to also output blocks\n" + "-o <GAB,GAM,SPI,ALL> output type. Gabriel, 4 gamete, spine output or all 3. default is Gabriel.\n" + "-m <distance> maximum comparison distance in kilobases (integer). default is 500"); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha") || args[i].equals("-l")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equals("-a")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-a requires a filename"); System.exit(1); } else{ if(!hapmapFileName.equals("")){ System.out.println("multiple -a arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one -o argument is allowed"); System.exit(1); } if(args[i].equals("SFS") || args[i].equals("GAB")){ outputType = BLOX_GABRIEL; } else if(args[i].equals("GAM")){ outputType = BLOX_4GAM; } else if(args[i].equals("MJD") || args[i].equals("SPI")){ outputType = BLOX_SPINE; } else if(args[i].equals("ALL")) { outputType = BLOX_ALL; } } else { //defaults to SFS output outputType = BLOX_GABRIEL; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = true; } else if (args[i].equals("-c")){ outputCheck = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("") || !hapmapFileName.equals("")) && !outputDprime && !outputCheck) { outputType = BLOX_GABRIEL; if(nogui && !quietMode) { System.out.println("No output type specified. Default of Gabriel will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_hapmapfile = hapmapFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; arg_check = outputCheck; }
| 1,112,332
|
public HaploView(){ try{ fc = new JFileChooser(System.getProperty("user.dir")); }catch(NullPointerException n){ try{ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); fc = new JFileChooser(System.getProperty("user.dir")); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }catch(Exception e){ } } //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); analysisItem = new JMenuItem(READ_ANALYSIS_TRACK); setAccelerator(analysisItem, 'A', false); analysisItem.addActionListener(this); analysisItem.setEnabled(false); fileMenu.add(analysisItem); blocksItem = new JMenuItem(READ_BLOCKS_FILE); setAccelerator(blocksItem, 'B', false); blocksItem.addActionListener(this); blocksItem.setEnabled(false); fileMenu.add(blocksItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } exportMenuItems[2].setEnabled(true); fileMenu.addSeparator(); fileMenu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem("Quit"); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); displayMenu.setMnemonic(KeyEvent.VK_D); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); viewMenuItems[i].setEnabled(false); group.add(viewMenuItems[i]); } displayMenu.addSeparator(); //a submenu ButtonGroup zg = new ButtonGroup(); JMenu zoomMenu = new JMenu("LD zoom"); zoomMenu.setMnemonic(KeyEvent.VK_Z); zoomMenuItems = new JRadioButtonMenuItem[zoomItems.length]; for (int i = 0; i < zoomItems.length; i++){ zoomMenuItems[i] = new JRadioButtonMenuItem(zoomItems[i], i==0); zoomMenuItems[i].addActionListener(this); zoomMenuItems[i].setActionCommand("zoom" + i); zoomMenu.add(zoomMenuItems[i]); zg.add(zoomMenuItems[i]); } displayMenu.add(zoomMenu); //another submenu ButtonGroup cg = new ButtonGroup(); JMenu colorMenu = new JMenu("LD color scheme"); colorMenu.setMnemonic(KeyEvent.VK_C); colorMenuItems = new JRadioButtonMenuItem[colorItems.length]; for (int i = 0; i< colorItems.length; i++){ colorMenuItems[i] = new JRadioButtonMenuItem(colorItems[i],i==0); colorMenuItems[i].addActionListener(this); colorMenuItems[i].setActionCommand("color" + i); colorMenu.add(colorMenuItems[i]); cg.add(colorMenuItems[i]); } displayMenu.add(colorMenu); //analysis menu JMenu analysisMenu = new JMenu("Analysis"); analysisMenu.setMnemonic(KeyEvent.VK_A); menuBar.add(analysisMenu); //a submenu ButtonGroup bg = new ButtonGroup(); JMenu blockMenu = new JMenu("Define Blocks"); blockMenu.setMnemonic(KeyEvent.VK_B); blockMenuItems = new JRadioButtonMenuItem[blockItems.length]; for (int i = 0; i < blockItems.length; i++){ blockMenuItems[i] = new JRadioButtonMenuItem(blockItems[i], i==0); blockMenuItems[i].addActionListener(this); blockMenuItems[i].setActionCommand("block" + i); blockMenu.add(blockMenuItems[i]); bg.add(blockMenuItems[i]); } blockMenuItems[3].setEnabled(false); analysisMenu.add(blockMenu); clearBlocksItem = new JMenuItem(CLEAR_BLOCKS); setAccelerator(clearBlocksItem, 'C', false); clearBlocksItem.addActionListener(this); clearBlocksItem.setEnabled(false); analysisMenu.add(clearBlocksItem); JMenuItem customizeBlocksItem = new JMenuItem(CUST_BLOCKS); customizeBlocksItem.addActionListener(this); analysisMenu.add(customizeBlocksItem); //color key keyMenu = new JMenu("Key"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(keyMenu); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); addComponentListener(new ResizeListener()); }
|
public HaploView(){ try{ fc = new JFileChooser(System.getProperty("user.dir")); }catch(NullPointerException n){ try{ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); fc = new JFileChooser(System.getProperty("user.dir")); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }catch(Exception e){ } } //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); analysisItem = new JMenuItem(READ_ANALYSIS_TRACK); setAccelerator(analysisItem, 'A', false); analysisItem.addActionListener(this); analysisItem.setEnabled(false); fileMenu.add(analysisItem); blocksItem = new JMenuItem(READ_BLOCKS_FILE); setAccelerator(blocksItem, 'B', false); blocksItem.addActionListener(this); blocksItem.setEnabled(false); fileMenu.add(blocksItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); fileMenu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem("Quit"); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); displayMenu.setMnemonic(KeyEvent.VK_D); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); viewMenuItems[i].setEnabled(false); group.add(viewMenuItems[i]); } displayMenu.addSeparator(); //a submenu ButtonGroup zg = new ButtonGroup(); JMenu zoomMenu = new JMenu("LD zoom"); zoomMenu.setMnemonic(KeyEvent.VK_Z); zoomMenuItems = new JRadioButtonMenuItem[zoomItems.length]; for (int i = 0; i < zoomItems.length; i++){ zoomMenuItems[i] = new JRadioButtonMenuItem(zoomItems[i], i==0); zoomMenuItems[i].addActionListener(this); zoomMenuItems[i].setActionCommand("zoom" + i); zoomMenu.add(zoomMenuItems[i]); zg.add(zoomMenuItems[i]); } displayMenu.add(zoomMenu); //another submenu ButtonGroup cg = new ButtonGroup(); JMenu colorMenu = new JMenu("LD color scheme"); colorMenu.setMnemonic(KeyEvent.VK_C); colorMenuItems = new JRadioButtonMenuItem[colorItems.length]; for (int i = 0; i< colorItems.length; i++){ colorMenuItems[i] = new JRadioButtonMenuItem(colorItems[i],i==0); colorMenuItems[i].addActionListener(this); colorMenuItems[i].setActionCommand("color" + i); colorMenu.add(colorMenuItems[i]); cg.add(colorMenuItems[i]); } displayMenu.add(colorMenu); //analysis menu JMenu analysisMenu = new JMenu("Analysis"); analysisMenu.setMnemonic(KeyEvent.VK_A); menuBar.add(analysisMenu); //a submenu ButtonGroup bg = new ButtonGroup(); JMenu blockMenu = new JMenu("Define Blocks"); blockMenu.setMnemonic(KeyEvent.VK_B); blockMenuItems = new JRadioButtonMenuItem[blockItems.length]; for (int i = 0; i < blockItems.length; i++){ blockMenuItems[i] = new JRadioButtonMenuItem(blockItems[i], i==0); blockMenuItems[i].addActionListener(this); blockMenuItems[i].setActionCommand("block" + i); blockMenu.add(blockMenuItems[i]); bg.add(blockMenuItems[i]); } blockMenuItems[3].setEnabled(false); analysisMenu.add(blockMenu); clearBlocksItem = new JMenuItem(CLEAR_BLOCKS); setAccelerator(clearBlocksItem, 'C', false); clearBlocksItem.addActionListener(this); clearBlocksItem.setEnabled(false); analysisMenu.add(clearBlocksItem); JMenuItem customizeBlocksItem = new JMenuItem(CUST_BLOCKS); customizeBlocksItem.addActionListener(this); analysisMenu.add(customizeBlocksItem); //color key keyMenu = new JMenu("Key"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(keyMenu); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); addComponentListener(new ResizeListener()); }
| 1,112,333
|
void export(int tabNum, int format, int start, int stop){ fc.setSelectedFile(new File("")); if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){ File outfile = fc.getSelectedFile(); if (format == PNG_MODE){ BufferedImage image; if (tabNum == VIEW_D_NUM){ image = dPrimeDisplay.export(start, stop); }else if (tabNum == VIEW_HAP_NUM){ image = hapDisplay.export(); }else{ image = new BufferedImage(1,1,BufferedImage.TYPE_3BYTE_BGR); } try{ String filename = outfile.getPath(); if (! (filename.endsWith(".png") || filename.endsWith(".PNG"))){ filename += ".png"; } Jimi.putImage("image/png", image, filename); }catch(JimiException je){ JOptionPane.showMessageDialog(this, je.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } else if (format == TXT_MODE){ try{ if (tabNum == VIEW_D_NUM){ theData.saveDprimeToText(outfile, TABLE_TYPE, start, stop); }else if (tabNum == VIEW_HAP_NUM){ theData.saveHapsToText(hapDisplay.filteredHaplos,hapDisplay.multidprimeArray, outfile); }else if (tabNum == VIEW_CHECK_NUM){ checkPanel.printTable(outfile); }else if (tabNum == VIEW_TDT_NUM){ JTable table = tdtPanel.getTable(); FileWriter checkWriter = new FileWriter(outfile); int numCols = table.getColumnCount(); StringBuffer header = new StringBuffer(); for (int i = 0; i < numCols; i++){ header.append(table.getColumnName(i)).append("\t"); } header.append("\n"); checkWriter.write(header.toString()); for (int i = 0; i < table.getRowCount(); i++){ StringBuffer sb = new StringBuffer(); for (int j = 0; j < numCols; j++){ sb.append(table.getValueAt(i,j)).append("\t"); } sb.append("\n"); checkWriter.write(sb.toString()); } checkWriter.close(); } }catch(IOException ioe){ JOptionPane.showMessageDialog(this, ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } }
|
void export(int tabNum, int format, int start, int stop){ fc.setSelectedFile(new File("")); if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){ File outfile = fc.getSelectedFile(); if (format == PNG_MODE || format == COMPRESSED_PNG_MODE){ BufferedImage image; if (tabNum == VIEW_D_NUM){ image = dPrimeDisplay.export(start, stop); }else if (tabNum == VIEW_HAP_NUM){ image = hapDisplay.export(); }else{ image = new BufferedImage(1,1,BufferedImage.TYPE_3BYTE_BGR); } try{ String filename = outfile.getPath(); if (! (filename.endsWith(".png") || filename.endsWith(".PNG"))){ filename += ".png"; } Jimi.putImage("image/png", image, filename); }catch(JimiException je){ JOptionPane.showMessageDialog(this, je.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } else if (format == TXT_MODE){ try{ if (tabNum == VIEW_D_NUM){ theData.saveDprimeToText(outfile, TABLE_TYPE, start, stop); }else if (tabNum == VIEW_HAP_NUM){ theData.saveHapsToText(hapDisplay.filteredHaplos,hapDisplay.multidprimeArray, outfile); }else if (tabNum == VIEW_CHECK_NUM){ checkPanel.printTable(outfile); }else if (tabNum == VIEW_TDT_NUM){ JTable table = tdtPanel.getTable(); FileWriter checkWriter = new FileWriter(outfile); int numCols = table.getColumnCount(); StringBuffer header = new StringBuffer(); for (int i = 0; i < numCols; i++){ header.append(table.getColumnName(i)).append("\t"); } header.append("\n"); checkWriter.write(header.toString()); for (int i = 0; i < table.getRowCount(); i++){ StringBuffer sb = new StringBuffer(); for (int j = 0; j < numCols; j++){ sb.append(table.getValueAt(i,j)).append("\t"); } sb.append("\n"); checkWriter.write(sb.toString()); } checkWriter.close(); } }catch(IOException ioe){ JOptionPane.showMessageDialog(this, ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } }
| 1,112,334
|
void export(int tabNum, int format, int start, int stop){ fc.setSelectedFile(new File("")); if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){ File outfile = fc.getSelectedFile(); if (format == PNG_MODE){ BufferedImage image; if (tabNum == VIEW_D_NUM){ image = dPrimeDisplay.export(start, stop); }else if (tabNum == VIEW_HAP_NUM){ image = hapDisplay.export(); }else{ image = new BufferedImage(1,1,BufferedImage.TYPE_3BYTE_BGR); } try{ String filename = outfile.getPath(); if (! (filename.endsWith(".png") || filename.endsWith(".PNG"))){ filename += ".png"; } Jimi.putImage("image/png", image, filename); }catch(JimiException je){ JOptionPane.showMessageDialog(this, je.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } else if (format == TXT_MODE){ try{ if (tabNum == VIEW_D_NUM){ theData.saveDprimeToText(outfile, TABLE_TYPE, start, stop); }else if (tabNum == VIEW_HAP_NUM){ theData.saveHapsToText(hapDisplay.filteredHaplos,hapDisplay.multidprimeArray, outfile); }else if (tabNum == VIEW_CHECK_NUM){ checkPanel.printTable(outfile); }else if (tabNum == VIEW_TDT_NUM){ JTable table = tdtPanel.getTable(); FileWriter checkWriter = new FileWriter(outfile); int numCols = table.getColumnCount(); StringBuffer header = new StringBuffer(); for (int i = 0; i < numCols; i++){ header.append(table.getColumnName(i)).append("\t"); } header.append("\n"); checkWriter.write(header.toString()); for (int i = 0; i < table.getRowCount(); i++){ StringBuffer sb = new StringBuffer(); for (int j = 0; j < numCols; j++){ sb.append(table.getValueAt(i,j)).append("\t"); } sb.append("\n"); checkWriter.write(sb.toString()); } checkWriter.close(); } }catch(IOException ioe){ JOptionPane.showMessageDialog(this, ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } }
|
void export(int tabNum, int format, int start, int stop){ fc.setSelectedFile(new File("")); if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){ File outfile = fc.getSelectedFile(); if (format == PNG_MODE){ BufferedImage image; if (tabNum == VIEW_D_NUM){ if (format == PNG_MODE){ image = dPrimeDisplay.export(start, stop, false); }else{ image = dPrimeDisplay.export(start, stop, true); } }else if (tabNum == VIEW_HAP_NUM){ image = hapDisplay.export(); }else{ image = new BufferedImage(1,1,BufferedImage.TYPE_3BYTE_BGR); } try{ String filename = outfile.getPath(); if (! (filename.endsWith(".png") || filename.endsWith(".PNG"))){ filename += ".png"; } Jimi.putImage("image/png", image, filename); }catch(JimiException je){ JOptionPane.showMessageDialog(this, je.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } else if (format == TXT_MODE){ try{ if (tabNum == VIEW_D_NUM){ theData.saveDprimeToText(outfile, TABLE_TYPE, start, stop); }else if (tabNum == VIEW_HAP_NUM){ theData.saveHapsToText(hapDisplay.filteredHaplos,hapDisplay.multidprimeArray, outfile); }else if (tabNum == VIEW_CHECK_NUM){ checkPanel.printTable(outfile); }else if (tabNum == VIEW_TDT_NUM){ JTable table = tdtPanel.getTable(); FileWriter checkWriter = new FileWriter(outfile); int numCols = table.getColumnCount(); StringBuffer header = new StringBuffer(); for (int i = 0; i < numCols; i++){ header.append(table.getColumnName(i)).append("\t"); } header.append("\n"); checkWriter.write(header.toString()); for (int i = 0; i < table.getRowCount(); i++){ StringBuffer sb = new StringBuffer(); for (int j = 0; j < numCols; j++){ sb.append(table.getValueAt(i,j)).append("\t"); } sb.append("\n"); checkWriter.write(sb.toString()); } checkWriter.close(); } }catch(IOException ioe){ JOptionPane.showMessageDialog(this, ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } }
| 1,112,335
|
public byte elementAt(int i){ return genotypes[i]; }
|
public byte elementAt(int i){ return genotypes[realIndex[i]]; }
| 1,112,338
|
public int size(){ return genotypes.length; }
|
public int size(){ return genotypes.length; }
| 1,112,339
|
private void deleteReplica(S replica) throws PersistException { // Disable replication to prevent trigger from being invoked by // deleting replica. setReplicationDisabled(true); try { replica.tryDelete(); } finally { setReplicationDisabled(false); } }
|
void deleteReplica(Storable replica) throws PersistException { // Disable replication to prevent trigger from being invoked by // deleting replica. setReplicationDisabled(true); try { replica.tryDelete(); } finally { setReplicationDisabled(false); } }
| 1,112,340
|
private void deleteReplica(S replica) throws PersistException { // Disable replication to prevent trigger from being invoked by // deleting replica. setReplicationDisabled(true); try { replica.tryDelete(); } finally { setReplicationDisabled(false); } }
|
private void deleteReplica(S replica) throws PersistException { // Disable replication to prevent trigger from being invoked by // deleting replica. setReplicationDisabled(true); try { replica.delete(); } finally { setReplicationDisabled(false); } }
| 1,112,341
|
public void run(Context context, XMLOutput output) throws Exception { if ( select != null ) { Iterator iter = select.selectNodes(null).iterator(); while ( iter.hasNext() ) { Object value = iter.next(); if (var != null) { context.setVariable( var, value ); } getBody().run( context, output ); } } }
|
public void run(JellyContext context, XMLOutput output) throws Exception { if ( select != null ) { Iterator iter = select.selectNodes(null).iterator(); while ( iter.hasNext() ) { Object value = iter.next(); if (var != null) { context.setVariable( var, value ); } getBody().run( context, output ); } } }
| 1,112,342
|
public void run(Context context, XMLOutput output) throws Exception { for ( int i = 0, size = whenTags.length; i < size; i++ ) { TagScript script = whenTags[i]; script.run( context, output ); WhenTag tag = (WhenTag) script.getTag(); if ( tag.getValue() ) { return; } } if ( otherwiseTag != null ) { otherwiseTag.run( context, output ); } }
|
public void run(JellyContext context, XMLOutput output) throws Exception { for ( int i = 0, size = whenTags.length; i < size; i++ ) { TagScript script = whenTags[i]; script.run( context, output ); WhenTag tag = (WhenTag) script.getTag(); if ( tag.getValue() ) { return; } } if ( otherwiseTag != null ) { otherwiseTag.run( context, output ); } }
| 1,112,343
|
private String getAttributeType(ServerConnection connection, ObjectAttributeInfo[] objAttributes, String attribute, ObjectName objectName){ String itemName = null; int index = attribute.indexOf('.'); if(index != -1){ itemName = attribute.substring(index + 1); attribute = attribute.substring(0, index); } for(int i=0; i<objAttributes.length; i++){ if(objAttributes[i].getName().equals(attribute)){ if(itemName != null){ // it is a CompositeData type CompositeType type = getCompositeType(connection, objectName, objAttributes[i]); return type.getType(itemName).getClassName(); } return objAttributes[i].getType(); } } throw new ServiceException(ErrorCodes.INVALID_MBEAN_ATTRIBUTE, attribute, objectName); }
|
private String getAttributeType(ServerConnection connection, ObjectAttributeInfo[] objAttributes, String attribute, ObjectName objectName){ String itemName = null; final int index = attribute.indexOf(COMPOSITE_ATTR_SEPARATOR); if(index != -1){ itemName = attribute.substring(index + 1); attribute = attribute.substring(0, index); } for(int i=0; i<objAttributes.length; i++){ if(objAttributes[i].getName().equals(attribute)){ if(itemName != null){ // it is a CompositeData type CompositeType type = getCompositeType(connection, objectName, objAttributes[i]); return type.getType(itemName).getClassName(); } return objAttributes[i].getType(); } } throw new ServiceException(ErrorCodes.INVALID_MBEAN_ATTRIBUTE, attribute, objectName); }
| 1,112,344
|
private String getAttributeType(ServerConnection connection, ObjectAttributeInfo[] objAttributes, String attribute, ObjectName objectName){ String itemName = null; int index = attribute.indexOf('.'); if(index != -1){ itemName = attribute.substring(index + 1); attribute = attribute.substring(0, index); } for(int i=0; i<objAttributes.length; i++){ if(objAttributes[i].getName().equals(attribute)){ if(itemName != null){ // it is a CompositeData type CompositeType type = getCompositeType(connection, objectName, objAttributes[i]); return type.getType(itemName).getClassName(); } return objAttributes[i].getType(); } } throw new ServiceException(ErrorCodes.INVALID_MBEAN_ATTRIBUTE, attribute, objectName); }
|
private String getAttributeType(ServerConnection connection, ObjectAttributeInfo[] objAttributes, String attribute, ObjectName objectName){ String itemName = null; int index = attribute.indexOf('.'); if(index != -1){ itemName = attribute.substring(index + 1); attribute = attribute.substring(0, index); } for(int i=0; i<objAttributes.length; i++){ if(objAttributes[i].getName().equals(attribute)){ if(itemName != null){ // it is a CompositeData type CompositeType type = getCompositeType(connection, objectName, objAttributes[i]); return type.getType(itemName).getClassName(); } return objAttributes[i].getType(); } } throw new ServiceException(ErrorCodes.INVALID_MBEAN_ATTRIBUTE, attribute, objectName); }
| 1,112,345
|
private String getAttributeType(ServerConnection connection, ObjectAttributeInfo[] objAttributes, String attribute, ObjectName objectName){ String itemName = null; int index = attribute.indexOf('.'); if(index != -1){ itemName = attribute.substring(index + 1); attribute = attribute.substring(0, index); } for(int i=0; i<objAttributes.length; i++){ if(objAttributes[i].getName().equals(attribute)){ if(itemName != null){ // it is a CompositeData type CompositeType type = getCompositeType(connection, objectName, objAttributes[i]); return type.getType(itemName).getClassName(); } return objAttributes[i].getType(); } } throw new ServiceException(ErrorCodes.INVALID_MBEAN_ATTRIBUTE, attribute, objectName); }
|
private String getAttributeType(ServerConnection connection, ObjectAttributeInfo[] objAttributes, String attribute, ObjectName objectName){ String itemName = null; int index = attribute.indexOf('.'); if(index != -1){ itemName = attribute.substring(index + 1); attribute = attribute.substring(0, index); } for(int i=0; i<objAttributes.length; i++){ if(objAttributes[i].getName().equals(attribute)){ if(itemName != null){ // it is a CompositeData type CompositeType type = getCompositeType(connection, objectName, objAttributes[i]); return type.getType(itemName).getClassName(); } } } throw new ServiceException(ErrorCodes.INVALID_MBEAN_ATTRIBUTE, attribute, objectName); }
| 1,112,346
|
public ObjectAttribute getObjectAttribute(ServiceContext context, String attribute) throws ServiceException{ assert context.getObjectName() != null; assert context.getApplicationConfig() != null; canAccessThisMBean(context); AccessController.checkAccess(context, ACLConstants.ACL_VIEW_MBEAN_ATTRIBUTES, attribute); // we don't support clustering here assert !context.getApplicationConfig().isCluster(); ServerConnection connection = context.getServerConnection(); String itemName = null; int index = attribute.indexOf("."); String attributeName = attribute; if(index != -1){ // composite data attribute attributeName = attribute.substring(0, index); itemName = attribute.substring(index + 1); } List attrList = connection.getAttributes(context.getObjectName(), new String[]{attributeName}); ObjectAttribute attrValue = (ObjectAttribute)attrList.get(0); if(itemName != null){ CompositeData compositeData = (CompositeData)attrValue.getValue(); attrValue = new ObjectAttribute(attribute, compositeData.get(itemName)); } return attrValue; }
|
public ObjectAttribute getObjectAttribute(ServiceContext context, String attribute) throws ServiceException{ assert context.getObjectName() != null; assert context.getApplicationConfig() != null; canAccessThisMBean(context); AccessController.checkAccess(context, ACLConstants.ACL_VIEW_MBEAN_ATTRIBUTES, attribute); // we don't support clustering here assert !context.getApplicationConfig().isCluster(); ServerConnection connection = context.getServerConnection(); String itemName = null; int index = attribute.indexOf("."); String attributeName = attribute; if(index != -1){ // composite data attribute attributeName = attribute.substring(0, index); itemName = attribute.substring(index + 1); } List attrList = connection.getAttributes(context.getObjectName(), new String[]{attributeName}); ObjectAttribute attrValue = (ObjectAttribute)attrList.get(0); if(itemName != null){ CompositeData compositeData = (CompositeData)attrValue.getValue(); attrValue = new ObjectAttribute(attribute, compositeData.get(itemName)); } return attrValue; }
| 1,112,347
|
public ObjectAttribute getObjectAttribute(ServiceContext context, String attribute) throws ServiceException{ assert context.getObjectName() != null; assert context.getApplicationConfig() != null; canAccessThisMBean(context); AccessController.checkAccess(context, ACLConstants.ACL_VIEW_MBEAN_ATTRIBUTES, attribute); // we don't support clustering here assert !context.getApplicationConfig().isCluster(); ServerConnection connection = context.getServerConnection(); String itemName = null; int index = attribute.indexOf("."); String attributeName = attribute; if(index != -1){ // composite data attribute attributeName = attribute.substring(0, index); itemName = attribute.substring(index + 1); } List attrList = connection.getAttributes(context.getObjectName(), new String[]{attributeName}); ObjectAttribute attrValue = (ObjectAttribute)attrList.get(0); if(itemName != null){ CompositeData compositeData = (CompositeData)attrValue.getValue(); attrValue = new ObjectAttribute(attribute, compositeData.get(itemName)); } return attrValue; }
|
public ObjectAttribute getObjectAttribute(ServiceContext context, String attribute) throws ServiceException{ assert context.getObjectName() != null; assert context.getApplicationConfig() != null; canAccessThisMBean(context); AccessController.checkAccess(context, ACLConstants.ACL_VIEW_MBEAN_ATTRIBUTES, attribute); // we don't support clustering here assert !context.getApplicationConfig().isCluster(); ServerConnection connection = context.getServerConnection(); String itemName = null; int index = attribute.indexOf("."); String attributeName = attribute; if(index != -1){ // composite data attribute attributeName = attribute.substring(0, index); itemName = attribute.substring(index + 1); } String attributeName = null; String itemName = null; int index = attribute.indexOf(COMPOSITE_ATTR_SEPARATOR); if(index == -1) return attrValue; itemName = attribute.substring(index + 1); attributeName = attribute.substring(0, index); attrList = connection.getAttributes(context.getObjectName(), new String[]{attributeName}); ObjectAttribute attrValue = (ObjectAttribute)attrList.get(0); if(itemName != null){ CompositeData compositeData = (CompositeData)attrValue.getValue(); attrValue = new ObjectAttribute(attribute, compositeData.get(itemName)); } return attrValue; }
| 1,112,348
|
public ObjectAttribute getObjectAttribute(ServiceContext context, String attribute) throws ServiceException{ assert context.getObjectName() != null; assert context.getApplicationConfig() != null; canAccessThisMBean(context); AccessController.checkAccess(context, ACLConstants.ACL_VIEW_MBEAN_ATTRIBUTES, attribute); // we don't support clustering here assert !context.getApplicationConfig().isCluster(); ServerConnection connection = context.getServerConnection(); String itemName = null; int index = attribute.indexOf("."); String attributeName = attribute; if(index != -1){ // composite data attribute attributeName = attribute.substring(0, index); itemName = attribute.substring(index + 1); } List attrList = connection.getAttributes(context.getObjectName(), new String[]{attributeName}); ObjectAttribute attrValue = (ObjectAttribute)attrList.get(0); if(itemName != null){ CompositeData compositeData = (CompositeData)attrValue.getValue(); attrValue = new ObjectAttribute(attribute, compositeData.get(itemName)); } return attrValue; }
|
public ObjectAttribute getObjectAttribute(ServiceContext context, String attribute) throws ServiceException{ assert context.getObjectName() != null; assert context.getApplicationConfig() != null; canAccessThisMBean(context); AccessController.checkAccess(context, ACLConstants.ACL_VIEW_MBEAN_ATTRIBUTES, attribute); // we don't support clustering here assert !context.getApplicationConfig().isCluster(); ServerConnection connection = context.getServerConnection(); String itemName = null; int index = attribute.indexOf("."); String attributeName = attribute; if(index != -1){ // composite data attribute attributeName = attribute.substring(0, index); itemName = attribute.substring(index + 1); } List attrList = connection.getAttributes(context.getObjectName(), new String[]{attributeName}); ObjectAttribute attrValue = (ObjectAttribute)attrList.get(0); if(itemName != null){ CompositeData compositeData = (CompositeData)attrValue.getValue(); attrValue = new ObjectAttribute(attribute, compositeData.get(itemName)); } return attrValue; }
| 1,112,349
|
private void handleCompositeData(ServerConnection connection, ObjectName objectName, ObjectAttributeInfo attrInfo, String[] dataTypes, List attributesList){ CompositeType type = getCompositeType(connection, objectName, attrInfo); for(Iterator it=type.keySet().iterator(); it.hasNext(); ){ String itemName = (String)it.next(); OpenType itemType = type.getType(itemName); Class itemTypeClass = getClass(itemType.getClassName(), this.getClass().getClassLoader()); for(int j=0; j<dataTypes.length; j++){ Class dataType = getClass(dataTypes[j], this.getClass().getClassLoader()); if(dataType.isAssignableFrom(itemTypeClass)){ attributesList.add( new ObjectAttributeInfo(attrInfo.getName() + "." + itemName, type.getDescription(itemName), itemType.getClassName(), false, true, false)); } } } }
|
private void handleCompositeData(ServerConnection connection, ObjectName objectName, ObjectAttributeInfo attrInfo, String[] dataTypes, List attributesList){ CompositeType type = getCompositeType(connection, objectName, attrInfo); for(Iterator it=type.keySet().iterator(); it.hasNext(); ){ String itemName = (String)it.next(); OpenType itemType = type.getType(itemName); Class itemTypeClass = getClass(itemType.getClassName(), this.getClass().getClassLoader()); for(int j=0; j<dataTypes.length; j++){ Class dataType = getClass(dataTypes[j], this.getClass().getClassLoader()); if(dataType.isAssignableFrom(itemTypeClass)){ attributesList.add( new ObjectAttributeInfo( attrInfo.getName() + COMPOSITE_ATTR_SEPARATOR + itemName, type.getDescription(itemName), itemType.getClassName(), false, true, false)); } } } }
| 1,112,350
|
public PresentationObject getLettersHeads() { Table T = new Table(); if (letters != null && letters.size() > 0) { Iterator iter = letters.iterator(); EmailLetter let; int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); row++; Link link; while (iter.hasNext()) { let = (EmailLetter) iter.next(); int id = Integer.parseInt(let.toString()); if (id == letter) theLetter = let; link = getStyleLink(let.getSubject(), SN_SUBJ); link.addParameter(prmTopic, String.valueOf(topic)); link.addParameter(prmLetter, String.valueOf(let.toString())); T.add(link, 1, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } return T; }
|
public PresentationObject getLettersHeads() { Table T = new Table(); if (letters != null && letters.size() > 0) { Iterator iter = letters.iterator(); EmailLetter let; int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); row++; Link link; while (iter.hasNext()) { let = (EmailLetter) iter.next(); int id = let.getIdentifier().intValue(); if (id == letter) theLetter = let; link = getStyleLink(let.getSubject(), SN_SUBJ); link.addParameter(prmTopic, String.valueOf(topic)); link.addParameter(prmLetter, String.valueOf(let.toString())); T.add(link, 1, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } return T; }
| 1,112,351
|
public PresentationObject getLettersHeads() { Table T = new Table(); if (letters != null && letters.size() > 0) { Iterator iter = letters.iterator(); EmailLetter let; int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); row++; Link link; while (iter.hasNext()) { let = (EmailLetter) iter.next(); int id = Integer.parseInt(let.toString()); if (id == letter) theLetter = let; link = getStyleLink(let.getSubject(), SN_SUBJ); link.addParameter(prmTopic, String.valueOf(topic)); link.addParameter(prmLetter, String.valueOf(let.toString())); T.add(link, 1, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } return T; }
|
public PresentationObject getLettersHeads() { Table T = new Table(); if (letters != null && letters.size() > 0) { Iterator iter = letters.iterator(); EmailLetter let; int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); row++; Link link; while (iter.hasNext()) { let = (EmailLetter) iter.next(); int id = Integer.parseInt(let.toString()); if (id == letter) theLetter = let; link = getStyleLink(let.getSubject(), SN_SUBJ); link.addParameter(prmTopic, String.valueOf(topic)); link.addParameter(prmLetter, String.valueOf(let.getIdentifier().toString())); T.add(link, 1, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } return T; }
| 1,112,352
|
private PresentationObject getTopics() { Table T = new Table(); //T.add(getStyleText(iwrb.getLocalizedString("topic","Topic"),SN_TITLE),1,1); //T.add(getStyleText(iwrb.getLocalizedString("issue","Issue"),SN_TITLE),2,1); if (topics != null && topics.size() > 0) { Iterator iter = topics.iterator(); EmailTopic tpc; Link link; int row = 2; while (iter.hasNext()) { tpc = (EmailTopic) iter.next(); int id = Integer.parseInt(tpc.toString()); if (letter > 0) { if (topic == id) { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; } } } } else { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (topic > 0 && topic == id) { //T.add(getLettersHeads(),2,row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); //row++; Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; subject = getStyleLink(let.getSubject(), SN_SUBJ); subject.addParameter(prmTopic, String.valueOf(topic)); subject.addParameter(prmLetter, String.valueOf(let.toString())); T.add(subject, 2, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } } } } } return T; }
|
private PresentationObject getTopics() { Table T = new Table(); //T.add(getStyleText(iwrb.getLocalizedString("topic","Topic"),SN_TITLE),1,1); //T.add(getStyleText(iwrb.getLocalizedString("issue","Issue"),SN_TITLE),2,1); if (topics != null && topics.size() > 0) { Iterator iter = topics.iterator(); EmailTopic tpc; Link link; int row = 2; while (iter.hasNext()) { tpc = (EmailTopic) iter.next(); int id = tpc.getIdentifier().intValue(); if (letter > 0) { if (topic == id) { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; } } } } else { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (topic > 0 && topic == id) { //T.add(getLettersHeads(),2,row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); //row++; Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; subject = getStyleLink(let.getSubject(), SN_SUBJ); subject.addParameter(prmTopic, String.valueOf(topic)); subject.addParameter(prmLetter, String.valueOf(let.toString())); T.add(subject, 2, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } } } } } return T; }
| 1,112,353
|
private PresentationObject getTopics() { Table T = new Table(); //T.add(getStyleText(iwrb.getLocalizedString("topic","Topic"),SN_TITLE),1,1); //T.add(getStyleText(iwrb.getLocalizedString("issue","Issue"),SN_TITLE),2,1); if (topics != null && topics.size() > 0) { Iterator iter = topics.iterator(); EmailTopic tpc; Link link; int row = 2; while (iter.hasNext()) { tpc = (EmailTopic) iter.next(); int id = Integer.parseInt(tpc.toString()); if (letter > 0) { if (topic == id) { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; } } } } else { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (topic > 0 && topic == id) { //T.add(getLettersHeads(),2,row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); //row++; Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; subject = getStyleLink(let.getSubject(), SN_SUBJ); subject.addParameter(prmTopic, String.valueOf(topic)); subject.addParameter(prmLetter, String.valueOf(let.toString())); T.add(subject, 2, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } } } } } return T; }
|
private PresentationObject getTopics() { Table T = new Table(); //T.add(getStyleText(iwrb.getLocalizedString("topic","Topic"),SN_TITLE),1,1); //T.add(getStyleText(iwrb.getLocalizedString("issue","Issue"),SN_TITLE),2,1); if (topics != null && topics.size() > 0) { Iterator iter = topics.iterator(); EmailTopic tpc; Link link; int row = 2; while (iter.hasNext()) { tpc = (EmailTopic) iter.next(); int id = Integer.parseInt(tpc.toString()); if (letter > 0) { if (topic == id) { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.getIdentifier().toString()); T.add(link, 1, row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; } } } } else { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.getIdentifier().toString()); T.add(link, 1, row++); if (topic > 0 && topic == id) { //T.add(getLettersHeads(),2,row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); //row++; Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; subject = getStyleLink(let.getSubject(), SN_SUBJ); subject.addParameter(prmTopic, String.valueOf(topic)); subject.addParameter(prmLetter, String.valueOf(let.toString())); T.add(subject, 2, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } } } } } return T; }
| 1,112,354
|
private PresentationObject getTopics() { Table T = new Table(); //T.add(getStyleText(iwrb.getLocalizedString("topic","Topic"),SN_TITLE),1,1); //T.add(getStyleText(iwrb.getLocalizedString("issue","Issue"),SN_TITLE),2,1); if (topics != null && topics.size() > 0) { Iterator iter = topics.iterator(); EmailTopic tpc; Link link; int row = 2; while (iter.hasNext()) { tpc = (EmailTopic) iter.next(); int id = Integer.parseInt(tpc.toString()); if (letter > 0) { if (topic == id) { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; } } } } else { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (topic > 0 && topic == id) { //T.add(getLettersHeads(),2,row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); //row++; Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; subject = getStyleLink(let.getSubject(), SN_SUBJ); subject.addParameter(prmTopic, String.valueOf(topic)); subject.addParameter(prmLetter, String.valueOf(let.toString())); T.add(subject, 2, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } } } } } return T; }
|
private PresentationObject getTopics() { Table T = new Table(); //T.add(getStyleText(iwrb.getLocalizedString("topic","Topic"),SN_TITLE),1,1); //T.add(getStyleText(iwrb.getLocalizedString("issue","Issue"),SN_TITLE),2,1); if (topics != null && topics.size() > 0) { Iterator iter = topics.iterator(); EmailTopic tpc; Link link; int row = 2; while (iter.hasNext()) { tpc = (EmailTopic) iter.next(); int id = Integer.parseInt(tpc.toString()); if (letter > 0) { if (topic == id) { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = let.getIdentifier().intValue(); if (lid == letter) theLetter = let; } } } } else { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (topic > 0 && topic == id) { //T.add(getLettersHeads(),2,row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); //row++; Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = let.getIdentifier().intValue(); if (lid == letter) theLetter = let; subject = getStyleLink(let.getSubject(), SN_SUBJ); subject.addParameter(prmTopic, String.valueOf(topic)); subject.addParameter(prmLetter, String.valueOf(let.toString())); T.add(subject, 2, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } } } } } return T; }
| 1,112,355
|
private PresentationObject getTopics() { Table T = new Table(); //T.add(getStyleText(iwrb.getLocalizedString("topic","Topic"),SN_TITLE),1,1); //T.add(getStyleText(iwrb.getLocalizedString("issue","Issue"),SN_TITLE),2,1); if (topics != null && topics.size() > 0) { Iterator iter = topics.iterator(); EmailTopic tpc; Link link; int row = 2; while (iter.hasNext()) { tpc = (EmailTopic) iter.next(); int id = Integer.parseInt(tpc.toString()); if (letter > 0) { if (topic == id) { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; } } } } else { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (topic > 0 && topic == id) { //T.add(getLettersHeads(),2,row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); //row++; Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; subject = getStyleLink(let.getSubject(), SN_SUBJ); subject.addParameter(prmTopic, String.valueOf(topic)); subject.addParameter(prmLetter, String.valueOf(let.toString())); T.add(subject, 2, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } } } } } return T; }
|
private PresentationObject getTopics() { Table T = new Table(); //T.add(getStyleText(iwrb.getLocalizedString("topic","Topic"),SN_TITLE),1,1); //T.add(getStyleText(iwrb.getLocalizedString("issue","Issue"),SN_TITLE),2,1); if (topics != null && topics.size() > 0) { Iterator iter = topics.iterator(); EmailTopic tpc; Link link; int row = 2; while (iter.hasNext()) { tpc = (EmailTopic) iter.next(); int id = Integer.parseInt(tpc.toString()); if (letter > 0) { if (topic == id) { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; } } } } else { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (topic > 0 && topic == id) { //T.add(getLettersHeads(),2,row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); //row++; Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; subject = getStyleLink(let.getSubject(), SN_SUBJ); subject.addParameter(prmTopic, String.valueOf(topic)); subject.addParameter(prmLetter, let.getIdentifier().toString()); T.add(subject, 2, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } } } } } return T; }
| 1,112,356
|
public void main(IWContext iwc) { iwb = getBundle(iwc); core = iwc.getApplication().getCoreBundle(); iwrb = getResourceBundle(iwc); Table T = new Table(); int row = 1; df = DateFormat.getDateInstance(DateFormat.LONG, iwc.getCurrentLocale()); if (iwc.isParameterSet(prmTopic)) { topic = Integer.parseInt(iwc.getParameter(prmTopic)); } if (iwc.isParameterSet(prmLetter)) { letter = Integer.parseInt(iwc.getParameter(prmLetter)); } if(iwc.isParameterSet(prmLetterDelete) && letter >0){ MailBusiness.getInstance().deleteLetter(letter); } if (getCategoryId() > 0) { topics = MailFinder.getInstance().getTopics(this.getICObjectInstanceID()); if (topic > 0) letters = MailFinder.getInstance().getEmailLetters(topic); } if (iwc.hasEditPermission(this)) { T.add(getAdminView(iwc), 1, row); T.setAlignment(1, row, "left"); T.mergeCells(1, row, 2, row); row++; } if (topics != null && !topics.isEmpty()) { T.add(getTopics(), 1, row++); if (topic < 0) topic = Integer.parseInt(((EmailTopic) topics.iterator().next()).toString()); } if (theLetter != null) T.add(getLetter(iwc), 2, row); T.setAlignment(1, 2, T.VERTICAL_ALIGN_TOP); T.setAlignment(2, 2, T.VERTICAL_ALIGN_TOP); Form F = new Form(); F.add(T); add(F); }
|
public void main(IWContext iwc) { iwb = getBundle(iwc); core = iwc.getApplication().getCoreBundle(); iwrb = getResourceBundle(iwc); Table T = new Table(); int row = 1; df = DateFormat.getDateInstance(DateFormat.LONG, iwc.getCurrentLocale()); if (iwc.isParameterSet(prmTopic)) { topic = Integer.parseInt(iwc.getParameter(prmTopic)); } if (iwc.isParameterSet(prmLetter)) { letter = Integer.parseInt(iwc.getParameter(prmLetter)); } if(iwc.isParameterSet(prmLetterDelete) && letter >0){ MailBusiness.getInstance().deleteLetter(letter); } if (getCategoryId() > 0) { topics = MailFinder.getInstance().getTopics(this.getICObjectInstanceID()); if (topic > 0) letters = MailFinder.getInstance().getEmailLetters(topic); } if (iwc.hasEditPermission(this)) { T.add(getAdminView(iwc), 1, row); T.setAlignment(1, row, "left"); T.mergeCells(1, row, 2, row); row++; } if (topics != null && !topics.isEmpty()) { T.add(getTopics(), 1, row++); if (topic < 0) topic =(((EmailTopic) topics.iterator().next()).getIdentifier().intValue()); } if (theLetter != null) T.add(getLetter(iwc), 2, row); T.setAlignment(1, 2, T.VERTICAL_ALIGN_TOP); T.setAlignment(2, 2, T.VERTICAL_ALIGN_TOP); Form F = new Form(); F.add(T); add(F); }
| 1,112,357
|
public void removeNotificationListener(ObjectName objectName, ObjectNotificationListener listener, ObjectNotificationFilter filter, Object handback){ throw new RuntimeException("Notifications not supported"); }
|
public void removeNotificationListener(ObjectName objectName, ObjectNotificationListener listener, ObjectNotificationFilter filter, Object handback){ NotificationListener notifListener = (NotificationListener)notifications.remove(listener); NotificationFilter notifFilter = (NotificationFilter)notifFilters.remove(filter); assert notifListener != null; assert notifFilter != null; Class[] methodSignature = new Class[]{javax.management.ObjectName.class, NotificationListener.class, NotificationFilter.class, Object.class}; Object[] methodArgs = new Object[]{toJMXObjectName(objectName), notifListener, notifFilter, handback}; callMBeanServer("removeNotificationListener", methodSignature, methodArgs); }
| 1,112,359
|
private static OperationResultData executeMBeanOperation( ServiceContext context, ApplicationConfig appConfig, ObjectName objectName, String operationName, String[] params, String[] signature){ OperationResultData resultData = new OperationResultData(appConfig.getName()); try { final ServerConnection serverConnection = ServerConnector.getServerConnection(appConfig); Object[] typedParams = CoreUtils.getTypedArray(params, signature); final Object result = serverConnection.invoke(objectName, operationName, typedParams, signature); resultData.setOutput(result.toString()); UserActivityLogger.getInstance().logActivity( context.getUser().getUsername(), "Performed "+operationName+" on "+objectName.getCanonicalName() + " in application " + appConfig.getName()); } catch (ConnectionFailedException e) { logger.log(Level.INFO, "Error executing operation " + operationName + " on " + objectName, e); resultData.setResult(OperationResultData.RESULT_ERROR); resultData.setErrorString(ErrorCatalog.getMessage(ErrorCodes.CONNECTION_FAILED)); } catch (Exception e){ logger.log(Level.SEVERE, "Error executing operation " + operationName + " on " + objectName, e); resultData.setResult(OperationResultData.RESULT_ERROR); resultData.setErrorString(e.getMessage()); } return resultData; }
|
private static OperationResultData executeMBeanOperation( ServiceContext context, ApplicationConfig appConfig, ObjectName objectName, String operationName, String[] params, String[] signature){ OperationResultData resultData = new OperationResultData(appConfig.getName()); try { final ServerConnection serverConnection = ServerConnector.getServerConnection(appConfig); Object[] typedParams = CoreUtils.getTypedArray(params, signature); final Object result = serverConnection.invoke(objectName, operationName, typedParams, signature); resultData.setOutput(result != null?result.toString():"null"); UserActivityLogger.getInstance().logActivity( context.getUser().getUsername(), "Performed "+operationName+" on "+objectName.getCanonicalName() + " in application " + appConfig.getName()); } catch (ConnectionFailedException e) { logger.log(Level.INFO, "Error executing operation " + operationName + " on " + objectName, e); resultData.setResult(OperationResultData.RESULT_ERROR); resultData.setErrorString(ErrorCatalog.getMessage(ErrorCodes.CONNECTION_FAILED)); } catch (Exception e){ logger.log(Level.SEVERE, "Error executing operation " + operationName + " on " + objectName, e); resultData.setResult(OperationResultData.RESULT_ERROR); resultData.setErrorString(e.getMessage()); } return resultData; }
| 1,112,360
|
public void doTag(XMLOutput output) throws Exception { suite = createSuite(); TestSuite parent = (TestSuite) context.getVariable("org.apache.commons.jelly.junit.suite"); if ( parent == null ) { context.setVariable("org.apache.commons.jelly.junit.suite", suite ); } else { parent.addTest( suite ); } invokeBody(output); if ( var != null ) { context.setVariable(var, suite); } }
|
public void doTag(XMLOutput output) throws JellyTagException { suite = createSuite(); TestSuite parent = (TestSuite) context.getVariable("org.apache.commons.jelly.junit.suite"); if ( parent == null ) { context.setVariable("org.apache.commons.jelly.junit.suite", suite ); } else { parent.addTest( suite ); } invokeBody(output); if ( var != null ) { context.setVariable(var, suite); } }
| 1,112,362
|
public void doTag(final XMLOutput output) throws Exception { if ( name != null ) { Writer writer = new FileWriter(name); writeBody(writer); } else if (var != null) { StringWriter writer = new StringWriter(); writeBody(writer); context.setVariable(var, writer.toString()); } else { throw new JellyException( "This tag must have either the 'name' or the 'var' variables defined" ); } }
|
public void doTag(final XMLOutput output) throws Exception { if ( name != null ) { String encoding = (this.encoding != null) ? this.encoding : "UTF-8"; Writer writer = new OutputStreamWriter( new FileOutputStream( name ), encoding ); writeBody(writer); } else if (var != null) { StringWriter writer = new StringWriter(); writeBody(writer); context.setVariable(var, writer.toString()); } else { throw new JellyException( "This tag must have either the 'name' or the 'var' variables defined" ); } }
| 1,112,364
|
void readGenotypes(String[] inputOptions, int type){ //input is a 3 element array with //inputOptions[0] = ped file //inputOptions[1] = info file ("" if none) //inputOptions[2] = max comparison distance (don't compute d' if markers are greater than this dist apart) //type is either 3 or 4 for ped and hapmap files respectively final File inFile = new File(inputOptions[0]); //deal with max comparison distance if (inputOptions[2].equals("")){ inputOptions[2] = "0"; } maxCompDist = Long.parseLong(inputOptions[2])*1000; try { if (inFile.length() < 1){ throw new HaploViewException("Genotype file is empty or nonexistent: " + inFile.getName()); } if (type == HAPS){ //these are not available for non ped files viewMenuItems[VIEW_CHECK_NUM].setEnabled(false); viewMenuItems[VIEW_TDT_NUM].setEnabled(false); assocTest = 0; } theData = new HaploData(); if (type == HAPS){ theData.prepareHapsInput(new File(inputOptions[0])); }else{ theData.linkageToChrom(inFile, type); } //deal with marker information theData.infoKnown = false; File markerFile; if (inputOptions[1].equals("")){ markerFile = null; }else{ markerFile = new File(inputOptions[1]); } checkPanel = null; if (type == HAPS){ readMarkers(markerFile, null); }else{ readMarkers(markerFile, theData.getPedFile().getHMInfo()); checkPanel = new CheckDataPanel(theData, true); checkPanel.setAlignmentX(Component.CENTER_ALIGNMENT); } //let's start the math this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; changeKey(1); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); //theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first colorMenuItems[0].setSelected(true); blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(window); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); viewMenuItems[VIEW_D_NUM].setEnabled(true); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); //LOD panel /*panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); LODDisplay ld = new LODDisplay(theData); JScrollPane lodScroller = new JScrollPane(ld); panel.add(lodScroller); tabs.addTab(viewItems[VIEW_LOD_NUM], panel); viewMenuItems[VIEW_LOD_NUM].setEnabled(true);*/ //int optionalTabCount = 1; //check data panel if (checkPanel != null){ //optionalTabCount++; //VIEW_CHECK_NUM = optionalTabCount; //viewItems[VIEW_CHECK_NUM] = VIEW_CHECK_PANEL; JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //TDT panel if(assocTest > 0) { //optionalTabCount++; //VIEW_TDT_NUM = optionalTabCount; //viewItems[VIEW_TDT_NUM] = VIEW_TDT; try{ tdtPanel = new TDTPanel(theData.getPedFile(), assocTest); } catch(PedFileException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inFile.getName()); return null; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); for (int i = 0; i < blockMenuItems.length; i++){ blockMenuItems[i].setEnabled(true); } clearBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); blocksItem.setEnabled(true); exportMenuItems[2].setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); worker.start(); timer.start(); }catch(IOException ioexec) { JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } catch(PedFileException pfe){ JOptionPane.showMessageDialog(this, pfe.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (HaploViewException hve){ JOptionPane.showMessageDialog(this, hve.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } }
|
void readGenotypes(String[] inputOptions, int type){ //input is a 3 element array with //inputOptions[0] = ped file //inputOptions[1] = info file ("" if none) //inputOptions[2] = max comparison distance (don't compute d' if markers are greater than this dist apart) //type is either 3 or 4 for ped and hapmap files respectively final File inFile = new File(inputOptions[0]); //deal with max comparison distance if (inputOptions[2].equals("")){ inputOptions[2] = "0"; } maxCompDist = Long.parseLong(inputOptions[2])*1000; try { if (inFile.length() < 1){ throw new HaploViewException("Genotype file is empty or nonexistent: " + inFile.getName()); } if (type == HAPS){ //these are not available for non ped files viewMenuItems[VIEW_CHECK_NUM].setEnabled(false); viewMenuItems[VIEW_TDT_NUM].setEnabled(false); assocTest = 0; } theData = new HaploData(); if (type == HAPS){ theData.prepareHapsInput(new File(inputOptions[0])); }else{ theData.linkageToChrom(inFile, type); } //deal with marker information theData.infoKnown = false; File markerFile; if (inputOptions[1] == null){ markerFile = null; }else{ markerFile = new File(inputOptions[1]); } checkPanel = null; if (type == HAPS){ readMarkers(markerFile, null); }else{ readMarkers(markerFile, theData.getPedFile().getHMInfo()); checkPanel = new CheckDataPanel(theData, true); checkPanel.setAlignmentX(Component.CENTER_ALIGNMENT); } //let's start the math this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; changeKey(1); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); //theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first colorMenuItems[0].setSelected(true); blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(window); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); viewMenuItems[VIEW_D_NUM].setEnabled(true); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); //LOD panel /*panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); LODDisplay ld = new LODDisplay(theData); JScrollPane lodScroller = new JScrollPane(ld); panel.add(lodScroller); tabs.addTab(viewItems[VIEW_LOD_NUM], panel); viewMenuItems[VIEW_LOD_NUM].setEnabled(true);*/ //int optionalTabCount = 1; //check data panel if (checkPanel != null){ //optionalTabCount++; //VIEW_CHECK_NUM = optionalTabCount; //viewItems[VIEW_CHECK_NUM] = VIEW_CHECK_PANEL; JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //TDT panel if(assocTest > 0) { //optionalTabCount++; //VIEW_TDT_NUM = optionalTabCount; //viewItems[VIEW_TDT_NUM] = VIEW_TDT; try{ tdtPanel = new TDTPanel(theData.getPedFile(), assocTest); } catch(PedFileException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inFile.getName()); return null; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); for (int i = 0; i < blockMenuItems.length; i++){ blockMenuItems[i].setEnabled(true); } clearBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); blocksItem.setEnabled(true); exportMenuItems[2].setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); worker.start(); timer.start(); }catch(IOException ioexec) { JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } catch(PedFileException pfe){ JOptionPane.showMessageDialog(this, pfe.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (HaploViewException hve){ JOptionPane.showMessageDialog(this, hve.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } }
| 1,112,365
|
public void addColumn(SQLColumn c, SQLTable t) throws ArchitectDiffException { Map colNameMap = new HashMap(); print("\n ALTER TABLE "); printQualified(t.getPhysicalName()); print(" ADD COLUMN "); print(columnDefinition(c,colNameMap)); endStatement(DDLStatement.StatementType.CREATE, c); }
|
public void addColumn(SQLColumn c, SQLTable t) throws ArchitectDiffException { Map colNameMap = new HashMap(); print("\n ALTER TABLE "); print( DDLUtils.toQualifiedName(t.getCatalogName(),t.getSchemaName(),t.getPhysicalName()) ); print(" ADD COLUMN "); print(columnDefinition(c,colNameMap)); endStatement(DDLStatement.StatementType.CREATE, c); }
| 1,112,366
|
public void addRelationship(SQLRelationship r) throws ArchitectDiffException { print("\n ALTER TABLE "); printQualified(r.getFkTable().getPhysicalName()); print(" ADD CONSTRAINT "); print(r.getName()); print(" FOREIGN KEY ( "); Map<String, SQLColumn> colNameMap = new HashMap<String, SQLColumn> (); boolean firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getFkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" ) REFERENCES "); printQualified(r.getPkTable().getPhysicalName()); print(" ( "); colNameMap = new HashMap<String, SQLColumn> (); firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getPkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" )"); endStatement(DDLStatement.StatementType.CREATE, r); }
|
public void addRelationship(SQLRelationship r) throws ArchitectDiffException { print("\n ALTER TABLE "); print( DDLUtils.toQualifiedName(r.getFkTable().getCatalogName(),r.getFkTable().getSchemaName(),r.getFkTable().getPhysicalName()) ); print(" ADD CONSTRAINT "); print(r.getName()); print(" FOREIGN KEY ( "); Map<String, SQLColumn> colNameMap = new HashMap<String, SQLColumn> (); boolean firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getFkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" ) REFERENCES "); printQualified(r.getPkTable().getPhysicalName()); print(" ( "); colNameMap = new HashMap<String, SQLColumn> (); firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getPkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" )"); endStatement(DDLStatement.StatementType.CREATE, r); }
| 1,112,367
|
public void addRelationship(SQLRelationship r) throws ArchitectDiffException { print("\n ALTER TABLE "); printQualified(r.getFkTable().getPhysicalName()); print(" ADD CONSTRAINT "); print(r.getName()); print(" FOREIGN KEY ( "); Map<String, SQLColumn> colNameMap = new HashMap<String, SQLColumn> (); boolean firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getFkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" ) REFERENCES "); printQualified(r.getPkTable().getPhysicalName()); print(" ( "); colNameMap = new HashMap<String, SQLColumn> (); firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getPkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" )"); endStatement(DDLStatement.StatementType.CREATE, r); }
|
public void addRelationship(SQLRelationship r) throws ArchitectDiffException { print("\n ALTER TABLE "); printQualified(r.getFkTable().getPhysicalName()); print(" ADD CONSTRAINT "); print(r.getName()); print(" FOREIGN KEY ( "); Map<String, SQLColumn> colNameMap = new HashMap<String, SQLColumn> (); boolean firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getFkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" ) REFERENCES "); print( DDLUtils.toQualifiedName(r.getPkTable().getCatalogName(),r.getPkTable().getSchemaName(),r.getPkTable().getPhysicalName()) ); print(" ( "); colNameMap = new HashMap<String, SQLColumn> (); firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getPkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" )"); endStatement(DDLStatement.StatementType.CREATE, r); }
| 1,112,368
|
public void dropColumn(SQLColumn c, SQLTable t) throws ArchitectDiffException { Map colNameMap = new HashMap(); print("\n ALTER TABLE "); printQualified(t.getPhysicalName()); print(" DROP COLUMN "); print(getPhysicalName(colNameMap,c)); endStatement(DDLStatement.StatementType.DROP, c); }
|
public void dropColumn(SQLColumn c, SQLTable t) throws ArchitectDiffException { Map colNameMap = new HashMap(); print("\n ALTER TABLE "); print( DDLUtils.toQualifiedName(t.getCatalogName(),t.getSchemaName(),t.getPhysicalName()) ); print(" DROP COLUMN "); print(getPhysicalName(colNameMap,c)); endStatement(DDLStatement.StatementType.DROP, c); }
| 1,112,369
|
public void dropRelationship(SQLRelationship r) { print("\n ALTER TABLE "); printQualified(r.getFkTable().getPhysicalName()); print(" DROP CONSTRAINT "); print(r.getName()); endStatement(DDLStatement.StatementType.DROP, r); }
|
public void dropRelationship(SQLRelationship r) { print("\n ALTER TABLE "); print( DDLUtils.toQualifiedName(r.getFkTable().getCatalogName(),r.getFkTable().getSchemaName(),r.getFkTable().getPhysicalName()) ); print(" DROP CONSTRAINT "); print(r.getName()); endStatement(DDLStatement.StatementType.DROP, r); }
| 1,112,370
|
protected void writeExportedRelationships(SQLTable t) throws ArchitectException { Iterator it = t.getExportedKeys().iterator(); while (it.hasNext()) { SQLRelationship rel = (SQLRelationship) it.next(); // geneate a physical name for this relationship getPhysicalName(topLevelNames,rel); // println(""); print("ALTER TABLE "); // this works because all the tables have had their physical names generated already... printQualified(rel.getFkTable().getPhysicalName()); print(" ADD CONSTRAINT "); print(rel.getPhysicalName()); println(""); print("FOREIGN KEY ("); StringBuffer pkCols = new StringBuffer(); StringBuffer fkCols = new StringBuffer(); boolean firstCol = true; Iterator mappings = rel.getChildren().iterator(); while (mappings.hasNext()) { SQLRelationship.ColumnMapping cmap = (SQLRelationship.ColumnMapping) mappings.next(); if (!firstCol) { pkCols.append(", "); fkCols.append(", "); } // append(pkCols, cmap.getPkColumn().getPhysicalName()); append(fkCols, cmap.getFkColumn().getPhysicalName()); firstCol = false; } print(fkCols.toString()); println(")"); print("REFERENCES "); printQualified(rel.getPkTable().getPhysicalName()); print(" ("); print(pkCols.toString()); print(")"); endStatement(DDLStatement.StatementType.ADD_FK, t); } }
|
protected void writeExportedRelationships(SQLTable t) throws ArchitectException { Iterator it = t.getExportedKeys().iterator(); while (it.hasNext()) { SQLRelationship rel = (SQLRelationship) it.next(); // geneate a physical name for this relationship getPhysicalName(topLevelNames,rel); // println(""); print("ALTER TABLE "); // this works because all the tables have had their physical names generated already... print( DDLUtils.toQualifiedName(rel.getFkTable().getCatalogName(),rel.getFkTable().getSchemaName(),rel.getFkTable().getPhysicalName()) ); print(" ADD CONSTRAINT "); print(rel.getPhysicalName()); println(""); print("FOREIGN KEY ("); StringBuffer pkCols = new StringBuffer(); StringBuffer fkCols = new StringBuffer(); boolean firstCol = true; Iterator mappings = rel.getChildren().iterator(); while (mappings.hasNext()) { SQLRelationship.ColumnMapping cmap = (SQLRelationship.ColumnMapping) mappings.next(); if (!firstCol) { pkCols.append(", "); fkCols.append(", "); } // append(pkCols, cmap.getPkColumn().getPhysicalName()); append(fkCols, cmap.getFkColumn().getPhysicalName()); firstCol = false; } print(fkCols.toString()); println(")"); print("REFERENCES "); printQualified(rel.getPkTable().getPhysicalName()); print(" ("); print(pkCols.toString()); print(")"); endStatement(DDLStatement.StatementType.ADD_FK, t); } }
| 1,112,371
|
protected void writeExportedRelationships(SQLTable t) throws ArchitectException { Iterator it = t.getExportedKeys().iterator(); while (it.hasNext()) { SQLRelationship rel = (SQLRelationship) it.next(); // geneate a physical name for this relationship getPhysicalName(topLevelNames,rel); // println(""); print("ALTER TABLE "); // this works because all the tables have had their physical names generated already... printQualified(rel.getFkTable().getPhysicalName()); print(" ADD CONSTRAINT "); print(rel.getPhysicalName()); println(""); print("FOREIGN KEY ("); StringBuffer pkCols = new StringBuffer(); StringBuffer fkCols = new StringBuffer(); boolean firstCol = true; Iterator mappings = rel.getChildren().iterator(); while (mappings.hasNext()) { SQLRelationship.ColumnMapping cmap = (SQLRelationship.ColumnMapping) mappings.next(); if (!firstCol) { pkCols.append(", "); fkCols.append(", "); } // append(pkCols, cmap.getPkColumn().getPhysicalName()); append(fkCols, cmap.getFkColumn().getPhysicalName()); firstCol = false; } print(fkCols.toString()); println(")"); print("REFERENCES "); printQualified(rel.getPkTable().getPhysicalName()); print(" ("); print(pkCols.toString()); print(")"); endStatement(DDLStatement.StatementType.ADD_FK, t); } }
|
protected void writeExportedRelationships(SQLTable t) throws ArchitectException { Iterator it = t.getExportedKeys().iterator(); while (it.hasNext()) { SQLRelationship rel = (SQLRelationship) it.next(); // geneate a physical name for this relationship getPhysicalName(topLevelNames,rel); // println(""); print("ALTER TABLE "); // this works because all the tables have had their physical names generated already... printQualified(rel.getFkTable().getPhysicalName()); print(" ADD CONSTRAINT "); print(rel.getPhysicalName()); println(""); print("FOREIGN KEY ("); StringBuffer pkCols = new StringBuffer(); StringBuffer fkCols = new StringBuffer(); boolean firstCol = true; Iterator mappings = rel.getChildren().iterator(); while (mappings.hasNext()) { SQLRelationship.ColumnMapping cmap = (SQLRelationship.ColumnMapping) mappings.next(); if (!firstCol) { pkCols.append(", "); fkCols.append(", "); } // append(pkCols, cmap.getPkColumn().getPhysicalName()); append(fkCols, cmap.getFkColumn().getPhysicalName()); firstCol = false; } print(fkCols.toString()); println(")"); print("REFERENCES "); print( DDLUtils.toQualifiedName(rel.getPkTable().getCatalogName(),rel.getPkTable().getSchemaName(),rel.getPkTable().getPhysicalName()) ); print(" ("); print(pkCols.toString()); print(")"); endStatement(DDLStatement.StatementType.ADD_FK, t); } }
| 1,112,372
|
protected void writePrimaryKey(SQLTable t) throws ArchitectException { boolean firstCol = true; Iterator it = t.getColumns().iterator(); while (it.hasNext()) { SQLColumn col = (SQLColumn) it.next(); if (col.getPrimaryKeySeq() == null) break; if (firstCol) { // generate a unique primary key name getPhysicalPrimaryKeyName(topLevelNames,t); // println(""); print("ALTER TABLE "); printQualified(t.getPhysicalName()); print(" ADD CONSTRAINT "); print(t.getPhysicalPrimaryKeyName()); println(""); print("PRIMARY KEY ("); firstCol = false; } else { print(", "); } print(col.getPhysicalName()); } if (!firstCol) { print(")"); endStatement(DDLStatement.StatementType.ADD_PK, t); } }
|
protected void writePrimaryKey(SQLTable t) throws ArchitectException { boolean firstCol = true; Iterator it = t.getColumns().iterator(); while (it.hasNext()) { SQLColumn col = (SQLColumn) it.next(); if (col.getPrimaryKeySeq() == null) break; if (firstCol) { // generate a unique primary key name getPhysicalPrimaryKeyName(topLevelNames,t); // println(""); print("ALTER TABLE "); print( DDLUtils.toQualifiedName(t.getCatalogName(),t.getSchemaName(),t.getPhysicalName()) ); print(" ADD CONSTRAINT "); print(t.getPhysicalPrimaryKeyName()); println(""); print("PRIMARY KEY ("); firstCol = false; } else { print(", "); } print(col.getPhysicalName()); } if (!firstCol) { print(")"); endStatement(DDLStatement.StatementType.ADD_PK, t); } }
| 1,112,373
|
public void writeTable(SQLTable t) throws SQLException, ArchitectException { Map colNameMap = new HashMap(); // for detecting duplicate column names // generate a new physical name if necessary getPhysicalName(topLevelNames,t); // also adds generated physical name to the map print("\nCREATE TABLE "); printQualified(t.getPhysicalName()); println(" ("); boolean firstCol = true; Iterator it = t.getColumns().iterator(); while (it.hasNext()) { SQLColumn c = (SQLColumn) it.next(); // generate a new physical name if necessary if (!firstCol) println(","); print(" "); print(columnDefinition(c,colNameMap)); // XXX: default values handled only in ETL? firstCol = false; } println(""); print(")"); endStatement(DDLStatement.StatementType.CREATE, t); }
|
public void writeTable(SQLTable t) throws SQLException, ArchitectException { Map colNameMap = new HashMap(); // for detecting duplicate column names // generate a new physical name if necessary getPhysicalName(topLevelNames,t); // also adds generated physical name to the map print("\nCREATE TABLE "); print( DDLUtils.toQualifiedName(t.getCatalogName(),t.getSchemaName(),t.getPhysicalName()) ); println(" ("); boolean firstCol = true; Iterator it = t.getColumns().iterator(); while (it.hasNext()) { SQLColumn c = (SQLColumn) it.next(); // generate a new physical name if necessary if (!firstCol) println(","); print(" "); print(columnDefinition(c,colNameMap)); // XXX: default values handled only in ETL? firstCol = false; } println(""); print(")"); endStatement(DDLStatement.StatementType.CREATE, t); }
| 1,112,374
|
public boolean evaluateAsBoolean(Context context) { Object value = evaluate(context); if ( value instanceof Boolean ) { Boolean b = (Boolean) value; return b.booleanValue(); } else if ( value instanceof String ) { return Boolean.getBoolean( (String) value ); } return false; }
|
public boolean evaluateAsBoolean(JellyContext context) { Object value = evaluate(context); if ( value instanceof Boolean ) { Boolean b = (Boolean) value; return b.booleanValue(); } else if ( value instanceof String ) { return Boolean.getBoolean( (String) value ); } return false; }
| 1,112,375
|
public Iterator evaluateAsIterator(Context context) { Object value = evaluate(context); if ( value == null ) { return EMPTY_ITERATOR; } else if ( value instanceof Iterator ) { return (Iterator) value; } else if ( value instanceof List ) { List list = (List) value; return list.iterator(); } else if ( value instanceof Map ) { Map map = (Map) value; return map.entrySet().iterator(); } else if ( value.getClass().isArray() ) { return new ArrayIterator( value ); } else { // XXX: should we return single iterator? return new SingletonIterator( value ); } }
|
public Iterator evaluateAsIterator(JellyContext context) { Object value = evaluate(context); if ( value == null ) { return EMPTY_ITERATOR; } else if ( value instanceof Iterator ) { return (Iterator) value; } else if ( value instanceof List ) { List list = (List) value; return list.iterator(); } else if ( value instanceof Map ) { Map map = (Map) value; return map.entrySet().iterator(); } else if ( value.getClass().isArray() ) { return new ArrayIterator( value ); } else { // XXX: should we return single iterator? return new SingletonIterator( value ); } }
| 1,112,376
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.