bugged
stringlengths
6
599k
fixed
stringlengths
10
599k
__index_level_0__
int64
0
1.13M
public String evaluateAsString(Context context) { Object value = evaluate(context); if ( value != null ) { return value.toString(); } return null; }
public String evaluateAsString(JellyContext context) { Object value = evaluate(context); if ( value != null ) { return value.toString(); } return null; }
1,112,377
public Project getProject() { if ( project == null ) { // we may be invoked inside a child script, so lets try find the parent project project = (Project) context.findVariable( "org.apache.commons.jelly.werkz.Project" ); if ( project == null ) { project = new Project(); context.setVariable( "org.apache.commons.jelly.werkz.Project", project ); } } return project; }
public Project getProject() { if ( project == null && context != null ) { // we may be invoked inside a child script, so lets try find the parent project project = (Project) context.findVariable( "org.apache.commons.jelly.werkz.Project" ); if ( project == null && context != null ) { project = new Project(); context.setVariable( "org.apache.commons.jelly.werkz.Project", project ); } } return project; }
1,112,378
private void doColumnProfile(List<SQLColumn> columns, Connection conn) throws SQLException, ArchitectException { Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { if ( columns.size() == 0 ) return; SQLColumn col1 = columns.get(0); DDLGenerator ddlg = null; try { ddlg = (DDLGenerator) DDLUtils.createDDLGenerator( col1.getParentTable().getParentDatabase().getDataSource()); } catch (InstantiationException e1) { throw new ArchitectException("problem running Profile Manager", e1); } catch ( IllegalAccessException e1 ) { throw new ArchitectException("problem running Profile Manager", e1); } stmt = conn.createStatement(); stmt.setEscapeProcessing(false); for (SQLColumn col : columns ) { synchronized (monitorableMutex) { if (userCancel) { remove(col.getParentTable()); return; } } ProfileFunctionDescriptor pfd = ddlg.getProfileFunctionMap().get(col.getSourceDataTypeName()); ColumnProfileResult colResult = null; long profileStartTime = System.currentTimeMillis(); if ( pfd == null ) { System.out.println(col.getName()+ " Unknown DataType:(" + col.getSourceDataTypeName() + ")."); pfd = discoverProfileFunctionDescriptor(col,ddlg,conn); } try { colResult = execProfileFunction(pfd,col,ddlg,conn); } catch ( Exception ex ) { colResult = new ColumnProfileResult(col); colResult.setCreateStartTime(profileStartTime); colResult.setError(true); colResult.setException(ex); colResult.setCreateEndTime(System.currentTimeMillis()); logger.error("Error in Column Profiling: "+lastSQL, ex); } finally { putResult(colResult); } synchronized (monitorableMutex) { progress++; if (userCancel) { remove(col.getParentTable()); break; } } } // XXX: add where filter later } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } } }
private void doColumnProfile(List<SQLColumn> columns, Connection conn) throws SQLException, ArchitectException { Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { if ( columns.size() == 0 ) return; SQLColumn col1 = columns.get(0); DDLGenerator ddlg = null; try { ddlg = (DDLGenerator) DDLUtils.createDDLGenerator( col1.getParentTable().getParentDatabase().getDataSource()); } catch (InstantiationException e1) { throw new ArchitectException("problem running Profile Manager", e1); } catch ( IllegalAccessException e1 ) { throw new ArchitectException("problem running Profile Manager", e1); } stmt = conn.createStatement(); stmt.setEscapeProcessing(false); for (SQLColumn col : columns ) { synchronized (monitorableMutex) { if (userCancel) { remove(col.getParentTable()); return; } } ProfileFunctionDescriptor pfd = ddlg.getProfileFunctionMap().get(col.getSourceDataTypeName()); ColumnProfileResult colResult = null; long profileStartTime = System.currentTimeMillis(); if ( pfd == null ) { logger.debug(col.getName()+ " Unknown DataType:(" + col.getSourceDataTypeName() + ")."); pfd = discoverProfileFunctionDescriptor(col,ddlg,conn); } try { colResult = execProfileFunction(pfd,col,ddlg,conn); } catch ( Exception ex ) { colResult = new ColumnProfileResult(col); colResult.setCreateStartTime(profileStartTime); colResult.setError(true); colResult.setException(ex); colResult.setCreateEndTime(System.currentTimeMillis()); logger.error("Error in Column Profiling: "+lastSQL, ex); } finally { putResult(colResult); } synchronized (monitorableMutex) { progress++; if (userCancel) { remove(col.getParentTable()); break; } } } // XXX: add where filter later } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } } }
1,112,379
public void updateUI() { RelationshipUI ui = (RelationshipUI) BasicRelationshipUI.createUI(this); ui.installUI(this); setUI(ui); revalidate(); }
public void updateUI() { RelationshipUI ui = (RelationshipUI) IERelationshipUI.createUI(this); ui.installUI(this); setUI(ui); revalidate(); }
1,112,382
public void dPrimeDraw(String[][] table, boolean info, Vector snps, Graphics g){ int scale = table.length*30; int activeOffset = 0; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); if (info) activeOffset = labeloffset; //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale+activeOffset,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", activeOffset + shifts[0], shifts[1]); //if we know the marker names, print them down the side if (info){ g.setFont(regFont); for (int y = 0; y < table.length; y++){ String name = ((SNP)snps.elementAt(y)).getName(); g.drawString(name, labeloffset-3-regfm.stringWidth(name), y*30 + shifts[1]); } //now draw a diagonal bar showing marker spacings if (table.length > 3){ g.drawLine(labeloffset+90,5,labeloffset+scale-5,scale-90); double lineLength = Math.sqrt((scale-95)*(scale-95)*2); double start = ((SNP)snps.elementAt(0)).getPosition(); double totalLength = ((SNP)snps.elementAt(table.length-1)).getPosition() - start; int numKB = (int)(totalLength/1000); g.drawString(numKB+" Kb", labeloffset+150, 30); for (int y = 0; y < table.length; y++){ double fracLength = (((SNP)snps.elementAt(y)).getPosition() - start)/totalLength; double xOrYDist = Math.sqrt((fracLength*lineLength*fracLength*lineLength)/2); g.drawLine(labeloffset+25+y*30, 5+y*30,(int)(labeloffset+90+xOrYDist),(int)(5+xOrYDist)); } } } //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(nf.format(Float.parseFloat(st.nextToken()))); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1+activeOffset, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30+activeOffset, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30)+activeOffset,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30+activeOffset, shifts[1]+(x+1)*30); } }
public void dPrimeDraw(String[][] table, boolean info, Vector snps, Graphics g){ int scale = table.length*30; int activeOffset = 0; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); if (info) activeOffset = labeloffset; //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale+activeOffset,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", activeOffset + shifts[0], shifts[1]); //if we know the marker names, print them down the side if (info){ g.setFont(regFont); for (int y = 0; y < table.length; y++){ String name = ((SNP)snps.elementAt(y)).getName(); g.drawString(name, labeloffset-3-regfm.stringWidth(name), y*30 + shifts[1]); } //now draw a diagonal bar showing marker spacings if (table.length > 3){ g.drawLine(labeloffset+90,5,labeloffset+scale-5,scale-90); double lineLength = Math.sqrt((scale-95)*(scale-95)*2); double start = ((SNP)snps.elementAt(0)).getPosition(); double totalLength = ((SNP)snps.elementAt(table.length-1)).getPosition() - start; int numKB = (int)(totalLength/1000); g.drawString(numKB+" Kb", labeloffset+150, 30); for (int y = 0; y < table.length; y++){ double fracLength = (((SNP)snps.elementAt(y)).getPosition() - start)/totalLength; double xOrYDist = Math.sqrt((fracLength*lineLength*fracLength*lineLength)/2); g.drawLine(labeloffset+25+y*30, 5+y*30,(int)(labeloffset+90+xOrYDist),(int)(5+xOrYDist)); } } } //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(nf.format(Float.parseFloat(st.nextToken()))); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1+activeOffset, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30+activeOffset, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30)+activeOffset,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30+activeOffset, shifts[1]+(x+1)*30); } }
1,112,383
public void dPrimeDraw(String[][] table, boolean info, Vector snps, Graphics g){ int scale = table.length*30; int activeOffset = 0; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); if (info) activeOffset = labeloffset; //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale+activeOffset,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", activeOffset + shifts[0], shifts[1]); //if we know the marker names, print them down the side if (info){ g.setFont(regFont); for (int y = 0; y < table.length; y++){ String name = ((SNP)snps.elementAt(y)).getName(); g.drawString(name, labeloffset-3-regfm.stringWidth(name), y*30 + shifts[1]); } //now draw a diagonal bar showing marker spacings if (table.length > 3){ g.drawLine(labeloffset+90,5,labeloffset+scale-5,scale-90); double lineLength = Math.sqrt((scale-95)*(scale-95)*2); double start = ((SNP)snps.elementAt(0)).getPosition(); double totalLength = ((SNP)snps.elementAt(table.length-1)).getPosition() - start; int numKB = (int)(totalLength/1000); g.drawString(numKB+" Kb", labeloffset+150, 30); for (int y = 0; y < table.length; y++){ double fracLength = (((SNP)snps.elementAt(y)).getPosition() - start)/totalLength; double xOrYDist = Math.sqrt((fracLength*lineLength*fracLength*lineLength)/2); g.drawLine(labeloffset+25+y*30, 5+y*30,(int)(labeloffset+90+xOrYDist),(int)(5+xOrYDist)); } } } //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(nf.format(Float.parseFloat(st.nextToken()))); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1+activeOffset, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30+activeOffset, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30)+activeOffset,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30+activeOffset, shifts[1]+(x+1)*30); } }
public void dPrimeDraw(String[][] table, boolean info, Vector snps, Graphics g){ int scale = table.length*30; int activeOffset = 0; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); if (info) activeOffset = labeloffset; //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale+activeOffset,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", activeOffset + shifts[0], shifts[1]); //if we know the marker names, print them down the side if (info){ g.setFont(regFont); for (int y = 0; y < table.length; y++){ String name = ((SNP)snps.elementAt(y)).getName(); g.drawString(name, labeloffset-3-regfm.stringWidth(name), y*30 + shifts[1]); } //now draw a diagonal bar showing marker spacings if (table.length > 3){ g.drawLine(labeloffset+90,5,labeloffset+scale-5,scale-90); double lineLength = Math.sqrt((scale-95)*(scale-95)*2); double start = ((SNP)snps.elementAt(0)).getPosition(); double totalLength = ((SNP)snps.elementAt(table.length-1)).getPosition() - start; int numKB = (int)(totalLength/1000); g.drawString(numKB+" Kb", labeloffset+150, 30); for (int y = 0; y < table.length; y++){ double fracLength = (((SNP)snps.elementAt(y)).getPosition() - start)/totalLength; double xOrYDist = Math.sqrt((fracLength*lineLength*fracLength*lineLength)/2); g.drawLine(labeloffset+25+y*30, 5+y*30,(int)(labeloffset+90+xOrYDist),(int)(5+xOrYDist)); } } } //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(st.nextToken()); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1+activeOffset, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30+activeOffset, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30)+activeOffset,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30+activeOffset, shifts[1]+(x+1)*30); } }
1,112,384
private void runFinished() { if (!SwingUtilities.isEventDispatchThread()) { logger.error("runFinished is running on the wrong thread!"); } if (errorMessage != null) { JOptionPane.showMessageDialog(parentDialog, errorMessage, "Error", JOptionPane.ERROR_MESSAGE); } else if (!cr.isEmpty()) { Object[] messages = new Object[3]; messages[0] = "The following objects in the target database" +"\nconflict with those you wish to create:"; messages[1] = new JLabel(cr.toConflictTree()); //FIXME: needs to be in a scrollpane, but there seems to be a serious issue when this is done. messages[2] = "Do you want the Architect to drop these objects" +"\nbefore attempting to create the new ones?"; int choice = JOptionPane.showConfirmDialog( parentDialog, messages, "Conflicting Objects Found", JOptionPane.YES_NO_CANCEL_OPTION); if (choice == JOptionPane.YES_OPTION) { shouldDropConflicts = true; } else if (choice == JOptionPane.NO_OPTION) { shouldDropConflicts = false; } else if (choice == JOptionPane.CANCEL_OPTION) { shouldDropConflicts = false; nextProcess = null; } } if (nextProcess != null) { new Thread(nextProcess).start(); } }
private void runFinished() { if (!SwingUtilities.isEventDispatchThread()) { logger.error("runFinished is running on the wrong thread!"); } if (errorMessage != null) { JOptionPane.showMessageDialog(parentDialog, errorMessage, "Error", JOptionPane.ERROR_MESSAGE); } else if (!cr.isEmpty()) { Object[] messages = new Object[3]; messages[0] = "The following objects in the target database" +"\nconflict with those you wish to create:"; JTextArea conflictsPane = new JTextArea(cr.toConflictTree()); conflictsPane.setRows(15); conflictsPane.setEditable(false); messages[1] = new JScrollPane(conflictsPane); //FIXME: needs to be in a scrollpane, but there seems to be a serious issue when this is done. messages[2] = "Do you want the Architect to drop these objects" +"\nbefore attempting to create the new ones?"; int choice = JOptionPane.showConfirmDialog( parentDialog, messages, "Conflicting Objects Found", JOptionPane.YES_NO_CANCEL_OPTION); if (choice == JOptionPane.YES_OPTION) { shouldDropConflicts = true; } else if (choice == JOptionPane.NO_OPTION) { shouldDropConflicts = false; } else if (choice == JOptionPane.CANCEL_OPTION) { shouldDropConflicts = false; nextProcess = null; } } if (nextProcess != null) { new Thread(nextProcess).start(); } }
1,112,387
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; 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" + "-ha <hapsfile> specify an input file in .haps format\n" + "-a <hapmapfile> specify an input file in HapMap 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" + " note: -d defaults to no blocks output. use -o to also output blocks\n" + "-o <SFS,GAM,MJD,ALL> output type. SFS, 4 gamete, MJD output or all 3. default is SFS.\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")) { 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")){ outputType = 0; } else if(args[i].equals("GAM")){ outputType = 1; } else if(args[i].equals("MJD")){ outputType = 2; } else if(args[i].equals("ALL")) { outputType = 3; } } else { //defaults to SFS output outputType =0; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = 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("")) && !outputDprime ) { outputType = 0; 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; }
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; 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" + "-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" + " note: -d defaults to no blocks output. use -o to also output blocks\n" + "-o <SFS,GAM,MJD,ALL> output type. SFS, 4 gamete, MJD output or all 3. default is SFS.\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")) { 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")){ outputType = 0; } else if(args[i].equals("GAM")){ outputType = 1; } else if(args[i].equals("MJD")){ outputType = 2; } else if(args[i].equals("ALL")) { outputType = 3; } } else { //defaults to SFS output outputType =0; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = 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("")) && !outputDprime ) { outputType = 0; 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; }
1,112,388
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; 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" + "-ha <hapsfile> specify an input file in .haps format\n" + "-a <hapmapfile> specify an input file in HapMap 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" + " note: -d defaults to no blocks output. use -o to also output blocks\n" + "-o <SFS,GAM,MJD,ALL> output type. SFS, 4 gamete, MJD output or all 3. default is SFS.\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")) { 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")){ outputType = 0; } else if(args[i].equals("GAM")){ outputType = 1; } else if(args[i].equals("MJD")){ outputType = 2; } else if(args[i].equals("ALL")) { outputType = 3; } } else { //defaults to SFS output outputType =0; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = 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("")) && !outputDprime ) { outputType = 0; 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; }
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; 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" + "-ha <hapsfile> specify an input file in .haps format\n" + "-a <hapmapfile> specify an input file in HapMap 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" + " note: -d defaults to no blocks output. use -o to also output blocks\n" + "-o <SFS,GAM,MJD,ALL> output type. SFS, 4 gamete, MJD output or all 3. default is SFS.\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")) { 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")){ outputType = 0; } else if(args[i].equals("GAM")){ outputType = 1; } else if(args[i].equals("MJD")){ outputType = 2; } else if(args[i].equals("ALL")) { outputType = 3; } } else { //defaults to SFS output outputType =0; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = 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("")) && !outputDprime ) { outputType = 0; 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; }
1,112,389
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; 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" + "-ha <hapsfile> specify an input file in .haps format\n" + "-a <hapmapfile> specify an input file in HapMap 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" + " note: -d defaults to no blocks output. use -o to also output blocks\n" + "-o <SFS,GAM,MJD,ALL> output type. SFS, 4 gamete, MJD output or all 3. default is SFS.\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")) { 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")){ outputType = 0; } else if(args[i].equals("GAM")){ outputType = 1; } else if(args[i].equals("MJD")){ outputType = 2; } else if(args[i].equals("ALL")) { outputType = 3; } } else { //defaults to SFS output outputType =0; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = 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("")) && !outputDprime ) { outputType = 0; 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; }
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; 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" + "-ha <hapsfile> specify an input file in .haps format\n" + "-a <hapmapfile> specify an input file in HapMap 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" + " note: -d defaults to no blocks output. use -o to also output blocks\n" + "-o <SFS,GAM,MJD,ALL> output type. SFS, 4 gamete, MJD output or all 3. default is SFS.\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")){ outputType = 0; } else if(args[i].equals("GAM")){ outputType = 1; } else if(args[i].equals("MJD")){ outputType = 2; } else if(args[i].equals("ALL")) { outputType = 3; } } else { //defaults to SFS output outputType =0; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = 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("")) && !outputDprime ) { outputType = 0; 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; }
1,112,390
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; 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" + "-ha <hapsfile> specify an input file in .haps format\n" + "-a <hapmapfile> specify an input file in HapMap 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" + " note: -d defaults to no blocks output. use -o to also output blocks\n" + "-o <SFS,GAM,MJD,ALL> output type. SFS, 4 gamete, MJD output or all 3. default is SFS.\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")) { 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")){ outputType = 0; } else if(args[i].equals("GAM")){ outputType = 1; } else if(args[i].equals("MJD")){ outputType = 2; } else if(args[i].equals("ALL")) { outputType = 3; } } else { //defaults to SFS output outputType =0; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = 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("")) && !outputDprime ) { outputType = 0; 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; }
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; 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" + "-ha <hapsfile> specify an input file in .haps format\n" + "-a <hapmapfile> specify an input file in HapMap 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" + " note: -d defaults to no blocks output. use -o to also output blocks\n" + "-o <SFS,GAM,MJD,ALL> output type. SFS, 4 gamete, MJD output or all 3. default is SFS.\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")) { 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")){ outputType = 0; } else if(args[i].equals("GAM")){ outputType = 1; } else if(args[i].equals("MJD")){ outputType = 2; } else if(args[i].equals("ALL")) { outputType = 3; } } else { //defaults to SFS output outputType =0; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = 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("")) && !outputDprime && !outputCheck) { outputType = 0; 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; }
1,112,391
private void processFile(String fileName,int fileType,String infoFileName){ try { int outputType; long maxDistance; long negMaxDistance; 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; negMaxDistance = -maxDistance; outputType = this.arg_output; textData = new HaploData(); 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)); } } } }*/ textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile textData.linkageToChrom(inputFile,4,arg_skipCheck); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); if(!infoFileName.equals("")) { File infoFile = new File(infoFileName); if(infoFile.exists()) { textData.prepareMarkerInput(infoFile,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; } else if(!this.arg_quiet) { System.out.println("info file " + infoFileName + " does not exist"); } } else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } if(this.arg_showCheck && result != null) { System.out.println("Data check results:\n" + "Name\t\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } if(outputType != -1){ textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; switch(outputType){ case 0: OutputFile = new File(fileName + ".SFSblocks"); break; case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } //this handles output type ALL if(outputType == 3) { OutputFile = new File(fileName + ".SFSblocks"); textData.guessBlocks(0); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(1); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".MJDblocks"); textData.guessBlocks(2); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType); 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); }else{ //this means that we're just writing dprime so we won't //keep the (potentially huge) dprime table in memory but instead //write out one line at a time forget FileWriter saveDprimeWriter = new FileWriter(OutputFile); if (textData.infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + linkageResult.toString() + "\t" + dist + "\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + linkageResult + "\n"); } } } } } saveDprimeWriter.close(); } } //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){ try { int outputType; long maxDistance; long negMaxDistance; 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; negMaxDistance = -maxDistance; outputType = this.arg_output; textData = new HaploData(); 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 textData.linkageToChrom(inputFile,4,arg_skipCheck); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); if(!infoFileName.equals("")) { File infoFile = new File(infoFileName); if(infoFile.exists()) { textData.prepareMarkerInput(infoFile,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; } else if(!this.arg_quiet) { System.out.println("info file " + infoFileName + " does not exist"); } } else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } if(this.arg_showCheck && result != null) { System.out.println("Data check results:\n" + "Name\t\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } if(outputType != -1){ textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; switch(outputType){ case 0: OutputFile = new File(fileName + ".SFSblocks"); break; case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } //this handles output type ALL if(outputType == 3) { OutputFile = new File(fileName + ".SFSblocks"); textData.guessBlocks(0); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(1); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".MJDblocks"); textData.guessBlocks(2); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType); 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); }else{ //this means that we're just writing dprime so we won't //keep the (potentially huge) dprime table in memory but instead //write out one line at a time forget FileWriter saveDprimeWriter = new FileWriter(OutputFile); if (textData.infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + linkageResult.toString() + "\t" + dist + "\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + linkageResult + "\n"); } } } } } saveDprimeWriter.close(); } } //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,393
private void processFile(String fileName,int fileType,String infoFileName){ try { int outputType; long maxDistance; long negMaxDistance; 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; negMaxDistance = -maxDistance; outputType = this.arg_output; textData = new HaploData(); 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)); } } } }*/ textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile textData.linkageToChrom(inputFile,4,arg_skipCheck); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); if(!infoFileName.equals("")) { File infoFile = new File(infoFileName); if(infoFile.exists()) { textData.prepareMarkerInput(infoFile,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; } else if(!this.arg_quiet) { System.out.println("info file " + infoFileName + " does not exist"); } } else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } if(this.arg_showCheck && result != null) { System.out.println("Data check results:\n" + "Name\t\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } if(outputType != -1){ textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; switch(outputType){ case 0: OutputFile = new File(fileName + ".SFSblocks"); break; case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } //this handles output type ALL if(outputType == 3) { OutputFile = new File(fileName + ".SFSblocks"); textData.guessBlocks(0); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(1); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".MJDblocks"); textData.guessBlocks(2); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType); 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); }else{ //this means that we're just writing dprime so we won't //keep the (potentially huge) dprime table in memory but instead //write out one line at a time forget FileWriter saveDprimeWriter = new FileWriter(OutputFile); if (textData.infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + linkageResult.toString() + "\t" + dist + "\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + linkageResult + "\n"); } } } } } saveDprimeWriter.close(); } } //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){ try { int outputType; long maxDistance; long negMaxDistance; 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; negMaxDistance = -maxDistance; outputType = this.arg_output; textData = new HaploData(); 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)); } } } }*/ textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile textData.linkageToChrom(inputFile,4,arg_skipCheck); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); if(!infoFileName.equals("")) { File infoFile = new File(infoFileName); if(infoFile.exists()) { textData.prepareMarkerInput(infoFile,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; } else if(!this.arg_quiet) { System.out.println("info file " + infoFileName + " does not exist"); } } else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } if(this.arg_showCheck && result != null) { System.out.println("Data check results:\n" + "Name\t\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } if(outputType != -1){ textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; switch(outputType){ case 0: OutputFile = new File(fileName + ".SFSblocks"); break; case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } //this handles output type ALL if(outputType == 3) { OutputFile = new File(fileName + ".SFSblocks"); textData.guessBlocks(0); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(1); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".MJDblocks"); textData.guessBlocks(2); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType); 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); }else{ //this means that we're just writing dprime so we won't //keep the (potentially huge) dprime table in memory but instead //write out one line at a time forget FileWriter saveDprimeWriter = new FileWriter(OutputFile); if (textData.infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + linkageResult.toString() + "\t" + dist + "\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + linkageResult + "\n"); } } } } } saveDprimeWriter.close(); } } //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,394
private void processFile(String fileName,int fileType,String infoFileName){ try { int outputType; long maxDistance; long negMaxDistance; 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; negMaxDistance = -maxDistance; outputType = this.arg_output; textData = new HaploData(); 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)); } } } }*/ textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile textData.linkageToChrom(inputFile,4,arg_skipCheck); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); if(!infoFileName.equals("")) { File infoFile = new File(infoFileName); if(infoFile.exists()) { textData.prepareMarkerInput(infoFile,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; } else if(!this.arg_quiet) { System.out.println("info file " + infoFileName + " does not exist"); } } else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } if(this.arg_showCheck && result != null) { System.out.println("Data check results:\n" + "Name\t\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } if(outputType != -1){ textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; switch(outputType){ case 0: OutputFile = new File(fileName + ".SFSblocks"); break; case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } //this handles output type ALL if(outputType == 3) { OutputFile = new File(fileName + ".SFSblocks"); textData.guessBlocks(0); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(1); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".MJDblocks"); textData.guessBlocks(2); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType); 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); }else{ //this means that we're just writing dprime so we won't //keep the (potentially huge) dprime table in memory but instead //write out one line at a time forget FileWriter saveDprimeWriter = new FileWriter(OutputFile); if (textData.infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + linkageResult.toString() + "\t" + dist + "\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + linkageResult + "\n"); } } } } } saveDprimeWriter.close(); } } //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){ try { int outputType; long maxDistance; long negMaxDistance; 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; negMaxDistance = -maxDistance; outputType = this.arg_output; textData = new HaploData(); 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)); } } } }*/ textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile textData.linkageToChrom(inputFile,4,arg_skipCheck); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); if(!infoFileName.equals("")) { File infoFile = new File(infoFileName); if(infoFile.exists()) { textData.prepareMarkerInput(infoFile,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; } else if(!this.arg_quiet) { System.out.println("info file " + infoFileName + " does not exist"); } } else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } if(this.arg_showCheck && result != null) { System.out.println("Data check results:\n" + "Name\t\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } if(outputType != -1){ textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; switch(outputType){ case 0: OutputFile = new File(fileName + ".SFSblocks"); break; case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } //this handles output type ALL if(outputType == 3) { OutputFile = new File(fileName + ".SFSblocks"); textData.guessBlocks(0); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(1); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".MJDblocks"); textData.guessBlocks(2); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType); 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); }else{ //this means that we're just writing dprime so we won't //keep the (potentially huge) dprime table in memory but instead //write out one line at a time forget FileWriter saveDprimeWriter = new FileWriter(OutputFile); if (textData.infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + linkageResult.toString() + "\t" + dist + "\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + linkageResult + "\n"); } } } } } saveDprimeWriter.close(); } } //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,395
private void processFile(String fileName,int fileType,String infoFileName){ try { int outputType; long maxDistance; long negMaxDistance; 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; negMaxDistance = -maxDistance; outputType = this.arg_output; textData = new HaploData(); 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)); } } } }*/ textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile textData.linkageToChrom(inputFile,4,arg_skipCheck); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); if(!infoFileName.equals("")) { File infoFile = new File(infoFileName); if(infoFile.exists()) { textData.prepareMarkerInput(infoFile,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; } else if(!this.arg_quiet) { System.out.println("info file " + infoFileName + " does not exist"); } } else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } if(this.arg_showCheck && result != null) { System.out.println("Data check results:\n" + "Name\t\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } if(outputType != -1){ textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; switch(outputType){ case 0: OutputFile = new File(fileName + ".SFSblocks"); break; case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } //this handles output type ALL if(outputType == 3) { OutputFile = new File(fileName + ".SFSblocks"); textData.guessBlocks(0); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(1); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".MJDblocks"); textData.guessBlocks(2); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType); 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); }else{ //this means that we're just writing dprime so we won't //keep the (potentially huge) dprime table in memory but instead //write out one line at a time forget FileWriter saveDprimeWriter = new FileWriter(OutputFile); if (textData.infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + linkageResult.toString() + "\t" + dist + "\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + linkageResult + "\n"); } } } } } saveDprimeWriter.close(); } } //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){ try { int outputType; long maxDistance; long negMaxDistance; 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; negMaxDistance = -maxDistance; outputType = this.arg_output; textData = new HaploData(); 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)); } } } }*/ textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile textData.linkageToChrom(inputFile,4,arg_skipCheck); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); if(!infoFileName.equals("")) { File infoFile = new File(infoFileName); if(infoFile.exists()) { textData.prepareMarkerInput(infoFile,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; } else if(!this.arg_quiet) { System.out.println("info file " + infoFileName + " does not exist"); } } else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } if(this.arg_showCheck && result != null) { System.out.println("Data check results:\n" + "Name\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } if(outputType != -1){ textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; switch(outputType){ case 0: OutputFile = new File(fileName + ".SFSblocks"); break; case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } //this handles output type ALL if(outputType == 3) { OutputFile = new File(fileName + ".SFSblocks"); textData.guessBlocks(0); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(1); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".MJDblocks"); textData.guessBlocks(2); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType); 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); }else{ //this means that we're just writing dprime so we won't //keep the (potentially huge) dprime table in memory but instead //write out one line at a time forget FileWriter saveDprimeWriter = new FileWriter(OutputFile); if (textData.infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + linkageResult.toString() + "\t" + dist + "\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + linkageResult + "\n"); } } } } } saveDprimeWriter.close(); } } //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,396
protected void createTypeMap() throws SQLException { typeMap = new HashMap(); typeMap.put(new Integer(Types.BIGINT), new GenericTypeDescriptor("NUMBER", Types.BIGINT, 38, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.BINARY), new GenericTypeDescriptor("RAW", Types.BINARY, 2000, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.BIT), new GenericTypeDescriptor("NUMBER", Types.BIT, 1, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.BLOB), new GenericTypeDescriptor("BLOB", Types.BLOB, 4000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.CHAR), new GenericTypeDescriptor("CHAR", Types.CHAR, 2000, "'", "'", DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.CLOB), new GenericTypeDescriptor("CLOB", Types.CLOB, 4000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.DATE), new GenericTypeDescriptor("DATE", Types.DATE, 0, "'", "'", DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.DECIMAL), new GenericTypeDescriptor("NUMBER", Types.DECIMAL, 38, null, null, DatabaseMetaData.columnNullable, true, true)); typeMap.put(new Integer(Types.DOUBLE), new GenericTypeDescriptor("NUMBER", Types.DOUBLE, 38, null, null, DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.FLOAT), new GenericTypeDescriptor("NUMBER", Types.FLOAT, 38, null, null, DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.INTEGER), new GenericTypeDescriptor("NUMBER", Types.INTEGER, 38, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.LONGVARBINARY), new GenericTypeDescriptor("LONG RAW", Types.LONGVARBINARY, 2000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.LONGVARCHAR), new GenericTypeDescriptor("VARCHAR2", Types.LONGVARCHAR, 4000, "'", "'", DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.NUMERIC), new GenericTypeDescriptor("NUMBER", Types.NUMERIC, 38, null, null, DatabaseMetaData.columnNullable, true, true)); typeMap.put(new Integer(Types.REAL), new GenericTypeDescriptor("NUMBER", Types.REAL, 38, null, null, DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.SMALLINT), new GenericTypeDescriptor("NUMBER", Types.SMALLINT, 38, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.TIME), new GenericTypeDescriptor("DATE", Types.TIME, 0, "'", "'", DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.TIMESTAMP), new GenericTypeDescriptor("DATE", Types.TIMESTAMP, 0, "'", "'", DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.TINYINT), new GenericTypeDescriptor("NUMBER", Types.TINYINT, 38, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.VARBINARY), new GenericTypeDescriptor("LONG RAW", Types.VARBINARY, 2000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.VARCHAR), new GenericTypeDescriptor("VARCHAR2", Types.VARCHAR, 4000, "'", "'", DatabaseMetaData.columnNullable, true, false)); }
protected void createTypeMap() throws SQLException { typeMap = new HashMap(); typeMap.put(new Integer(Types.BIGINT), new GenericTypeDescriptor("NUMBER", Types.BIGINT, 38, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.BINARY), new GenericTypeDescriptor("RAW", Types.BINARY, 2000, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.BIT), new GenericTypeDescriptor("NUMBER", Types.BIT, 1, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.BLOB), new GenericTypeDescriptor("BLOB", Types.BLOB, 4000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.CHAR), new GenericTypeDescriptor("CHAR", Types.CHAR, 2000, "'", "'", DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.CLOB), new GenericTypeDescriptor("CLOB", Types.CLOB, 4000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.DATE), new GenericTypeDescriptor("DATE", Types.DATE, 0, "'", "'", DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.DECIMAL), new GenericTypeDescriptor("NUMBER", Types.DECIMAL, 38, null, null, DatabaseMetaData.columnNullable, true, true)); typeMap.put(new Integer(Types.DOUBLE), new GenericTypeDescriptor("NUMBER", Types.DOUBLE, 38, null, null, DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.FLOAT), new GenericTypeDescriptor("NUMBER", Types.FLOAT, 38, null, null, DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.INTEGER), new GenericTypeDescriptor("NUMBER", Types.INTEGER, 38, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.LONGVARBINARY), new GenericTypeDescriptor("LONG RAW", Types.LONGVARBINARY, 2000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.LONGVARCHAR), new GenericTypeDescriptor("VARCHAR2", Types.LONGVARCHAR, 4000, "'", "'", DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.NUMERIC), new GenericTypeDescriptor("NUMBER", Types.NUMERIC, 38, null, null, DatabaseMetaData.columnNullable, true, true)); typeMap.put(new Integer(Types.REAL), new GenericTypeDescriptor("NUMBER", Types.REAL, 38, null, null, DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.SMALLINT), new GenericTypeDescriptor("NUMBER", Types.SMALLINT, 38, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.TIME), new GenericTypeDescriptor("DATE", Types.TIME, 0, "'", "'", DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.TIMESTAMP), new GenericTypeDescriptor("DATE", Types.TIMESTAMP, 0, "'", "'", DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.TINYINT), new GenericTypeDescriptor("NUMBER", Types.TINYINT, 38, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.LONGVARCHAR), new GenericTypeDescriptor("LONG", Types.LONGVARCHAR, 2000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.VARBINARY), new GenericTypeDescriptor("LONG RAW", Types.VARBINARY, 2000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.VARCHAR), new GenericTypeDescriptor("VARCHAR2", Types.VARCHAR, 4000, "'", "'", DatabaseMetaData.columnNullable, true, false)); }
1,112,398
public synchronized void connect() throws ArchitectException { if (connection != null) return; connection = (Connection) dbConnections.get(connectionSpec); if (connection != null) return; try { Class.forName(connectionSpec.getDriverClass()); logger.info("Driver Class "+connectionSpec.getDriverClass()+" loaded without exception"); connection = DriverManager.getConnection(connectionSpec.getUrl(), connectionSpec.getUser(), connectionSpec.getPass()); dbConnections.put(connectionSpec, connection); } catch (ClassNotFoundException e) { logger.warn("Driver Class not found"); throw new ArchitectException("dbconnect.noDriver", e); } catch (SQLException e) { throw new ArchitectException("dbconnect.connectionFailed", e); } }
public synchronized void connect() throws ArchitectException { if (connection != null) return; connection = (Connection) dbConnections.get(connectionSpec); if (connection != null) return; try { Class.forName(connectionSpec.getDriverClass()); logger.info("Driver Class "+connectionSpec.getDriverClass()+" loaded without exception"); connection = DriverManager.getConnection(connectionSpec.getUrl(), connectionSpec.getUser(), connectionSpec.getPass()); dbConnections.put(connectionSpec, connection); } catch (ClassNotFoundException e) { logger.warn("Driver Class not found"); throw new ArchitectException("dbconnect.noDriver", e); } catch (SQLException e) { throw new ArchitectException("dbconnect.connectionFailed", e); } }
1,112,399
public Connection getConnection() throws ArchitectException { if (connection == null && connectionSpec != null) connect(); return this.connection; }
public Connection getConnection() throws ArchitectException { if (connectionSpec != null) { connect(); } return this.connection; }
1,112,401
protected void setUp() throws Exception { db = new SQLDatabase(); table = new SQLTable(db,"Table1","remark1","Table",true); table2 = new SQLTable(db,"Table2","remark2","Table",true); db.addChild(0,table); col1 = new SQLColumn(table,"Column 1",1,2,3); col2 = new SQLColumn(table,"Column 2",2,3,4); col3 = new SQLColumn(table,"Column 3",1,2,3); col4 = new SQLColumn(table,"Column 4",1,2,3); col2.setAutoIncrement(false); col2.setNullable(0); col2.setPrimaryKeySeq(0); table.addColumn(col1); table.addColumn(col2); table.addColumn(col3); table2.addColumn(col4); panel = new ColumnEditPanel(table,1); super.setUp(); }
protected void setUp() throws Exception { db = new SQLDatabase(); table = new SQLTable(db,"Table1","remark1","Table",true); table2 = new SQLTable(db,"Table2","remark2","Table",true); db.addChild(0,table); col1 = new SQLColumn(table,"Column 1",1,2,3); col2 = new SQLColumn(table,"Column 2",2,3,4); col3 = new SQLColumn(table,"Column 3",1,2,3); col4 = new SQLColumn(table,"Column 4",1,2,3); col2.setAutoIncrement(false); col2.setNullable(0); col2.setPrimaryKeySeq(0); table.addColumn(col1); table.addColumn(col2); table.addColumn(col3); table2.addColumn(col4); panel = new ColumnEditPanel(table,1); super.setUp(); }
1,112,402
protected void setUp() throws Exception { db = new SQLDatabase(); table = new SQLTable(db,"Table1","remark1","Table",true); table2 = new SQLTable(db,"Table2","remark2","Table",true); db.addChild(0,table); col1 = new SQLColumn(table,"Column 1",1,2,3); col2 = new SQLColumn(table,"Column 2",2,3,4); col3 = new SQLColumn(table,"Column 3",1,2,3); col4 = new SQLColumn(table,"Column 4",1,2,3); col2.setAutoIncrement(false); col2.setNullable(0); col2.setPrimaryKeySeq(0); table.addColumn(col1); table.addColumn(col2); table.addColumn(col3); table2.addColumn(col4); panel = new ColumnEditPanel(table,1); super.setUp(); }
protected void setUp() throws Exception { db = new SQLDatabase(); table = new SQLTable(db,"Table1","remark1","Table",true); table2 = new SQLTable(db,"Table2","remark2","Table",true); db.addChild(0,table); col1 = new SQLColumn(table,"Column 1",1,2,3); col2 = new SQLColumn(table,"Column 2",2,3,4); col3 = new SQLColumn(table,"Column 3",1,2,3); col4 = new SQLColumn(table,"Column 4",1,2,3); col2.setAutoIncrement(false); col2.setNullable(DatabaseMetaData.columnNoNulls); col2.setPrimaryKeySeq(0); table.addColumn(col1); table.addColumn(col2); table.addColumn(col3); table2.addColumn(col4); panel = new ColumnEditPanel(table,1); super.setUp(); }
1,112,403
protected void setUp() throws Exception { db = new SQLDatabase(); table = new SQLTable(db,"Table1","remark1","Table",true); table2 = new SQLTable(db,"Table2","remark2","Table",true); db.addChild(0,table); col1 = new SQLColumn(table,"Column 1",1,2,3); col2 = new SQLColumn(table,"Column 2",2,3,4); col3 = new SQLColumn(table,"Column 3",1,2,3); col4 = new SQLColumn(table,"Column 4",1,2,3); col2.setAutoIncrement(false); col2.setNullable(0); col2.setPrimaryKeySeq(0); table.addColumn(col1); table.addColumn(col2); table.addColumn(col3); table2.addColumn(col4); panel = new ColumnEditPanel(table,1); super.setUp(); }
protected void setUp() throws Exception { db = new SQLDatabase(); table = new SQLTable(db,"Table1","remark1","Table",true); table2 = new SQLTable(db,"Table2","remark2","Table",true); db.addChild(0,table); col1 = new SQLColumn(table,"Column 1",1,2,3); col2 = new SQLColumn(table,"Column 2",2,3,4); col3 = new SQLColumn(table,"Column 3",1,2,3); col4 = new SQLColumn(table,"Column 4",1,2,3); col2.setAutoIncrement(false); col2.setNullable(0); col2.setPrimaryKeySeq(0); table.addColumn(col1); table.addColumn(col2); table.addColumn(col3); table2.addColumn(col4); panel = new ColumnEditPanel(table,table.getColumnIndex(col2)); super.setUp(); }
1,112,404
public void testEditColumn() { assertEquals("Wrong column name",col2.getName(),panel.getColName().getText()); assertEquals("Wrong Precision",col2.getPrecision(),((Integer) (panel.getColPrec().getValue())).intValue()); assertEquals("Wrong type",2,((SQLType)(panel.getColType().getSelectedItem())).getType()); assertEquals("Wrong Scale",col2.getScale(),((Integer) (panel.getColScale().getValue())).intValue()); assertFalse(panel.getColAutoInc().getModel().isSelected()); assertFalse(panel.getColAutoInc().getModel().isEnabled()); assertFalse(panel.getColInPK().getModel().isSelected()); assertTrue(panel.getColInPK().getModel().isEnabled()); assertFalse(panel.getColNullable().getModel().isSelected()); assertTrue(panel.getColNullable().getModel().isEnabled()); assertEquals("None Specified",panel.getSourceDB().getText()); assertEquals("None Specified",panel.getSourceTableCol().getText()); }
public void testEditColumn() throws ArchitectException { assertEquals(null, col1.getPrimaryKeySeq()); assertEquals(1, table.getColumnIndex(col2)); assertEquals("The column we're editing is not in PK", null, col2.getPrimaryKeySeq()); assertEquals("Wrong column name",col2.getName(),panel.getColName().getText()); assertEquals("Wrong Precision",col2.getPrecision(),((Integer) (panel.getColPrec().getValue())).intValue()); assertEquals("Wrong type",2,((SQLType)(panel.getColType().getSelectedItem())).getType()); assertEquals("Wrong Scale",col2.getScale(),((Integer) (panel.getColScale().getValue())).intValue()); assertFalse(panel.getColAutoInc().getModel().isSelected()); assertFalse(panel.getColAutoInc().getModel().isEnabled()); assertFalse(panel.getColInPK().getModel().isSelected()); assertTrue(panel.getColInPK().getModel().isEnabled()); assertFalse(panel.getColNullable().getModel().isSelected()); assertTrue(panel.getColNullable().getModel().isEnabled()); assertEquals("None Specified",panel.getSourceDB().getText()); assertEquals("None Specified",panel.getSourceTableCol().getText()); }
1,112,405
public void testPKColumnMoveRegression() throws ArchitectException{ SQLColumn c1 = new SQLColumn(table,"PKColumn 1",1,2,3); SQLColumn c2 = new SQLColumn(table,"PKColumn 2",1,2,3); table.addColumn(c1); table.addColumn(c2); c1.setPrimaryKeySeq(0); c2.setPrimaryKeySeq(1); assertEquals (5, table.getColumns().size()); ColumnEditPanel editPanel = new ColumnEditPanel(table,0); editPanel.applyChanges(); assertEquals (0, table.getColumnIndex(table.getColumnByName("PKColumn 1"))); }
public void testPKColumnMoveRegression() throws ArchitectException{ SQLColumn c1 = new SQLColumn(table,"PKColumn 1",1,2,3); SQLColumn c2 = new SQLColumn(table,"PKColumn 2",1,2,3); table.addColumn(c1); table.addColumn(c2); c1.setPrimaryKeySeq(0); c2.setPrimaryKeySeq(1); assertEquals (5, table.getColumns().size()); int previousIdx = table.getColumnIndex(table.getColumnByName("PKColumn 1")); ColumnEditPanel editPanel = new ColumnEditPanel(table, previousIdx); editPanel.applyChanges(); assertEquals (0, table.getColumnIndex(table.getColumnByName("PKColumn 1"))); }
1,112,406
public void testPKColumnMoveRegression() throws ArchitectException{ SQLColumn c1 = new SQLColumn(table,"PKColumn 1",1,2,3); SQLColumn c2 = new SQLColumn(table,"PKColumn 2",1,2,3); table.addColumn(c1); table.addColumn(c2); c1.setPrimaryKeySeq(0); c2.setPrimaryKeySeq(1); assertEquals (5, table.getColumns().size()); ColumnEditPanel editPanel = new ColumnEditPanel(table,0); editPanel.applyChanges(); assertEquals (0, table.getColumnIndex(table.getColumnByName("PKColumn 1"))); }
public void testPKColumnMoveRegression() throws ArchitectException{ SQLColumn c1 = new SQLColumn(table,"PKColumn 1",1,2,3); SQLColumn c2 = new SQLColumn(table,"PKColumn 2",1,2,3); table.addColumn(c1); table.addColumn(c2); c1.setPrimaryKeySeq(0); c2.setPrimaryKeySeq(1); assertEquals (5, table.getColumns().size()); ColumnEditPanel editPanel = new ColumnEditPanel(table,0); editPanel.applyChanges(); assertEquals (previousIdx, table.getColumnIndex(table.getColumnByName("PKColumn 1"))); }
1,112,407
public void doTag(final XMLOutput output) throws Exception { Border border = createBorder(); // allow some nested tags to set properties invokeBody(output); if (var != null) { context.setVariable(var, border); } else { ComponentTag tag = (ComponentTag) findAncestorWithClass( ComponentTag.class ); if ( tag != null ) { tag.setBorder(border); } else { throw new JellyException( "Either the 'var' attribute must be specified to export this Border or this tag must be nested within a JellySwing widget tag" ); } } }
public void doTag(final XMLOutput output) throws Exception { Border border = createBorder(); // allow some nested tags to set properties invokeBody(output); if (var != null) { context.setVariable(var, border); } else { ComponentTag tag = (ComponentTag) findAncestorWithClass( ComponentTag.class ); if ( tag != null ) { tag.setBorder(border); } else { throw new JellyException( "Either the 'var' attribute must be specified to export this Border or this tag must be nested within a JellySwing widget tag" ); } } }
1,112,408
public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { ApplicationForm appForm = (ApplicationForm)actionForm; String appId = ApplicationConfig.getNextApplicationId(); Integer port = appForm.getPort() != null && !"".equals(appForm.getPort()) ? new Integer(appForm.getPort()) : null; ApplicationConfig config = ApplicationConfigFactory.create(appId, appForm.getName(), appForm.getType(), appForm.getHost(), port, null, appForm.getUsername(), appForm.getPassword(), null); ApplicationConfigManager.addApplication(config); UserActivityLogger.getInstance().logActivity( context.getUser().getUsername(), "Added application with ID "+config.getApplicationId()); return mapping.findForward(Forwards.SUCCESS); }
public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { ApplicationForm appForm = (ApplicationForm)actionForm; String appId = ApplicationConfig.getNextApplicationId(); Integer port = appForm.getPort() != null && !"".equals(appForm.getPort()) ? new Integer(appForm.getPort()) : null; ApplicationConfig config = ApplicationConfigFactory.create(appId, appForm.getName(), appForm.getType(), appForm.getHost(), port, null, appForm.getUsername(), appForm.getPassword(), null); ApplicationConfigManager.addApplication(config); UserActivityLogger.getInstance().logActivity( context.getUser().getUsername(), "Added application "+ "\""+config.getName()+"\""); return mapping.findForward(Forwards.SUCCESS); }
1,112,409
public void doAssociationTests(Vector affStatus, boolean[] permuteInd) { if(superprob == null || superdata == null || realAffectedStatus == null) { return; } if(affStatus == null){ affStatus = realAffectedStatus; } if(permuteInd == null) { permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); } Vector caseCounts = new Vector(); Vector controlCounts = new Vector(); double[] tempCase, tempControl, totalCase, totalControl; if (Options.getAssocTest() == ASSOC_CC){ tempCase = new double[superprob.length]; tempControl = new double[superprob.length]; totalCase = new double[superprob.length]; totalControl = new double[superprob.length]; double tempnorm=0; for (int i = numFileteredTrios*2; i < superdata.length; i++){ for (int n=0; n<superdata[i].nsuper; n++) { if (((Integer)affStatus.elementAt(i)).intValue() == 1){ tempControl[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempControl[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; }else if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempCase[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempCase[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; } tempnorm += superdata[i].superposs[n].p; } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempCase[j] > 0.0000 || tempControl[j] > 0.0000) { totalCase[j] += (tempCase[j]/tempnorm); totalControl[j] += (tempControl[j]/tempnorm); tempCase[j]=tempControl[j]=0.0000; } } tempnorm=0.00; } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { caseCounts.add(new Double(totalCase[j])); controlCounts.add(new Double(totalControl[j])); } } } double[] tempT,totalT,tempU,totalU; Vector obsT = new Vector(); Vector obsU = new Vector(); if(Options.getAssocTest() == ASSOC_TRIO) { double tempnorm=0,product; tempT = new double[superprob.length]; totalT = new double[superprob.length]; tempU = new double[superprob.length]; totalU = new double[superprob.length]; for (int i=0; i<numFileteredTrios*2; i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempnorm=0.00; for (int n=0; n<superdata[i].nsuper; n++) { for (int m=0; m<superdata[i+1].nsuper; m++) { if(kidConsistentCache[i/2][n][m]) { product=superdata[i].superposs[n].p*superdata[i+1].superposs[m].p; /*if(i<5) { System.out.println(superdata[i+1].superposs[m].h1 + "\t" + product); } */ if(permuteInd[i]) { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempU[superdata[i].superposs[n].h1]+=product; tempT[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempU[superdata[i+1].superposs[m].h1]+=product; tempT[superdata[i+1].superposs[m].h2]+=product; } } else { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempT[superdata[i].superposs[n].h1]+=product; tempU[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempT[superdata[i+1].superposs[m].h1]+=product; tempU[superdata[i+1].superposs[m].h2]+=product; } } /* normalize by all possibilities, even double hom */ tempnorm+=product; } } } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempT[j] > 0.0000 || tempU[j] > 0.0000) { totalT[j] += (tempT[j]/tempnorm); totalU[j] += (tempU[j]/tempnorm); tempT[j]=tempU[j]=0.0000; } } tempnorm=0.00; } } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { obsT.add(new Double(totalT[j])); obsU.add(new Double(totalU[j])); } } } if (Options.getAssocTest() == ASSOC_TRIO){ this.obsT = obsT; this.obsU = obsU; } else if (Options.getAssocTest() == ASSOC_CC){ this.caseCounts = caseCounts; this.controlCounts = controlCounts; } }
public void doAssociationTests(Vector affStatus, Vector permuteInd) { if(superprob == null || superdata == null || realAffectedStatus == null) { return; } if(affStatus == null){ affStatus = realAffectedStatus; } if(permuteInd == null) { permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); } Vector caseCounts = new Vector(); Vector controlCounts = new Vector(); double[] tempCase, tempControl, totalCase, totalControl; if (Options.getAssocTest() == ASSOC_CC){ tempCase = new double[superprob.length]; tempControl = new double[superprob.length]; totalCase = new double[superprob.length]; totalControl = new double[superprob.length]; double tempnorm=0; for (int i = numFileteredTrios*2; i < superdata.length; i++){ for (int n=0; n<superdata[i].nsuper; n++) { if (((Integer)affStatus.elementAt(i)).intValue() == 1){ tempControl[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempControl[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; }else if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempCase[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempCase[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; } tempnorm += superdata[i].superposs[n].p; } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempCase[j] > 0.0000 || tempControl[j] > 0.0000) { totalCase[j] += (tempCase[j]/tempnorm); totalControl[j] += (tempControl[j]/tempnorm); tempCase[j]=tempControl[j]=0.0000; } } tempnorm=0.00; } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { caseCounts.add(new Double(totalCase[j])); controlCounts.add(new Double(totalControl[j])); } } } double[] tempT,totalT,tempU,totalU; Vector obsT = new Vector(); Vector obsU = new Vector(); if(Options.getAssocTest() == ASSOC_TRIO) { double tempnorm=0,product; tempT = new double[superprob.length]; totalT = new double[superprob.length]; tempU = new double[superprob.length]; totalU = new double[superprob.length]; for (int i=0; i<numFileteredTrios*2; i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempnorm=0.00; for (int n=0; n<superdata[i].nsuper; n++) { for (int m=0; m<superdata[i+1].nsuper; m++) { if(kidConsistentCache[i/2][n][m]) { product=superdata[i].superposs[n].p*superdata[i+1].superposs[m].p; /*if(i<5) { System.out.println(superdata[i+1].superposs[m].h1 + "\t" + product); } */ if(permuteInd[i]) { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempU[superdata[i].superposs[n].h1]+=product; tempT[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempU[superdata[i+1].superposs[m].h1]+=product; tempT[superdata[i+1].superposs[m].h2]+=product; } } else { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempT[superdata[i].superposs[n].h1]+=product; tempU[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempT[superdata[i+1].superposs[m].h1]+=product; tempU[superdata[i+1].superposs[m].h2]+=product; } } /* normalize by all possibilities, even double hom */ tempnorm+=product; } } } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempT[j] > 0.0000 || tempU[j] > 0.0000) { totalT[j] += (tempT[j]/tempnorm); totalU[j] += (tempU[j]/tempnorm); tempT[j]=tempU[j]=0.0000; } } tempnorm=0.00; } } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { obsT.add(new Double(totalT[j])); obsU.add(new Double(totalU[j])); } } } if (Options.getAssocTest() == ASSOC_TRIO){ this.obsT = obsT; this.obsU = obsU; } else if (Options.getAssocTest() == ASSOC_CC){ this.caseCounts = caseCounts; this.controlCounts = controlCounts; } }
1,112,410
public void doAssociationTests(Vector affStatus, boolean[] permuteInd) { if(superprob == null || superdata == null || realAffectedStatus == null) { return; } if(affStatus == null){ affStatus = realAffectedStatus; } if(permuteInd == null) { permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); } Vector caseCounts = new Vector(); Vector controlCounts = new Vector(); double[] tempCase, tempControl, totalCase, totalControl; if (Options.getAssocTest() == ASSOC_CC){ tempCase = new double[superprob.length]; tempControl = new double[superprob.length]; totalCase = new double[superprob.length]; totalControl = new double[superprob.length]; double tempnorm=0; for (int i = numFileteredTrios*2; i < superdata.length; i++){ for (int n=0; n<superdata[i].nsuper; n++) { if (((Integer)affStatus.elementAt(i)).intValue() == 1){ tempControl[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempControl[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; }else if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempCase[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempCase[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; } tempnorm += superdata[i].superposs[n].p; } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempCase[j] > 0.0000 || tempControl[j] > 0.0000) { totalCase[j] += (tempCase[j]/tempnorm); totalControl[j] += (tempControl[j]/tempnorm); tempCase[j]=tempControl[j]=0.0000; } } tempnorm=0.00; } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { caseCounts.add(new Double(totalCase[j])); controlCounts.add(new Double(totalControl[j])); } } } double[] tempT,totalT,tempU,totalU; Vector obsT = new Vector(); Vector obsU = new Vector(); if(Options.getAssocTest() == ASSOC_TRIO) { double tempnorm=0,product; tempT = new double[superprob.length]; totalT = new double[superprob.length]; tempU = new double[superprob.length]; totalU = new double[superprob.length]; for (int i=0; i<numFileteredTrios*2; i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempnorm=0.00; for (int n=0; n<superdata[i].nsuper; n++) { for (int m=0; m<superdata[i+1].nsuper; m++) { if(kidConsistentCache[i/2][n][m]) { product=superdata[i].superposs[n].p*superdata[i+1].superposs[m].p; /*if(i<5) { System.out.println(superdata[i+1].superposs[m].h1 + "\t" + product); } */ if(permuteInd[i]) { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempU[superdata[i].superposs[n].h1]+=product; tempT[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempU[superdata[i+1].superposs[m].h1]+=product; tempT[superdata[i+1].superposs[m].h2]+=product; } } else { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempT[superdata[i].superposs[n].h1]+=product; tempU[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempT[superdata[i+1].superposs[m].h1]+=product; tempU[superdata[i+1].superposs[m].h2]+=product; } } /* normalize by all possibilities, even double hom */ tempnorm+=product; } } } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempT[j] > 0.0000 || tempU[j] > 0.0000) { totalT[j] += (tempT[j]/tempnorm); totalU[j] += (tempU[j]/tempnorm); tempT[j]=tempU[j]=0.0000; } } tempnorm=0.00; } } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { obsT.add(new Double(totalT[j])); obsU.add(new Double(totalU[j])); } } } if (Options.getAssocTest() == ASSOC_TRIO){ this.obsT = obsT; this.obsU = obsU; } else if (Options.getAssocTest() == ASSOC_CC){ this.caseCounts = caseCounts; this.controlCounts = controlCounts; } }
public void doAssociationTests(Vector affStatus, boolean[] permuteInd) { if(superprob == null || superdata == null || realAffectedStatus == null) { return; } if(affStatus == null){ affStatus = realAffectedStatus; } if(permuteInd == null) { permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); } Vector caseCounts = new Vector(); Vector controlCounts = new Vector(); double[] tempCase, tempControl, totalCase, totalControl; if (Options.getAssocTest() == ASSOC_CC){ tempCase = new double[superprob.length]; tempControl = new double[superprob.length]; totalCase = new double[superprob.length]; totalControl = new double[superprob.length]; double tempnorm=0; for (int i = numFileteredTrios*2; i < superdata.length; i++){ for (int n=0; n<superdata[i].nsuper; n++) { if (((Integer)affStatus.elementAt(i)).intValue() == 1){ tempControl[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempControl[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; }else if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempCase[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempCase[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; } tempnorm += superdata[i].superposs[n].p; } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempCase[j] > 0.0000 || tempControl[j] > 0.0000) { totalCase[j] += (tempCase[j]/tempnorm); totalControl[j] += (tempControl[j]/tempnorm); tempCase[j]=tempControl[j]=0.0000; } } tempnorm=0.00; } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { caseCounts.add(new Double(totalCase[j])); controlCounts.add(new Double(totalControl[j])); } } } double[] tempT,totalT,tempU,totalU; Vector obsT = new Vector(); Vector obsU = new Vector(); if(Options.getAssocTest() == ASSOC_TRIO) { double tempnorm=0,product; tempT = new double[superprob.length]; totalT = new double[superprob.length]; tempU = new double[superprob.length]; totalU = new double[superprob.length]; for (int i=0; i<numFileteredTrios*2; i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempnorm=0.00; for (int n=0; n<superdata[i].nsuper; n++) { for (int m=0; m<superdata[i+1].nsuper; m++) { if(kidConsistentCache[i/2][n][m]) { product=superdata[i].superposs[n].p*superdata[i+1].superposs[m].p; /*if(i<5) { System.out.println(superdata[i+1].superposs[m].h1 + "\t" + product); } */ if(permuteInd[i]) { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempU[superdata[i].superposs[n].h1]+=product; tempT[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempU[superdata[i+1].superposs[m].h1]+=product; tempT[superdata[i+1].superposs[m].h2]+=product; } } else { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempT[superdata[i].superposs[n].h1]+=product; tempU[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempT[superdata[i+1].superposs[m].h1]+=product; tempU[superdata[i+1].superposs[m].h2]+=product; } } /* normalize by all possibilities, even double hom */ tempnorm+=product; } } } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempT[j] > 0.0000 || tempU[j] > 0.0000) { totalT[j] += (tempT[j]/tempnorm); totalU[j] += (tempU[j]/tempnorm); tempT[j]=tempU[j]=0.0000; } } tempnorm=0.00; } } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { obsT.add(new Double(totalT[j])); obsU.add(new Double(totalU[j])); } } } if (Options.getAssocTest() == ASSOC_TRIO){ this.obsT = obsT; this.obsU = obsU; } else if (Options.getAssocTest() == ASSOC_CC){ this.caseCounts = caseCounts; this.controlCounts = controlCounts; } }
1,112,411
public void doAssociationTests(Vector affStatus, boolean[] permuteInd) { if(superprob == null || superdata == null || realAffectedStatus == null) { return; } if(affStatus == null){ affStatus = realAffectedStatus; } if(permuteInd == null) { permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); } Vector caseCounts = new Vector(); Vector controlCounts = new Vector(); double[] tempCase, tempControl, totalCase, totalControl; if (Options.getAssocTest() == ASSOC_CC){ tempCase = new double[superprob.length]; tempControl = new double[superprob.length]; totalCase = new double[superprob.length]; totalControl = new double[superprob.length]; double tempnorm=0; for (int i = numFileteredTrios*2; i < superdata.length; i++){ for (int n=0; n<superdata[i].nsuper; n++) { if (((Integer)affStatus.elementAt(i)).intValue() == 1){ tempControl[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempControl[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; }else if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempCase[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempCase[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; } tempnorm += superdata[i].superposs[n].p; } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempCase[j] > 0.0000 || tempControl[j] > 0.0000) { totalCase[j] += (tempCase[j]/tempnorm); totalControl[j] += (tempControl[j]/tempnorm); tempCase[j]=tempControl[j]=0.0000; } } tempnorm=0.00; } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { caseCounts.add(new Double(totalCase[j])); controlCounts.add(new Double(totalControl[j])); } } } double[] tempT,totalT,tempU,totalU; Vector obsT = new Vector(); Vector obsU = new Vector(); if(Options.getAssocTest() == ASSOC_TRIO) { double tempnorm=0,product; tempT = new double[superprob.length]; totalT = new double[superprob.length]; tempU = new double[superprob.length]; totalU = new double[superprob.length]; for (int i=0; i<numFileteredTrios*2; i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempnorm=0.00; for (int n=0; n<superdata[i].nsuper; n++) { for (int m=0; m<superdata[i+1].nsuper; m++) { if(kidConsistentCache[i/2][n][m]) { product=superdata[i].superposs[n].p*superdata[i+1].superposs[m].p; /*if(i<5) { System.out.println(superdata[i+1].superposs[m].h1 + "\t" + product); } */ if(permuteInd[i]) { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempU[superdata[i].superposs[n].h1]+=product; tempT[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempU[superdata[i+1].superposs[m].h1]+=product; tempT[superdata[i+1].superposs[m].h2]+=product; } } else { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempT[superdata[i].superposs[n].h1]+=product; tempU[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempT[superdata[i+1].superposs[m].h1]+=product; tempU[superdata[i+1].superposs[m].h2]+=product; } } /* normalize by all possibilities, even double hom */ tempnorm+=product; } } } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempT[j] > 0.0000 || tempU[j] > 0.0000) { totalT[j] += (tempT[j]/tempnorm); totalU[j] += (tempU[j]/tempnorm); tempT[j]=tempU[j]=0.0000; } } tempnorm=0.00; } } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { obsT.add(new Double(totalT[j])); obsU.add(new Double(totalU[j])); } } } if (Options.getAssocTest() == ASSOC_TRIO){ this.obsT = obsT; this.obsU = obsU; } else if (Options.getAssocTest() == ASSOC_CC){ this.caseCounts = caseCounts; this.controlCounts = controlCounts; } }
public void doAssociationTests(Vector affStatus, boolean[] permuteInd) { if(superprob == null || superdata == null || realAffectedStatus == null) { return; } if(affStatus == null){ affStatus = realAffectedStatus; } if(permuteInd == null) { permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); } Vector caseCounts = new Vector(); Vector controlCounts = new Vector(); double[] tempCase, tempControl, totalCase, totalControl; if (Options.getAssocTest() == ASSOC_CC){ tempCase = new double[superprob.length]; tempControl = new double[superprob.length]; totalCase = new double[superprob.length]; totalControl = new double[superprob.length]; double tempnorm=0; for (int i = numFilteredTrios*2; i < superdata.length; i++){ for (int n=0; n<superdata[i].nsuper; n++) { if (((Integer)affStatus.elementAt(i)).intValue() == 1){ tempControl[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempControl[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; }else if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempCase[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempCase[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; } tempnorm += superdata[i].superposs[n].p; } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempCase[j] > 0.0000 || tempControl[j] > 0.0000) { totalCase[j] += (tempCase[j]/tempnorm); totalControl[j] += (tempControl[j]/tempnorm); tempCase[j]=tempControl[j]=0.0000; } } tempnorm=0.00; } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { caseCounts.add(new Double(totalCase[j])); controlCounts.add(new Double(totalControl[j])); } } } double[] tempT,totalT,tempU,totalU; Vector obsT = new Vector(); Vector obsU = new Vector(); if(Options.getAssocTest() == ASSOC_TRIO) { double tempnorm=0,product; tempT = new double[superprob.length]; totalT = new double[superprob.length]; tempU = new double[superprob.length]; totalU = new double[superprob.length]; for (int i=0; i<numFileteredTrios*2; i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempnorm=0.00; for (int n=0; n<superdata[i].nsuper; n++) { for (int m=0; m<superdata[i+1].nsuper; m++) { if(kidConsistentCache[i/2][n][m]) { product=superdata[i].superposs[n].p*superdata[i+1].superposs[m].p; /*if(i<5) { System.out.println(superdata[i+1].superposs[m].h1 + "\t" + product); } */ if(permuteInd[i]) { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempU[superdata[i].superposs[n].h1]+=product; tempT[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempU[superdata[i+1].superposs[m].h1]+=product; tempT[superdata[i+1].superposs[m].h2]+=product; } } else { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempT[superdata[i].superposs[n].h1]+=product; tempU[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempT[superdata[i+1].superposs[m].h1]+=product; tempU[superdata[i+1].superposs[m].h2]+=product; } } /* normalize by all possibilities, even double hom */ tempnorm+=product; } } } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempT[j] > 0.0000 || tempU[j] > 0.0000) { totalT[j] += (tempT[j]/tempnorm); totalU[j] += (tempU[j]/tempnorm); tempT[j]=tempU[j]=0.0000; } } tempnorm=0.00; } } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { obsT.add(new Double(totalT[j])); obsU.add(new Double(totalU[j])); } } } if (Options.getAssocTest() == ASSOC_TRIO){ this.obsT = obsT; this.obsU = obsU; } else if (Options.getAssocTest() == ASSOC_CC){ this.caseCounts = caseCounts; this.controlCounts = controlCounts; } }
1,112,412
public void doAssociationTests(Vector affStatus, boolean[] permuteInd) { if(superprob == null || superdata == null || realAffectedStatus == null) { return; } if(affStatus == null){ affStatus = realAffectedStatus; } if(permuteInd == null) { permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); } Vector caseCounts = new Vector(); Vector controlCounts = new Vector(); double[] tempCase, tempControl, totalCase, totalControl; if (Options.getAssocTest() == ASSOC_CC){ tempCase = new double[superprob.length]; tempControl = new double[superprob.length]; totalCase = new double[superprob.length]; totalControl = new double[superprob.length]; double tempnorm=0; for (int i = numFileteredTrios*2; i < superdata.length; i++){ for (int n=0; n<superdata[i].nsuper; n++) { if (((Integer)affStatus.elementAt(i)).intValue() == 1){ tempControl[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempControl[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; }else if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempCase[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempCase[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; } tempnorm += superdata[i].superposs[n].p; } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempCase[j] > 0.0000 || tempControl[j] > 0.0000) { totalCase[j] += (tempCase[j]/tempnorm); totalControl[j] += (tempControl[j]/tempnorm); tempCase[j]=tempControl[j]=0.0000; } } tempnorm=0.00; } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { caseCounts.add(new Double(totalCase[j])); controlCounts.add(new Double(totalControl[j])); } } } double[] tempT,totalT,tempU,totalU; Vector obsT = new Vector(); Vector obsU = new Vector(); if(Options.getAssocTest() == ASSOC_TRIO) { double tempnorm=0,product; tempT = new double[superprob.length]; totalT = new double[superprob.length]; tempU = new double[superprob.length]; totalU = new double[superprob.length]; for (int i=0; i<numFileteredTrios*2; i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempnorm=0.00; for (int n=0; n<superdata[i].nsuper; n++) { for (int m=0; m<superdata[i+1].nsuper; m++) { if(kidConsistentCache[i/2][n][m]) { product=superdata[i].superposs[n].p*superdata[i+1].superposs[m].p; /*if(i<5) { System.out.println(superdata[i+1].superposs[m].h1 + "\t" + product); } */ if(permuteInd[i]) { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempU[superdata[i].superposs[n].h1]+=product; tempT[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempU[superdata[i+1].superposs[m].h1]+=product; tempT[superdata[i+1].superposs[m].h2]+=product; } } else { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempT[superdata[i].superposs[n].h1]+=product; tempU[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempT[superdata[i+1].superposs[m].h1]+=product; tempU[superdata[i+1].superposs[m].h2]+=product; } } /* normalize by all possibilities, even double hom */ tempnorm+=product; } } } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempT[j] > 0.0000 || tempU[j] > 0.0000) { totalT[j] += (tempT[j]/tempnorm); totalU[j] += (tempU[j]/tempnorm); tempT[j]=tempU[j]=0.0000; } } tempnorm=0.00; } } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { obsT.add(new Double(totalT[j])); obsU.add(new Double(totalU[j])); } } } if (Options.getAssocTest() == ASSOC_TRIO){ this.obsT = obsT; this.obsU = obsU; } else if (Options.getAssocTest() == ASSOC_CC){ this.caseCounts = caseCounts; this.controlCounts = controlCounts; } }
public void doAssociationTests(Vector affStatus, boolean[] permuteInd) { if(superprob == null || superdata == null || realAffectedStatus == null) { return; } if(affStatus == null){ affStatus = realAffectedStatus; } if(permuteInd == null) { permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); } Vector caseCounts = new Vector(); Vector controlCounts = new Vector(); double[] tempCase, tempControl, totalCase, totalControl; if (Options.getAssocTest() == ASSOC_CC){ tempCase = new double[superprob.length]; tempControl = new double[superprob.length]; totalCase = new double[superprob.length]; totalControl = new double[superprob.length]; double tempnorm=0; for (int i = numFileteredTrios*2; i < superdata.length; i++){ for (int n=0; n<superdata[i].nsuper; n++) { if (((Integer)affStatus.elementAt(i)).intValue() == 1){ tempControl[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempControl[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; }else if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempCase[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempCase[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; } tempnorm += superdata[i].superposs[n].p; } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempCase[j] > 0.0000 || tempControl[j] > 0.0000) { totalCase[j] += (tempCase[j]/tempnorm); totalControl[j] += (tempControl[j]/tempnorm); tempCase[j]=tempControl[j]=0.0000; } } tempnorm=0.00; } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { caseCounts.add(new Double(totalCase[j])); controlCounts.add(new Double(totalControl[j])); } } } double[] tempT,totalT,tempU,totalU; Vector obsT = new Vector(); Vector obsU = new Vector(); if(Options.getAssocTest() == ASSOC_TRIO) { double tempnorm=0,product; tempT = new double[superprob.length]; totalT = new double[superprob.length]; tempU = new double[superprob.length]; totalU = new double[superprob.length]; for (int i=0; i<numFilteredTrios*2; i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempnorm=0.00; for (int n=0; n<superdata[i].nsuper; n++) { for (int m=0; m<superdata[i+1].nsuper; m++) { if(kidConsistentCache[i/2][n][m]) { product=superdata[i].superposs[n].p*superdata[i+1].superposs[m].p; /*if(i<5) { System.out.println(superdata[i+1].superposs[m].h1 + "\t" + product); } */ if(permuteInd[i]) { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempU[superdata[i].superposs[n].h1]+=product; tempT[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempU[superdata[i+1].superposs[m].h1]+=product; tempT[superdata[i+1].superposs[m].h2]+=product; } } else { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempT[superdata[i].superposs[n].h1]+=product; tempU[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempT[superdata[i+1].superposs[m].h1]+=product; tempU[superdata[i+1].superposs[m].h2]+=product; } } /* normalize by all possibilities, even double hom */ tempnorm+=product; } } } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempT[j] > 0.0000 || tempU[j] > 0.0000) { totalT[j] += (tempT[j]/tempnorm); totalU[j] += (tempU[j]/tempnorm); tempT[j]=tempU[j]=0.0000; } } tempnorm=0.00; } } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { obsT.add(new Double(totalT[j])); obsU.add(new Double(totalU[j])); } } } if (Options.getAssocTest() == ASSOC_TRIO){ this.obsT = obsT; this.obsU = obsU; } else if (Options.getAssocTest() == ASSOC_CC){ this.caseCounts = caseCounts; this.controlCounts = controlCounts; } }
1,112,413
public void doAssociationTests(Vector affStatus, boolean[] permuteInd) { if(superprob == null || superdata == null || realAffectedStatus == null) { return; } if(affStatus == null){ affStatus = realAffectedStatus; } if(permuteInd == null) { permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); } Vector caseCounts = new Vector(); Vector controlCounts = new Vector(); double[] tempCase, tempControl, totalCase, totalControl; if (Options.getAssocTest() == ASSOC_CC){ tempCase = new double[superprob.length]; tempControl = new double[superprob.length]; totalCase = new double[superprob.length]; totalControl = new double[superprob.length]; double tempnorm=0; for (int i = numFileteredTrios*2; i < superdata.length; i++){ for (int n=0; n<superdata[i].nsuper; n++) { if (((Integer)affStatus.elementAt(i)).intValue() == 1){ tempControl[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempControl[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; }else if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempCase[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempCase[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; } tempnorm += superdata[i].superposs[n].p; } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempCase[j] > 0.0000 || tempControl[j] > 0.0000) { totalCase[j] += (tempCase[j]/tempnorm); totalControl[j] += (tempControl[j]/tempnorm); tempCase[j]=tempControl[j]=0.0000; } } tempnorm=0.00; } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { caseCounts.add(new Double(totalCase[j])); controlCounts.add(new Double(totalControl[j])); } } } double[] tempT,totalT,tempU,totalU; Vector obsT = new Vector(); Vector obsU = new Vector(); if(Options.getAssocTest() == ASSOC_TRIO) { double tempnorm=0,product; tempT = new double[superprob.length]; totalT = new double[superprob.length]; tempU = new double[superprob.length]; totalU = new double[superprob.length]; for (int i=0; i<numFileteredTrios*2; i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempnorm=0.00; for (int n=0; n<superdata[i].nsuper; n++) { for (int m=0; m<superdata[i+1].nsuper; m++) { if(kidConsistentCache[i/2][n][m]) { product=superdata[i].superposs[n].p*superdata[i+1].superposs[m].p; /*if(i<5) { System.out.println(superdata[i+1].superposs[m].h1 + "\t" + product); } */ if(permuteInd[i]) { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempU[superdata[i].superposs[n].h1]+=product; tempT[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempU[superdata[i+1].superposs[m].h1]+=product; tempT[superdata[i+1].superposs[m].h2]+=product; } } else { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempT[superdata[i].superposs[n].h1]+=product; tempU[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempT[superdata[i+1].superposs[m].h1]+=product; tempU[superdata[i+1].superposs[m].h2]+=product; } } /* normalize by all possibilities, even double hom */ tempnorm+=product; } } } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempT[j] > 0.0000 || tempU[j] > 0.0000) { totalT[j] += (tempT[j]/tempnorm); totalU[j] += (tempU[j]/tempnorm); tempT[j]=tempU[j]=0.0000; } } tempnorm=0.00; } } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { obsT.add(new Double(totalT[j])); obsU.add(new Double(totalU[j])); } } } if (Options.getAssocTest() == ASSOC_TRIO){ this.obsT = obsT; this.obsU = obsU; } else if (Options.getAssocTest() == ASSOC_CC){ this.caseCounts = caseCounts; this.controlCounts = controlCounts; } }
public void doAssociationTests(Vector affStatus, boolean[] permuteInd) { if(superprob == null || superdata == null || realAffectedStatus == null) { return; } if(affStatus == null){ affStatus = realAffectedStatus; } if(permuteInd == null) { permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); } Vector caseCounts = new Vector(); Vector controlCounts = new Vector(); double[] tempCase, tempControl, totalCase, totalControl; if (Options.getAssocTest() == ASSOC_CC){ tempCase = new double[superprob.length]; tempControl = new double[superprob.length]; totalCase = new double[superprob.length]; totalControl = new double[superprob.length]; double tempnorm=0; for (int i = numFileteredTrios*2; i < superdata.length; i++){ for (int n=0; n<superdata[i].nsuper; n++) { if (((Integer)affStatus.elementAt(i)).intValue() == 1){ tempControl[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempControl[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; }else if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempCase[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempCase[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; } tempnorm += superdata[i].superposs[n].p; } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempCase[j] > 0.0000 || tempControl[j] > 0.0000) { totalCase[j] += (tempCase[j]/tempnorm); totalControl[j] += (tempControl[j]/tempnorm); tempCase[j]=tempControl[j]=0.0000; } } tempnorm=0.00; } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { caseCounts.add(new Double(totalCase[j])); controlCounts.add(new Double(totalControl[j])); } } } double[] tempT,totalT,tempU,totalU; Vector obsT = new Vector(); Vector obsU = new Vector(); if(Options.getAssocTest() == ASSOC_TRIO) { double tempnorm=0,product; tempT = new double[superprob.length]; totalT = new double[superprob.length]; tempU = new double[superprob.length]; totalU = new double[superprob.length]; for (int i=0; i<numFileteredTrios*2; i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempnorm=0.00; for (int n=0; n<superdata[i].nsuper; n++) { for (int m=0; m<superdata[i+1].nsuper; m++) { if(kidConsistentCache[i/2][n][m]) { product=superdata[i].superposs[n].p*superdata[i+1].superposs[m].p; /*if(i<5) { System.out.println(superdata[i+1].superposs[m].h1 + "\t" + product); } */ if(((Boolean)permuteInd.get(i)).booleanValue()) { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempU[superdata[i].superposs[n].h1]+=product; tempT[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempU[superdata[i+1].superposs[m].h1]+=product; tempT[superdata[i+1].superposs[m].h2]+=product; } } else { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempT[superdata[i].superposs[n].h1]+=product; tempU[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempT[superdata[i+1].superposs[m].h1]+=product; tempU[superdata[i+1].superposs[m].h2]+=product; } } /* normalize by all possibilities, even double hom */ tempnorm+=product; } } } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempT[j] > 0.0000 || tempU[j] > 0.0000) { totalT[j] += (tempT[j]/tempnorm); totalU[j] += (tempU[j]/tempnorm); tempT[j]=tempU[j]=0.0000; } } tempnorm=0.00; } } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { obsT.add(new Double(totalT[j])); obsU.add(new Double(totalU[j])); } } } if (Options.getAssocTest() == ASSOC_TRIO){ this.obsT = obsT; this.obsU = obsU; } else if (Options.getAssocTest() == ASSOC_CC){ this.caseCounts = caseCounts; this.controlCounts = controlCounts; } }
1,112,414
public void doEM(int[] theBlock) throws HaploViewException{ //break up large blocks if needed int[] block_size; if (theBlock.length < 9){ block_size = new int[1]; block_size[0] = theBlock.length; } else { //some base-8 arithmetic int ones = theBlock.length%8; int eights = (theBlock.length - ones)/8; if (ones == 0){ block_size = new int[eights]; for (int i = 0; i < eights; i++){ block_size[i]=8; } } else { block_size = new int[eights+1]; for (int i = 0; i < eights-1; i++){ block_size[i]=8; } block_size[eights-1] = (8+ones)/2; block_size[eights] = 8+ones-block_size[eights-1]; } } byte[] thisHap; Vector inputHaploSingletons = new Vector(); Vector inputHaploTrios = new Vector(); Vector affSingletons = new Vector(); Vector affTrios = new Vector(); //whichVector[i] stores a value which indicates which vector chromosome i's genotype should go in //1 indicates inputHaploSingletons (singletons), 2 indicates inputHaploTrios, //3 indicates a person from a broken trio who is treated as a singleton //0 indicates none (too much missing data) int[] whichVector = new int[chromosomes.size()]; for(int i=0;i<numTrios*4; i+=4) { Chromosome parentAFirst = (Chromosome) chromosomes.elementAt(i); Chromosome parentASecond = (Chromosome) chromosomes.elementAt(i+1); Chromosome parentBFirst = (Chromosome) chromosomes.elementAt(i+2); Chromosome parentBSecond = (Chromosome) chromosomes.elementAt(i+3); boolean tooManyMissingInASegmentA = false; boolean tooManyMissingInASegmentB = false; int totalMissingA = 0; int totalMissingB = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missingA = 0; int missingB = 0; for (int j = 0; j < block_size[n]; j++){ byte AFirstGeno = parentAFirst.getGenotype(theBlock[segmentShift+j]); byte ASecondGeno = parentASecond.getGenotype(theBlock[segmentShift+j]); byte BFirstGeno = parentBFirst.getGenotype(theBlock[segmentShift+j]); byte BSecondGeno = parentBSecond.getGenotype(theBlock[segmentShift+j]); if(AFirstGeno == 0 || ASecondGeno == 0) missingA++; if(BFirstGeno == 0 || BSecondGeno == 0) missingB++; } segmentShift += block_size[n]; if (missingA >= MISSINGLIMIT){ tooManyMissingInASegmentA = true; } if (missingB >= MISSINGLIMIT){ tooManyMissingInASegmentB = true; } totalMissingA += missingA; totalMissingB += missingB; } if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3 && !tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { //both parents are good so all 4 chroms are added as a trio whichVector[i] = 2; whichVector[i+1] = 2; whichVector[i+2] = 2; whichVector[i+3] = 2; } else if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3) { //first person good, so he's added as a singleton, other parent is dropped whichVector[i] = 3; whichVector[i+1] =3; whichVector[i+2] =0; whichVector[i+3]=0; } else if(!tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { //second person good, so he's added as a singleton, other parent is dropped whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =3; whichVector[i+3]=3; } else { //both people have too much missing data so neither is used whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =0; whichVector[i+3]=0; } } for (int i = numTrios*4; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); Chromosome nextChrom = (Chromosome)chromosomes.elementAt(++i); boolean tooManyMissingInASegment = false; int totalMissing = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missing = 0; for (int j = 0; j < block_size[n]; j++){ byte theGeno = thisChrom.getGenotype(theBlock[segmentShift+j]); byte nextGeno = nextChrom.getGenotype(theBlock[segmentShift+j]); if(theGeno == 0 || nextGeno == 0) missing++; } segmentShift += block_size[n]; if (missing >= MISSINGLIMIT){ tooManyMissingInASegment = true; } totalMissing += missing; } //we want to use chromosomes without too many missing genotypes in a given //subsegment (first term) or without too many missing genotypes in the //whole block (second term) if (!tooManyMissingInASegment && totalMissing <= 1+theBlock.length/3){ whichVector[i-1] = 1; whichVector[i] = 1; } } //we only want to add an affected status every other chromosome, so we flip this boolean each time boolean addAff = true; for (int i = 0; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); if(whichVector[i] > 0) { thisHap = new byte[theBlock.length]; for (int j = 0; j < theBlock.length; j++){ byte a1 = Chromosome.getMarker(theBlock[j]).getMajor(); byte a2 = Chromosome.getMarker(theBlock[j]).getMinor(); byte theGeno = thisChrom.getGenotype(theBlock[j]); if (theGeno >= 5){ thisHap[j] = 'h'; } else { if (theGeno == 0){ thisHap[j] = '0'; }else if (theGeno == a1){ thisHap[j] = '1'; }else if (theGeno == a2){ thisHap[j] = '2'; }else{ throw new HaploViewException("Marker with > 2 alleles: " + Chromosome.getMarker(theBlock[j]).getName()); } } } if(whichVector[i] == 1) { inputHaploSingletons.add(thisHap); if(addAff) { affSingletons.add(new Integer(thisChrom.getAffected())); } } else if(whichVector[i] ==2) { inputHaploTrios.add(thisHap); if(addAff) { affTrios.add(new Integer(thisChrom.getAffected())); } }else if (whichVector[i] == 3){ inputHaploSingletons.add(thisHap); if(addAff) { affSingletons.add(new Integer(0)); } } if(addAff) { addAff = false; } else { addAff =true; } } } numFileteredTrios = inputHaploTrios.size() / 4; inputHaploTrios.addAll(inputHaploSingletons); affTrios.addAll(affSingletons); byte[][] input_haplos = (byte[][])inputHaploTrios.toArray(new byte[0][0]); full_em_breakup(input_haplos, block_size, affTrios); }
public void doEM(int[] theBlock) throws HaploViewException{ //break up large blocks if needed int[] block_size; if (theBlock.length < 9){ block_size = new int[1]; block_size[0] = theBlock.length; } else { //some base-8 arithmetic int ones = theBlock.length%8; int eights = (theBlock.length - ones)/8; if (ones == 0){ block_size = new int[eights]; for (int i = 0; i < eights; i++){ block_size[i]=8; } } else { block_size = new int[eights+1]; for (int i = 0; i < eights-1; i++){ block_size[i]=8; } block_size[eights-1] = (8+ones)/2; block_size[eights] = 8+ones-block_size[eights-1]; } } byte[] thisHap; Vector inputHaploSingletons = new Vector(); Vector inputHaploTrios = new Vector(); Vector affSingletons = new Vector(); Vector affTrios = new Vector(); //whichVector[i] stores a value which indicates which vector chromosome i's genotype should go in //1 indicates inputHaploSingletons (singletons), 2 indicates inputHaploTrios, //3 indicates a person from a broken trio who is treated as a singleton //0 indicates none (too much missing data) int[] whichVector = new int[chromosomes.size()]; for(int i=0;i<numTrios*4; i+=4) { Chromosome parentAFirst = (Chromosome) chromosomes.elementAt(i); Chromosome parentASecond = (Chromosome) chromosomes.elementAt(i+1); Chromosome parentBFirst = (Chromosome) chromosomes.elementAt(i+2); Chromosome parentBSecond = (Chromosome) chromosomes.elementAt(i+3); boolean tooManyMissingInASegmentA = false; boolean tooManyMissingInASegmentB = false; int totalMissingA = 0; int totalMissingB = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missingA = 0; int missingB = 0; for (int j = 0; j < block_size[n]; j++){ byte AFirstGeno = parentAFirst.getGenotype(theBlock[segmentShift+j]); byte ASecondGeno = parentASecond.getGenotype(theBlock[segmentShift+j]); byte BFirstGeno = parentBFirst.getGenotype(theBlock[segmentShift+j]); byte BSecondGeno = parentBSecond.getGenotype(theBlock[segmentShift+j]); if(AFirstGeno == 0 || ASecondGeno == 0) missingA++; if(BFirstGeno == 0 || BSecondGeno == 0) missingB++; } segmentShift += block_size[n]; if (missingA >= MISSINGLIMIT){ tooManyMissingInASegmentA = true; } if (missingB >= MISSINGLIMIT){ tooManyMissingInASegmentB = true; } totalMissingA += missingA; totalMissingB += missingB; } if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3 && !tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { //both parents are good so all 4 chroms are added as a trio whichVector[i] = 2; whichVector[i+1] = 2; whichVector[i+2] = 2; whichVector[i+3] = 2; } else if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3) { //first person good, so he's added as a singleton, other parent is dropped whichVector[i] = 3; whichVector[i+1] =3; whichVector[i+2] =0; whichVector[i+3]=0; } else if(!tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { //second person good, so he's added as a singleton, other parent is dropped whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =3; whichVector[i+3]=3; } else { //both people have too much missing data so neither is used whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =0; whichVector[i+3]=0; } } for (int i = numTrios*4; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); Chromosome nextChrom = (Chromosome)chromosomes.elementAt(++i); boolean tooManyMissingInASegment = false; int totalMissing = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missing = 0; for (int j = 0; j < block_size[n]; j++){ byte theGeno = thisChrom.getGenotype(theBlock[segmentShift+j]); byte nextGeno = nextChrom.getGenotype(theBlock[segmentShift+j]); if(theGeno == 0 || nextGeno == 0) missing++; } segmentShift += block_size[n]; if (missing >= MISSINGLIMIT){ tooManyMissingInASegment = true; } totalMissing += missing; } //we want to use chromosomes without too many missing genotypes in a given //subsegment (first term) or without too many missing genotypes in the //whole block (second term) if (!tooManyMissingInASegment && totalMissing <= 1+theBlock.length/3){ whichVector[i-1] = 1; whichVector[i] = 1; } } //we only want to add an affected status every other chromosome, so we flip this boolean each time boolean addAff = true; for (int i = 0; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); if(whichVector[i] > 0) { thisHap = new byte[theBlock.length]; for (int j = 0; j < theBlock.length; j++){ byte a1 = Chromosome.getMarker(theBlock[j]).getMajor(); byte a2 = Chromosome.getMarker(theBlock[j]).getMinor(); byte theGeno = thisChrom.getGenotype(theBlock[j]); if (theGeno >= 5){ thisHap[j] = 'h'; } else { if (theGeno == 0){ thisHap[j] = '0'; }else if (theGeno == a1){ thisHap[j] = '1'; }else if (theGeno == a2){ thisHap[j] = '2'; }else{ throw new HaploViewException("Marker with > 2 alleles: " + Chromosome.getMarker(theBlock[j]).getName()); } } } if(whichVector[i] == 1) { inputHaploSingletons.add(thisHap); if(addAff) { affSingletons.add(new Integer(thisChrom.getAffected())); } } else if(whichVector[i] ==2) { inputHaploTrios.add(thisHap); if(addAff) { affTrios.add(new Integer(thisChrom.getAffected())); } }else if (whichVector[i] == 3){ inputHaploSingletons.add(thisHap); if(addAff) { affSingletons.add(new Integer(0)); } } if(addAff) { addAff = false; } else { addAff =true; } } } numFilteredTrios = inputHaploTrios.size() / 4; inputHaploTrios.addAll(inputHaploSingletons); affTrios.addAll(affSingletons); byte[][] input_haplos = (byte[][])inputHaploTrios.toArray(new byte[0][0]); full_em_breakup(input_haplos, block_size, affTrios); }
1,112,415
private void full_em_breakup( byte[][] input_haplos, int[] block_size, Vector affStatus) throws HaploViewException{ int num_poss, iter;//, maxk, numk; double total;//, maxprob; int block, start_locus, end_locus, biggest_block_size; int poss_full;//, best, h1, h2; int num_indivs=0; int num_blocks = block_size.length; int num_haplos = input_haplos.length; int num_loci = input_haplos[0].length; Recovery tempRec; if (num_loci > MAXLOCI){ throw new HaploViewException("Too many loci in a single block (> 100)"); } //figure out the size of the biggest block biggest_block_size=block_size[0]; for (int i=1; i<num_blocks; i++) { if (block_size[i] > biggest_block_size) biggest_block_size=block_size[i]; } num_poss = two_n[biggest_block_size]; data = new OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) data[i]= new OBS(); superdata = new SUPER_OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) superdata[i]= new SUPER_OBS(num_blocks); double[][] hprob = new double[num_blocks][num_poss]; int[][] hlist = new int[num_blocks][num_poss]; int[] num_hlist = new int[num_blocks]; int[] hint = new int[num_poss]; prob = new double[num_poss]; /* for trio option */ if (Options.getAssocTest() == ASSOC_TRIO) { ambighet = new int[(num_haplos/4)][num_loci]; store_dhet_status(num_haplos,num_loci,input_haplos); } end_locus=-1; //System.out.println("made it to 110"); //now we loop through the blocks for (block=0; block<num_blocks; block++) { start_locus=end_locus+1; end_locus=start_locus+block_size[block]-1; num_poss=two_n[block_size[block]]; //read_observations initializes the values in data[] (array of OBS) num_indivs=read_observations(num_haplos,num_loci,input_haplos,start_locus,end_locus); // start prob array with probabilities from full observations for (int j=0; j<num_poss; j++) { prob[j]=PSEUDOCOUNT; } total=(double)num_poss; total *= PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (int i=0; i<num_indivs; i++) { if (data[i].nposs==1) { tempRec = (Recovery)data[i].poss.elementAt(0); prob[tempRec.h1]+=1.0; prob[tempRec.h2]+=1.0; total+=2.0; } } // normalize for (int j=0; j<num_poss; j++) { prob[j] /= total; } // EM LOOP: assign ambiguous data based on p, then re-estimate p iter=0; while (iter<20) { // compute probabilities of each possible observation for (int i=0; i<num_indivs; i++) { total=0.0; for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); tempRec.p = (float)(prob[tempRec.h1]*prob[tempRec.h2]); total+=tempRec.p; } // normalize for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); tempRec.p /= total; } } // re-estimate prob for (int j=0; j<num_poss; j++) { prob[j]=1e-10; } total=num_poss*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); prob[tempRec.h1]+=tempRec.p; prob[tempRec.h2]+=tempRec.p; total+=(2.0*(tempRec.p)); } } // normalize for (int j=0; j<num_poss; j++) { prob[j] /= total; } iter++; } // printf("FINAL PROBABILITIES:\n"); int m=0; for (int j=0; j<num_poss; j++) { hint[j]=-1; if (prob[j] > .001) { // printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); hlist[block][m]=j; hprob[block][m]=prob[j]; hint[j]=m; m++; } } num_hlist[block]=m; // store current block results in super obs structure store_block_haplos(hlist, hprob, hint, block, num_indivs); } /* for each block */ poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } //TODO:System.out.println(poss_full); /* LIGATE and finish this mess :) *//* if (poss_full > 1000000) {/* what we really need to do is go through and pare backto using a smaller number (e.g., > .002, .005)//printf("too many possibilities: %d\n",poss_full);return(-5);}*/ superprob = new double[poss_full]; create_super_haplos(num_indivs,num_blocks,num_hlist); /* run standard EM on supercombos */ /* start prob array with probabilities from full observations */ for (int j=0; j<poss_full; j++) { superprob[j]=PSEUDOCOUNT; } total=(double)poss_full; total *= PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (int i=0; i<num_indivs; i++) { if (superdata[i].nsuper==1) { superprob[superdata[i].superposs[0].h1]+=1.0; superprob[superdata[i].superposs[0].h2]+=1.0; total+=2.0; } } /* normalize */ for (int j=0; j<poss_full; j++) { superprob[j] /= total; } /* EM LOOP: assign ambiguous data based on p, then re-estimate p */ iter=0; while (iter<20) { /* compute probabilities of each possible observation */ for (int i=0; i<num_indivs; i++) { total=0.0; for (int k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p = (float) (superprob[superdata[i].superposs[k].h1]* superprob[superdata[i].superposs[k].h2]); total+=superdata[i].superposs[k].p; } /* normalize */ for (int k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p /= total; } } /* re-estimate prob */ for (int j=0; j<poss_full; j++) { superprob[j]=1e-10; } total=poss_full*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<superdata[i].nsuper; k++) { superprob[superdata[i].superposs[k].h1]+=superdata[i].superposs[k].p; superprob[superdata[i].superposs[k].h2]+=superdata[i].superposs[k].p; total+=(2.0*superdata[i].superposs[k].p); } } /* normalize */ for (int j=0; j<poss_full; j++) { superprob[j] /= total; } iter++; } /* we're done - the indices of superprob now have to be decoded to reveal the actual haplotypes they represent */ if(Options.getAssocTest() == ASSOC_TRIO) { kidConsistentCache = new boolean[numFileteredTrios][][]; for(int i=0;i<numFileteredTrios*2;i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ kidConsistentCache[i/2] = new boolean[superdata[i].nsuper][]; for (int n=0; n<superdata[i].nsuper; n++) { kidConsistentCache[i/2][n] = new boolean[superdata[i+1].nsuper]; for (int m=0; m<superdata[i+1].nsuper; m++) { kidConsistentCache[i/2][n][m] = kid_consistent(superdata[i].superposs[n].h1, superdata[i+1].superposs[m].h1,num_blocks, block_size,hlist,num_hlist,i/2,num_loci); } } } } } realAffectedStatus = affStatus; doAssociationTests(affStatus, null); Vector haplos_present = new Vector(); Vector haplo_freq= new Vector(); for (int j=0; j<poss_full; j++) { if (superprob[j] > .001) { haplos_present.addElement(decode_haplo_str(j,num_blocks,block_size,hlist,num_hlist)); //sprintf(haplos_present[k],"%s",decode_haplo_str(j,num_blocks,block_size,hlist,num_hlist)); haplo_freq.addElement(new Double(superprob[j])); } } double[] freqs = new double[haplo_freq.size()]; for(int j=0;j<haplo_freq.size();j++) { freqs[j] = ((Double)haplo_freq.elementAt(j)).doubleValue(); } this.haplotypes = (int[][])haplos_present.toArray(new int[0][0]); this.frequencies = freqs; /* if (dump_phased_haplos) { if ((fpdump=fopen("emphased.haps","w"))!=NULL) { for (i=0; i<num_indivs; i++) { best=0; for (k=0; k<superdata[i].nsuper; k++) { if (superdata[i].superposs[k].p > superdata[i].superposs[best].p) { best=k; } } h1 = superdata[i].superposs[best].h1; h2 = superdata[i].superposs[best].h2; fprintf(fpdump,"%s\n",decode_haplo_str(h1,num_blocks,block_size,hlist,num_hlist)); fprintf(fpdump,"%s\n",decode_haplo_str(h2,num_blocks,block_size,hlist,num_hlist)); } fclose(fpdump); } } */ //return 0; }
private void full_em_breakup( byte[][] input_haplos, int[] block_size, Vector affStatus) throws HaploViewException{ int num_poss, iter;//, maxk, numk; double total;//, maxprob; int block, start_locus, end_locus, biggest_block_size; int poss_full;//, best, h1, h2; int num_indivs=0; int num_blocks = block_size.length; int num_haplos = input_haplos.length; int num_loci = input_haplos[0].length; Recovery tempRec; if (num_loci > MAXLOCI){ throw new HaploViewException("Too many loci in a single block (> 100)"); } //figure out the size of the biggest block biggest_block_size=block_size[0]; for (int i=1; i<num_blocks; i++) { if (block_size[i] > biggest_block_size) biggest_block_size=block_size[i]; } num_poss = two_n[biggest_block_size]; data = new OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) data[i]= new OBS(); superdata = new SUPER_OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) superdata[i]= new SUPER_OBS(num_blocks); double[][] hprob = new double[num_blocks][num_poss]; int[][] hlist = new int[num_blocks][num_poss]; int[] num_hlist = new int[num_blocks]; int[] hint = new int[num_poss]; prob = new double[num_poss]; /* for trio option */ if (Options.getAssocTest() == ASSOC_TRIO) { ambighet = new int[(num_haplos/4)][num_loci]; store_dhet_status(num_haplos,num_loci,input_haplos); } end_locus=-1; //System.out.println("made it to 110"); //now we loop through the blocks for (block=0; block<num_blocks; block++) { start_locus=end_locus+1; end_locus=start_locus+block_size[block]-1; num_poss=two_n[block_size[block]]; //read_observations initializes the values in data[] (array of OBS) num_indivs=read_observations(num_haplos,num_loci,input_haplos,start_locus,end_locus); // start prob array with probabilities from full observations for (int j=0; j<num_poss; j++) { prob[j]=PSEUDOCOUNT; } total=(double)num_poss; total *= PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (int i=0; i<num_indivs; i++) { if (data[i].nposs==1) { tempRec = (Recovery)data[i].poss.elementAt(0); prob[tempRec.h1]+=1.0; prob[tempRec.h2]+=1.0; total+=2.0; } } // normalize for (int j=0; j<num_poss; j++) { prob[j] /= total; } // EM LOOP: assign ambiguous data based on p, then re-estimate p iter=0; while (iter<20) { // compute probabilities of each possible observation for (int i=0; i<num_indivs; i++) { total=0.0; for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); tempRec.p = (float)(prob[tempRec.h1]*prob[tempRec.h2]); total+=tempRec.p; } // normalize for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); tempRec.p /= total; } } // re-estimate prob for (int j=0; j<num_poss; j++) { prob[j]=1e-10; } total=num_poss*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); prob[tempRec.h1]+=tempRec.p; prob[tempRec.h2]+=tempRec.p; total+=(2.0*(tempRec.p)); } } // normalize for (int j=0; j<num_poss; j++) { prob[j] /= total; } iter++; } // printf("FINAL PROBABILITIES:\n"); int m=0; for (int j=0; j<num_poss; j++) { hint[j]=-1; if (prob[j] > .001) { // printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); hlist[block][m]=j; hprob[block][m]=prob[j]; hint[j]=m; m++; } } num_hlist[block]=m; // store current block results in super obs structure store_block_haplos(hlist, hprob, hint, block, num_indivs); } /* for each block */ poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } //TODO:System.out.println(poss_full); /* LIGATE and finish this mess :) *//* if (poss_full > 1000000) {/* what we really need to do is go through and pare backto using a smaller number (e.g., > .002, .005)//printf("too many possibilities: %d\n",poss_full);return(-5);}*/ superprob = new double[poss_full]; create_super_haplos(num_indivs,num_blocks,num_hlist); /* run standard EM on supercombos */ /* start prob array with probabilities from full observations */ for (int j=0; j<poss_full; j++) { superprob[j]=PSEUDOCOUNT; } total=(double)poss_full; total *= PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (int i=0; i<num_indivs; i++) { if (superdata[i].nsuper==1) { superprob[superdata[i].superposs[0].h1]+=1.0; superprob[superdata[i].superposs[0].h2]+=1.0; total+=2.0; } } /* normalize */ for (int j=0; j<poss_full; j++) { superprob[j] /= total; } /* EM LOOP: assign ambiguous data based on p, then re-estimate p */ iter=0; while (iter<20) { /* compute probabilities of each possible observation */ for (int i=0; i<num_indivs; i++) { total=0.0; for (int k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p = (float) (superprob[superdata[i].superposs[k].h1]* superprob[superdata[i].superposs[k].h2]); total+=superdata[i].superposs[k].p; } /* normalize */ for (int k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p /= total; } } /* re-estimate prob */ for (int j=0; j<poss_full; j++) { superprob[j]=1e-10; } total=poss_full*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<superdata[i].nsuper; k++) { superprob[superdata[i].superposs[k].h1]+=superdata[i].superposs[k].p; superprob[superdata[i].superposs[k].h2]+=superdata[i].superposs[k].p; total+=(2.0*superdata[i].superposs[k].p); } } /* normalize */ for (int j=0; j<poss_full; j++) { superprob[j] /= total; } iter++; } /* we're done - the indices of superprob now have to be decoded to reveal the actual haplotypes they represent */ if(Options.getAssocTest() == ASSOC_TRIO) { kidConsistentCache = new boolean[numFileteredTrios][][]; for(int i=0;i<numFileteredTrios*2;i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ kidConsistentCache[i/2] = new boolean[superdata[i].nsuper][]; for (int n=0; n<superdata[i].nsuper; n++) { kidConsistentCache[i/2][n] = new boolean[superdata[i+1].nsuper]; for (int m=0; m<superdata[i+1].nsuper; m++) { kidConsistentCache[i/2][n][m] = kid_consistent(superdata[i].superposs[n].h1, superdata[i+1].superposs[m].h1,num_blocks, block_size,hlist,num_hlist,i/2,num_loci); } } } } } realAffectedStatus = affStatus; doAssociationTests(affStatus, null); Vector haplos_present = new Vector(); Vector haplo_freq= new Vector(); for (int j=0; j<poss_full; j++) { if (superprob[j] > .001) { haplos_present.addElement(decode_haplo_str(j,num_blocks,block_size,hlist,num_hlist)); //sprintf(haplos_present[k],"%s",decode_haplo_str(j,num_blocks,block_size,hlist,num_hlist)); haplo_freq.addElement(new Double(superprob[j])); } } double[] freqs = new double[haplo_freq.size()]; for(int j=0;j<haplo_freq.size();j++) { freqs[j] = ((Double)haplo_freq.elementAt(j)).doubleValue(); } this.haplotypes = (int[][])haplos_present.toArray(new int[0][0]); this.frequencies = freqs; /* if (dump_phased_haplos) { if ((fpdump=fopen("emphased.haps","w"))!=NULL) { for (i=0; i<num_indivs; i++) { best=0; for (k=0; k<superdata[i].nsuper; k++) { if (superdata[i].superposs[k].p > superdata[i].superposs[best].p) { best=k; } } h1 = superdata[i].superposs[best].h1; h2 = superdata[i].superposs[best].h2; fprintf(fpdump,"%s\n",decode_haplo_str(h1,num_blocks,block_size,hlist,num_hlist)); fprintf(fpdump,"%s\n",decode_haplo_str(h2,num_blocks,block_size,hlist,num_hlist)); } fclose(fpdump); } } */ //return 0; }
1,112,416
public Object getVariableValue( String namespaceURI, String prefix, String localName ) { return context.getVariable( localName ); }
public Object getVariableValue( String namespaceURI, String prefix, String localName ) { return context.getVariable( localName ); }
1,112,417
private SQLColumn() { }
public SQLColumn() { logger.debug("NEW COLUMN (noargs) @"+hashCode()); }
1,112,418
public void doTag(final XMLOutput output) throws Exception { if ( name == null ) { throw new MissingAttributeException( "name" ); } XMLOutput newOutput = XMLOutput.createXMLOutput(new FileOutputStream(name)); try { newOutput.startDocument(); invokeBody(newOutput); newOutput.endDocument(); } finally { newOutput.close(); } }
public void doTag(final XMLOutput output) throws Exception { if ( name == null ) { throw new MissingAttributeException( "name" ); } XMLOutput newOutput = createXMLOutput(); try { newOutput.startDocument(); invokeBody(newOutput); newOutput.endDocument(); } finally { newOutput.close(); } }
1,112,419
public void createUI() { setLayout( new BorderLayout() ); imageView = new JAIPhotoView(); scrollPane = new JScrollPane( imageView ); scrollPane.setPreferredSize( new Dimension( 500, 500 ) ); add( scrollPane, BorderLayout.CENTER ); // Listen fot resize events of the scroll area so that fitted image can // be resized as well. addComponentListener( this ); JToolBar toolbar = new JToolBar(); String[] defaultZooms = { "12%", "25%", "50%", "100%", "Fit" }; JLabel zoomLabel = new JLabel( "Zoom" ); JComboBox zoomCombo = new JComboBox( defaultZooms ); zoomCombo.setEditable( true ); zoomCombo.setSelectedItem( "Fit" ); final JAIPhotoViewer viewer = this; zoomCombo.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent ev ) { JComboBox cb = (JComboBox) ev.getSource(); String selected = (String)cb.getSelectedItem(); log.debug( "Selected: " + selected ); isFit = false; // Parse the pattern DecimalFormat percentFormat = new DecimalFormat( "#####.#%" ); if ( selected == "Fit" ) { isFit = true; log.debug( "Fitting to window" ); fit(); float newScale = getScale(); String strNewScale = "Fit"; cb.setSelectedItem( strNewScale ); } else { // Parse the number. First remove all white space to ease the parsing StringBuffer b = new StringBuffer( selected ); int spaceIndex = b.indexOf( " " ); while ( spaceIndex >= 0 ) { b.deleteCharAt( spaceIndex ); spaceIndex = b.indexOf( " " ); } selected = b.toString(); boolean success = false; float newScale = 0; try { newScale = Float.parseFloat( selected ); newScale /= 100.0; success = true; } catch (NumberFormatException e ) { // Not a float } if ( !success ) { try { newScale = percentFormat.parse( selected ).floatValue(); success = true; } catch ( ParseException e ) { } } if ( success ) { log.debug( "New scale: " + newScale ); viewer.setScale( newScale ); String strNewScale = percentFormat.format( newScale ); cb.setSelectedItem( strNewScale ); } } } }); toolbar.add( zoomLabel ); toolbar.add( zoomCombo ); add( toolbar, BorderLayout.NORTH ); }
public void createUI() { setLayout( new BorderLayout() ); imageView = new JAIPhotoView(); scrollPane = new JScrollPane( imageView ); scrollPane.setPreferredSize( new Dimension( 500, 500 ) ); add( scrollPane, BorderLayout.CENTER ); // Listen fot resize events of the scroll area so that fitted image can // be resized as well. addComponentListener( this ); JToolBar toolbar = new JToolBar(); String[] defaultZooms = { "12%", "25%", "50%", "100%", "Fit" }; JLabel zoomLabel = new JLabel( "Zoom" ); JComboBox zoomCombo = new JComboBox( defaultZooms ); zoomCombo.setEditable( true ); zoomCombo.setSelectedItem( "Fit" ); final JAIPhotoViewer viewer = this; zoomCombo.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent ev ) { JComboBox cb = (JComboBox) ev.getSource(); String selected = (String)cb.getSelectedItem(); log.debug( "Selected: " + selected ); isFit = false; // Parse the pattern DecimalFormat percentFormat = new DecimalFormat( "#####.#%" ); if ( selected == "Fit" ) { isFit = true; log.debug( "Fitting to window" ); fit(); String strNewScale = "Fit"; cb.setSelectedItem( strNewScale ); } else { // Parse the number. First remove all white space to ease the parsing StringBuffer b = new StringBuffer( selected ); int spaceIndex = b.indexOf( " " ); while ( spaceIndex >= 0 ) { b.deleteCharAt( spaceIndex ); spaceIndex = b.indexOf( " " ); } selected = b.toString(); boolean success = false; float newScale = 0; try { newScale = Float.parseFloat( selected ); newScale /= 100.0; success = true; } catch (NumberFormatException e ) { // Not a float } if ( !success ) { try { newScale = percentFormat.parse( selected ).floatValue(); success = true; } catch ( ParseException e ) { } } if ( success ) { log.debug( "New scale: " + newScale ); viewer.setScale( newScale ); String strNewScale = percentFormat.format( newScale ); cb.setSelectedItem( strNewScale ); } } } }); toolbar.add( zoomLabel ); toolbar.add( zoomCombo ); add( toolbar, BorderLayout.NORTH ); }
1,112,420
public void actionPerformed( ActionEvent ev ) { JComboBox cb = (JComboBox) ev.getSource(); String selected = (String)cb.getSelectedItem(); log.debug( "Selected: " + selected ); isFit = false; // Parse the pattern DecimalFormat percentFormat = new DecimalFormat( "#####.#%" ); if ( selected == "Fit" ) { isFit = true; log.debug( "Fitting to window" ); fit(); float newScale = getScale(); String strNewScale = "Fit"; cb.setSelectedItem( strNewScale ); } else { // Parse the number. First remove all white space to ease the parsing StringBuffer b = new StringBuffer( selected ); int spaceIndex = b.indexOf( " " ); while ( spaceIndex >= 0 ) { b.deleteCharAt( spaceIndex ); spaceIndex = b.indexOf( " " ); } selected = b.toString(); boolean success = false; float newScale = 0; try { newScale = Float.parseFloat( selected ); newScale /= 100.0; success = true; } catch (NumberFormatException e ) { // Not a float } if ( !success ) { try { newScale = percentFormat.parse( selected ).floatValue(); success = true; } catch ( ParseException e ) { } } if ( success ) { log.debug( "New scale: " + newScale ); viewer.setScale( newScale ); String strNewScale = percentFormat.format( newScale ); cb.setSelectedItem( strNewScale ); } } }
public void actionPerformed( ActionEvent ev ) { JComboBox cb = (JComboBox) ev.getSource(); String selected = (String)cb.getSelectedItem(); log.debug( "Selected: " + selected ); isFit = false; // Parse the pattern DecimalFormat percentFormat = new DecimalFormat( "#####.#%" ); if ( selected == "Fit" ) { isFit = true; log.debug( "Fitting to window" ); fit(); String strNewScale = "Fit"; cb.setSelectedItem( strNewScale ); } else { // Parse the number. First remove all white space to ease the parsing StringBuffer b = new StringBuffer( selected ); int spaceIndex = b.indexOf( " " ); while ( spaceIndex >= 0 ) { b.deleteCharAt( spaceIndex ); spaceIndex = b.indexOf( " " ); } selected = b.toString(); boolean success = false; float newScale = 0; try { newScale = Float.parseFloat( selected ); newScale /= 100.0; success = true; } catch (NumberFormatException e ) { // Not a float } if ( !success ) { try { newScale = percentFormat.parse( selected ).floatValue(); success = true; } catch ( ParseException e ) { } } if ( success ) { log.debug( "New scale: " + newScale ); viewer.setScale( newScale ); String strNewScale = percentFormat.format( newScale ); cb.setSelectedItem( strNewScale ); } } }
1,112,421
public void drawInternal(DashboardContext context, StringBuffer output) { Map<String, String> data = getData(context.getWebContext()); Select select = new Select("dummy", size, true); //select.onChange("alert(''test'');"); select.onChange("handleEvent(''" + getId() + "'', ''onChange'', this.options[this.selectedIndex].value);"); for(String id:data.keySet()){ select.addOption(id, data.get(id)); } output.append(select.draw()); }
public void drawInternal(DashboardContext context, StringBuffer output) { Map<String, String> data = getData(context.getWebContext()); Select select = new Select("dummy", size, true); //select.onChange("alert(''test'');"); final String dashboardId = context.getDashboardConfig().getDashboardId(); select.onChange("handleEvent(''" + dashboardId + "'', ''" + getId() + "'', ''onChange'', this.options[this.selectedIndex].value);"); for(String id:data.keySet()){ select.addOption(id, data.get(id)); } output.append(select.draw()); }
1,112,424
public void doTag(XMLOutput output) throws Exception { Task task = getTask(); // setDynaBean( new ConvertingWrapDynaBean( task ) ); // if the task has an addText() Method method = MethodUtils.getAccessibleMethod( taskType, "addText", addTaskParamTypes ); if (method != null) { String text = getBodyText(); Object[] args = { text }; method.invoke(task, args); } else { getBody().run(context, output); } task.perform(); }
public void doTag(XMLOutput output) throws Exception { Task task = getTask(); // setDynaBean( new ConvertingWrapDynaBean( task ) ); // if the task has an addText() Method method = MethodUtils.getAccessibleMethod( taskType, "addText", addTaskParamTypes ); if (method != null) { String text = getBodyText(); Object[] args = { text }; method.invoke(task, args); } else { invokeBody(output); } task.perform(); }
1,112,425
public Date getCreationDate() { return creationDate; }
public Date getCreationDate() { return creationDate != null ? (Date) creationDate.clone() : null; }
1,112,426
private boolean login( LoginDlg ld ) { boolean success = false; String user = ld.getUsername(); String passwd = ld.getPassword(); String dbName = ld.getDb(); log.debug( "Using configuration " + dbName ); settings.setConfiguration( dbName ); PVDatabase db = settings.getDatabase( dbName ); String sqldbName = db.getDbName(); log.debug( "Mysql DB name: " + sqldbName ); if ( sqldbName == null ) { JOptionPane.showMessageDialog( ld, "Could not find dbname for configuration " + db, "Configuration error", JOptionPane.ERROR_MESSAGE ); return false; } if ( ODMG.initODMG( user, passwd, db ) ) { log.debug( "Connection succesful!!!" ); // Login is succesfull // ld.setVisible( false ); success = true; } if ( db.getSchemaVersion() < db.CURRENT_SCHEMA_VERSION ) { String options[] = {"Proceed", "Exit Photovault"}; if ( JOptionPane.YES_OPTION == JOptionPane.showOptionDialog( ld, "The database was created with an older version of Photovault\n" + "Photovault will upgrade the database format before starting.", "Upgrade database", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, null ) ) { final SchemaUpdateAction updater = new SchemaUpdateAction( db ); SchemaUpdateStatusDlg statusDlg = new SchemaUpdateStatusDlg( null, true ); updater.addSchemaUpdateListener( statusDlg ); Thread upgradeThread = new Thread() { public void run() { updater.upgradeDatabase(); } }; upgradeThread.start(); statusDlg.setVisible( true ); success = true; } } return success; }
private boolean login( LoginDlg ld ) { boolean success = false; String user = ld.getUsername(); String passwd = ld.getPassword(); String dbName = ld.getDb(); log.debug( "Using configuration " + dbName ); settings.setConfiguration( dbName ); PVDatabase db = settings.getDatabase( dbName ); String sqldbName = db.getDbName(); log.debug( "Mysql DB name: " + sqldbName ); if ( sqldbName == null ) { JOptionPane.showMessageDialog( ld, "Could not find dbname for configuration " + db, "Configuration error", JOptionPane.ERROR_MESSAGE ); return false; } if ( ODMG.initODMG( user, passwd, db ) ) { log.debug( "Connection succesful!!!" ); // Login is succesfull // ld.setVisible( false ); success = true; } int schemaVersion = db.getSchemaVersion(); if ( schemaVersion < db.CURRENT_SCHEMA_VERSION ) { String options[] = {"Proceed", "Exit Photovault"}; if ( JOptionPane.YES_OPTION == JOptionPane.showOptionDialog( ld, "The database was created with an older version of Photovault\n" + "Photovault will upgrade the database format before starting.", "Upgrade database", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, null ) ) { final SchemaUpdateAction updater = new SchemaUpdateAction( db ); SchemaUpdateStatusDlg statusDlg = new SchemaUpdateStatusDlg( null, true ); updater.addSchemaUpdateListener( statusDlg ); Thread upgradeThread = new Thread() { public void run() { updater.upgradeDatabase(); } }; upgradeThread.start(); statusDlg.setVisible( true ); success = true; } } return success; }
1,112,427
private void makeDialog(SQLTable st, int colIdx) throws ArchitectException { if (editDialog != null) { columnEditPanel.setModel(st); columnEditPanel.selectColumn(colIdx); editDialog.setTitle("Column Properties of "+st.getName()); editDialog.setVisible(true); //editDialog.requestFocus(); } else { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(12,12)); panel.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); columnEditPanel = new ColumnEditPanel(st, colIdx); panel.add(columnEditPanel, BorderLayout.CENTER); editDialog = ArchitectPanelBuilder.createArchitectPanelDialog( columnEditPanel, ArchitectFrame.getMainInstance(), "Column Properties of "+st.getName(), "OK", new AbstractAction(){ public void actionPerformed(ActionEvent e) { columnEditPanel.applyChanges();System.out.println("applied changes:"+columnEditPanel.getColName().getText()); EditColumnAction.this.putValue(SHORT_DESCRIPTION, "Editting "+columnEditPanel.getColName().getText() ); } },null); panel.setOpaque(true); editDialog.pack(); editDialog.setLocationRelativeTo(ArchitectFrame.getMainInstance()); editDialog.setVisible(true); } }
private void makeDialog(SQLTable st, int colIdx) throws ArchitectException { if (editDialog != null) { columnEditPanel.setModel(st); columnEditPanel.selectColumn(colIdx); editDialog.setTitle("Column Properties of "+st.getName()); editDialog.setVisible(true); //editDialog.requestFocus(); } else { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(12,12)); panel.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); columnEditPanel = new ColumnEditPanel(st, colIdx); panel.add(columnEditPanel, BorderLayout.CENTER); editDialog = ArchitectPanelBuilder.createArchitectPanelDialog( columnEditPanel, ArchitectFrame.getMainInstance(), "Column Properties of "+st.getName(), "OK", new AbstractAction(){ public void actionPerformed(ActionEvent e) { columnEditPanel.applyChanges(); EditColumnAction.this.putValue(SHORT_DESCRIPTION, "Editting "+columnEditPanel.getColName().getText() ); } },null); panel.setOpaque(true); editDialog.pack(); editDialog.setLocationRelativeTo(ArchitectFrame.getMainInstance()); editDialog.setVisible(true); } }
1,112,429
public void actionPerformed(ActionEvent e) { columnEditPanel.applyChanges();System.out.println("applied changes:"+columnEditPanel.getColName().getText()); EditColumnAction.this.putValue(SHORT_DESCRIPTION, "Editting "+columnEditPanel.getColName().getText() ); }
public void actionPerformed(ActionEvent e) { columnEditPanel.applyChanges(); EditColumnAction.this.putValue(SHORT_DESCRIPTION, "Editting "+columnEditPanel.getColName().getText() ); }
1,112,430
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); int idx = tp.getSelectedColumnIndex(); try { if (idx < 0) idx = tp.getModel().getColumnsFolder().getChildCount(); } catch (ArchitectException e) { idx = 0; } tp.getModel().addColumn(idx, new SQLColumn()); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); int idx = tp.getSelectedColumnIndex(); try { if (idx < 0) idx = tp.getModel().getColumnsFolder().getChildCount(); } catch (ArchitectException e) { idx = 0; } tp.getModel().addColumn(idx, new SQLColumn()); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
1,112,431
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); int idx = tp.getSelectedColumnIndex(); try { if (idx < 0) idx = tp.getModel().getColumnsFolder().getChildCount(); } catch (ArchitectException e) { idx = 0; } tp.getModel().addColumn(idx, new SQLColumn()); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); int idx = tp.getSelectedColumnIndex(); try { if (idx < 0) idx = tp.getModel().getColumnsFolder().getChildCount(); } catch (ArchitectException e) { idx = 0; } } else if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE)) { TreePath [] selections = dbt.getSelectionPaths(); logger.debug("selections length is: " + selections.length); if (selections.length != 1) { JOptionPane.showMessageDialog(dbt, "To indicate where you would like to insert a column, please select a single item."); } else { TreePath tp = selections[0]; SQLObject so = (SQLObject) tp.getLastPathComponent(); SQLTable st = null; int idx = 0; if (so instanceof SQLTable) { logger.debug("user clicked on table, so we shall try to add a column to the end of the table."); try { st = (SQLTable) so; idx = st.getColumnsFolder().getChildCount(); } catch (ArchitectException ex) { idx = 0; } logger.debug("SQLTable click -- idx set to: " + idx); } else if (so instanceof SQLColumn) { logger.debug("trying to determine insertion index for table."); SQLColumn sc = (SQLColumn) so; st = sc.getParentTable(); idx = st.getColumnIndex(sc); if (idx == -1) { logger.debug("did not find column, inserting at start of table."); idx = 0; } } else { idx = 0; } st.addColumn(idx, new SQLColumn()); } } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
1,112,432
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); int idx = tp.getSelectedColumnIndex(); try { if (idx < 0) idx = tp.getModel().getColumnsFolder().getChildCount(); } catch (ArchitectException e) { idx = 0; } tp.getModel().addColumn(idx, new SQLColumn()); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); int idx = tp.getSelectedColumnIndex(); try { if (idx < 0) idx = tp.getModel().getColumnsFolder().getChildCount(); } catch (ArchitectException e) { idx = 0; } tp.getModel().addColumn(idx, new SQLColumn()); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
1,112,433
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
1,112,435
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); tt.add(editPanel, BorderLayout.CENTER); tabbedPane.addTab("TableProperties",tt); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
1,112,436
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
1,112,437
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
1,112,438
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
1,112,440
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
1,112,441
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
1,112,443
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.getContentPane().add(buttonPanel, BorderLayout.SOUTH); d.getContentPane().add(tabbedPane, BorderLayout.CENTER); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
1,112,444
void dropTableNoFail(Connection con, String tableName) throws SQLException { Statement stmt = null; try { stmt = con.createStatement(); stmt.executeUpdate("DROP TABLE "+tableName); } catch (SQLException e) { System.out.println("Ignoring SQLException. Assuming it means the table we tried to drop didn't exist."); e.printStackTrace(); } finally { if (stmt != null) stmt.close(); } }
private static void dropTableNoFail(Connection con, String tableName) throws SQLException { Statement stmt = null; try { stmt = con.createStatement(); stmt.executeUpdate("DROP TABLE "+tableName); } catch (SQLException e) { System.out.println("Ignoring SQLException. Assuming it means the table we tried to drop didn't exist."); e.printStackTrace(); } finally { if (stmt != null) stmt.close(); } }
1,112,445
protected void setUp() throws Exception { super.setUp(); SQLDatabase mydb = new SQLDatabase(db.getDataSource()); Connection con = mydb.getConnection(); Statement stmt = con.createStatement(); dropTableNoFail(con, "SQL_COLUMN_TEST_1PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_3PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_0PK"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_1PK (\n" + " cow numeric(11) CONSTRAINT test1pk PRIMARY KEY,\n" + " moo varchar(10),\n" + " foo char(10))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_3PK (\n" + " cow numeric(11) NOT NULL,\n" + " moo varchar(10) NOT NULL,\n" + " foo char(10) NOT NULL,\n" + " CONSTRAINT test3pk PRIMARY KEY (cow, moo, foo))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_0PK (\n" + " cow numeric(11),\n" + " moo varchar(10),\n" + " foo char(10))"); table1pk = db.getTableByName("SQL_COLUMN_TEST_1PK"); table0pk = db.getTableByName("SQL_COLUMN_TEST_0PK"); table3pk = db.getTableByName("SQL_COLUMN_TEST_3PK"); stmt.close(); //mydb.disconnect(); FIXME: this should be uncommented when bug 1005 is fixed }
protected void setUp() throws Exception { super.setUp(); SQLDatabase mydb = new SQLDatabase(db.getDataSource()); Connection con = mydb.getConnection(); Statement stmt = con.createStatement(); dropTableNoFail(con, "SQL_COLUMN_TEST_1PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_3PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_0PK"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_1PK (\n" + " cow numeric(11) CONSTRAINT test1pk PRIMARY KEY,\n" + " moo varchar(10),\n" + " foo char(10))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_3PK (\n" + " cow numeric(11) NOT NULL,\n" + " moo varchar(10) NOT NULL,\n" + " foo char(10) NOT NULL,\n" + " CONSTRAINT test3pk PRIMARY KEY (cow, moo, foo))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_0PK (\n" + " cow numeric(11),\n" + " moo varchar(10),\n" + " foo char(10))"); table1pk = db.getTableByName("SQL_COLUMN_TEST_1PK"); table0pk = db.getTableByName("SQL_COLUMN_TEST_0PK"); table3pk = db.getTableByName("SQL_COLUMN_TEST_3PK"); stmt.close(); //mydb.disconnect(); FIXME: this should be uncommented when bug 1005 is fixed }
1,112,446
protected void setUp() throws Exception { super.setUp(); SQLDatabase mydb = new SQLDatabase(db.getDataSource()); Connection con = mydb.getConnection(); Statement stmt = con.createStatement(); dropTableNoFail(con, "SQL_COLUMN_TEST_1PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_3PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_0PK"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_1PK (\n" + " cow numeric(11) CONSTRAINT test1pk PRIMARY KEY,\n" + " moo varchar(10),\n" + " foo char(10))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_3PK (\n" + " cow numeric(11) NOT NULL,\n" + " moo varchar(10) NOT NULL,\n" + " foo char(10) NOT NULL,\n" + " CONSTRAINT test3pk PRIMARY KEY (cow, moo, foo))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_0PK (\n" + " cow numeric(11),\n" + " moo varchar(10),\n" + " foo char(10))"); table1pk = db.getTableByName("SQL_COLUMN_TEST_1PK"); table0pk = db.getTableByName("SQL_COLUMN_TEST_0PK"); table3pk = db.getTableByName("SQL_COLUMN_TEST_3PK"); stmt.close(); //mydb.disconnect(); FIXME: this should be uncommented when bug 1005 is fixed }
protected void setUp() throws Exception { super.setUp(); SQLDatabase mydb = new SQLDatabase(db.getDataSource()); Connection con = mydb.getConnection(); Statement stmt = con.createStatement(); dropTableNoFail(con, "SQL_COLUMN_TEST_1PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_3PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_0PK"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_1PK (\n" + " cow numeric(11) CONSTRAINT test1pk PRIMARY KEY,\n" + " moo varchar(10),\n" + " foo char(10))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_3PK (\n" + " cow numeric(11) NOT NULL,\n" + " moo varchar(10) NOT NULL,\n" + " foo char(10) NOT NULL,\n" + " CONSTRAINT test3pk PRIMARY KEY (cow, moo, foo))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_0PK (\n" + " cow numeric(11),\n" + " moo varchar(10),\n" + " foo char(10))"); table1pk = db.getTableByName("SQL_COLUMN_TEST_1PK"); table0pk = db.getTableByName("SQL_COLUMN_TEST_0PK"); table3pk = db.getTableByName("SQL_COLUMN_TEST_3PK"); //mydb.disconnect(); FIXME: this should be uncommented when bug 1005 is fixed }
1,112,447
public File getInstanceName( PhotoInfo photo, String strExtension ) { return getNewFname( photo.getShootTime(), strExtension ); }
public File getInstanceName( PhotoInfo photo, String strExtension ) { java.util.Date d = photo.getShootTime(); if ( d == null ) { d = new java.util.Date(); } return getNewFname( d, strExtension ); }
1,112,448
private void processTextOnly(){ try { String fileName; int outputType; long maxDistance; HaploData textData; File OutputFile; File inputFile; //we use this boolean to keep track of the type of file we're processing (haps or ped) //false means haps, true means ped. boolean fileType = false; if(!this.arg_hapsfile.equals("")) { fileName = this.arg_hapsfile; fileType = false; } else { fileName = this.arg_pedfile; fileType = true; } 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; switch(outputType){ case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } textData = new HaploData(); if(!fileType){ //read in haps file textData.prepareHapsInput(inputFile); } else { //read in ped file PedFile ped; Vector pedFileStrings; BufferedReader reader; String line; Vector result; boolean[] markerResultArray; ped = new PedFile(); pedFileStrings = new Vector(); reader = new BufferedReader(new FileReader(inputFile)); while((line = reader.readLine())!=null){ pedFileStrings.add(line); } ped.parse(pedFileStrings); result = ped.check(); if(this.arg_showCheck) { System.out.println("Data check results:\n" + "Name\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr\tRating"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( currentResult.getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } markerResultArray = new boolean[ped.getNumMarkers()]; for (int i = 0; i < markerResultArray.length; i++){ if(((MarkerResult)result.get(i)).getRating() > 0) { markerResultArray[i] = true; } else { markerResultArray[i] = false; } } textData.linkageToChrom(markerResultArray,ped); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo); } textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; textData.guessBlocks(outputType); haplos = textData.generateHaplotypes(textData.blocks, 1); new TextMethods().saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } catch(IOException e){} }
private void processTextOnly(){ try { String fileName; int outputType; long maxDistance; HaploData textData; File OutputFile; File inputFile; //we use this boolean to keep track of the type of file we're processing (haps or ped) //false means haps, true means ped. boolean fileType = false; if(!this.arg_hapsfile.equals("")) { fileName = this.arg_hapsfile; fileType = false; } else { fileName = this.arg_pedfile; fileType = true; } 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; switch(outputType){ case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } textData = new HaploData(); if(!fileType){ //read in haps file textData.prepareHapsInput(inputFile); } else { //read in ped file PedFile ped; Vector pedFileStrings; BufferedReader reader; String line; Vector result; boolean[] markerResultArray; ped = new PedFile(); pedFileStrings = new Vector(); reader = new BufferedReader(new FileReader(inputFile)); while((line = reader.readLine())!=null){ pedFileStrings.add(line); } ped.parse(pedFileStrings); result = ped.check(); if(this.arg_showCheck) { System.out.println("Data check results:\n" + "Name\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr\tRating"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( currentResult.getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } markerResultArray = new boolean[ped.getNumMarkers()]; for (int i = 0; i < markerResultArray.length; i++){ if(((MarkerResult)result.get(i)).getRating() > 0) { markerResultArray[i] = true; } else { markerResultArray[i] = false; } } textData.linkageToChrom(markerResultArray,ped); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,arg_distance); } textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; textData.guessBlocks(outputType); haplos = textData.generateHaplotypes(textData.blocks, 1); new TextMethods().saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } catch(IOException e){} }
1,112,450
public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ }
public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ }
1,112,451
public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ }
public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ }
1,112,452
public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ }
public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More..."); parentMenu.add(subMenu); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ }
1,112,453
public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ }
public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ }
1,112,454
public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ }
public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ }
1,112,455
public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ }
public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ }
1,112,456
public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ }
public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ }
1,112,457
public UpdateDisplayDialog(HaploView h, String title, UpdateChecker uc) { super(h, title); JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); Font bigguns = new Font("Default", Font.PLAIN, 14); JTextArea announceArea = new JTextArea(); announceArea.setFont(bigguns); if (BETA_VERSION > 0){ announceArea.append("A newer BETA version of Haploview is available: " + uc.getNewVersion() + "beta" + uc.getNewBetaVersion() + "\n"); }else{ announceArea.append("A newer version of Haploview is available: " + uc.getNewVersion() + "\n"); } announceArea.append("\n" + WEBSITE_STRING + "\n"); announceArea.setAlignmentX(Component.CENTER_ALIGNMENT); announceArea.setEditable(false); announceArea.setOpaque(false); JPanel announcePanel = new JPanel(); announcePanel.add(announceArea); JScrollPane changeScroller = null; if (BETA_VERSION == 0){ try { JEditorPane changePane = new JEditorPane(); changePane.setEditable(false); changePane.setPage(new URL("http://www.broad.mit.edu/mpg/haploview/uc/changes.html")); changePane.setOpaque(false); changeScroller = new JScrollPane(changePane); changeScroller.setPreferredSize(new Dimension(250,150)); } catch(IOException ioe) { //if were here then we were able to check for an update, so well just show them a dialog //without listing the changes } } contents.add(announcePanel); if(changeScroller != null) { changeScroller.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel scrollHolder = new JPanel(); scrollHolder.add(changeScroller); contents.add(scrollHolder); } JButton okButton = new JButton("OK"); okButton.addActionListener(this); okButton.setAlignmentX(Component.CENTER_ALIGNMENT); contents.add(okButton); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
public UpdateDisplayDialog(HaploView h, String title, UpdateChecker uc) { super(h, title); JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); Font bigguns = new Font("Default", Font.PLAIN, 14); JTextArea announceArea = new JTextArea(); announceArea.setFont(bigguns); if (BETA_VERSION > 0 && VERSION == uc.getNewVersion()){ announceArea.append("A newer BETA version of Haploview is available: " + uc.getNewVersion() + "beta" + uc.getNewBetaVersion() + "\n"); }else{ announceArea.append("A newer version of Haploview is available: " + uc.getNewVersion() + "\n"); } announceArea.append("\n" + WEBSITE_STRING + "\n"); announceArea.setAlignmentX(Component.CENTER_ALIGNMENT); announceArea.setEditable(false); announceArea.setOpaque(false); JPanel announcePanel = new JPanel(); announcePanel.add(announceArea); JScrollPane changeScroller = null; if (BETA_VERSION == 0){ try { JEditorPane changePane = new JEditorPane(); changePane.setEditable(false); changePane.setPage(new URL("http://www.broad.mit.edu/mpg/haploview/uc/changes.html")); changePane.setOpaque(false); changeScroller = new JScrollPane(changePane); changeScroller.setPreferredSize(new Dimension(250,150)); } catch(IOException ioe) { //if were here then we were able to check for an update, so well just show them a dialog //without listing the changes } } contents.add(announcePanel); if(changeScroller != null) { changeScroller.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel scrollHolder = new JPanel(); scrollHolder.add(changeScroller); contents.add(scrollHolder); } JButton okButton = new JButton("OK"); okButton.addActionListener(this); okButton.setAlignmentX(Component.CENTER_ALIGNMENT); contents.add(okButton); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
1,112,458
public void testCreateDB() { File confFile = null; File dbDir = null; // Create an empty configuration file & volume directory try { confFile = File.createTempFile( "photovault_settings_", ".xml" ); confFile.delete(); dbDir = File.createTempFile( "photovault_test_volume", "" ); dbDir.delete(); dbDir.mkdir(); } catch (IOException ex) { ex.printStackTrace(); fail( ex.getMessage() ); } System.setProperty( "photovault.configfile", confFile.getAbsolutePath() ); PhotovaultSettings settings = PhotovaultSettings.getSettings(); PVDatabase db = new PVDatabase(); db.setDbName( "pc_testest"); Volume vol = new Volume( "testvolume", dbDir.getAbsolutePath() ); db.addVolume( vol ); settings.addDatabase( db ); settings.saveConfig(); db.createDatabase( "harri", "" ); // Verify that the database can be used by importing a file ODMG.initODMG( "harri", "", db ); File photoFile = new File( "testfiles/test1.jpg" ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB(photoFile); } catch (PhotoNotFoundException ex) { ex.printStackTrace(); fail( ex.getMessage() ); } photo.setPhotographer( "test" ); try { PhotoInfo photo2 = PhotoInfo.retrievePhotoInfo( photo.getUid() ); Thumbnail thumb = photo2.getThumbnail(); this.assertFalse( "Default thumbnail returned", thumb == Thumbnail.getDefaultThumbnail() ); } catch (PhotoNotFoundException ex) { fail( "Photo not found in database" ); } }
public void testCreateDB() { File confFile = null; File dbDir = null; // Create an empty configuration file & volume directory try { confFile = File.createTempFile( "photovault_settings_", ".xml" ); confFile.delete(); dbDir = File.createTempFile( "photovault_test_volume", "" ); dbDir.delete(); dbDir.mkdir(); } catch (IOException ex) { ex.printStackTrace(); fail( ex.getMessage() ); } System.setProperty( "photovault.configfile", confFile.getAbsolutePath() ); PhotovaultSettings settings = PhotovaultSettings.getSettings(); PVDatabase db = new PVDatabase(); db.setDbName( "pc_testest"); Volume vol = new Volume( "testvolume", dbDir.getAbsolutePath() ); db.addVolume( vol ); settings.addDatabase( db ); settings.saveConfig(); db.createDatabase( "harri", "" ); // Verify that the database can be used by importing a file ODMG.initODMG( "harri", "", db ); File photoFile = new File( "testfiles/test1.jpg" ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB(photoFile); } catch (PhotoNotFoundException ex) { ex.printStackTrace(); fail( ex.getMessage() ); } photo.setPhotographer( "test" ); try { PhotoInfo photo2 = PhotoInfo.retrievePhotoInfo( photo.getUid() ); Thumbnail thumb = photo2.getThumbnail(); this.assertFalse( "Default thumbnail returned", thumb == Thumbnail.getDefaultThumbnail() ); } catch (PhotoNotFoundException ex) { fail( "Photo not found in database" ); } }
1,112,460
public ResultSet getSchemas() throws SQLException { String catalogList = connection.getProperties().getProperty("catalogs"); MockJDBCResultSet rs = new MockJDBCResultSet(null, 2); rs.setColumnName(1, "TABLE_SCHEM"); rs.setColumnName(2, "TABLE_CATALOG"); if (getSchemaTerm() == null) { logger.debug("getSchemas: schemaTerm==null; returning empty result set"); } else if (getCatalogTerm() == null) { String schemaList = connection.getProperties().getProperty("schemas"); logger.debug("getSchemas: catalogTerm==null; schemaList="+schemaList); if (schemaList == null) throw new SQLException("Missing property: 'schemas'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, null); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+schName+"'"); } } else { logger.debug("getSchemas: database has catalogs and schemas!"); for (String catName : Arrays.asList(catalogList.split(","))) { String schemaList = connection.getProperties().getProperty("schemas."+catName); if (schemaList == null) throw new SQLException("Missing property: 'schemas."+catName+"'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, catName); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+catName+"'.'"+schName+"'"); } } } rs.beforeFirst(); return rs; }
public ResultSet getSchemas() throws SQLException { String catalogList = connection.getProperties().getProperty("catalogs"); MockJDBCResultSet rs = new MockJDBCResultSet(null, 2); rs.setColumnName(1, "TABLE_SCHEM"); rs.setColumnName(2, "TABLE_CATALOG"); if (getSchemaTerm() == null) { logger.debug("getSchemas: schemaTerm==null; returning empty result set"); } else if (getCatalogTerm() == null) { String schemaList = connection.getProperties().getProperty("schemas"); logger.debug("getSchemas: catalogTerm==null; schemaList="+schemaList); if (schemaList == null) throw new SQLException("Missing property: 'schemas'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, null); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+schName+"'"); } } else { logger.debug("getSchemas: database has catalogs and schemas!"); for (String catName : Arrays.asList(catalogList.split(","))) { String schemaList = connection.getProperties().getProperty("schemas."+catName); if (schemaList == null) throw new SQLException("Missing property: 'schemas."+catName+"'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, catName); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+catName+"'.'"+schName+"'"); } } } rs.beforeFirst(); return rs; }
1,112,461
public ResultSet getSchemas() throws SQLException { String catalogList = connection.getProperties().getProperty("catalogs"); MockJDBCResultSet rs = new MockJDBCResultSet(null, 2); rs.setColumnName(1, "TABLE_SCHEM"); rs.setColumnName(2, "TABLE_CATALOG"); if (getSchemaTerm() == null) { logger.debug("getSchemas: schemaTerm==null; returning empty result set"); } else if (getCatalogTerm() == null) { String schemaList = connection.getProperties().getProperty("schemas"); logger.debug("getSchemas: catalogTerm==null; schemaList="+schemaList); if (schemaList == null) throw new SQLException("Missing property: 'schemas'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, null); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+schName+"'"); } } else { logger.debug("getSchemas: database has catalogs and schemas!"); for (String catName : Arrays.asList(catalogList.split(","))) { String schemaList = connection.getProperties().getProperty("schemas."+catName); if (schemaList == null) throw new SQLException("Missing property: 'schemas."+catName+"'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, catName); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+catName+"'.'"+schName+"'"); } } } rs.beforeFirst(); return rs; }
public ResultSet getSchemas() throws SQLException { String catalogList = connection.getProperties().getProperty("catalogs"); MockJDBCResultSet rs = new MockJDBCResultSet(null, 2); rs.setColumnName(1, "TABLE_SCHEM"); rs.setColumnName(2, "TABLE_CATALOG"); if (getSchemaTerm() == null) { logger.debug("getSchemas: schemaTerm==null; returning empty result set"); } else if (getCatalogTerm() == null) { String schemaList = connection.getProperties().getProperty("schemas"); logger.debug("getSchemas: catalogTerm==null; schemaList="+schemaList); if (schemaList == null) throw new SQLException("Missing property: 'schemas'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, null); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+schName+"'"); } } else { logger.debug("getSchemas: database has catalogs and schemas!"); for (String catName : Arrays.asList(catalogList.split(","))) { String schemaList = connection.getProperties().getProperty("schemas."+catName); if (schemaList == null) throw new SQLException("Missing property: 'schemas."+catName+"'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, catName); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+catName+"'.'"+schName+"'"); } } } rs.beforeFirst(); return rs; }
1,112,462
public ResultSet getSchemas() throws SQLException { String catalogList = connection.getProperties().getProperty("catalogs"); MockJDBCResultSet rs = new MockJDBCResultSet(null, 2); rs.setColumnName(1, "TABLE_SCHEM"); rs.setColumnName(2, "TABLE_CATALOG"); if (getSchemaTerm() == null) { logger.debug("getSchemas: schemaTerm==null; returning empty result set"); } else if (getCatalogTerm() == null) { String schemaList = connection.getProperties().getProperty("schemas"); logger.debug("getSchemas: catalogTerm==null; schemaList="+schemaList); if (schemaList == null) throw new SQLException("Missing property: 'schemas'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, null); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+schName+"'"); } } else { logger.debug("getSchemas: database has catalogs and schemas!"); for (String catName : Arrays.asList(catalogList.split(","))) { String schemaList = connection.getProperties().getProperty("schemas."+catName); if (schemaList == null) throw new SQLException("Missing property: 'schemas."+catName+"'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, catName); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+catName+"'.'"+schName+"'"); } } } rs.beforeFirst(); return rs; }
public ResultSet getSchemas() throws SQLException { String catalogList = connection.getProperties().getProperty("catalogs"); MockJDBCResultSet rs = new MockJDBCResultSet(null, 2); rs.setColumnName(1, "TABLE_SCHEM"); rs.setColumnName(2, "TABLE_CATALOG"); if (getSchemaTerm() == null) { logger.debug("getSchemas: schemaTerm==null; returning empty result set"); } else if (getCatalogTerm() == null) { String schemaList = connection.getProperties().getProperty("schemas"); logger.debug("getSchemas: catalogTerm==null; schemaList="+schemaList); if (schemaList == null) throw new SQLException("Missing property: 'schemas'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, null); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+schName+"'"); } } else { logger.debug("getSchemas: database has catalogs and schemas!"); for (String catName : Arrays.asList(catalogList.split(","))) { String schemaList = connection.getProperties().getProperty("schemas."+catName); if (schemaList == null) throw new SQLException("Missing property: 'schemas."+catName+"'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, catName); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+catName+"'.'"+schName+"'"); } } } rs.beforeFirst(); return rs; }
1,112,463
private PresentationObject getButtonsBelowTable(IWContext iwc) { Table T = new Table(); T.setCellpadding(0); T.setCellspacing(0); SubmitButton send,cancel; if (submitImage != null) { send = new SubmitButton(submitImage, "nl_send"); } else { send = new SubmitButton(iwrb.getLocalizedImageButton("subscribe", "Subscribe"), "nl_send"); } if (cancelImage != null) { cancel = new SubmitButton(cancelImage, "nl_stop"); } else { cancel = new SubmitButton(iwrb.getLocalizedImageButton("unsubscribe", "Unsubscribe"), "nl_stop"); } T.add(send,1,1); if (_showCancelImage) T.add(cancel, 2, 1); return T; }
private PresentationObject getButtonsBelowTable(IWContext iwc) { Table T = new Table(); T.setCellpadding(0); T.setCellspacing(0); SubmitButton send,cancel; if (submitImage != null) { send = new SubmitButton(submitImage, "nl_send"); } else { send = new SubmitButton(iwrb.getLocalizedImageButton("subscribe", "Subscribe"), "nl_send"); } if (cancelImage != null) { cancel = new SubmitButton(cancelImage, "nl_stop"); } else { cancel = new SubmitButton(iwrb.getLocalizedImageButton("unsubscribe", "Unsubscribe"), "nl_stop"); } T.add(send,1,1); if (_showCancelImage) T.add(cancel, 3, 1); return T; }
1,112,465
public void main(IWContext iwc) { //debugParameters(iwc); iwb = getBundle(iwc); core = iwc.getIWMainApplication().getCoreBundle(); iwrb = getResourceBundle(iwc); Table T = new Table(); T.setCellpaddingAndCellspacing(0); T.setColor(_bgColor); int row = 1; int categoryID = getCategoryId(); if (categoryID > 0) { processForm(iwc); topics = MailFinder.getInstance().getInstanceTopics(getICObjectInstanceID()); } if(iwc.hasEditPermission(this)){ T.add(getAdminView(iwc), 1, row); T.setAlignment(1, row++, "left"); } if (categoryID > 0 ){ if(topics!=null && !topics.isEmpty()) { T.add(getMailInputTable(iwc),1,row++); PresentationObject obj = null; switch (viewType) { case DROP: obj = getDropdownView(iwc); break; case CHECK: obj = getCheckBoxView(iwc); break; case SINGLE: obj = getCheckBoxView(iwc); break; } if ( obj != null ) T.add(obj,1,row); T.add(getButtonsBelowTable(iwc),1,row); } else{ T.add(iwrb.getLocalizedString("no_topic","Please create a topic"),1,row); } } else{ T.add(iwrb.getLocalizedString("no_category","Please create a category"),1,row); } Form F = new Form(); F.add(T); add(F); }
public void main(IWContext iwc) { //debugParameters(iwc); iwb = getBundle(iwc); core = iwc.getIWMainApplication().getCoreBundle(); iwrb = getResourceBundle(iwc); Table T = new Table(); T.setCellpaddingAndCellspacing(0); T.setColor(_bgColor); int row = 1; int categoryID = getCategoryId(); if (categoryID > 0) { processForm(iwc); topics = MailFinder.getInstance().getInstanceTopics(getICObjectInstanceID()); } if(iwc.hasEditPermission(this)){ T.add(getAdminView(iwc), 1, row); T.setAlignment(1, row++, "left"); } if (categoryID > 0 ){ if(topics!=null && !topics.isEmpty()) { T.add(getMailInputTable(iwc),1,row++); PresentationObject obj = null; switch (viewType) { case DROP: obj = getDropdownView(iwc); break; case CHECK: obj = getCheckBoxView(iwc); break; case SINGLE: obj = getCheckBoxView(iwc); break; } if ( obj != null ) T.add(obj,1,row); if(_submitBelowTopics) T.add(getButtonsBelowTable(iwc),1,row); } else{ T.add(iwrb.getLocalizedString("no_topic","Please create a topic"),1,row); } } else{ T.add(iwrb.getLocalizedString("no_category","Please create a category"),1,row); } Form F = new Form(); F.add(T); add(F); }
1,112,466
public void mouseClicked(MouseEvent evt) { if ((evt.getModifiers() & MouseEvent.BUTTON1_MASK) != 0 && evt.getClickCount() == 2) { TablePane tp = (TablePane) evt.getSource(); if (tp.isSelected()) { ArchitectFrame af = ArchitectFrame.getMainInstance(); int selectedColIndex = tp.getSelectedColumnIndex(); if (selectedColIndex == COLUMN_INDEX_NONE) { af.editTableAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } else if (selectedColIndex >= 0) { af.editColumnAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } } } }
public void mouseClicked(MouseEvent evt) { if ((evt.getModifiers() & MouseEvent.BUTTON1_MASK) != 0 && evt.getClickCount() == 2) { TablePane tp = (TablePane) evt.getSource(); if (tp.isSelected()) { ArchitectFrame af = ArchitectFrame.getMainInstance(); int selectedColIndex = tp.getSelectedColumnIndex(); if (selectedColIndex == COLUMN_INDEX_NONE) { af.editTableAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } else if (selectedColIndex >= 0) { af.editColumnAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } } } }
1,112,467
public void mouseClicked(MouseEvent evt) { if ((evt.getModifiers() & MouseEvent.BUTTON1_MASK) != 0 && evt.getClickCount() == 2) { TablePane tp = (TablePane) evt.getSource(); if (tp.isSelected()) { ArchitectFrame af = ArchitectFrame.getMainInstance(); int selectedColIndex = tp.getSelectedColumnIndex(); if (selectedColIndex == COLUMN_INDEX_NONE) { af.editTableAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } else if (selectedColIndex >= 0) { af.editColumnAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } } } }
public void mouseClicked(MouseEvent evt) { if ((evt.getModifiers() & MouseEvent.BUTTON1_MASK) != 0 && evt.getClickCount() == 2) { TablePane tp = (TablePane) evt.getSource(); if (tp.isSelected()) { ArchitectFrame af = ArchitectFrame.getMainInstance(); int selectedColIndex = tp.getSelectedColumnIndex(); if (selectedColIndex == COLUMN_INDEX_NONE) { af.editTableAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } else if (selectedColIndex >= 0) { af.editColumnAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } } } }
1,112,468
public void mousePressed(MouseEvent evt) { evt.getComponent().requestFocus(); if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { try { // table/column selection TablePane tp = (TablePane) evt.getComponent(); PlayPen pp = (PlayPen) tp.getPlayPen(); int clickCol = tp.pointToColumnIndex(evt.getPoint()); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { pp.selectNone(); } tp.setSelected(true); tp.selectNone(); if (clickCol < tp.model.getColumns().size()) { tp.selectColumn(clickCol); } // dragging if (clickCol == COLUMN_INDEX_TITLE) { Point handle = getPlayPen().zoomPoint(new Point(evt.getPoint())); new PlayPen.FloatingTableListener(getPlayPen(), this, handle); } } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } } maybeShowPopup(evt); }
public void mousePressed(MouseEvent evt) { evt.getComponent().requestFocus(); if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { try { // table/column selection PlayPen pp = (PlayPen) tp.getPlayPen(); int clickCol = tp.pointToColumnIndex(evt.getPoint()); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { pp.selectNone(); } tp.setSelected(true); tp.selectNone(); if (clickCol < tp.model.getColumns().size()) { tp.selectColumn(clickCol); } // dragging if (clickCol == COLUMN_INDEX_TITLE) { Point handle = getPlayPen().zoomPoint(new Point(evt.getPoint())); new PlayPen.FloatingTableListener(getPlayPen(), this, handle); } } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } } maybeShowPopup(evt); }
1,112,470
public void mousePressed(MouseEvent evt) { evt.getComponent().requestFocus(); if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { try { // table/column selection TablePane tp = (TablePane) evt.getComponent(); PlayPen pp = (PlayPen) tp.getPlayPen(); int clickCol = tp.pointToColumnIndex(evt.getPoint()); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { pp.selectNone(); } tp.setSelected(true); tp.selectNone(); if (clickCol < tp.model.getColumns().size()) { tp.selectColumn(clickCol); } // dragging if (clickCol == COLUMN_INDEX_TITLE) { Point handle = getPlayPen().zoomPoint(new Point(evt.getPoint())); new PlayPen.FloatingTableListener(getPlayPen(), this, handle); } } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } } maybeShowPopup(evt); }
public void mousePressed(MouseEvent evt) { evt.getComponent().requestFocus(); if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { try { // table/column selection TablePane tp = (TablePane) evt.getComponent(); PlayPen pp = (PlayPen) tp.getPlayPen(); int clickCol = tp.pointToColumnIndex(evt.getPoint()); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { pp.selectNone(); } tp.setSelected(true); tp.selectNone(); if (clickCol < tp.model.getColumns().size()) { tp.selectColumn(clickCol); } // dragging if (clickCol == COLUMN_INDEX_TITLE) { Point handle = getPlayPen().zoomPoint(new Point(evt.getPoint())); new PlayPen.FloatingTableListener(getPlayPen(), this, handle); } } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } } maybeShowPopup(evt); }
1,112,471
public void mousePressed(MouseEvent evt) { evt.getComponent().requestFocus(); if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { try { // table/column selection TablePane tp = (TablePane) evt.getComponent(); PlayPen pp = (PlayPen) tp.getPlayPen(); int clickCol = tp.pointToColumnIndex(evt.getPoint()); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { pp.selectNone(); } tp.setSelected(true); tp.selectNone(); if (clickCol < tp.model.getColumns().size()) { tp.selectColumn(clickCol); } // dragging if (clickCol == COLUMN_INDEX_TITLE) { Point handle = getPlayPen().zoomPoint(new Point(evt.getPoint())); new PlayPen.FloatingTableListener(getPlayPen(), this, handle); } } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } } maybeShowPopup(evt); }
public void mousePressed(MouseEvent evt) { evt.getComponent().requestFocus(); if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { try { // table/column selection TablePane tp = (TablePane) evt.getComponent(); PlayPen pp = (PlayPen) tp.getPlayPen(); int clickCol = tp.pointToColumnIndex(evt.getPoint()); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { pp.selectNone(); } tp.setSelected(true); tp.selectNone(); if (clickCol < tp.model.getColumns().size()) { tp.selectColumn(clickCol); } // dragging if (clickCol == COLUMN_INDEX_TITLE) { Point handle = getPlayPen().zoomPoint(new Point(evt.getPoint())); new PlayPen.FloatingTableListener(getPlayPen(), this, handle); } } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } } maybeShowPopup(evt); }
1,112,472
public static void initODMG( String user, String passwd, PVDatabase dbDesc ) throws PhotovaultException { getODMGImplementation(); // Find the connection repository info ConnectionRepository cr = MetadataManager.getInstance().connectionRepository(); PBKey connKey = cr.getStandardPBKeyForJcdAlias( "pv" ); JdbcConnectionDescriptor connDesc = cr.getDescriptor( connKey ); // Set up the OJB connection with parameters from photovault.properties if ( dbDesc.getInstanceType() == PVDatabase.TYPE_EMBEDDED ) { connDesc.setDriver( "org.apache.derby.jdbc.EmbeddedDriver" ); connDesc.setDbms( "derby" ); connDesc.setSubProtocol( "derby" ); connDesc.setDbAlias( "photovault" ); File derbyDir = new File( dbDesc.getEmbeddedDirectory(), "derby" ); System.setProperty( "derby.system.home", derbyDir.getAbsolutePath() ); } else { // This is a MySQL database String dbhost = dbDesc.getDbHost(); String dbname = dbDesc.getDbName(); connDesc.setDbAlias( "//" + dbhost + "/" + dbname ); connDesc.setUserName( user ); connDesc.setPassWord( passwd ); connDesc.setDriver( "com.mysql.jdbc.Driver" ); connDesc.setDbms( "MySQL" ); connDesc.setSubProtocol( "mysql" ); } // Open the database connection db = odmg.newDatabase(); boolean success = false; try { log.debug( "Opening database" ); db.open( "pv#" + user + "#" + passwd, Database.OPEN_READ_WRITE ); log.debug( "Success!!!" ); } catch ( Exception e ) { log.error( "Failed to get connection: " + e.getMessage() ); e.printStackTrace(); } // Check whether the database was opened correctly try { PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(connKey); broker.beginTransaction(); Connection con = broker.serviceConnectionManager().getConnection(); broker.commitTransaction(); broker.close(); } catch (Exception ex) { /* Finding the real reason for the error needs a bit of guesswork: first lets find the original exception */ Throwable rootCause = ex; while ( rootCause.getCause() != null ) { rootCause = rootCause.getCause(); } log.error( rootCause.getMessage() ); if ( rootCause instanceof SQLException ) { if ( rootCause instanceof EmbedSQLException ) { /* We are using Derby, the problem is likely that another instance of the database has been started */ throw new PhotovaultException( "Cannot start database.\n" + "Do you have another instance of Photovault running?", rootCause ); } if ( dbDesc.getInstanceType() == PVDatabase.TYPE_SERVER ) { throw new PhotovaultException( "Cannot log in to MySQL database", rootCause ); } } throw new PhotovaultException( "Unknown error while starting database:\n" + rootCause.getMessage(), rootCause ); } // 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" ); } throw new PhotovaultException( "Unknown error while starting database:\n" ); } } catch ( Exception 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" ); } throw new PhotovaultException( "Unknown error while starting database:\n" + t.getMessage(), t ); } }
public static void initODMG( String user, String passwd, PVDatabase dbDesc ) throws PhotovaultException { getODMGImplementation(); // Find the connection repository info ConnectionRepository cr = MetadataManager.getInstance().connectionRepository(); PBKey connKey = cr.getStandardPBKeyForJcdAlias( "pv" ); JdbcConnectionDescriptor connDesc = cr.getDescriptor( connKey ); // Set up the OJB connection with parameters from photovault.properties if ( dbDesc.getInstanceType() == PVDatabase.TYPE_EMBEDDED ) { connDesc.setDriver( "org.apache.derby.jdbc.EmbeddedDriver" ); connDesc.setDbms( "derby" ); connDesc.setSubProtocol( "derby" ); connDesc.setDbAlias( "photovault" ); File derbyDir = new File( dbDesc.getEmbeddedDirectory(), "derby" ); System.setProperty( "derby.system.home", derbyDir.getAbsolutePath() ); } else { // This is a MySQL database String dbhost = dbDesc.getDbHost(); String dbname = dbDesc.getDbName(); connDesc.setDbAlias( "//" + dbhost + "/" + dbname ); connDesc.setUserName( user ); connDesc.setPassWord( passwd ); connDesc.setDriver( "com.mysql.jdbc.Driver" ); connDesc.setDbms( "MySQL" ); connDesc.setSubProtocol( "mysql" ); } // Open the database connection db = odmg.newDatabase(); boolean success = false; try { log.debug( "Opening database" ); db.open( "pv#" + user + "#" + passwd, Database.OPEN_READ_WRITE ); log.debug( "Success!!!" ); } catch ( Throwable e ) { log.error( "Failed to get connection: " + e.getMessage() ); e.printStackTrace(); } // Check whether the database was opened correctly try { PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(connKey); broker.beginTransaction(); Connection con = broker.serviceConnectionManager().getConnection(); broker.commitTransaction(); broker.close(); } catch (Exception ex) { /* Finding the real reason for the error needs a bit of guesswork: first lets find the original exception */ Throwable rootCause = ex; while ( rootCause.getCause() != null ) { rootCause = rootCause.getCause(); } log.error( rootCause.getMessage() ); if ( rootCause instanceof SQLException ) { if ( rootCause instanceof EmbedSQLException ) { /* We are using Derby, the problem is likely that another instance of the database has been started */ throw new PhotovaultException( "Cannot start database.\n" + "Do you have another instance of Photovault running?", rootCause ); } if ( dbDesc.getInstanceType() == PVDatabase.TYPE_SERVER ) { throw new PhotovaultException( "Cannot log in to MySQL database", rootCause ); } } throw new PhotovaultException( "Unknown error while starting database:\n" + rootCause.getMessage(), rootCause ); } // 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" ); } throw new PhotovaultException( "Unknown error while starting database:\n" ); } } catch ( Exception 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" ); } throw new PhotovaultException( "Unknown error while starting database:\n" + t.getMessage(), t ); } }
1,112,473
public static void initODMG( String user, String passwd, PVDatabase dbDesc ) throws PhotovaultException { getODMGImplementation(); // Find the connection repository info ConnectionRepository cr = MetadataManager.getInstance().connectionRepository(); PBKey connKey = cr.getStandardPBKeyForJcdAlias( "pv" ); JdbcConnectionDescriptor connDesc = cr.getDescriptor( connKey ); // Set up the OJB connection with parameters from photovault.properties if ( dbDesc.getInstanceType() == PVDatabase.TYPE_EMBEDDED ) { connDesc.setDriver( "org.apache.derby.jdbc.EmbeddedDriver" ); connDesc.setDbms( "derby" ); connDesc.setSubProtocol( "derby" ); connDesc.setDbAlias( "photovault" ); File derbyDir = new File( dbDesc.getEmbeddedDirectory(), "derby" ); System.setProperty( "derby.system.home", derbyDir.getAbsolutePath() ); } else { // This is a MySQL database String dbhost = dbDesc.getDbHost(); String dbname = dbDesc.getDbName(); connDesc.setDbAlias( "//" + dbhost + "/" + dbname ); connDesc.setUserName( user ); connDesc.setPassWord( passwd ); connDesc.setDriver( "com.mysql.jdbc.Driver" ); connDesc.setDbms( "MySQL" ); connDesc.setSubProtocol( "mysql" ); } // Open the database connection db = odmg.newDatabase(); boolean success = false; try { log.debug( "Opening database" ); db.open( "pv#" + user + "#" + passwd, Database.OPEN_READ_WRITE ); log.debug( "Success!!!" ); } catch ( Exception e ) { log.error( "Failed to get connection: " + e.getMessage() ); e.printStackTrace(); } // Check whether the database was opened correctly try { PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(connKey); broker.beginTransaction(); Connection con = broker.serviceConnectionManager().getConnection(); broker.commitTransaction(); broker.close(); } catch (Exception ex) { /* Finding the real reason for the error needs a bit of guesswork: first lets find the original exception */ Throwable rootCause = ex; while ( rootCause.getCause() != null ) { rootCause = rootCause.getCause(); } log.error( rootCause.getMessage() ); if ( rootCause instanceof SQLException ) { if ( rootCause instanceof EmbedSQLException ) { /* We are using Derby, the problem is likely that another instance of the database has been started */ throw new PhotovaultException( "Cannot start database.\n" + "Do you have another instance of Photovault running?", rootCause ); } if ( dbDesc.getInstanceType() == PVDatabase.TYPE_SERVER ) { throw new PhotovaultException( "Cannot log in to MySQL database", rootCause ); } } throw new PhotovaultException( "Unknown error while starting database:\n" + rootCause.getMessage(), rootCause ); } // 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" ); } throw new PhotovaultException( "Unknown error while starting database:\n" ); } } catch ( Exception 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" ); } throw new PhotovaultException( "Unknown error while starting database:\n" + t.getMessage(), t ); } }
public static void initODMG( String user, String passwd, PVDatabase dbDesc ) throws PhotovaultException { getODMGImplementation(); // Find the connection repository info ConnectionRepository cr = MetadataManager.getInstance().connectionRepository(); PBKey connKey = cr.getStandardPBKeyForJcdAlias( "pv" ); JdbcConnectionDescriptor connDesc = cr.getDescriptor( connKey ); // Set up the OJB connection with parameters from photovault.properties if ( dbDesc.getInstanceType() == PVDatabase.TYPE_EMBEDDED ) { connDesc.setDriver( "org.apache.derby.jdbc.EmbeddedDriver" ); connDesc.setDbms( "derby" ); connDesc.setSubProtocol( "derby" ); connDesc.setDbAlias( "photovault" ); File derbyDir = new File( dbDesc.getEmbeddedDirectory(), "derby" ); System.setProperty( "derby.system.home", derbyDir.getAbsolutePath() ); } else { // This is a MySQL database String dbhost = dbDesc.getDbHost(); String dbname = dbDesc.getDbName(); connDesc.setDbAlias( "//" + dbhost + "/" + dbname ); connDesc.setUserName( user ); connDesc.setPassWord( passwd ); connDesc.setDriver( "com.mysql.jdbc.Driver" ); connDesc.setDbms( "MySQL" ); connDesc.setSubProtocol( "mysql" ); } // Open the database connection db = odmg.newDatabase(); boolean success = false; try { log.debug( "Opening database" ); db.open( "pv#" + user + "#" + passwd, Database.OPEN_READ_WRITE ); log.debug( "Success!!!" ); } catch ( Exception e ) { log.error( "Failed to get connection: " + e.getMessage() ); e.printStackTrace(); } // Check whether the database was opened correctly try { PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(connKey); broker.beginTransaction(); Connection con = broker.serviceConnectionManager().getConnection(); broker.commitTransaction(); broker.close(); } catch (Exception ex) { /* Finding the real reason for the error needs a bit of guesswork: first lets find the original exception */ Throwable rootCause = ex; while ( rootCause.getCause() != null ) { rootCause = rootCause.getCause(); } log.error( rootCause.getMessage() ); if ( rootCause instanceof SQLException ) { if ( rootCause instanceof EmbedSQLException ) { /* We are using Derby, the problem is likely that another instance of the database has been started */ throw new PhotovaultException( "Cannot start database.\n" + "Do you have another instance of Photovault running?", rootCause ); } if ( dbDesc.getInstanceType() == PVDatabase.TYPE_SERVER ) { throw new PhotovaultException( "Cannot log in to MySQL database", rootCause ); } } throw new PhotovaultException( "Unknown error while starting database:\n" + rootCause.getMessage(), rootCause ); } // 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 ( Exception 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" ); } throw new PhotovaultException( "Unknown error while starting database:\n" + t.getMessage(), t ); } }
1,112,474
public static void initODMG( String user, String passwd, PVDatabase dbDesc ) throws PhotovaultException { getODMGImplementation(); // Find the connection repository info ConnectionRepository cr = MetadataManager.getInstance().connectionRepository(); PBKey connKey = cr.getStandardPBKeyForJcdAlias( "pv" ); JdbcConnectionDescriptor connDesc = cr.getDescriptor( connKey ); // Set up the OJB connection with parameters from photovault.properties if ( dbDesc.getInstanceType() == PVDatabase.TYPE_EMBEDDED ) { connDesc.setDriver( "org.apache.derby.jdbc.EmbeddedDriver" ); connDesc.setDbms( "derby" ); connDesc.setSubProtocol( "derby" ); connDesc.setDbAlias( "photovault" ); File derbyDir = new File( dbDesc.getEmbeddedDirectory(), "derby" ); System.setProperty( "derby.system.home", derbyDir.getAbsolutePath() ); } else { // This is a MySQL database String dbhost = dbDesc.getDbHost(); String dbname = dbDesc.getDbName(); connDesc.setDbAlias( "//" + dbhost + "/" + dbname ); connDesc.setUserName( user ); connDesc.setPassWord( passwd ); connDesc.setDriver( "com.mysql.jdbc.Driver" ); connDesc.setDbms( "MySQL" ); connDesc.setSubProtocol( "mysql" ); } // Open the database connection db = odmg.newDatabase(); boolean success = false; try { log.debug( "Opening database" ); db.open( "pv#" + user + "#" + passwd, Database.OPEN_READ_WRITE ); log.debug( "Success!!!" ); } catch ( Exception e ) { log.error( "Failed to get connection: " + e.getMessage() ); e.printStackTrace(); } // Check whether the database was opened correctly try { PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(connKey); broker.beginTransaction(); Connection con = broker.serviceConnectionManager().getConnection(); broker.commitTransaction(); broker.close(); } catch (Exception ex) { /* Finding the real reason for the error needs a bit of guesswork: first lets find the original exception */ Throwable rootCause = ex; while ( rootCause.getCause() != null ) { rootCause = rootCause.getCause(); } log.error( rootCause.getMessage() ); if ( rootCause instanceof SQLException ) { if ( rootCause instanceof EmbedSQLException ) { /* We are using Derby, the problem is likely that another instance of the database has been started */ throw new PhotovaultException( "Cannot start database.\n" + "Do you have another instance of Photovault running?", rootCause ); } if ( dbDesc.getInstanceType() == PVDatabase.TYPE_SERVER ) { throw new PhotovaultException( "Cannot log in to MySQL database", rootCause ); } } throw new PhotovaultException( "Unknown error while starting database:\n" + rootCause.getMessage(), rootCause ); } // 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" ); } throw new PhotovaultException( "Unknown error while starting database:\n" ); } } catch ( Exception 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" ); } throw new PhotovaultException( "Unknown error while starting database:\n" + t.getMessage(), t ); } }
public static void initODMG( String user, String passwd, PVDatabase dbDesc ) throws PhotovaultException { getODMGImplementation(); // Find the connection repository info ConnectionRepository cr = MetadataManager.getInstance().connectionRepository(); PBKey connKey = cr.getStandardPBKeyForJcdAlias( "pv" ); JdbcConnectionDescriptor connDesc = cr.getDescriptor( connKey ); // Set up the OJB connection with parameters from photovault.properties if ( dbDesc.getInstanceType() == PVDatabase.TYPE_EMBEDDED ) { connDesc.setDriver( "org.apache.derby.jdbc.EmbeddedDriver" ); connDesc.setDbms( "derby" ); connDesc.setSubProtocol( "derby" ); connDesc.setDbAlias( "photovault" ); File derbyDir = new File( dbDesc.getEmbeddedDirectory(), "derby" ); System.setProperty( "derby.system.home", derbyDir.getAbsolutePath() ); } else { // This is a MySQL database String dbhost = dbDesc.getDbHost(); String dbname = dbDesc.getDbName(); connDesc.setDbAlias( "//" + dbhost + "/" + dbname ); connDesc.setUserName( user ); connDesc.setPassWord( passwd ); connDesc.setDriver( "com.mysql.jdbc.Driver" ); connDesc.setDbms( "MySQL" ); connDesc.setSubProtocol( "mysql" ); } // Open the database connection db = odmg.newDatabase(); boolean success = false; try { log.debug( "Opening database" ); db.open( "pv#" + user + "#" + passwd, Database.OPEN_READ_WRITE ); log.debug( "Success!!!" ); } catch ( Exception e ) { log.error( "Failed to get connection: " + e.getMessage() ); e.printStackTrace(); } // Check whether the database was opened correctly try { PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(connKey); broker.beginTransaction(); Connection con = broker.serviceConnectionManager().getConnection(); broker.commitTransaction(); broker.close(); } catch (Exception ex) { /* Finding the real reason for the error needs a bit of guesswork: first lets find the original exception */ Throwable rootCause = ex; while ( rootCause.getCause() != null ) { rootCause = rootCause.getCause(); } log.error( rootCause.getMessage() ); if ( rootCause instanceof SQLException ) { if ( rootCause instanceof EmbedSQLException ) { /* We are using Derby, the problem is likely that another instance of the database has been started */ throw new PhotovaultException( "Cannot start database.\n" + "Do you have another instance of Photovault running?", rootCause ); } if ( dbDesc.getInstanceType() == PVDatabase.TYPE_SERVER ) { throw new PhotovaultException( "Cannot log in to MySQL database", rootCause ); } } throw new PhotovaultException( "Unknown error while starting database:\n" + rootCause.getMessage(), rootCause ); } // 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 ( Exception e ) { log.error( "Error closing database" ); } throw new PhotovaultException( "Unknown error while starting database:\n" ); } } catch ( Exception t ) { log.error( "Could not open database connection" ); log.error( t.getMessage() ); t.printStackTrace(); try { db.close(); } catch ( Exception e ) { log.error( "Error closing database" ); } throw new PhotovaultException( "Unknown error while starting database:\n" + t.getMessage(), t ); } }
1,112,475
public Individual(int numLines) { this.markers = new Vector(numLines); //this.zeroed = new Vector(numLines); this.zeroed = new boolean[numLines]; this.currMarker = 0; }
public Individual(int numLines) { this.markers = new Vector(numLines); //this.zeroed = new Vector(numLines); this.zeroed = new boolean[numLines]; this.currMarker = 0; }
1,112,477
public void addMarker(byte[] marker){ this.markers.add(marker); //this.zeroed.add(new Boolean(false)); this.zeroed[currMarker] = false; this.currMarker++; if (!(marker[0] == 0 || marker[1] == 0)){ numGoodMarkers++; } }
public void addMarker(byte[] marker){ this.markers.add(marker); //this.zeroed.add(new Boolean(false)); this.zeroed[currMarker] = false; this.currMarker++; if (!(marker[0] == 0 || marker[1] == 0)){ numGoodMarkers++; } }
1,112,478
public double getGenoPC(){ return numGoodMarkers/markers.size(); }
public double getGenoPC(){ return numGoodMarkers/markersa.length; }
1,112,479
public Vector getMarkers() { return markers; }
public Vector getMarkers() { return null; }
1,112,480
public int getNumMarkers(){ return this.markers.size(); }
public int getNumMarkers(){ return this.markersa.length; }
1,112,481
public void setMarkers(Vector m){ markers = m; }
public void setMarkers(Vector m){ markers = m; }
1,112,482
protected void handleException(Exception e) throws Exception { log.error( "Caught exception: " + e, e ); throw new JellyException(e, columnNumber, lineNumber); }
protected void handleException(Exception e) throws Exception { log.error( "Caught exception: " + e, e ); throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); }
1,112,483
protected TagScript createTag( String namespaceURI, String localName, Attributes list) throws SAXException { try { // use the URI to load a taglib TagLibrary taglib = context.getTagLibrary(namespaceURI); if (taglib == null) { if (namespaceURI != null && namespaceURI.startsWith("jelly:")) { String uri = namespaceURI.substring(6); // try to find the class on the claspath try { Class taglibClass = getClassLoader().loadClass(uri); taglib = (TagLibrary) taglibClass.newInstance(); context.registerTagLibrary(namespaceURI, taglib); } catch (ClassNotFoundException e) { log.warn("Could not load class: " + uri + " so disabling the taglib"); } } } if (taglib != null) { TagScript script = taglib.createTagScript(localName, list); if ( script != null ) { // clone the attributes to keep them around after this parse script.setSaxAttributes(new AttributesImpl(list)); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = taglib.createExpression( getExpressionFactory(), localName, attributeName, attributeValue); if (expression == null) { expression = createConstantExpression(localName, attributeName, attributeValue); } script.addAttribute(attributeName, expression); } } return script; } return null; } catch (Exception e) { log.warn( "Could not create taglib or URI: " + namespaceURI + " tag name: " + localName, e); throw createSAXException(e); } }
protected TagScript createTag( String namespaceURI, String script, Attributes list) throws SAXException { try { // use the URI to load a taglib TagLibrary taglib = context.getTagLibrary(namespaceURI); if (taglib == null) { if (namespaceURI != null && namespaceURI.startsWith("jelly:")) { String uri = namespaceURI.substring(6); // try to find the class on the claspath try { Class taglibClass = getClassLoader().loadClass(uri); taglib = (TagLibrary) taglibClass.newInstance(); context.registerTagLibrary(namespaceURI, taglib); } catch (ClassNotFoundException e) { log.warn("Could not load class: " + uri + " so disabling the taglib"); } } } if (taglib != null) { TagScript script = taglib.createTagScript(script, list); if ( script != null ) { // clone the attributes to keep them around after this parse script.setSaxAttributes(new AttributesImpl(list)); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = taglib.createExpression( getExpressionFactory(), script, attributeName, attributeValue); if (expression == null) { expression = createConstantExpression(script, attributeName, attributeValue); } script.addAttribute(attributeName, expression); } } return script; } return null; } catch (Exception e) { log.warn( "Could not create taglib or URI: " + namespaceURI + " tag name: " + script, e); throw createSAXException(e); } }
1,112,485
public void startElement( String namespaceURI, String localName, String qName, Attributes list) throws SAXException { try { // add check to ensure namespace URI is "" for no namespace if ( namespaceURI == null ) { namespaceURI = ""; } // if this is a tag then create a script to run it // otherwise pass the text to the current body TagScript parentTagScript = tagScript; tagScript = createTag(namespaceURI, localName, list); if (tagScript == null) { tagScript = createStaticTag(namespaceURI, localName, qName, list); } tagScriptStack.add(tagScript); if (tagScript != null) { // set parent relationship... tagScript.setParent(parentTagScript); // set the namespace Map if ( elementNamespaces != null ) { tagScript.setNamespacesMap( elementNamespaces ); elementNamespaces = null; } // set the line number details if ( locator != null ) { tagScript.setLocator(locator); } // sets the file name element names tagScript.setFileName(fileName); tagScript.setElementName(qName); tagScript.setLocalName(localName); if (textBuffer.length() > 0) { addTextScript(textBuffer.toString()); textBuffer.setLength(0); } script.addScript(tagScript); // start a new body scriptStack.push(script); script = new ScriptBlock(); tagScript.setTagBody(script); } else { // XXXX: might wanna handle empty elements later... textBuffer.append("<"); textBuffer.append(qName); int size = list.getLength(); for (int i = 0; i < size; i++) { textBuffer.append(" "); textBuffer.append(list.getQName(i)); textBuffer.append("="); textBuffer.append("\""); textBuffer.append(list.getValue(i)); textBuffer.append("\""); } textBuffer.append(">"); } } catch (SAXException e) { throw e; } catch (Exception e) { log.error( "Caught exception: " + e, e ); throw new SAXException( "Runtime Exception: " + e, e ); } }
public void startElement( String namespaceURI, String localName, String qName, Attributes list) throws SAXException { try { // add check to ensure namespace URI is "" for no namespace if ( namespaceURI == null ) { namespaceURI = ""; } // if this is a tag then create a script to run it // otherwise pass the text to the current body TagScript parentTagScript = tagScript; tagScript = createTag(namespaceURI, localName, list); if (tagScript == null) { tagScript = createStaticTag(namespaceURI, localName, qName, list); } tagScriptStack.add(tagScript); if (tagScript != null) { // set parent relationship... tagScript.setParent(parentTagScript); // set the namespace Map if ( elementNamespaces != null ) { tagScript.setNamespacesMap( elementNamespaces ); elementNamespaces = null; } // set the line number details if ( locator != null ) { tagScript.setLocator(locator); } // sets the file name element names tagScript.setFileName(fileName); tagScript.setElementName(qName); tagScript.setLocalName(localName); if (textBuffer.length() > 0) { addTextScript(textBuffer.toString()); textBuffer.setLength(0); } script.addScript(tagScript); // start a new body scriptStack.push(script); script = new ScriptBlock(); tagScript.setTagBody(script); } else { // XXXX: might wanna handle empty elements later... textBuffer.append("<"); textBuffer.append(qName); int size = list.getLength(); for (int i = 0; i < size; i++) { textBuffer.append(" "); textBuffer.append(list.getQName(i)); textBuffer.append("="); textBuffer.append("\""); textBuffer.append(list.getValue(i)); textBuffer.append("\""); } textBuffer.append(">"); } } catch (SAXException e) { throw e; } catch (Exception e) { log.error( "Caught exception: " + e, e ); throw new SAXException( "Runtime Exception: " + e, e ); } }
1,112,486
public void startElement( String namespaceURI, String localName, String qName, Attributes list) throws SAXException { try { // add check to ensure namespace URI is "" for no namespace if ( namespaceURI == null ) { namespaceURI = ""; } // if this is a tag then create a script to run it // otherwise pass the text to the current body TagScript parentTagScript = tagScript; tagScript = createTag(namespaceURI, localName, list); if (tagScript == null) { tagScript = createStaticTag(namespaceURI, localName, qName, list); } tagScriptStack.add(tagScript); if (tagScript != null) { // set parent relationship... tagScript.setParent(parentTagScript); // set the namespace Map if ( elementNamespaces != null ) { tagScript.setNamespacesMap( elementNamespaces ); elementNamespaces = null; } // set the line number details if ( locator != null ) { tagScript.setLocator(locator); } // sets the file name element names tagScript.setFileName(fileName); tagScript.setElementName(qName); tagScript.setLocalName(localName); if (textBuffer.length() > 0) { addTextScript(textBuffer.toString()); textBuffer.setLength(0); } script.addScript(tagScript); // start a new body scriptStack.push(script); script = new ScriptBlock(); tagScript.setTagBody(script); } else { // XXXX: might wanna handle empty elements later... textBuffer.append("<"); textBuffer.append(qName); int size = list.getLength(); for (int i = 0; i < size; i++) { textBuffer.append(" "); textBuffer.append(list.getQName(i)); textBuffer.append("="); textBuffer.append("\""); textBuffer.append(list.getValue(i)); textBuffer.append("\""); } textBuffer.append(">"); } } catch (SAXException e) { throw e; } catch (Exception e) { log.error( "Caught exception: " + e, e ); throw new SAXException( "Runtime Exception: " + e, e ); } }
public void startElement( String namespaceURI, String localName, String qName, Attributes list) throws SAXException { try { // add check to ensure namespace URI is "" for no namespace if ( namespaceURI == null ) { namespaceURI = ""; } // if this is a tag then create a script to run it // otherwise pass the text to the current body TagScript parentTagScript = tagScript; tagScript = createTag(namespaceURI, localName, list); if (tagScript == null) { tagScript = createStaticTag(namespaceURI, localName, qName, list); } tagScriptStack.add(tagScript); if (tagScript != null) { // set parent relationship... tagScript.setParent(parentTagScript); // set the namespace Map if ( elementNamespaces != null ) { tagScript.setNamespacesMap( elementNamespaces ); elementNamespaces = null; } // set the line number details if ( locator != null ) { tagScript.setLocator(locator); } // sets the file name element names tagScript.setFileName(fileName); tagScript.setElementName(qName); tagScript.setLocalName(localName); if (textBuffer.length() > 0) { addTextScript(textBuffer.toString()); textBuffer.setLength(0); } script.addScript(tagScript); // start a new body scriptStack.push(script); script = new ScriptBlock(); tagScript.setTagBody(script); } else { // XXXX: might wanna handle empty elements later... textBuffer.append("<"); textBuffer.append(qName); int size = list.getLength(); for (int i = 0; i < size; i++) { textBuffer.append(" "); textBuffer.append(list.getQName(i)); textBuffer.append("="); textBuffer.append("\""); textBuffer.append(list.getValue(i)); textBuffer.append("\""); } textBuffer.append(">"); } } catch (SAXException e) { throw e; } catch (Exception e) { log.error( "Caught exception: " + e, e ); throw new SAXException( "Runtime Exception: " + e, e ); } }
1,112,487
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); blockMenuItems[i].setEnabled(false); blockMenu.add(blockMenuItems[i]); bg.add(blockMenuItems[i]); } 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); **/ 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); blockMenuItems[i].setEnabled(false); blockMenu.add(blockMenuItems[i]); bg.add(blockMenuItems[i]); } 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); **/ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); }
1,112,488
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command == READ_GENOTYPES){ ReadDataDialog readDialog = new ReadDataDialog("Open new data", this); readDialog.pack(); readDialog.setVisible(true); } else if (command == READ_MARKERS){ //JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); fc.setSelectedFile(new File("")); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { readMarkers(fc.getSelectedFile(),null); } }else if (command == READ_ANALYSIS_TRACK){ fc.setSelectedFile(new File("")); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION){ readAnalysisFile(fc.getSelectedFile()); } }else if (command == READ_BLOCKS_FILE){ fc.setSelectedFile(new File("")); if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION){ readBlocksFile(fc.getSelectedFile()); } }else if (command == CUST_BLOCKS){ TweakBlockDefsDialog tweakDialog = new TweakBlockDefsDialog("Customize Blocks", this); tweakDialog.pack(); tweakDialog.setVisible(true); }else if (command == CLEAR_BLOCKS){ changeBlocks(BLOX_NONE); //blockdef clauses }else if (command.startsWith("block")){ int method = Integer.valueOf(command.substring(5)).intValue(); changeBlocks(method); /*for (int i = 1; i < colorMenuItems.length; i++){ if (method+1 == i){ colorMenuItems[i].setEnabled(true); }else{ colorMenuItems[i].setEnabled(false); } } colorMenuItems[0].setSelected(true);*/ //zooming clauses }else if (command.startsWith("zoom")){ dPrimeDisplay.zoom(Integer.valueOf(command.substring(4)).intValue()); //coloring clauses }else if (command.startsWith("color")){ currentScheme = Integer.valueOf(command.substring(5)).intValue()+1; dPrimeDisplay.colorDPrime(currentScheme); dPrimeDisplay.refresh(); changeKey(currentScheme); //exporting clauses }else if (command == EXPORT_PNG){ export(tabs.getSelectedIndex(), PNG_MODE, 0, Chromosome.getSize()); }else if (command == EXPORT_TEXT){ export(tabs.getSelectedIndex(), TXT_MODE, 0, Chromosome.getSize()); }else if (command == EXPORT_OPTIONS){ ExportDialog exDialog = new ExportDialog(this); exDialog.pack(); exDialog.setVisible(true); }else if (command == "Select All"){ checkPanel.selectAll(); }else if (command == "Rescore Markers"){ String cut = cdc.hwcut.getText(); if (cut.equals("")){ cut = "0"; } CheckData.hwCut = Double.parseDouble(cut); cut = cdc.genocut.getText(); if (cut.equals("")){ cut="0"; } CheckData.failedGenoCut = Integer.parseInt(cut); cut = cdc.mendcut.getText(); if (cut.equals("")){ cut="0"; } CheckData.numMendErrCut = Integer.parseInt(cut); cut = cdc.mafcut.getText(); if (cut.equals("")){ cut="0"; } CheckData.mafCut = Double.parseDouble(cut); checkPanel.redoRatings(); }else if (command == "Tutorial"){ showHelp(); } else if (command == "Quit"){ quit(); } else { for (int i = 0; i < viewItems.length; i++) { if (command == viewItems[i]) tabs.setSelectedIndex(i); } } }
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command == READ_GENOTYPES){ ReadDataDialog readDialog = new ReadDataDialog("Open new data", this); readDialog.pack(); readDialog.setVisible(true); } else if (command == READ_MARKERS){ //JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); fc.setSelectedFile(new File("")); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { readMarkers(fc.getSelectedFile(),null); } }else if (command == READ_ANALYSIS_TRACK){ fc.setSelectedFile(new File("")); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION){ readAnalysisFile(fc.getSelectedFile()); } }else if (command == READ_BLOCKS_FILE){ fc.setSelectedFile(new File("")); if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION){ readBlocksFile(fc.getSelectedFile()); } }else if (command == CUST_BLOCKS){ TweakBlockDefsDialog tweakDialog = new TweakBlockDefsDialog("Customize Blocks", this); tweakDialog.pack(); tweakDialog.setVisible(true); }else if (command == CLEAR_BLOCKS){ changeBlocks(BLOX_NONE); //blockdef clauses }else if (command.startsWith("block")){ int method = Integer.valueOf(command.substring(5)).intValue(); changeBlocks(method); /*for (int i = 1; i < colorMenuItems.length; i++){ if (method+1 == i){ colorMenuItems[i].setEnabled(true); }else{ colorMenuItems[i].setEnabled(false); } } colorMenuItems[0].setSelected(true);*/ //zooming clauses }else if (command.startsWith("zoom")){ dPrimeDisplay.zoom(Integer.valueOf(command.substring(4)).intValue()); //coloring clauses }else if (command.startsWith("color")){ currentScheme = Integer.valueOf(command.substring(5)).intValue()+1; dPrimeDisplay.colorDPrime(currentScheme); changeKey(currentScheme); //exporting clauses }else if (command == EXPORT_PNG){ export(tabs.getSelectedIndex(), PNG_MODE, 0, Chromosome.getSize()); }else if (command == EXPORT_TEXT){ export(tabs.getSelectedIndex(), TXT_MODE, 0, Chromosome.getSize()); }else if (command == EXPORT_OPTIONS){ ExportDialog exDialog = new ExportDialog(this); exDialog.pack(); exDialog.setVisible(true); }else if (command == "Select All"){ checkPanel.selectAll(); }else if (command == "Rescore Markers"){ String cut = cdc.hwcut.getText(); if (cut.equals("")){ cut = "0"; } CheckData.hwCut = Double.parseDouble(cut); cut = cdc.genocut.getText(); if (cut.equals("")){ cut="0"; } CheckData.failedGenoCut = Integer.parseInt(cut); cut = cdc.mendcut.getText(); if (cut.equals("")){ cut="0"; } CheckData.numMendErrCut = Integer.parseInt(cut); cut = cdc.mafcut.getText(); if (cut.equals("")){ cut="0"; } CheckData.mafCut = Double.parseDouble(cut); checkPanel.redoRatings(); }else if (command == "Tutorial"){ showHelp(); } else if (command == "Quit"){ quit(); } else { for (int i = 0; i < viewItems.length; i++) { if (command == viewItems[i]) tabs.setSelectedIndex(i); } } }
1,112,489
public void drop(DropTargetDropEvent dtde) { TablePane tp = (TablePane) dtde.getDropTargetContext().getComponent(); logger.debug("Drop target drop event on "+tp.getName()+": "+dtde); Transferable t = dtde.getTransferable(); DataFlavor importFlavor = bestImportFlavor(tp, t.getTransferDataFlavors()); if (importFlavor == null) { dtde.rejectDrop(); tp.setInsertionPoint(COLUMN_INDEX_NONE); } else { try { DBTree dbtree = ArchitectFrame.getMainInstance().dbTree; // XXX: bad int insertionPoint = tp.pointToColumnIndex(dtde.getLocation()); if (insertionPoint < 0) insertionPoint = 0; ArrayList paths = (ArrayList) t.getTransferData(importFlavor); Iterator pathIt = paths.iterator(); while (pathIt.hasNext()) { Object someData = dbtree.getNodeForDnDPath((int[]) pathIt.next()); logger.debug("drop: got object of type "+someData.getClass().getName()); if (someData instanceof SQLTable) { SQLTable table = (SQLTable) someData; if (table.getParentDatabase() == tp.getModel().getParentDatabase()) { // can't import table from target into target!! dtde.rejectDrop(); } else { dtde.acceptDrop(DnDConstants.ACTION_COPY); tp.getModel().inherit(insertionPoint, table); dtde.dropComplete(true); } return; } else if (someData instanceof SQLColumn) { SQLColumn col = (SQLColumn) someData; if (col.getParentTable().getParentDatabase() == tp.getModel().getParentDatabase()) { dtde.acceptDrop(DnDConstants.ACTION_MOVE); int removedIndex = col.getParent().getChildren().indexOf(col); if (tp.getModel() == col.getParentTable()) { // moving column inside the same table if (insertionPoint > removedIndex) { insertionPoint--; } } col.getParentTable().removeColumn(col); logger.debug("Adding column '"+col.getName() +"' to table '"+tp.getModel().getName() +"' at position "+insertionPoint); tp.getModel().addColumn(insertionPoint, col); dtde.dropComplete(true); } else { dtde.acceptDrop(DnDConstants.ACTION_COPY); tp.getModel().inherit(insertionPoint, col); logger.debug("Inherited "+col.getColumnName()+" to table"); dtde.dropComplete(true); } return; } else { dtde.rejectDrop(); } } } catch(Exception ex) { JOptionPane.showMessageDialog(tp, "Drop failed: "+ex.getMessage()); logger.error("Error processing drop operation", ex); dtde.rejectDrop(); } finally { tp.setInsertionPoint(COLUMN_INDEX_NONE); } } }
public void drop(DropTargetDropEvent dtde) { TablePane tp = (TablePane) dtde.getDropTargetContext().getComponent(); logger.debug("Drop target drop event on "+tp.getName()+": "+dtde); Transferable t = dtde.getTransferable(); DataFlavor importFlavor = bestImportFlavor(tp, t.getTransferDataFlavors()); if (importFlavor == null) { dtde.rejectDrop(); tp.setInsertionPoint(COLUMN_INDEX_NONE); } else { try { DBTree dbtree = ArchitectFrame.getMainInstance().dbTree; // XXX: bad int insertionPoint = tp.pointToColumnIndex(dtde.getLocation()); if (insertionPoint < 0) insertionPoint = 0; ArrayList paths = (ArrayList) t.getTransferData(importFlavor); Iterator pathIt = paths.iterator(); while (pathIt.hasNext()) { Object someData = dbtree.getNodeForDnDPath((int[]) pathIt.next()); logger.debug("drop: got object of type "+someData.getClass().getName()); if (someData instanceof SQLTable) { SQLTable table = (SQLTable) someData; if (table.getParentDatabase() == tp.getModel().getParentDatabase()) { // can't import table from target into target!! dtde.rejectDrop(); } else { dtde.acceptDrop(DnDConstants.ACTION_COPY); tp.getModel().inherit(insertionPoint, table); dtde.dropComplete(true); } } else if (someData instanceof SQLColumn) { SQLColumn col = (SQLColumn) someData; if (col.getParentTable().getParentDatabase() == tp.getModel().getParentDatabase()) { dtde.acceptDrop(DnDConstants.ACTION_MOVE); int removedIndex = col.getParent().getChildren().indexOf(col); if (tp.getModel() == col.getParentTable()) { // moving column inside the same table if (insertionPoint > removedIndex) { insertionPoint--; } } col.getParentTable().removeColumn(col); logger.debug("Adding column '"+col.getName() +"' to table '"+tp.getModel().getName() +"' at position "+insertionPoint); tp.getModel().addColumn(insertionPoint, col); dtde.dropComplete(true); } else { dtde.acceptDrop(DnDConstants.ACTION_COPY); tp.getModel().inherit(insertionPoint, col); logger.debug("Inherited "+col.getColumnName()+" to table"); dtde.dropComplete(true); } } else { dtde.rejectDrop(); } } } catch(Exception ex) { JOptionPane.showMessageDialog(tp, "Drop failed: "+ex.getMessage()); logger.error("Error processing drop operation", ex); dtde.rejectDrop(); } finally { tp.setInsertionPoint(COLUMN_INDEX_NONE); } } }
1,112,491
protected Tag findDynamicTag(JellyContext context, StaticTag tag) throws Exception { // lets see if there's a tag library for this URI... TagLibrary taglib = context.getTagLibrary( tag.getUri() ); if ( taglib instanceof DynamicTagLibrary ) { DynamicTagLibrary dynaLib = (DynamicTagLibrary) taglib; Tag newTag = dynaLib.createTag( tag.getLocalName() ); if ( newTag != null ) { newTag.setParent( tag.getParent() ); newTag.setBody( tag.getBody() ); return newTag; } } return tag; }
protected Tag findDynamicTag(JellyContext context, StaticTag tag) throws Exception { // lets see if there's a tag library for this URI... TagLibrary taglib = context.getTagLibrary( tag.getUri() ); if ( taglib instanceof DynamicTagLibrary ) { DynamicTagLibrary dynaLib = (DynamicTagLibrary) taglib; Tag newTag = dynaLib.createTag( tag.getLocalName(), getSaxAttributes() ); if ( newTag != null ) { newTag.setParent( tag.getParent() ); newTag.setBody( tag.getBody() ); return newTag; } } return tag; }
1,112,492
protected JPopupMenu refreshMenu(TreePath p) { logger.debug("refreshMenu is being called."); JPopupMenu newMenu = new JPopupMenu(); newMenu.add(connectionsMenu = new JMenu("Add Source Connection")); connectionsMenu.add(new JMenuItem(newDBCSAction)); connectionsMenu.addSeparator(); // populate for (ArchitectDataSource dbcs : ArchitectFrame.getMainInstance().getUserSettings().getConnections()) { connectionsMenu.add(new JMenuItem(new AddDBCSAction(dbcs))); } if (isTargetDatabaseNode(p)) { newMenu.addSeparator(); // two menu items: "Set Target Database" and "Connection Properties newMenu.add(connectionsMenu = new JMenu("Set Target Database")); if (ArchitectFrame.getMainInstance().getUserSettings().getConnections().size() == 0) { // disable if there's no connections in user settings yet (annoying, but less confusing) connectionsMenu.setEnabled(false); } else { SQLDatabase ppdb = ArchitectFrame.getMainInstance().getProject().getPlayPen().getDatabase(); // populate for (ArchitectDataSource dbcs : ArchitectFrame.getMainInstance().getUserSettings().getConnections()) { connectionsMenu.add(new JMenuItem(new SetDataSourceAction(ppdb, dbcs))); } } JMenuItem popupProperties = new JMenuItem(dbcsPropertiesAction); newMenu.add(popupProperties); } else if (isTargetDatabaseChild(p)) { newMenu.addSeparator(); ArchitectFrame af = ArchitectFrame.getMainInstance(); JMenuItem mi; mi = new JMenuItem(); mi.setAction(af.editColumnAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if (p.getLastPathComponent() instanceof SQLColumn) { mi.setEnabled(true); } else { mi.setEnabled(false); } mi = new JMenuItem(); mi.setAction(af.insertColumnAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if (p.getLastPathComponent() instanceof SQLTable || p.getLastPathComponent() instanceof SQLColumn) { mi.setEnabled(true); } else { mi.setEnabled(false); } newMenu.addSeparator(); mi = new JMenuItem(); mi.setAction(showInPlayPenAction); newMenu.add(mi); mi = new JMenuItem(); mi.setAction(af.editTableAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if (p.getLastPathComponent() instanceof SQLTable || p.getLastPathComponent() instanceof SQLColumn) { mi.setEnabled(true); } else { mi.setEnabled(false); } mi = new JMenuItem(); mi.setAction(af.editRelationshipAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if (p.getLastPathComponent() instanceof SQLRelationship) { mi.setEnabled(true); } else { mi.setEnabled(false); } mi = new JMenuItem(); mi.setAction(af.deleteSelectedAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if (p.getLastPathComponent() instanceof SQLTable || p.getLastPathComponent() instanceof SQLColumn || p.getLastPathComponent() instanceof SQLRelationship) { mi.setEnabled(true); } else { mi.setEnabled(false); } } else if (p != null) { // clicked on DBCS item in DBTree newMenu.addSeparator(); if (p.getLastPathComponent() instanceof SQLDatabase) { newMenu.add(new JMenuItem(removeDBCSAction)); } JMenuItem popupProperties = new JMenuItem(dbcsPropertiesAction); newMenu.add(popupProperties); } // Show exception details (SQLException node can appear anywhere in the hierarchy) if (p != null && p.getLastPathComponent() instanceof SQLExceptionNode) { newMenu.addSeparator(); final SQLExceptionNode node = (SQLExceptionNode) p.getLastPathComponent(); newMenu.add(new JMenuItem(new AbstractAction("Show Exception Details") { public void actionPerformed(ActionEvent e) { ASUtils.showExceptionDialog("Exception Node Report", node.getException()); } })); // If the sole child is an exception node, we offer the user a way to re-try the operation try { final SQLObject parent = node.getParent(); if (parent.getChildCount() == 1) { newMenu.add(new JMenuItem(new AbstractAction("Retry") { public void actionPerformed(ActionEvent e) { parent.removeChild(0); parent.setPopulated(false); try { parent.getChildren(); // forces populate } catch (ArchitectException ex) { try { parent.addChild(new SQLExceptionNode(ex, "New exception during retry")); } catch (ArchitectException e1) { logger.error("Couldn't add SQLExceptionNode to menu:", e1); JOptionPane.showMessageDialog(null, "Failed to add SQLExceptionNode:\n"+e1.getMessage()); } ASUtils.showExceptionDialog("Exception occurred during retry", ex); } } })); } } catch (ArchitectException ex) { logger.error("Couldn't count siblings of SQLExceptionNode", ex); } } // add in Show Listeners if debug is enabled if (logger.isDebugEnabled()) { newMenu.addSeparator(); JMenuItem showListeners = new JMenuItem("Show Listeners"); showListeners.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SQLObject so = (SQLObject) getLastSelectedPathComponent(); if (so != null) { JOptionPane.showMessageDialog(DBTree.this, new JScrollPane(new JList(new java.util.Vector(so.getSQLObjectListeners())))); } } }); newMenu.add(showListeners); } return newMenu; }
protected JPopupMenu refreshMenu(TreePath p) { logger.debug("refreshMenu is being called."); JPopupMenu newMenu = new JPopupMenu(); newMenu.add(connectionsMenu = new JMenu("Add Source Connection")); connectionsMenu.add(new JMenuItem(newDBCSAction)); connectionsMenu.addSeparator(); // populate for (ArchitectDataSource dbcs : ArchitectFrame.getMainInstance().getUserSettings().getConnections()) { connectionsMenu.add(new JMenuItem(new AddDBCSAction(dbcs))); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); if (isTargetDatabaseNode(p)) { newMenu.addSeparator(); // two menu items: "Set Target Database" and "Connection Properties newMenu.add(connectionsMenu = new JMenu("Set Target Database")); if (ArchitectFrame.getMainInstance().getUserSettings().getConnections().size() == 0) { // disable if there's no connections in user settings yet (annoying, but less confusing) connectionsMenu.setEnabled(false); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); else { SQLDatabase ppdb = ArchitectFrame.getMainInstance().getProject().getPlayPen().getDatabase(); // populate for (ArchitectDataSource dbcs : ArchitectFrame.getMainInstance().getUserSettings().getConnections()) { connectionsMenu.add(new JMenuItem(new SetDataSourceAction(ppdb, dbcs))); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); JMenuItem popupProperties = new JMenuItem(dbcsPropertiesAction); newMenu.add(popupProperties); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); else if (isTargetDatabaseChild(p)) { newMenu.addSeparator(); ArchitectFrame af = ArchitectFrame.getMainInstance(); JMenuItem mi; mi = new JMenuItem(); mi.setAction(af.editColumnAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if (p.getLastPathComponent() instanceof SQLColumn) { mi.setEnabled(true); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); else { mi.setEnabled(false); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); mi = new JMenuItem(); mi.setAction(af.insertColumnAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if (p.getLastPathComponent() instanceof SQLTable || p.getLastPathComponent() instanceof SQLColumn) { mi.setEnabled(true); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); else { mi.setEnabled(false); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); newMenu.addSeparator(); mi = new JMenuItem(); mi.setAction(showInPlayPenAction); newMenu.add(mi); mi = new JMenuItem(); mi.setAction(af.editTableAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if (p.getLastPathComponent() instanceof SQLTable || p.getLastPathComponent() instanceof SQLColumn) { mi.setEnabled(true); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); else { mi.setEnabled(false); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); mi = new JMenuItem(); mi.setAction(af.editRelationshipAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if (p.getLastPathComponent() instanceof SQLRelationship) { mi.setEnabled(true); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); else { mi.setEnabled(false); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); mi = new JMenuItem(); mi.setAction(af.deleteSelectedAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if (p.getLastPathComponent() instanceof SQLTable || p.getLastPathComponent() instanceof SQLColumn || p.getLastPathComponent() instanceof SQLRelationship) { mi.setEnabled(true); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); else { mi.setEnabled(false); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); else if (p != null) { // clicked on DBCS item in DBTree newMenu.addSeparator(); if (p.getLastPathComponent() instanceof SQLDatabase) { newMenu.add(new JMenuItem(removeDBCSAction)); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); JMenuItem popupProperties = new JMenuItem(dbcsPropertiesAction); newMenu.add(popupProperties); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); // Show exception details (SQLException node can appear anywhere in the hierarchy) if (p != null && p.getLastPathComponent() instanceof SQLExceptionNode) { newMenu.addSeparator(); final SQLExceptionNode node = (SQLExceptionNode) p.getLastPathComponent(); newMenu.add(new JMenuItem(new AbstractAction("Show Exception Details") { public void actionPerformed(ActionEvent e) { ASUtils.showExceptionDialog("Exception Node Report", node.getException()); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu);)); // If the sole child is an exception node, we offer the user a way to re-try the operation try { final SQLObject parent = node.getParent(); if (parent.getChildCount() == 1) { newMenu.add(new JMenuItem(new AbstractAction("Retry") { public void actionPerformed(ActionEvent e) { parent.removeChild(0); parent.setPopulated(false); try { parent.getChildren(); // forces populate } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); catch (ArchitectException ex) { try { parent.addChild(new SQLExceptionNode(ex, "New exception during retry")); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); catch (ArchitectException e1) { logger.error("Couldn't add SQLExceptionNode to menu:", e1); JOptionPane.showMessageDialog(null, "Failed to add SQLExceptionNode:\n"+e1.getMessage()); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); ASUtils.showExceptionDialog("Exception occurred during retry", ex); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu);)); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); catch (ArchitectException ex) { logger.error("Couldn't count siblings of SQLExceptionNode", ex); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); // add in Show Listeners if debug is enabled if (logger.isDebugEnabled()) { newMenu.addSeparator(); JMenuItem showListeners = new JMenuItem("Show Listeners"); showListeners.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SQLObject so = (SQLObject) getLastSelectedPathComponent(); if (so != null) { JOptionPane.showMessageDialog(DBTree.this, new JScrollPane(new JList(new java.util.Vector(so.getSQLObjectListeners())))); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu);); newMenu.add(showListeners); } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); return newMenu; } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu);
1,112,493
public void propertyChange( PropertyChangeEvent ev ) { if ( ev.getPropertyName().equals( "value" ) ) { Object src = ev.getSource(); if ( src.getClass() == JFormattedTextField.class ) { Object field = ((JFormattedTextField) src).getClientProperty( FIELD_NAME ); ctrl.viewChanged( this, (String) field ); } } }
public void propertyChange( PropertyChangeEvent ev ) { if ( ev.getPropertyName().equals( "value" ) ) { Object src = ev.getSource(); if ( src.getClass() == JFormattedTextField.class ) { Object field = ((JFormattedTextField) src).getClientProperty( FIELD_NAME ); Object value = ((JFormattedTextField) src).getValue(); if ( value != null ) { log.warn( "Property changed: " + (String) field ); System.out.println( "Property changed: " + (String) field ); ctrl.viewChanged( this, (String) field ); } } } }
1,112,495
public ReadDataDialog(String title, HaploView h){ super(h, title); //Ped Panel... pedFileField = new JTextField("",20); JButton browsePedFileButton = new JButton("Browse"); browsePedFileButton.setActionCommand(BROWSE_GENO); browsePedFileButton.addActionListener(this); pedInfoField = new JTextField("",20); pedInfoField.getDocument().addDocumentListener(this); JButton browsePedInfoButton = new JButton("Browse"); browsePedInfoButton.setActionCommand(BROWSE_INFO); browsePedInfoButton.addActionListener(this); JPanel assocPanel = new JPanel(); doAssociation = new JCheckBox("Do association test?"); doAssociation.setSelected(false); doAssociation.setEnabled(false); doAssociation.setActionCommand("association"); doAssociation.addActionListener(this); xChrom = new JCheckBox("X Chromosome"); xChrom.setSelected(false); xChrom.setActionCommand("xChrom"); xChrom.addActionListener(this); assocPanel.add(xChrom); assocPanel.add(doAssociation); JPanel tdtOptsPanel = new JPanel(); trioButton = new JRadioButton("Family trio data", true); trioButton.setEnabled(false); trioButton.setActionCommand("tdt"); trioButton.addActionListener(this); ccButton = new JRadioButton("Case/Control data"); ccButton.setEnabled(false); ccButton.setActionCommand("ccButton"); ccButton.addActionListener(this); ButtonGroup group = new ButtonGroup(); group.add(trioButton); group.add(ccButton); tdtOptsPanel.add(trioButton); tdtOptsPanel.add(ccButton); JPanel tdtTypePanel = new JPanel(); standardTDT = new JRadioButton("Standard TDT", true); standardTDT.setEnabled(false); parenTDT = new JRadioButton("ParenTDT", true); parenTDT.setEnabled(false); ButtonGroup tdtGroup = new ButtonGroup(); tdtGroup.add(standardTDT); tdtGroup.add(parenTDT); tdtTypePanel.add(standardTDT); tdtTypePanel.add(parenTDT); testFileField = new JTextField("",20); testFileField.setEnabled(false); testFileField.setBackground(this.getBackground()); browseAssocButton = new JButton("Browse"); browseAssocButton.setActionCommand(BROWSE_ASSOC); browseAssocButton.addActionListener(this); browseAssocButton.setEnabled(false); testFileLabel = new JLabel("Test list file (optional):"); testFileLabel.setEnabled(false); //Haps Panel.. hapsFileField = new JTextField("",20); JButton browseHapsFileButton = new JButton("Browse"); browseHapsFileButton.setActionCommand(BROWSE_HAPS); browseHapsFileButton.addActionListener(this); hapsInfoField = new JTextField("",20); JButton browseHapsInfoButton = new JButton("Browse"); browseHapsInfoButton.setActionCommand(BROWSE_INFO); browseHapsInfoButton.addActionListener(this); hapsXChrom = new JCheckBox("X Chromosome"); hapsXChrom.setSelected(false); hapsXChrom.setActionCommand("xChrom"); hapsXChrom.addActionListener(this); //HMP panel... hmpFileField = new JTextField("",20); JButton browseHmpButton = new JButton("Browse"); browseHmpButton.setActionCommand(BROWSE_HMP); browseHmpButton.addActionListener(this); doGB = new JCheckBox("Download and show HapMap info track? (requires internet connection)"); doGB.setSelected(false); //PHASE panel... phaseFileField = new JTextField("",20); JButton browsePhaseButton = new JButton("Browse"); browsePhaseButton.setActionCommand(BROWSE_PHASE); browsePhaseButton.addActionListener(this); phaseSampleField = new JTextField("",20); JButton browseSampleButton = new JButton("Browse"); browseSampleButton.setActionCommand(BROWSE_SAMPLE); browseSampleButton.addActionListener(this); phaseLegendField = new JTextField("",20); JButton browseLegendButton = new JButton("Browse"); browseLegendButton.setActionCommand(BROWSE_LEGEND); browseLegendButton.addActionListener(this); JPanel phaseGzipPanel = new JPanel(); gZip = new JCheckBox("Files are GZIP compressed", false); gZip.setEnabled(true); phaseGzipPanel.add(gZip); JPanel phaseChromPanel = new JPanel(); phaseChromPanel.add(new JLabel("Chromosome (Required for Info Track):")); loadChromChooser.setSelectedIndex(-1); phaseChromPanel.add(loadChromChooser); JPanel phaseBrowsePanel = new JPanel(); phaseDoGB = new JCheckBox("Download and show HapMap info track? (requires internet connection)"); phaseDoGB.setSelected(false); phaseBrowsePanel.add(phaseDoGB); //Download Panel... JPanel downloadChooserPanel = new JPanel(); downloadChooserPanel.add(new JLabel("Phase")); downloadChooserPanel.add(phaseChooser); phaseChooser.setSelectedIndex(1); downloadChooserPanel.add(new JLabel("Chromosome:")); chromChooser.setSelectedIndex(-1); downloadChooserPanel.add(chromChooser); downloadChooserPanel.add(new JLabel("Population:")); downloadChooserPanel.add(popChooser); JPanel downloadPositionPanel = new JPanel(); chromStartField = new NumberTextField("",6,false); chromStartField.setEnabled(true); chromEndField = new NumberTextField("",6,false); chromEndField.setEnabled(true); downloadPositionPanel.add(new JLabel("Start kb:")); downloadPositionPanel.add(chromStartField); downloadPositionPanel.add(new JLabel("End kb:")); downloadPositionPanel.add(chromEndField); JPanel downloadBrowsePanel = new JPanel(); downloadDoGB = new JCheckBox("Download and show HapMap info track? (requires internet connection)"); downloadDoGB.setSelected(true); downloadBrowsePanel.add(downloadDoGB); //Plink Panel... plinkFileField = new JTextField("",20); JButton browsePlinkFileButton = new JButton("Browse"); browsePlinkFileButton.setActionCommand(BROWSE_WGA); browsePlinkFileButton.addActionListener(this); mapLabel = new JLabel("Map File:"); plinkMapField = new JTextField("",20); browsePlinkMapButton = new JButton("Browse"); browsePlinkMapButton.setActionCommand(BROWSE_MAP); browsePlinkMapButton.addActionListener(this); embeddedMap = new JCheckBox("Integrated Map Info"); embeddedMap.addActionListener(this); embeddedMap.setSelected(false); JPanel pedTab = new JPanel(new GridBagLayout()); pedTab.setPreferredSize(new Dimension(375,200)); JPanel hapsTab = new JPanel(new GridBagLayout()); JPanel hmpTab = new JPanel(new GridBagLayout()); JPanel phaseTab = new JPanel(new GridBagLayout()); JPanel downloadTab = new JPanel(new GridBagLayout()); JPanel plinkTab = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.EAST; c.gridx = 0; c.gridy = 0; c.insets = new Insets(5,5,5,5); pedTab.add(new JLabel("Data File:"),c); hapsTab.add(new JLabel("Data File:"),c); phaseTab.add(new JLabel("Phase File:"),c); plinkTab.add(new JLabel("Results File:"),c); c.weightx = 1; hmpTab.add(new JLabel("Data File:"),c); c.anchor = GridBagConstraints.CENTER; c.weightx = 0; downloadTab.add(downloadChooserPanel,c); c.gridx = 1; pedTab.add(pedFileField,c); hapsTab.add(hapsFileField,c); hmpTab.add(hmpFileField,c); phaseTab.add(phaseFileField,c); plinkTab.add(plinkFileField,c); c.gridx = 2; c.insets = new Insets(0,10,0,0); pedTab.add(browsePedFileButton,c); hapsTab.add(browseHapsFileButton,c); plinkTab.add(browsePlinkFileButton,c); c.anchor = GridBagConstraints.WEST; phaseTab.add(browsePhaseButton,c); c.weightx = 1; hmpTab.add(browseHmpButton,c); c.weightx = 0; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(5,5,5,5); c.gridy = 1; c.gridx = 0; downloadTab.add(downloadPositionPanel,c); c.gridy = 2; downloadTab.add(downloadBrowsePanel,c); c.anchor = GridBagConstraints.EAST; c.gridx = 0; c.gridy = 1; c.insets = new Insets(5,5,5,5); pedTab.add(new JLabel("Locus Information File:"),c); hapsTab.add(new JLabel("Locus Information File:"),c); phaseTab.add(new JLabel("Sample File:"),c); plinkTab.add(mapLabel,c); c.anchor = GridBagConstraints.CENTER; c.gridx = 1; c.insets = new Insets(0,0,0,0); pedTab.add(pedInfoField,c); hapsTab.add(hapsInfoField,c); phaseTab.add(phaseSampleField,c); plinkTab.add(plinkMapField,c); c.gridx = 2; c.insets = new Insets(0,10,0,0); pedTab.add(browsePedInfoButton,c); hapsTab.add(browseHapsInfoButton,c); plinkTab.add(browsePlinkMapButton,c); c.anchor = GridBagConstraints.WEST; phaseTab.add(browseSampleButton,c); c.anchor = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.EAST; c.insets = new Insets(5,5,5,5); phaseTab.add(new JLabel("Legend File:"),c); c.anchor = GridBagConstraints.CENTER; c.gridx = 1; phaseTab.add(phaseLegendField,c); c.gridx = 2; c.insets = new Insets(0,10,0,0); c.anchor = GridBagConstraints.WEST; phaseTab.add(browseLegendButton,c); c.anchor = GridBagConstraints.CENTER; c.gridx = 0; c.gridwidth = 3; c.insets = new Insets(0,0,0,0); pedTab.add(assocPanel,c); hapsTab.add(hapsXChrom, c); hmpTab.add(doGB,c); plinkTab.add(embeddedMap,c); c.gridy = 3; pedTab.add(tdtOptsPanel,c); phaseTab.add(phaseGzipPanel,c); c.gridy = 4; pedTab.add(tdtTypePanel,c); phaseTab.add(phaseChromPanel,c); c.gridy = 5; phaseTab.add(phaseBrowsePanel,c); c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.insets = new Insets(0,0,0,5); pedTab.add(testFileLabel,c); c.gridx = 1; c.insets = new Insets(0,0,0,0); pedTab.add(testFileField,c); c.gridx = 2; c.insets = new Insets(0,10,0,0); pedTab.add(browseAssocButton,c); dataFormatPane.setFont(new Font("Default",Font.BOLD,12)); dataFormatPane.addTab("Linkage Format",pedTab); dataFormatPane.addTab("Haps Format",hapsTab); dataFormatPane.addTab("HapMap Format",hmpTab); dataFormatPane.addTab("PHASE Format",phaseTab); dataFormatPane.addTab("<html>Phased HapMap<br>Download",downloadTab); dataFormatPane.addTab("PLINK Format",plinkTab); JButton okButton = new JButton("OK"); okButton.addActionListener(this); this.getRootPane().setDefaultButton(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); JButton proxyButton = new JButton("Proxy Settings"); proxyButton.addActionListener(this); JPanel choicePanel = new JPanel(); choicePanel.add(okButton); choicePanel.add(cancelButton); JPanel proxyPanel = new JPanel(); proxyPanel.add(proxyButton); JPanel contents = new JPanel(); contents.setLayout(new GridBagLayout()); GridBagConstraints a = new GridBagConstraints(); a.gridwidth = 3; a.gridx = 0; a.gridy = 0; contents.add(dataFormatPane, a); JPanel compDistPanel = new JPanel(); compDistPanel.add(new JLabel("Ignore pairwise comparisons of markers >")); maxComparisonDistField = new NumberTextField(String.valueOf(Options.getMaxDistance()/1000),6, false); compDistPanel.add(maxComparisonDistField); compDistPanel.add(new JLabel("kb apart.")); a.gridy = 1; contents.add(compDistPanel,a); JPanel missingCutoffPanel = new JPanel(); missingCutoffField = new NumberTextField(String.valueOf(Options.getMissingThreshold()*100),3, false); missingCutoffPanel.add(new JLabel("Exclude individuals with >")); missingCutoffPanel.add(missingCutoffField); missingCutoffPanel.add(new JLabel("% missing genotypes.")); a.gridy = 2; contents.add(missingCutoffPanel,a); a.gridy = 3; contents.add(choicePanel,a); a.anchor = GridBagConstraints.EAST; a.gridx = 2; contents.add(proxyPanel,a); if (h.getPhasedSelection() != null){ if (((String)h.getPhasedSelection().get(0)).equals("I")){ phaseChooser.setSelectedIndex(0); } if (((String)h.getPhasedSelection().get(1)).equals("X")){ chromChooser.setSelectedIndex(22); }else{ chromChooser.setSelectedIndex(Integer.parseInt((String)h.getPhasedSelection().get(1))-1); } if (((String)h.getPhasedSelection().get(2)).equals("CEU")){ popChooser.setSelectedIndex(1); }else if (((String)h.getPhasedSelection().get(2)).equals("CHB+JPT")){ popChooser.setSelectedIndex(2); } chromStartField.setText((String)h.getPhasedSelection().get(3)); chromEndField.setText((String)h.getPhasedSelection().get(4)); } //contents.setPreferredSize(new Dimension(700,700)); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); this.setResizable(false); }
public ReadDataDialog(String title, HaploView h){ super(h, title); //Ped Panel... pedFileField = new JTextField("",20); JButton browsePedFileButton = new JButton("Browse"); browsePedFileButton.setActionCommand(BROWSE_GENO); browsePedFileButton.addActionListener(this); pedInfoField = new JTextField("",20); pedInfoField.getDocument().addDocumentListener(this); JButton browsePedInfoButton = new JButton("Browse"); browsePedInfoButton.setActionCommand(BROWSE_INFO); browsePedInfoButton.addActionListener(this); JPanel assocPanel = new JPanel(); doAssociation = new JCheckBox("Do association test?"); doAssociation.setSelected(false); doAssociation.setEnabled(false); doAssociation.setActionCommand("association"); doAssociation.addActionListener(this); xChrom = new JCheckBox("X Chromosome"); xChrom.setSelected(false); xChrom.setActionCommand("xChrom"); xChrom.addActionListener(this); assocPanel.add(xChrom); assocPanel.add(doAssociation); JPanel tdtOptsPanel = new JPanel(); trioButton = new JRadioButton("Family trio data", true); trioButton.setEnabled(false); trioButton.setActionCommand("tdt"); trioButton.addActionListener(this); ccButton = new JRadioButton("Case/Control data"); ccButton.setEnabled(false); ccButton.setActionCommand("ccButton"); ccButton.addActionListener(this); ButtonGroup group = new ButtonGroup(); group.add(trioButton); group.add(ccButton); tdtOptsPanel.add(trioButton); tdtOptsPanel.add(ccButton); JPanel tdtTypePanel = new JPanel(); standardTDT = new JRadioButton("Standard TDT", true); standardTDT.setEnabled(false); parenTDT = new JRadioButton("ParenTDT", true); parenTDT.setEnabled(false); ButtonGroup tdtGroup = new ButtonGroup(); tdtGroup.add(standardTDT); tdtGroup.add(parenTDT); tdtTypePanel.add(standardTDT); tdtTypePanel.add(parenTDT); testFileField = new JTextField("",20); testFileField.setEnabled(false); testFileField.setBackground(this.getBackground()); browseAssocButton = new JButton("Browse"); browseAssocButton.setActionCommand(BROWSE_ASSOC); browseAssocButton.addActionListener(this); browseAssocButton.setEnabled(false); testFileLabel = new JLabel("Test list file (optional):"); testFileLabel.setEnabled(false); //Haps Panel.. hapsFileField = new JTextField("",20); JButton browseHapsFileButton = new JButton("Browse"); browseHapsFileButton.setActionCommand(BROWSE_HAPS); browseHapsFileButton.addActionListener(this); hapsInfoField = new JTextField("",20); JButton browseHapsInfoButton = new JButton("Browse"); browseHapsInfoButton.setActionCommand(BROWSE_INFO); browseHapsInfoButton.addActionListener(this); hapsXChrom = new JCheckBox("X Chromosome"); hapsXChrom.setSelected(false); hapsXChrom.setActionCommand("xChrom"); hapsXChrom.addActionListener(this); //HMP panel... hmpFileField = new JTextField("",20); JButton browseHmpButton = new JButton("Browse"); browseHmpButton.setActionCommand(BROWSE_HMP); browseHmpButton.addActionListener(this); doGB = new JCheckBox("Download and show HapMap info track? (requires internet connection)"); doGB.setSelected(false); //PHASE panel... phaseFileField = new JTextField("",20); JButton browsePhaseButton = new JButton("Browse"); browsePhaseButton.setActionCommand(BROWSE_PHASE); browsePhaseButton.addActionListener(this); phaseSampleField = new JTextField("",20); JButton browseSampleButton = new JButton("Browse"); browseSampleButton.setActionCommand(BROWSE_SAMPLE); browseSampleButton.addActionListener(this); phaseLegendField = new JTextField("",20); JButton browseLegendButton = new JButton("Browse"); browseLegendButton.setActionCommand(BROWSE_LEGEND); browseLegendButton.addActionListener(this); JPanel phaseGzipPanel = new JPanel(); gZip = new JCheckBox("Files are GZIP compressed", false); gZip.setEnabled(true); phaseGzipPanel.add(gZip); JPanel phaseChromPanel = new JPanel(); phaseChromPanel.add(new JLabel("Chromosome (Required for Info Track):")); loadChromChooser.setSelectedIndex(-1); phaseChromPanel.add(loadChromChooser); JPanel phaseBrowsePanel = new JPanel(); phaseDoGB = new JCheckBox("Download and show HapMap info track? (requires internet connection)"); phaseDoGB.setSelected(false); phaseBrowsePanel.add(phaseDoGB); //Download Panel... JPanel downloadChooserPanel = new JPanel(); downloadChooserPanel.add(new JLabel("Phase")); downloadChooserPanel.add(phaseChooser); phaseChooser.setSelectedIndex(1); downloadChooserPanel.add(new JLabel("Chromosome:")); chromChooser.setSelectedIndex(-1); downloadChooserPanel.add(chromChooser); downloadChooserPanel.add(new JLabel("Population:")); downloadChooserPanel.add(popChooser); JPanel downloadPositionPanel = new JPanel(); chromStartField = new NumberTextField("",6,false); chromStartField.setEnabled(true); chromEndField = new NumberTextField("",6,false); chromEndField.setEnabled(true); downloadPositionPanel.add(new JLabel("Start kb:")); downloadPositionPanel.add(chromStartField); downloadPositionPanel.add(new JLabel("End kb:")); downloadPositionPanel.add(chromEndField); JPanel downloadBrowsePanel = new JPanel(); downloadDoGB = new JCheckBox("Download and show HapMap info track? (requires internet connection)"); downloadDoGB.setSelected(true); downloadBrowsePanel.add(downloadDoGB); //Plink Panel... plinkFileField = new JTextField("",20); JButton browsePlinkFileButton = new JButton("Browse"); browsePlinkFileButton.setActionCommand(BROWSE_WGA); browsePlinkFileButton.addActionListener(this); mapLabel = new JLabel("Map File:"); plinkMapField = new JTextField("",20); browsePlinkMapButton = new JButton("Browse"); browsePlinkMapButton.setActionCommand(BROWSE_MAP); browsePlinkMapButton.addActionListener(this); embeddedMap = new JCheckBox("Integrated Map Info"); embeddedMap.addActionListener(this); embeddedMap.setSelected(false); JPanel pedTab = new JPanel(new GridBagLayout()); pedTab.setPreferredSize(new Dimension(375,200)); JPanel hapsTab = new JPanel(new GridBagLayout()); JPanel hmpTab = new JPanel(new GridBagLayout()); JPanel phaseTab = new JPanel(new GridBagLayout()); JPanel downloadTab = new JPanel(new GridBagLayout()); JPanel plinkTab = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.EAST; c.gridx = 0; c.gridy = 0; c.insets = new Insets(5,5,5,5); pedTab.add(new JLabel("Data File:"),c); hapsTab.add(new JLabel("Data File:"),c); phaseTab.add(new JLabel("Phase File:"),c); plinkTab.add(new JLabel("Results File:"),c); c.weightx = 1; hmpTab.add(new JLabel("Data File:"),c); c.anchor = GridBagConstraints.CENTER; c.weightx = 0; downloadTab.add(downloadChooserPanel,c); c.gridx = 1; pedTab.add(pedFileField,c); hapsTab.add(hapsFileField,c); hmpTab.add(hmpFileField,c); phaseTab.add(phaseFileField,c); plinkTab.add(plinkFileField,c); c.gridx = 2; c.insets = new Insets(0,10,0,0); pedTab.add(browsePedFileButton,c); hapsTab.add(browseHapsFileButton,c); plinkTab.add(browsePlinkFileButton,c); c.anchor = GridBagConstraints.WEST; phaseTab.add(browsePhaseButton,c); c.weightx = 1; hmpTab.add(browseHmpButton,c); c.weightx = 0; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(5,5,5,5); c.gridy = 1; c.gridx = 0; downloadTab.add(downloadPositionPanel,c); c.gridy = 2; downloadTab.add(downloadBrowsePanel,c); c.anchor = GridBagConstraints.EAST; c.gridx = 0; c.gridy = 1; c.insets = new Insets(5,5,5,5); pedTab.add(new JLabel("Locus Information File:"),c); hapsTab.add(new JLabel("Locus Information File:"),c); phaseTab.add(new JLabel("Sample File:"),c); plinkTab.add(mapLabel,c); c.anchor = GridBagConstraints.CENTER; c.gridx = 1; c.insets = new Insets(0,0,0,0); pedTab.add(pedInfoField,c); hapsTab.add(hapsInfoField,c); phaseTab.add(phaseSampleField,c); plinkTab.add(plinkMapField,c); c.gridx = 2; c.insets = new Insets(0,10,0,0); pedTab.add(browsePedInfoButton,c); hapsTab.add(browseHapsInfoButton,c); plinkTab.add(browsePlinkMapButton,c); c.anchor = GridBagConstraints.WEST; phaseTab.add(browseSampleButton,c); c.anchor = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.EAST; c.insets = new Insets(5,5,5,5); phaseTab.add(new JLabel("Legend File:"),c); c.anchor = GridBagConstraints.CENTER; c.gridx = 1; phaseTab.add(phaseLegendField,c); c.gridx = 2; c.insets = new Insets(0,10,0,0); c.anchor = GridBagConstraints.WEST; phaseTab.add(browseLegendButton,c); c.anchor = GridBagConstraints.CENTER; c.gridx = 0; c.gridwidth = 3; c.insets = new Insets(0,0,0,0); pedTab.add(assocPanel,c); hapsTab.add(hapsXChrom, c); hmpTab.add(doGB,c); plinkTab.add(embeddedMap,c); c.gridy = 3; pedTab.add(tdtOptsPanel,c); phaseTab.add(phaseGzipPanel,c); c.gridy = 4; pedTab.add(tdtTypePanel,c); phaseTab.add(phaseChromPanel,c); c.gridy = 5; phaseTab.add(phaseBrowsePanel,c); c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.insets = new Insets(0,0,0,5); pedTab.add(testFileLabel,c); c.gridx = 1; c.insets = new Insets(0,0,0,0); pedTab.add(testFileField,c); c.gridx = 2; c.insets = new Insets(0,10,0,0); pedTab.add(browseAssocButton,c); dataFormatPane.setFont(new Font("Default",Font.BOLD,12)); dataFormatPane.addTab("Linkage Format",pedTab); dataFormatPane.addTab("Haps Format",hapsTab); dataFormatPane.addTab("HapMap Format",hmpTab); dataFormatPane.addTab("PHASE Format",phaseTab); dataFormatPane.addTab("<html>Phased HapMap<br>Download",downloadTab); dataFormatPane.addTab("PLINK Format",plinkTab); JButton okButton = new JButton("OK"); okButton.addActionListener(this); this.getRootPane().setDefaultButton(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); JButton proxyButton = new JButton("Proxy Settings"); proxyButton.addActionListener(this); JPanel choicePanel = new JPanel(); choicePanel.add(okButton); choicePanel.add(cancelButton); JPanel proxyPanel = new JPanel(); proxyPanel.add(proxyButton); JPanel contents = new JPanel(); contents.setLayout(new GridBagLayout()); GridBagConstraints a = new GridBagConstraints(); a.gridwidth = 3; a.gridx = 0; a.gridy = 0; contents.add(dataFormatPane, a); JPanel compDistPanel = new JPanel(); compDistPanel.add(new JLabel("Ignore pairwise comparisons of markers >")); maxComparisonDistField = new NumberTextField(String.valueOf(Options.getMaxDistance()/1000),6, false); compDistPanel.add(maxComparisonDistField); compDistPanel.add(new JLabel("kb apart.")); a.gridy = 1; contents.add(compDistPanel,a); JPanel missingCutoffPanel = new JPanel(); missingCutoffField = new NumberTextField(String.valueOf(Options.getMissingThreshold()*100),3, false); missingCutoffPanel.add(new JLabel("Exclude individuals with >")); missingCutoffPanel.add(missingCutoffField); missingCutoffPanel.add(new JLabel("% missing genotypes.")); a.gridy = 2; contents.add(missingCutoffPanel,a); a.gridy = 3; contents.add(choicePanel,a); a.anchor = GridBagConstraints.EAST; a.gridx = 2; contents.add(proxyPanel,a); if (h.getPhasedSelection() != null){ if (((String)h.getPhasedSelection().get(0)).equals("I")){ phaseChooser.setSelectedIndex(0); } if (((String)h.getPhasedSelection().get(1)).equals("X")){ chromChooser.setSelectedIndex(22); }else{ chromChooser.setSelectedIndex(Integer.parseInt((String)h.getPhasedSelection().get(1))-1); } if (((String)h.getPhasedSelection().get(2)).equals("YRI")){ popChooser.setSelectedIndex(1); }else if (((String)h.getPhasedSelection().get(2)).equals("CHB+JPT")){ popChooser.setSelectedIndex(2); } chromStartField.setText((String)h.getPhasedSelection().get(3)); chromEndField.setText((String)h.getPhasedSelection().get(4)); } //contents.setPreferredSize(new Dimension(700,700)); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); this.setResizable(false); }
1,112,497
public void parsePhasedData(String[] info) throws IOException, PedFileException{ if (info[4].equals("")){ Chromosome.setDataChrom("none"); }else{ Chromosome.setDataChrom("chr" + info[4]); } Chromosome.setDataBuild("ncbi_b35"); Vector sampleData = new Vector(); Vector legendData = new Vector(); Vector legendMarkers = new Vector(); Vector legendPositions = new Vector(); Individual ind = null; byte[] byteDataT = new byte[0]; byte[] byteDataU = new byte[0]; this.allIndividuals = new Vector(); File phasedFile = new File(info[0]); File sampleFile = new File(info[1]); File legendFile = new File(info[2]); if (phasedFile.length() < 1){ throw new PedFileException("Genotypes file is empty or non-existent: " + phasedFile.getName()); }else if (sampleFile.length() < 1){ throw new PedFileException("Sample file is empty or non-existent: " + sampleFile.getName()); }else if (legendFile.length() < 1){ throw new PedFileException("Legend file is empty or non-existent: " + legendFile.getName()); } //read in the individual ids data. try{ BufferedReader sampleBuffReader; if (Options.getGzip()){ FileInputStream sampleFis = new FileInputStream(sampleFile); GZIPInputStream sampleInputStream = new GZIPInputStream(sampleFis); sampleBuffReader = new BufferedReader(new InputStreamReader(sampleInputStream)); }else{ FileReader sampleReader = new FileReader(sampleFile); sampleBuffReader = new BufferedReader(sampleReader); } String sampleLine; while((sampleLine = sampleBuffReader.readLine())!=null){ StringTokenizer sampleTokenizer = new StringTokenizer(sampleLine); sampleData.add(sampleTokenizer.nextToken()); } }catch(NoSuchElementException nse){ throw new PedFileException("File format error: " + sampleFile.getName()); } //read in the legend data try{ BufferedReader legendBuffReader; if (Options.getGzip()){ FileInputStream legendFis = new FileInputStream(legendFile); GZIPInputStream legendInputStream = new GZIPInputStream(legendFis); legendBuffReader = new BufferedReader(new InputStreamReader(legendInputStream)); }else{ FileReader legendReader = new FileReader(legendFile); legendBuffReader = new BufferedReader(legendReader); } String legendLine; String zero, one; while((legendLine = legendBuffReader.readLine())!=null){ StringTokenizer legendSt = new StringTokenizer(legendLine); String markerid = legendSt.nextToken(); if (markerid.equals("marker")){ //skip header continue; } legendMarkers.add(markerid); legendPositions.add(legendSt.nextToken()); byte[] legendBytes = new byte[2]; zero = legendSt.nextToken(); one = legendSt.nextToken(); if (zero.equalsIgnoreCase("A")){ legendBytes[0] = 1; }else if (zero.equalsIgnoreCase("C")){ legendBytes[0] = 2; }else if (zero.equalsIgnoreCase("G")){ legendBytes[0] = 3; }else if (zero.equalsIgnoreCase("T")){ legendBytes[0] = 4; }else{ throw new PedFileException("Invalid allele: " + zero); } if (one.equalsIgnoreCase("A")){ legendBytes[1] = 1; }else if (one.equalsIgnoreCase("C")){ legendBytes[1] = 2; }else if (one.equalsIgnoreCase("G")){ legendBytes[1] = 3; }else if (one.equalsIgnoreCase("T")){ legendBytes[1] = 4; }else{ throw new PedFileException("Invalid allele: " + one); } legendData.add(legendBytes); } hminfo = new String[legendPositions.size()][2]; for (int i = 0; i < legendPositions.size(); i++){ //marker name. hminfo[i][0] = (String)legendMarkers.get(i); //marker position. hminfo[i][1] = (String)legendPositions.get(i); } }catch(NoSuchElementException nse){ throw new PedFileException("File format error: " + legendFile.getName()); } //read in the phased data. try{ BufferedReader phasedBuffReader; if (Options.getGzip()){ FileInputStream phasedFis = new FileInputStream(phasedFile); GZIPInputStream phasedInputStream = new GZIPInputStream(phasedFis); phasedBuffReader = new BufferedReader(new InputStreamReader(phasedInputStream)); }else{ FileReader phasedReader = new FileReader(phasedFile); phasedBuffReader = new BufferedReader(phasedReader); } String phasedLine; int columns = 0; String token; boolean even = false; int iterator = 0; while((phasedLine = phasedBuffReader.readLine()) != null){ StringTokenizer phasedSt = new StringTokenizer(phasedLine); columns = phasedSt.countTokens(); if(even){ iterator++; }else{ //Only set up a new individual every 2 lines. ind = new Individual(columns, true); try{ ind.setIndividualID((String)sampleData.get(iterator)); }catch (ArrayIndexOutOfBoundsException e){ throw new PedFileException("File error: Sample file is missing individual IDs"); } if (columns != legendData.size()){ throw new PedFileException("File error: invalid number of markers on Individual " + ind.getIndividualID()); } String details = (String)hapMapTranslate.get(ind.getIndividualID()); //exception in case of wierd compression combos in input files if (details == null){ throw new PedFileException("File format error: " + sampleFile.getName()); } StringTokenizer dt = new StringTokenizer(details, "\n\t\" \""); ind.setFamilyID(dt.nextToken().trim()); //skip individualID since we already have it. dt.nextToken(); ind.setDadID(dt.nextToken()); ind.setMomID(dt.nextToken()); 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 " + ind.getIndividualID()); } //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); this.allIndividuals.add(ind); } int index = 0; if (!even){ byteDataT = new byte[columns]; }else{ byteDataU = new byte[columns]; } while(phasedSt.hasMoreTokens()){ token = phasedSt.nextToken(); if (!even){ if (token.equalsIgnoreCase("0")){ byteDataT[index] = ((byte[])legendData.get(index))[0]; }else if (token.equalsIgnoreCase("1")){ byteDataT[index] = ((byte[])legendData.get(index))[1]; }else { throw new PedFileException("File format error: " + phasedFile.getName()); } }else{ if (token.equalsIgnoreCase("0")){ byteDataU[index] = ((byte[])legendData.get(index))[0]; }else if (token.equalsIgnoreCase("1")){ byteDataU[index] = ((byte[])legendData.get(index))[1]; }else { throw new PedFileException("File format error: " + phasedFile.getName()); } } index++; } if (even){ for(int i=0; i < columns; i++){ ind.addMarker(byteDataT[i], byteDataU[i]); } } even = !even; } }catch(NoSuchElementException nse){ throw new PedFileException("File format error: " + phasedFile.getName()); } }
public void parsePhasedData(String[] info) throws IOException, PedFileException{ if (info[4].equals("")){ Chromosome.setDataChrom("none"); }else{ Chromosome.setDataChrom("chr" + info[4]); } Chromosome.setDataBuild("ncbi_b35"); Vector sampleData = new Vector(); Vector legendData = new Vector(); Vector legendMarkers = new Vector(); Vector legendPositions = new Vector(); Individual ind = null; byte[] byteDataT = new byte[0]; byte[] byteDataU = new byte[0]; this.allIndividuals = new Vector(); File phasedFile = new File(info[0]); File sampleFile = new File(info[1]); File legendFile = new File(info[2]); if (phasedFile.length() < 1){ throw new PedFileException("Genotypes file is empty or non-existent: " + phasedFile.getName()); }else if (sampleFile.length() < 1){ throw new PedFileException("Sample file is empty or non-existent: " + sampleFile.getName()); }else if (legendFile.length() < 1){ throw new PedFileException("Legend file is empty or non-existent: " + legendFile.getName()); } //read in the individual ids data. try{ BufferedReader sampleBuffReader; if (Options.getGzip()){ FileInputStream sampleFis = new FileInputStream(sampleFile); GZIPInputStream sampleInputStream = new GZIPInputStream(sampleFis); sampleBuffReader = new BufferedReader(new InputStreamReader(sampleInputStream)); }else{ FileReader sampleReader = new FileReader(sampleFile); sampleBuffReader = new BufferedReader(sampleReader); } String sampleLine; while((sampleLine = sampleBuffReader.readLine())!=null){ StringTokenizer sampleTokenizer = new StringTokenizer(sampleLine); sampleData.add(sampleTokenizer.nextToken()); } }catch(NoSuchElementException nse){ throw new PedFileException("File format error: " + sampleFile.getName()); } //read in the legend data try{ BufferedReader legendBuffReader; if (Options.getGzip()){ FileInputStream legendFis = new FileInputStream(legendFile); GZIPInputStream legendInputStream = new GZIPInputStream(legendFis); legendBuffReader = new BufferedReader(new InputStreamReader(legendInputStream)); }else{ FileReader legendReader = new FileReader(legendFile); legendBuffReader = new BufferedReader(legendReader); } String legendLine; String zero, one; while((legendLine = legendBuffReader.readLine())!=null){ StringTokenizer legendSt = new StringTokenizer(legendLine); String markerid = legendSt.nextToken(); if (markerid.equals("rs")){ //skip header continue; } legendMarkers.add(markerid); legendPositions.add(legendSt.nextToken()); byte[] legendBytes = new byte[2]; zero = legendSt.nextToken(); one = legendSt.nextToken(); if (zero.equalsIgnoreCase("A")){ legendBytes[0] = 1; }else if (zero.equalsIgnoreCase("C")){ legendBytes[0] = 2; }else if (zero.equalsIgnoreCase("G")){ legendBytes[0] = 3; }else if (zero.equalsIgnoreCase("T")){ legendBytes[0] = 4; }else{ throw new PedFileException("Invalid allele: " + zero); } if (one.equalsIgnoreCase("A")){ legendBytes[1] = 1; }else if (one.equalsIgnoreCase("C")){ legendBytes[1] = 2; }else if (one.equalsIgnoreCase("G")){ legendBytes[1] = 3; }else if (one.equalsIgnoreCase("T")){ legendBytes[1] = 4; }else{ throw new PedFileException("Invalid allele: " + one); } legendData.add(legendBytes); } hminfo = new String[legendPositions.size()][2]; for (int i = 0; i < legendPositions.size(); i++){ //marker name. hminfo[i][0] = (String)legendMarkers.get(i); //marker position. hminfo[i][1] = (String)legendPositions.get(i); } }catch(NoSuchElementException nse){ throw new PedFileException("File format error: " + legendFile.getName()); } //read in the phased data. try{ BufferedReader phasedBuffReader; if (Options.getGzip()){ FileInputStream phasedFis = new FileInputStream(phasedFile); GZIPInputStream phasedInputStream = new GZIPInputStream(phasedFis); phasedBuffReader = new BufferedReader(new InputStreamReader(phasedInputStream)); }else{ FileReader phasedReader = new FileReader(phasedFile); phasedBuffReader = new BufferedReader(phasedReader); } String phasedLine; int columns = 0; String token; boolean even = false; int iterator = 0; while((phasedLine = phasedBuffReader.readLine()) != null){ StringTokenizer phasedSt = new StringTokenizer(phasedLine); columns = phasedSt.countTokens(); if(even){ iterator++; }else{ //Only set up a new individual every 2 lines. ind = new Individual(columns, true); try{ ind.setIndividualID((String)sampleData.get(iterator)); }catch (ArrayIndexOutOfBoundsException e){ throw new PedFileException("File error: Sample file is missing individual IDs"); } if (columns != legendData.size()){ throw new PedFileException("File error: invalid number of markers on Individual " + ind.getIndividualID()); } String details = (String)hapMapTranslate.get(ind.getIndividualID()); //exception in case of wierd compression combos in input files if (details == null){ throw new PedFileException("File format error: " + sampleFile.getName()); } StringTokenizer dt = new StringTokenizer(details, "\n\t\" \""); ind.setFamilyID(dt.nextToken().trim()); //skip individualID since we already have it. dt.nextToken(); ind.setDadID(dt.nextToken()); ind.setMomID(dt.nextToken()); 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 " + ind.getIndividualID()); } //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); this.allIndividuals.add(ind); } int index = 0; if (!even){ byteDataT = new byte[columns]; }else{ byteDataU = new byte[columns]; } while(phasedSt.hasMoreTokens()){ token = phasedSt.nextToken(); if (!even){ if (token.equalsIgnoreCase("0")){ byteDataT[index] = ((byte[])legendData.get(index))[0]; }else if (token.equalsIgnoreCase("1")){ byteDataT[index] = ((byte[])legendData.get(index))[1]; }else { throw new PedFileException("File format error: " + phasedFile.getName()); } }else{ if (token.equalsIgnoreCase("0")){ byteDataU[index] = ((byte[])legendData.get(index))[0]; }else if (token.equalsIgnoreCase("1")){ byteDataU[index] = ((byte[])legendData.get(index))[1]; }else { throw new PedFileException("File format error: " + phasedFile.getName()); } } index++; } if (even){ for(int i=0; i < columns; i++){ ind.addMarker(byteDataT[i], byteDataU[i]); } } even = !even; } }catch(NoSuchElementException nse){ throw new PedFileException("File format error: " + phasedFile.getName()); } }
1,112,498