bugged
stringlengths 6
599k
| fixed
stringlengths 10
599k
| __index_level_0__
int64 0
1.13M
|
|---|---|---|
public User getUser(String username){ return users.containsKey(username) ? (User)users.get(username) : null; }
|
public User getUser(String username){ return users.containsKey(username) ? (User)users.get(username) : null; }
| 1,108,235
|
public JellyContext newJellyContext() { return createChildContext(); }
|
public JellyContext newJellyContext() { return createChildContext(); }
| 1,108,236
|
public DataTypeTag(String name, DataType dataType) { this.name = name; this.dataType = dataType; setDynaBean( new ConvertingWrapDynaBean(dataType) ); }
|
public DataTypeTag(String name, DataType dataType) { this.name = name; this.dataType = dataType; setDynaBean( new ConvertingWrapDynaBean(dataType) ); }
| 1,108,237
|
public TaskPropertyTag(String name) { setName(name); }
|
public TaskPropertyTag(String name) { setName(name); }
| 1,108,238
|
public Object createNestedObject(Object object, String name) throws Exception { Object dataType = null; if ( object != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( object.getClass() ); if ( ih != null ) { try { dataType = ih.createElement( getAntProject(), object, name ); } catch (Exception e) { log.error(e); } } } if ( dataType == null ) { dataType = createDataType( name ); } return dataType; }
|
public Object createNestedObject(Object object, String name) throws Exception { Object dataType = null; if ( object != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( object.getClass() ); if ( ih != null ) { try { dataType = ih.createElement( getAntProject(), object, name.toLowerCase() ); } catch (Exception e) { log.error(e); } } } if ( dataType == null ) { dataType = createDataType( name ); } return dataType; }
| 1,108,240
|
public BeanTag(Class defaultClass, String tagName) { this(defaultClass, tagName, null); }
|
public BeanTag(Class defaultClass, String tagName) { this(defaultClass, tagName, null); }
| 1,108,241
|
public JellyTagException(String message, Throwable cause) { super(message,cause); }
|
public JellyTagException(String message, Throwable cause) { super(message,cause); }
| 1,108,242
|
public DBCS_OkAction(DBCSPanel dbcsPanel, boolean isNew) { super("Ok"); this.dbcsPanel = dbcsPanel; this.isNew = isNew; dbcsPanel.setDbcs(new ArchitectDataSource()); }
|
public DBCS_OkAction(DBCSPanel dbcsPanel, boolean isNew) { super("Ok"); this.dbcsPanel = dbcsPanel; this.isNew = isNew; }
| 1,108,244
|
public static JDialog createArchitectPanelDialog( final ArchitectPanel arch, final Window dialogParent, final String dialogTitle, final String actionButtonTitle, final Action okAction, final Action cancelAction) { final JDialog d; if (dialogParent instanceof Frame) { d = new JDialog((Frame) dialogParent, dialogTitle); } else if (dialogParent instanceof Dialog) { d = new JDialog((Dialog) dialogParent, dialogTitle); } else { throw new IllegalArgumentException( "The dialogParent you gave me is not a " + "Frame or Dialog (it is a " + dialogParent.getClass().getName() + ")"); } JComponent panel = arch.getPanel(); // In all cases we have to close the dialog. Action closeAction = new CommonCloseAction(d); JButton okButton = new JButton(okAction); okButton.setText(actionButtonTitle); okButton.addActionListener(closeAction); JButton cancelButton = new JButton(cancelAction); cancelButton.setText(CANCEL_BUTTON_LABEL); cancelButton.addActionListener(closeAction); // Handle if the user presses Enter in the dialog - do OK action d.getRootPane().setDefaultButton(okButton); makeJDialogCancellable(d, cancelAction); // Now build the GUI. JPanel cp = new JPanel(new BorderLayout()); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); cp.add(panel, BorderLayout.CENTER); cp.add(ButtonBarFactory.buildOKCancelBar(okButton, cancelButton), BorderLayout.SOUTH); cp.setBorder(Borders.DIALOG_BORDER); //d.add(cp); d.setContentPane(cp); // XXX maybe pass yet another argument for this? // d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.pack(); return d; }
|
public static JDialog createArchitectPanelDialog( final ArchitectPanel arch, final Window dialogParent, final String dialogTitle, final String actionButtonTitle, final Action okAction, final Action cancelAction) { final JDialog d; if (dialogParent instanceof Frame) { d = new JDialog((Frame) dialogParent, dialogTitle); } else if (dialogParent instanceof Dialog) { d = new JDialog((Dialog) dialogParent, dialogTitle); } else { throw new IllegalArgumentException( "The dialogParent you gave me is not a " + "Frame or Dialog (it is a " + dialogParent.getClass().getName() + ")"); } JComponent panel = arch.getPanel(); // In all cases we have to close the dialog. Action closeAction = new CommonCloseAction(d); JButton okButton = new JDefaultButton(okAction); okButton.setText(actionButtonTitle); okButton.addActionListener(closeAction); JButton cancelButton = new JButton(cancelAction); cancelButton.setText(CANCEL_BUTTON_LABEL); cancelButton.addActionListener(closeAction); // Handle if the user presses Enter in the dialog - do OK action d.getRootPane().setDefaultButton(okButton); makeJDialogCancellable(d, cancelAction); // Now build the GUI. JPanel cp = new JPanel(new BorderLayout()); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); cp.add(panel, BorderLayout.CENTER); cp.add(ButtonBarFactory.buildOKCancelBar(okButton, cancelButton), BorderLayout.SOUTH); cp.setBorder(Borders.DIALOG_BORDER); //d.add(cp); d.setContentPane(cp); // XXX maybe pass yet another argument for this? // d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.pack(); return d; }
| 1,108,245
|
public static JDialog createArchitectPanelDialog( final ArchitectPanel arch, final Window dialogParent, final String dialogTitle, final String actionButtonTitle, final Action okAction, final Action cancelAction) { final JDialog d; if (dialogParent instanceof Frame) { d = new JDialog((Frame) dialogParent, dialogTitle); } else if (dialogParent instanceof Dialog) { d = new JDialog((Dialog) dialogParent, dialogTitle); } else { throw new IllegalArgumentException( "The dialogParent you gave me is not a " + "Frame or Dialog (it is a " + dialogParent.getClass().getName() + ")"); } JComponent panel = arch.getPanel(); // In all cases we have to close the dialog. Action closeAction = new CommonCloseAction(d); JButton okButton = new JButton(okAction); okButton.setText(actionButtonTitle); okButton.addActionListener(closeAction); JButton cancelButton = new JButton(cancelAction); cancelButton.setText(CANCEL_BUTTON_LABEL); cancelButton.addActionListener(closeAction); // Handle if the user presses Enter in the dialog - do OK action d.getRootPane().setDefaultButton(okButton); makeJDialogCancellable(d, cancelAction); // Now build the GUI. JPanel cp = new JPanel(new BorderLayout()); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); cp.add(panel, BorderLayout.CENTER); cp.add(ButtonBarFactory.buildOKCancelBar(okButton, cancelButton), BorderLayout.SOUTH); cp.setBorder(Borders.DIALOG_BORDER); //d.add(cp); d.setContentPane(cp); // XXX maybe pass yet another argument for this? // d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.pack(); return d; }
|
public static JDialog createArchitectPanelDialog( final ArchitectPanel arch, final Window dialogParent, final String dialogTitle, final String actionButtonTitle, final Action okAction, final Action cancelAction) { final JDialog d; if (dialogParent instanceof Frame) { d = new JDialog((Frame) dialogParent, dialogTitle); } else if (dialogParent instanceof Dialog) { d = new JDialog((Dialog) dialogParent, dialogTitle); } else { throw new IllegalArgumentException( "The dialogParent you gave me is not a " + "Frame or Dialog (it is a " + dialogParent.getClass().getName() + ")"); } JComponent panel = arch.getPanel(); // In all cases we have to close the dialog. Action closeAction = new CommonCloseAction(d); JButton okButton = new JButton(okAction); okButton.setText(actionButtonTitle); okButton.addActionListener(closeAction); JButton cancelButton = new JDefaultButton(cancelAction); cancelButton.setText(CANCEL_BUTTON_LABEL); cancelButton.addActionListener(closeAction); // Handle if the user presses Enter in the dialog - do OK action d.getRootPane().setDefaultButton(okButton); makeJDialogCancellable(d, cancelAction); // Now build the GUI. JPanel cp = new JPanel(new BorderLayout()); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); cp.add(panel, BorderLayout.CENTER); cp.add(ButtonBarFactory.buildOKCancelBar(okButton, cancelButton), BorderLayout.SOUTH); cp.setBorder(Borders.DIALOG_BORDER); //d.add(cp); d.setContentPane(cp); // XXX maybe pass yet another argument for this? // d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.pack(); return d; }
| 1,108,246
|
public static void showExceptionDialog(Component parent, String message, Throwable throwable) { try { ExceptionReport er = new ExceptionReport(throwable); er.setNumObjectsInPlayPen(ArchitectFrame.getMainInstance().playpen.getTablePanes().size() + ArchitectFrame.getMainInstance().playpen.getRelationships().size()); er.setNumSourceConnections(ArchitectFrame.getMainInstance().dbTree.getDatabaseList().size()); er.setUserActivityDescription(""); logger.debug(er.toString()); er.postReport(); } catch (Throwable seriousProblem) { logger.error("Couldn't generate and send exception report! Note that this is not the primary problem; it's a side effect of trying to report the real problem.", seriousProblem); JOptionPane.showMessageDialog(null, "Error reporting failed: "+seriousProblem.getMessage()+"\nAdditional information is available in the application log."); } finally { displayExceptionDialog(parent,message,throwable); } }
|
public static void showExceptionDialog(Component parent, String message, Throwable throwable) { try { ExceptionReport er = new ExceptionReport(throwable); er.setNumObjectsInPlayPen(ArchitectFrame.getMainInstance().playpen.getTablePanes().size() + ArchitectFrame.getMainInstance().playpen.getRelationships().size()); er.setNumSourceConnections(ArchitectFrame.getMainInstance().dbTree.getDatabaseList().size()); er.setUserActivityDescription(""); logger.debug(er.toString()); er.postReport(); } catch (Throwable seriousProblem) { logger.error("Couldn't generate and send exception report! Note that this is not the primary problem; it's a side effect of trying to report the real problem.", seriousProblem); JOptionPane.showMessageDialog(null, "Error reporting failed: "+seriousProblem.getMessage()+"\nAdditional information is available in the application log."); } finally { displayExceptionDialog(parent,message,throwable); } }
| 1,108,247
|
public List<DiffChunk<SQLObject>> generateTableDiffs() throws ArchitectException { try { Iterator sourceIter = sourceTableSet.iterator(); Iterator targetIter = targetTableSet.iterator(); SQLTable targetTable; SQLTable sourceTable; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; sourceTable = null; } if (targetIter.hasNext()) { targetContinue = true; targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; targetTable = null; } // Will loop until one or both the list reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceTable, targetTable) < 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceTable, targetTable) > 0) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); // now do the columns results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceTable, targetTable) == 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.SAME)); // now do the columns results.addAll(generateColumnDiffs(sourceTable, targetTable)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; } } results.addAll(generateRelationshipDiffs(sourceTableSet, targetTableSet)); } finally { setFinished(true); } return results; }
|
public List<DiffChunk<SQLObject>> generateTableDiffs() throws ArchitectException { try { Iterator sourceIter = sourceTableSet.iterator(); Iterator targetIter = targetTableSet.iterator(); SQLTable targetTable; SQLTable sourceTable; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; sourceTable = null; } if (targetIter.hasNext()) { targetContinue = true; targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; targetTable = null; } // Will loop until one or both the list reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target if (comparator.compare(sourceTable, targetTable) < 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceTable, targetTable) > 0) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); // now do the columns results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceTable, targetTable) == 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.SAME)); // now do the columns results.addAll(generateColumnDiffs(sourceTable, targetTable)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; } } results.addAll(generateRelationshipDiffs(sourceTableSet, targetTableSet)); } finally { setFinished(true); } return results; }
| 1,108,248
|
public List<DiffChunk<SQLObject>> generateTableDiffs() throws ArchitectException { try { Iterator sourceIter = sourceTableSet.iterator(); Iterator targetIter = targetTableSet.iterator(); SQLTable targetTable; SQLTable sourceTable; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; sourceTable = null; } if (targetIter.hasNext()) { targetContinue = true; targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; targetTable = null; } // Will loop until one or both the list reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceTable, targetTable) < 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceTable, targetTable) > 0) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); // now do the columns results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceTable, targetTable) == 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.SAME)); // now do the columns results.addAll(generateColumnDiffs(sourceTable, targetTable)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; } } results.addAll(generateRelationshipDiffs(sourceTableSet, targetTableSet)); } finally { setFinished(true); } return results; }
|
public List<DiffChunk<SQLObject>> generateTableDiffs() throws ArchitectException { try { Iterator sourceIter = sourceTableSet.iterator(); Iterator targetIter = targetTableSet.iterator(); SQLTable targetTable; SQLTable sourceTable; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; sourceTable = null; } if (targetIter.hasNext()) { targetContinue = true; targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; targetTable = null; } // Will loop until one or both the list reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceTable, targetTable) < 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; } } // bring the target table up to the same level as the source while (comparator.compare(sourceTable, targetTable) > 0) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); // now do the columns results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; } } while (comparator.compare(sourceTable, targetTable) == 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.SAME)); // now do the columns results.addAll(generateColumnDiffs(sourceTable, targetTable)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; } if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; } if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; } } results.addAll(generateRelationshipDiffs(sourceTableSet, targetTableSet)); } finally { setFinished(true); } return results; }
| 1,108,249
|
public List<DiffChunk<SQLObject>> generateTableDiffs() throws ArchitectException { try { Iterator sourceIter = sourceTableSet.iterator(); Iterator targetIter = targetTableSet.iterator(); SQLTable targetTable; SQLTable sourceTable; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; sourceTable = null; } if (targetIter.hasNext()) { targetContinue = true; targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; targetTable = null; } // Will loop until one or both the list reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceTable, targetTable) < 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceTable, targetTable) > 0) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); // now do the columns results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceTable, targetTable) == 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.SAME)); // now do the columns results.addAll(generateColumnDiffs(sourceTable, targetTable)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; } } results.addAll(generateRelationshipDiffs(sourceTableSet, targetTableSet)); } finally { setFinished(true); } return results; }
|
public List<DiffChunk<SQLObject>> generateTableDiffs() throws ArchitectException { try { Iterator sourceIter = sourceTableSet.iterator(); Iterator targetIter = targetTableSet.iterator(); SQLTable targetTable; SQLTable sourceTable; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; sourceTable = null; } if (targetIter.hasNext()) { targetContinue = true; targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; targetTable = null; } // Will loop until one or both the list reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceTable, targetTable) < 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source if (comparator.compare(sourceTable, targetTable) > 0) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); // now do the columns results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceTable, targetTable) == 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.SAME)); // now do the columns results.addAll(generateColumnDiffs(sourceTable, targetTable)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; } } results.addAll(generateRelationshipDiffs(sourceTableSet, targetTableSet)); } finally { setFinished(true); } return results; }
| 1,108,250
|
public List<DiffChunk<SQLObject>> generateTableDiffs() throws ArchitectException { try { Iterator sourceIter = sourceTableSet.iterator(); Iterator targetIter = targetTableSet.iterator(); SQLTable targetTable; SQLTable sourceTable; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; sourceTable = null; } if (targetIter.hasNext()) { targetContinue = true; targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; targetTable = null; } // Will loop until one or both the list reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceTable, targetTable) < 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceTable, targetTable) > 0) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); // now do the columns results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceTable, targetTable) == 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.SAME)); // now do the columns results.addAll(generateColumnDiffs(sourceTable, targetTable)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; } } results.addAll(generateRelationshipDiffs(sourceTableSet, targetTableSet)); } finally { setFinished(true); } return results; }
|
public List<DiffChunk<SQLObject>> generateTableDiffs() throws ArchitectException { try { Iterator sourceIter = sourceTableSet.iterator(); Iterator targetIter = targetTableSet.iterator(); SQLTable targetTable; SQLTable sourceTable; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; sourceTable = null; } if (targetIter.hasNext()) { targetContinue = true; targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; targetTable = null; } // Will loop until one or both the list reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceTable, targetTable) < 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceTable, targetTable) > 0) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); // now do the columns results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } } if (comparator.compare(sourceTable, targetTable) == 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.SAME)); // now do the columns results.addAll(generateColumnDiffs(sourceTable, targetTable)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; } } results.addAll(generateRelationshipDiffs(sourceTableSet, targetTableSet)); } finally { setFinished(true); } return results; }
| 1,108,251
|
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); Rectangle visRect = getVisibleRect(); /* boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } */ //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); BasicStroke fatStroke = new BasicStroke(3.0f); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getFilteredSize(); i++) { double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks boolean even = true; //g.setColor(new Color(153,255,153)); g.setColor(new Color(51,153,51)); g2.setStroke(fatStroke); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; g.drawLine(left + (2*first + 1) * boxSize/2 - boxRadius, top + boxSize/2, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last - 1) * boxSize/2+boxRadius, top + boxSize/2); for (int j = 0; j < theBlock.length; j++){ g.drawLine(left + (2*theBlock[j]+1) * boxSize/2 - boxRadius, top + boxSize/2, left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius); g.drawLine (left + (2*theBlock[j]) * boxSize/2 - boxRadius, top + boxSize/2 - boxRadius, left + (2*theBlock[j]) * boxSize/2, top + boxSize/2); } } g2.setStroke(thickerStroke); if (pref.getWidth() > (2*visRect.width)){ //dataset is big enough to require worldmap if (noImage){ //first time through draw a worldmap if dataset is big: final int WM_MAX_WIDTH = visRect.width/3; double scalefactor; scalefactor = (double)(chartSize.width)/WM_MAX_WIDTH; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(this.getBackground()); gw2.fillRect(1,1,worldmap.getWidth()-2,worldmap.getHeight()-2); //make a pretty border gw2.setColor(Color.BLACK); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth()-1,worldmap.getHeight()-1); ir = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth()-1, worldmap.getHeight()-1); double prefBoxSize = boxSize/scalefactor; float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } g.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); worldmapRect = new Rectangle(visRect.x, visRect.y+visRect.height-worldmap.getHeight(), worldmap.getWidth(), worldmap.getHeight()); //draw the outline of the viewport g.setColor(Color.BLACK); double hRatio = ir.getWidth()/pref.getWidth(); double vRatio = ir.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-ir.width; int vBump = worldmap.getHeight()-ir.height; //bump a few pixels to avoid drawing on the border g.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } }
|
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); Rectangle visRect = getVisibleRect(); /* boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } */ //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); BasicStroke fatStroke = new BasicStroke(3.0f); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getFilteredSize(); i++) { double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks boolean even = true; //g.setColor(new Color(153,255,153)); g.setColor(Color.black); g2.setStroke(fatStroke); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; g.drawLine(left + (2*first + 1) * boxSize/2 - boxRadius, top + boxSize/2, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last - 1) * boxSize/2+boxRadius, top + boxSize/2); for (int j = 0; j < theBlock.length; j++){ g.drawLine(left + (2*theBlock[j]+1) * boxSize/2 - boxRadius, top + boxSize/2, left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius); g.drawLine (left + (2*theBlock[j]) * boxSize/2 - boxRadius, top + boxSize/2 - boxRadius, left + (2*theBlock[j]) * boxSize/2, top + boxSize/2); } } g2.setStroke(thickerStroke); if (pref.getWidth() > (2*visRect.width)){ //dataset is big enough to require worldmap if (noImage){ //first time through draw a worldmap if dataset is big: final int WM_MAX_WIDTH = visRect.width/3; double scalefactor; scalefactor = (double)(chartSize.width)/WM_MAX_WIDTH; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(this.getBackground()); gw2.fillRect(1,1,worldmap.getWidth()-2,worldmap.getHeight()-2); //make a pretty border gw2.setColor(Color.BLACK); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth()-1,worldmap.getHeight()-1); ir = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth()-1, worldmap.getHeight()-1); double prefBoxSize = boxSize/scalefactor; float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } g.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); worldmapRect = new Rectangle(visRect.x, visRect.y+visRect.height-worldmap.getHeight(), worldmap.getWidth(), worldmap.getHeight()); //draw the outline of the viewport g.setColor(Color.BLACK); double hRatio = ir.getWidth()/pref.getWidth(); double vRatio = ir.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-ir.width; int vBump = worldmap.getHeight()-ir.height; //bump a few pixels to avoid drawing on the border g.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } }
| 1,108,252
|
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); Rectangle visRect = getVisibleRect(); /* boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } */ //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); BasicStroke fatStroke = new BasicStroke(3.0f); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getFilteredSize(); i++) { double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks boolean even = true; //g.setColor(new Color(153,255,153)); g.setColor(new Color(51,153,51)); g2.setStroke(fatStroke); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; g.drawLine(left + (2*first + 1) * boxSize/2 - boxRadius, top + boxSize/2, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last - 1) * boxSize/2+boxRadius, top + boxSize/2); for (int j = 0; j < theBlock.length; j++){ g.drawLine(left + (2*theBlock[j]+1) * boxSize/2 - boxRadius, top + boxSize/2, left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius); g.drawLine (left + (2*theBlock[j]) * boxSize/2 - boxRadius, top + boxSize/2 - boxRadius, left + (2*theBlock[j]) * boxSize/2, top + boxSize/2); } } g2.setStroke(thickerStroke); if (pref.getWidth() > (2*visRect.width)){ //dataset is big enough to require worldmap if (noImage){ //first time through draw a worldmap if dataset is big: final int WM_MAX_WIDTH = visRect.width/3; double scalefactor; scalefactor = (double)(chartSize.width)/WM_MAX_WIDTH; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(this.getBackground()); gw2.fillRect(1,1,worldmap.getWidth()-2,worldmap.getHeight()-2); //make a pretty border gw2.setColor(Color.BLACK); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth()-1,worldmap.getHeight()-1); ir = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth()-1, worldmap.getHeight()-1); double prefBoxSize = boxSize/scalefactor; float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } g.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); worldmapRect = new Rectangle(visRect.x, visRect.y+visRect.height-worldmap.getHeight(), worldmap.getWidth(), worldmap.getHeight()); //draw the outline of the viewport g.setColor(Color.BLACK); double hRatio = ir.getWidth()/pref.getWidth(); double vRatio = ir.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-ir.width; int vBump = worldmap.getHeight()-ir.height; //bump a few pixels to avoid drawing on the border g.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } }
|
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); Rectangle visRect = getVisibleRect(); /* boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } */ //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); BasicStroke fatStroke = new BasicStroke(3.0f); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getFilteredSize(); i++) { double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks boolean even = true; //g.setColor(new Color(153,255,153)); g.setColor(new Color(51,153,51)); g2.setStroke(fatStroke); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; g.drawLine(left + (2*first + 1) * boxSize/2 - boxRadius, top + boxSize/2, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last - 1) * boxSize/2+boxRadius, top + boxSize/2); for (int j = 0; j < theBlock.length; j++){ g.drawLine(left + (2*theBlock[j]+1) * boxSize/2 - boxRadius, top + boxSize/2, left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius); g.drawLine (left + (2*theBlock[j]) * boxSize/2 - boxRadius, top + boxSize/2 - boxRadius, left + (2*theBlock[j]) * boxSize/2, top + boxSize/2); } } g2.setStroke(thickerStroke); if (pref.getWidth() > (2*visRect.width)){ //dataset is big enough to require worldmap if (noImage){ //first time through draw a worldmap if dataset is big: final int WM_MAX_WIDTH = visRect.width/3; double scalefactor; scalefactor = (double)(chartSize.width)/WM_MAX_WIDTH; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(this.getBackground()); gw2.fillRect(1,1,worldmap.getWidth()-2,worldmap.getHeight()-2); //make a pretty border gw2.setColor(Color.BLACK); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth()-1,worldmap.getHeight()-1); ir = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth()-1, worldmap.getHeight()-1); double prefBoxSize = boxSize/scalefactor; float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } g.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); worldmapRect = new Rectangle(visRect.x, visRect.y+visRect.height-worldmap.getHeight(), worldmap.getWidth(), worldmap.getHeight()); //draw the outline of the viewport g.setColor(Color.BLACK); double hRatio = ir.getWidth()/pref.getWidth(); double vRatio = ir.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-ir.width; int vBump = worldmap.getHeight()-ir.height; //bump a few pixels to avoid drawing on the border g.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } }
| 1,108,253
|
public JellyContext runScript(URL url, XMLOutput output) throws Exception { Script script = compileScript(url); URL newJellyContextURL = getJellyContextURL(url); JellyContext newJellyContext = new JellyContext(this, newJellyContextURL); if (log.isDebugEnabled() ) { log.debug( "About to run script: " + url ); log.debug( "root context URL: " + newJellyContext.rootURL ); log.debug( "current context URL: " + newJellyContext.currentURL ); } script.run(newJellyContext, output); return newJellyContext; }
|
public JellyContext runScript(URL url, XMLOutput output) throws Exception { Script script = compileScript(url); URL newJellyContextURL = getJellyContextURL(url); JellyContext newJellyContext = new JellyContext(this, newJellyContextURL); if (log.isDebugEnabled() ) { log.debug( "About to run script: " + url ); log.debug( "root context URL: " + newJellyContext.rootURL ); log.debug( "current context URL: " + newJellyContext.currentURL ); } script.run(newJellyContext, output); return newJellyContext; }
| 1,108,254
|
private void full_em_breakup( byte[][] input_haplos, int[] block_size, Vector affStatus) throws HaploViewException{ int num_poss, iter; double total = 0; int block, start_locus, end_locus, biggest_block_size; 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 (> "+MAXLOCI+" non-redundant)"); } //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]; MapWrap probMap = new MapWrap(PSEUDOCOUNT); /* 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; //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); 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); probMap.put(new Long(tempRec.h1), probMap.get(new Long(tempRec.h1)) + 1.0); probMap.put(new Long(tempRec.h2), probMap.get(new Long(tempRec.h2)) + 1.0); total+=2.0; } } probMap.normalize(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)(probMap.get(new Long(tempRec.h1))*probMap.get(new Long(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 probMap = new MapWrap(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); probMap.put(new Long(tempRec.h1),probMap.get(new Long(tempRec.h1)) + tempRec.p); probMap.put(new Long(tempRec.h2),probMap.get(new Long(tempRec.h2)) + tempRec.p); total+=(2.0*(tempRec.p)); } } probMap.normalize(total); iter++; } int m=0; for(long j=0;j<num_poss; j++){ hint[(int)j]=-1; if (probMap.get(new Long(j)) > .001) { // printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); hlist[block][m]=(int)j; hprob[block][m]=probMap.get(new Long(j)); hint[(int)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 */ double poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } /* LIGATE and finish this mess :) */ fullProbMap = new MapWrap(PSEUDOCOUNT); create_super_haplos(num_indivs,num_blocks,num_hlist); /* run standard EM on supercombos */ /* start prob array with probabilities from full observations */ total = poss_full * 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) { Long h1 = new Long(superdata[i].superposs[0].h1); Long h2 = new Long(superdata[i].superposs[0].h2); fullProbMap.put(h1,fullProbMap.get(h1) +1.0); fullProbMap.put(h2,fullProbMap.get(h2) +1.0); total+=2.0; } } fullProbMap.normalize(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) (fullProbMap.get(new Long(superdata[i].superposs[k].h1))* fullProbMap.get(new Long(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 */ fullProbMap = new MapWrap(1e-10); total=poss_full*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<superdata[i].nsuper; k++) { fullProbMap.put(new Long(superdata[i].superposs[k].h1),fullProbMap.get(new Long(superdata[i].superposs[k].h1)) + superdata[i].superposs[k].p); fullProbMap.put(new Long(superdata[i].superposs[k].h2),fullProbMap.get(new Long(superdata[i].superposs[k].h2)) + superdata[i].superposs[k].p); total+=(2.0*superdata[i].superposs[k].p); } } fullProbMap.normalize(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[numFilteredTrios][][]; for(int i=0;i<numFilteredTrios*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(); Iterator kitr = fullProbMap.theMap.keySet().iterator(); while(kitr.hasNext()) { Object key = kitr.next(); long keyLong = ((Long)key).longValue(); if(fullProbMap.get(key) > .001) { haplos_present.addElement(decode_haplo_str(keyLong,num_blocks,block_size,hlist,num_hlist)); haplo_freq.addElement(new Double(fullProbMap.get(key))); } } 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; double total = 0; int block, start_locus, end_locus, biggest_block_size; 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 (> "+MAXLOCI+" non-redundant)"); } //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]; MapWrap probMap = new MapWrap(PSEUDOCOUNT); /* 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; //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); 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); probMap.put(new Long(tempRec.h1), probMap.get(new Long(tempRec.h1)) + 1.0); probMap.put(new Long(tempRec.h2), probMap.get(new Long(tempRec.h2)) + 1.0); total+=2.0; } } probMap.normalize(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)(probMap.get(new Long(tempRec.h1))*probMap.get(new Long(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 probMap = new MapWrap(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); probMap.put(new Long(tempRec.h1),probMap.get(new Long(tempRec.h1)) + tempRec.p); probMap.put(new Long(tempRec.h2),probMap.get(new Long(tempRec.h2)) + tempRec.p); total+=(2.0*(tempRec.p)); } } probMap.normalize(total); iter++; } int m=0; for(long j=0;j<num_poss; j++){ hint[(int)j]=-1; if (probMap.get(new Long(j)) > .001) { // printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); hlist[block][m]=(int)j; hprob[block][m]=probMap.get(new Long(j)); hint[(int)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 */ double poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } /* LIGATE and finish this mess :) */ fullProbMap = new MapWrap(PSEUDOCOUNT); create_super_haplos(num_indivs,num_blocks,num_hlist); /* run standard EM on supercombos */ /* start prob array with probabilities from full observations */ total = poss_full * 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) { Long h1 = new Long(superdata[i].superposs[0].h1); Long h2 = new Long(superdata[i].superposs[0].h2); fullProbMap.put(h1,fullProbMap.get(h1) +1.0); fullProbMap.put(h2,fullProbMap.get(h2) +1.0); total+=2.0; } } fullProbMap.normalize(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) (fullProbMap.get(new Long(superdata[i].superposs[k].h1))* fullProbMap.get(new Long(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 */ fullProbMap = new MapWrap(1e-10); total=poss_full*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<superdata[i].nsuper; k++) { fullProbMap.put(new Long(superdata[i].superposs[k].h1),fullProbMap.get(new Long(superdata[i].superposs[k].h1)) + superdata[i].superposs[k].p); fullProbMap.put(new Long(superdata[i].superposs[k].h2),fullProbMap.get(new Long(superdata[i].superposs[k].h2)) + superdata[i].superposs[k].p); total+=(2.0*superdata[i].superposs[k].p); } } fullProbMap.normalize(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[numFilteredTrios][][]; for(int i=0;i<numFilteredTrios*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(); ArrayList keys = new ArrayList(fullProbMap.theMap.keySet()); Collections.sort(keys); Iterator kitr = keys.iterator(); while(kitr.hasNext()) { Object key = kitr.next(); long keyLong = ((Long)key).longValue(); if(fullProbMap.get(key) > .001) { haplos_present.addElement(decode_haplo_str(keyLong,num_blocks,block_size,hlist,num_hlist)); haplo_freq.addElement(new Double(fullProbMap.get(key))); } } 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,108,255
|
public UseBeanTag(Class defaultClass) { this.defaultClass = defaultClass; }
|
public UseBeanTag(Class defaultClass) { this.defaultClass = defaultClass; }
| 1,108,256
|
public Point parse(String text) { StringTokenizer items = new StringTokenizer( text, "," ); int x = 0; int y = 0; if ( items.hasMoreTokens() ) { x = parseNumber( items.nextToken() ); } if ( enum.hasMoreTokens() ) { y = parseNumber( items.nextToken() ); }
|
public Point parse(String text) { StringTokenizer items = new StringTokenizer( text, "," ); int x = 0; int y = 0; if ( items.hasMoreTokens() ) { x = parseNumber( items.nextToken() ); } if ( items.hasMoreTokens() ) { y = parseNumber( items.nextToken() ); }
| 1,108,257
|
public Point parse(String text) { StringTokenizer items = new StringTokenizer( text, "," ); int x = 0; int y = 0; if ( items.hasMoreTokens() ) { x = parseNumber( items.nextToken() ); } if ( enum.hasMoreTokens() ) { y = parseNumber( items.nextToken() ); }
|
public Point parse(String text) { StringTokenizer items = new StringTokenizer( text, "," ); int x = 0; int y = 0; if ( items.hasMoreTokens() ) { x = parseNumber( items.nextToken() ); } return new Point( x, y ); } if ( enum.hasMoreTokens() ) { y = parseNumber( items.nextToken() ); } return new Point( x, y ); }
| 1,108,258
|
public String evaluateAsString(Context context);
|
public String evaluateAsString(JellyContext context);
| 1,108,259
|
public static void main( String[] args ) { org.apache.log4j.BasicConfigurator.configure(); log.setLevel( org.apache.log4j.Level.DEBUG ); org.apache.log4j.Logger folderLog = org.apache.log4j.Logger.getLogger( PhotoFolder.class.getName() ); folderLog.setLevel( org.apache.log4j.Level.DEBUG ); junit.textui.TestRunner.run( suite() ); }
|
public static void main( String[] args ) { log.setLevel( org.apache.log4j.Level.DEBUG ); org.apache.log4j.Logger folderLog = org.apache.log4j.Logger.getLogger( PhotoFolder.class.getName() ); folderLog.setLevel( org.apache.log4j.Level.DEBUG ); junit.textui.TestRunner.run( suite() ); }
| 1,108,260
|
public void setUp() { odmg = OJB.getInstance(); db = odmg.newDatabase(); try { db.open( "repository.xml", Database.OPEN_READ_WRITE ); } catch ( ODMGException e ) { // log.warn( "Could not open database: " + e.getMessage() ); db = null; } tx = odmg.newTransaction(); tx.begin(); }
|
public void setUp() { odmg = OJB.getInstance(); db = odmg.newDatabase(); try { db.open( "repository.xml", Database.OPEN_READ_WRITE ); } catch ( ODMGException e ) { // log.warn( "Could not open database: " + e.getMessage() ); db = null; } tx = odmg.newTransaction(); tx.begin(); }
| 1,108,261
|
public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } tx.commit(); }
|
public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } tx.commit(); }
| 1,108,263
|
public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } tx.commit(); }
|
public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } tx.commit(); }
| 1,108,264
|
public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } tx.commit(); }
|
public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } tx.commit(); }
| 1,108,265
|
public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } tx.commit(); }
|
public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } tx.commit(); }
| 1,108,266
|
public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } tx.commit(); }
|
public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } }
| 1,108,267
|
public WidgetTag(Class widgetClass, int style) { super(widgetClass); this.style = style; }
|
public WidgetTag(Class widgetClass, int style) { super(widgetClass); this.style = style; }
| 1,108,270
|
public void registerBean(String name, Class type, Method method) { registerBean(name, type); if (method != null) { invokeMethods.put(name, method); } else { invokeMethods.remove(name); } }
|
public void registerBean(String name, Class type, Method method) { registerBean(name, type); if (method != null) { invokeMethods.put(name, method); } else { invokeMethods.remove(name); } }
| 1,108,272
|
public Object createObject(Attributes attributes) { SQLTable tab = new SQLTable(); String id = attributes.getValue("id"); if (id != null) { objectIdMap.put(id, tab); } else { logger.warn("No ID found in table element while loading project!"); } String populated = attributes.getValue("populated"); if (populated != null && populated.equals("false")) { tab.setColumnsPopulated(false); tab.setRelationshipsPopulated(false); tab.initFolders(); } return tab; }
|
public Object createObject(Attributes attributes) { SQLTable tab = new SQLTable(); String id = attributes.getValue("id"); if (id != null) { objectIdMap.put(id, tab); } else { logger.warn("No ID found in table element while loading project!"); } String populated = attributes.getValue("populated"); if (populated != null && populated.equals("false")) { tab.setColumnsPopulated(false); tab.setRelationshipsPopulated(false); tab.initFolders(); } return tab; }
| 1,108,273
|
protected Digester setupDigester() { Digester d = new Digester(); d.setValidating(false); d.push(this); // project name d.addCallMethod("architect-project/project-name", "setName", 0); // argument is element body text // source DB connection specs DBCSFactory dbcsFactory = new DBCSFactory(); d.addFactoryCreate("architect-project/project-connection-specs/dbcs", dbcsFactory); d.addSetProperties ("architect-project/project-connection-specs/dbcs", new String[] {"connection-name", "driver-class", "jdbc-url", "user-name", "user-pass", "sequence-number", "single-login"}, new String[] {"displayName", "driverClass", "url", "user", "pass", "seqNo", "singleLogin"}); d.addCallMethod("architect-project/project-connection-specs/dbcs", "setName", 0); // these instances get picked out of the dbcsIdMap by the SQLDatabase factory // source database hierarchy d.addObjectCreate("architect-project/source-databases", LinkedList.class); d.addSetNext("architect-project/source-databases", "setSourceDatabaseList"); SQLDatabaseFactory dbFactory = new SQLDatabaseFactory(); d.addFactoryCreate("architect-project/source-databases/database", dbFactory); d.addSetProperties("architect-project/source-databases/database"); d.addSetNext("architect-project/source-databases/database", "add"); d.addObjectCreate("architect-project/source-databases/database/catalog", SQLCatalog.class); d.addSetProperties("architect-project/source-databases/database/catalog"); d.addSetNext("architect-project/source-databases/database/catalog", "addChild"); d.addObjectCreate("*/schema", SQLSchema.class); d.addSetProperties("*/schema"); d.addSetNext("*/schema", "addChild"); SQLTableFactory tableFactory = new SQLTableFactory(); d.addFactoryCreate("*/table", tableFactory); d.addSetProperties("*/table"); d.addSetNext("*/table", "addChild"); d.addObjectCreate("*/folder", SQLTable.Folder.class); d.addSetProperties("*/folder"); d.addSetNext("*/folder", "addChild"); SQLColumnFactory columnFactory = new SQLColumnFactory(); d.addFactoryCreate("*/column", columnFactory); d.addSetProperties("*/column"); d.addSetNext("*/column", "addChild"); SQLRelationshipFactory relationshipFactory = new SQLRelationshipFactory(); d.addFactoryCreate("*/relationship", relationshipFactory); d.addSetProperties("*/relationship"); // the factory adds the relationships to the correct PK and FK tables ColumnMappingFactory columnMappingFactory = new ColumnMappingFactory(); d.addFactoryCreate("*/column-mapping", columnMappingFactory); d.addSetProperties("*/column-mapping"); d.addSetNext("*/column-mapping", "addChild"); // target database hierarchy d.addFactoryCreate("architect-project/target-database", dbFactory); d.addSetProperties("architect-project/target-database"); d.addSetNext("architect-project/target-database", "setTargetDatabase"); // the play pen TablePaneFactory tablePaneFactory = new TablePaneFactory(); d.addFactoryCreate("architect-project/play-pen/table-pane", tablePaneFactory); // factory will add the tablepanes to the playpen PPRelationshipFactory ppRelationshipFactory = new PPRelationshipFactory(); d.addFactoryCreate("architect-project/play-pen/table-link", ppRelationshipFactory); DDLGeneratorFactory ddlgFactory = new DDLGeneratorFactory(); d.addFactoryCreate("architect-project/ddl-generator", ddlgFactory); d.addSetProperties("architect-project/ddl-generator"); FileFactory fileFactory = new FileFactory(); d.addFactoryCreate("*/file", fileFactory); d.addSetNext("*/file", "setFile"); d.addSetNext("architect-project/ddl-generator", "setDDLGenerator"); return d; }
|
protected Digester setupDigester() { Digester d = new Digester(); d.setValidating(false); d.push(this); // project name d.addCallMethod("architect-project/project-name", "setName", 0); // argument is element body text // source DB connection specs DBCSFactory dbcsFactory = new DBCSFactory(); d.addFactoryCreate("architect-project/project-connection-specs/dbcs", dbcsFactory); d.addSetProperties ("architect-project/project-connection-specs/dbcs", new String[] {"connection-name", "driver-class", "jdbc-url", "user-name", "user-pass", "sequence-number", "single-login"}, new String[] {"displayName", "driverClass", "url", "user", "pass", "seqNo", "singleLogin"}); d.addCallMethod("architect-project/project-connection-specs/dbcs", "setName", 0); // these instances get picked out of the dbcsIdMap by the SQLDatabase factory // source database hierarchy d.addObjectCreate("architect-project/source-databases", LinkedList.class); d.addSetNext("architect-project/source-databases", "setSourceDatabaseList"); SQLDatabaseFactory dbFactory = new SQLDatabaseFactory(); d.addFactoryCreate("architect-project/source-databases/database", dbFactory); d.addSetProperties("architect-project/source-databases/database"); d.addSetNext("architect-project/source-databases/database", "add"); d.addObjectCreate("architect-project/source-databases/database/catalog", SQLCatalog.class); d.addSetProperties("architect-project/source-databases/database/catalog"); d.addSetNext("architect-project/source-databases/database/catalog", "addChild"); d.addObjectCreate("*/schema", SQLSchema.class); d.addSetProperties("*/schema"); d.addSetNext("*/schema", "addChild"); SQLTableFactory tableFactory = new SQLTableFactory(); d.addFactoryCreate("*/table", tableFactory); d.addSetProperties("*/table"); d.addSetNext("*/table", "addChild"); SQLFolderFactory folderFactory = new SQLFolderFactory(); d.addFactoryCreate("*/folder", folderFactory); d.addSetProperties("*/folder"); d.addSetNext("*/folder", "addChild"); SQLColumnFactory columnFactory = new SQLColumnFactory(); d.addFactoryCreate("*/column", columnFactory); d.addSetProperties("*/column"); d.addSetNext("*/column", "addChild"); SQLRelationshipFactory relationshipFactory = new SQLRelationshipFactory(); d.addFactoryCreate("*/relationship", relationshipFactory); d.addSetProperties("*/relationship"); // the factory adds the relationships to the correct PK and FK tables ColumnMappingFactory columnMappingFactory = new ColumnMappingFactory(); d.addFactoryCreate("*/column-mapping", columnMappingFactory); d.addSetProperties("*/column-mapping"); d.addSetNext("*/column-mapping", "addChild"); // target database hierarchy d.addFactoryCreate("architect-project/target-database", dbFactory); d.addSetProperties("architect-project/target-database"); d.addSetNext("architect-project/target-database", "setTargetDatabase"); // the play pen TablePaneFactory tablePaneFactory = new TablePaneFactory(); d.addFactoryCreate("architect-project/play-pen/table-pane", tablePaneFactory); // factory will add the tablepanes to the playpen PPRelationshipFactory ppRelationshipFactory = new PPRelationshipFactory(); d.addFactoryCreate("architect-project/play-pen/table-link", ppRelationshipFactory); DDLGeneratorFactory ddlgFactory = new DDLGeneratorFactory(); d.addFactoryCreate("architect-project/ddl-generator", ddlgFactory); d.addSetProperties("architect-project/ddl-generator"); FileFactory fileFactory = new FileFactory(); d.addFactoryCreate("*/file", fileFactory); d.addSetNext("*/file", "setFile"); d.addSetNext("architect-project/ddl-generator", "setDDLGenerator"); return d; }
| 1,108,275
|
public Relationship(PlayPen parentPP, SQLRelationship model) throws ArchitectException { super(parentPP.getPlayPenContentPane()); this.model = model; setPkTable(getPlayPen().findTablePane(model.getPkTable())); setFkTable(getPlayPen().findTablePane(model.getFkTable())); setup(); }
|
public Relationship(PlayPen parentPP, SQLRelationship model) throws ArchitectException { super(parentPP.getPlayPenContentPane()); this.model = model; setPkTable(getPlayPen().findTablePane(model.getPkTable())); setFkTable(getPlayPen().findTablePane(model.getFkTable())); setup(); }
| 1,108,276
|
public SQLTable() { //columnsPopulated = true; //relationshipsPopulated = true; children = new ArrayList(); }
|
public SQLTable() { //columnsPopulated = true; //relationshipsPopulated = true; children = new ArrayList(); }
| 1,108,277
|
public PlayPen(SQLDatabase db) { this(); setDatabase(db); }
|
public PlayPen(SQLDatabase db) { this(); setDatabase(db); }
| 1,108,278
|
public DBTree(List initialDatabases) throws ArchitectException { this(); setDatabaseList(initialDatabases); }
|
public DBTree(List initialDatabases) throws ArchitectException { this(); setDatabaseList(initialDatabases); }
| 1,108,279
|
public DBTreeModel(Collection initialDatabases) throws ArchitectException { this.root = new DBTreeRoot(); if (initialDatabases != null) { Iterator it = initialDatabases.iterator(); while (it.hasNext()) { root.addChild((SQLDatabase) it.next()); } } this.treeModelListeners = new LinkedList(); ArchitectUtils.listenToHierarchy(this, root); }
|
public DBTreeModel(Collection initialDatabases) throws ArchitectException { this.root = new DBTreeRoot(); if (initialDatabases != null) { Iterator it = initialDatabases.iterator(); while (it.hasNext()) { root.addChild((SQLDatabase) it.next()); } } this.treeModelListeners = new LinkedList(); ArchitectUtils.listenToHierarchy(this, root); }
| 1,108,280
|
public XMLOutput( ContentHandler contentHandler, LexicalHandler lexicalHandler) { this.contentHandler = contentHandler; this.lexicalHandler = lexicalHandler; }
|
public XMLOutput( ContentHandler contentHandler, LexicalHandler lexicalHandler) { this.contentHandler = contentHandler; this.lexicalHandler = lexicalHandler; }
| 1,108,281
|
public void endPrefixMapping(String prefix) throws SAXException { namespaceStack.popNamespace(prefix); // End prefix mapping was already called after endElement // contentHandler.endPrefixMapping(prefix); }
|
public void endPrefixMapping(String prefix) throws SAXException { // End prefix mapping was already called after endElement // contentHandler.endPrefixMapping(prefix); }
| 1,108,282
|
public void setContext(JellyContext context);
|
public void setContext(JellyContext context) throws Exception;
| 1,108,283
|
public Object evaluate(Context context);
|
public Object evaluate(JellyContext context);
| 1,108,284
|
public StartupException(String message, Throwable cause) { super(message, cause); }
|
public StartupException(String message, Throwable cause) { super(message, cause); }
| 1,108,285
|
public SamplingException(String message, Throwable cause) { super(message, cause); }
|
public SamplingException(String message, Throwable cause) { super(message, cause); }
| 1,108,286
|
public CheckDataPanel(PedFile pf) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = pf; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(1).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
|
public CheckDataPanel(HaploData hd) throws IOException, PedFileException{ STATUS_COL = 8; setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = pf; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(1).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
| 1,108,288
|
public CheckDataPanel(PedFile pf) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = pf; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(1).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
|
public CheckDataPanel(PedFile pf) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = hd.getPedFile(); theData = hd; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(1).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
| 1,108,289
|
public CheckDataPanel(PedFile pf) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = pf; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(1).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
|
public CheckDataPanel(PedFile pf) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = pf; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); if (theData.infoKnown){ tableColumnNames.add("Name"); tableColumnNames.add("Position"); STATUS_COL += 2; } tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(1).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
| 1,108,290
|
public CheckDataPanel(PedFile pf) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = pf; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(1).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
|
public CheckDataPanel(PedFile pf) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = pf; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); if (theData.infoKnown){ tempVect.add(Chromosome.getMarker(i).getName()); tempVect.add(new Long(Chromosome.getMarker(i).getPosition())); } tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(1).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
| 1,108,291
|
public CheckDataPanel(PedFile pf) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = pf; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(1).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
|
public CheckDataPanel(PedFile pf) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = pf; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); if (theData.infoKnown){ table.getColumnModel().getColumn(1).setPreferredWidth(100); } JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
| 1,108,292
|
protected void attachWidgets(Widget parent, Widget widget) { // set the content that will be scrolled if the parent is a ScrolledComposite if (parent instanceof ScrolledComposite && widget instanceof Control) { ScrolledComposite scrolledComposite = (ScrolledComposite) parent; scrolledComposite.setContent((Control) widget); } }
|
protected void attachWidgets(Widget parent, Widget widget) { // set the content that will be scrolled if the parent is a ScrolledComposite if (parent instanceof ScrolledComposite && widget instanceof Control) { ScrolledComposite scrolledComposite = (ScrolledComposite) parent; scrolledComposite.setContent((Control) widget); } }
| 1,108,293
|
public Widget getParentWidget() { if (parent == null) { WidgetTag tag = (WidgetTag) findAncestorWithClass(WidgetTag.class); if (tag != null) { parent = tag.getWidget(); } } return parent; }
|
public Widget getParentWidget() { if (parent == null) { WidgetTag tag = (WidgetTag) findAncestorWithClass(WidgetTag.class); if (tag != null) { parent = tag.getWidget(); } } return parent; }
| 1,108,294
|
private void argHandler(String[] args){ argHandlerMessages = new Vector(); int maxDistance = -1; //this means that user didn't specify any output type if it doesn't get changed below blockOutputType = -1; double hapThresh = -1; double minimumMAF=-1; double spacingThresh = -1; double minimumGenoPercent = -1; double hwCutoff = -1; double missingCutoff = -1; int maxMendel = -1; boolean assocTDT = false; boolean assocCC = false; permutationCount = 0; tagging = Tagger.NONE; maxNumTags = Tagger.DEFAULT_MAXNUMTAGS; findTags = true; double cutHighCI = -1; double cutLowCI = -1; double mafThresh = -1; double recHighCI = -1; double informFrac = -1; double fourGameteCutoff = -1; double spineDP = -1; for(int i =0; i < args.length; i++) { if(args[i].equalsIgnoreCase("-help") || args[i].equalsIgnoreCase("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equalsIgnoreCase("-n") || args[i].equalsIgnoreCase("-nogui")) { nogui = true; } else if(args[i].equalsIgnoreCase("-p") || args[i].equalsIgnoreCase("-pedfile")) { i++; if( i>=args.length || (args[i].charAt(0) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(pedFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-pcloadletter")){ die("PC LOADLETTER?! What the fuck does that mean?!"); } else if (args[i].equalsIgnoreCase("-skipcheck") || args[i].equalsIgnoreCase("--skipcheck")){ skipCheck = true; } else if (args[i].equalsIgnoreCase("-excludeMarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ die("-excludeMarkers requires a list of markers"); } else { StringTokenizer str = new StringTokenizer(args[i],","); try { StringBuffer sb = new StringBuffer(); if (!quietMode) sb.append("Excluding markers: "); while(str.hasMoreTokens()) { String token = str.nextToken(); if(token.indexOf("..") != -1) { int lastIndex = token.indexOf(".."); int rangeStart = Integer.parseInt(token.substring(0,lastIndex)); int rangeEnd = Integer.parseInt(token.substring(lastIndex+2,token.length())); for(int j=rangeStart;j<=rangeEnd;j++) { if (!quietMode) sb.append(j+" "); excludedMarkers.add(new Integer(j)); } } else { if (!quietMode) sb.append(token+" "); excludedMarkers.add(new Integer(token)); } } if (!quietMode) argHandlerMessages.add(sb.toString()); } catch(NumberFormatException nfe) { die("-excludeMarkers argument should be of the format: 1,3,5..8,12"); } } } else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-haps")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapsFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-i") || args[i].equalsIgnoreCase("-info")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(infoFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-hapmap")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapmapFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpdata")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpdataFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap data file listed will be used"); } phasedhmpdataFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpsample")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpsampleFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap sample file listed will be used"); } phasedhmpsampleFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmplegend")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmplegendFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap legend file listed will be used"); } phasedhmplegendFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhapmapdl")){ phasedhapmapDownload = true; } else if (args[i].equalsIgnoreCase("-plink")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last PLINK file listed will be used"); } plinkFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-map")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last map file listed will be used"); } mapFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-k") || args[i].equalsIgnoreCase("-blocks")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; blockOutputType = BLOX_CUSTOM; }else{ die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-png")){ outputPNG = true; } else if (args[i].equalsIgnoreCase("-smallpng") || args[i].equalsIgnoreCase("-compressedPNG")){ outputCompressedPNG = true; } else if (args[i].equalsIgnoreCase("-track")){ i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ trackFileName = args[i]; }else{ die("-track requires a filename"); } } else if(args[i].equalsIgnoreCase("-o") || args[i].equalsIgnoreCase("-output") || args[i].equalsIgnoreCase("-blockoutput")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(blockOutputType != -1){ die("Only one block output type argument is allowed."); } if(args[i].equalsIgnoreCase("SFS") || args[i].equalsIgnoreCase("GAB")){ blockOutputType = BLOX_GABRIEL; } else if(args[i].equalsIgnoreCase("GAM")){ blockOutputType = BLOX_4GAM; } else if(args[i].equalsIgnoreCase("MJD") || args[i].equalsIgnoreCase("SPI")){ blockOutputType = BLOX_SPINE; } else if(args[i].equalsIgnoreCase("ALL")) { blockOutputType = BLOX_ALL; } } else { //defaults to SFS output blockOutputType = BLOX_GABRIEL; i--; } } else if(args[i].equalsIgnoreCase("-d") || args[i].equalsIgnoreCase("--dprime") || args[i].equalsIgnoreCase("-dprime")) { outputDprime = true; } else if (args[i].equalsIgnoreCase("-c") || args[i].equalsIgnoreCase("-check")){ outputCheck = true; } else if (args[i].equalsIgnoreCase("-indcheck")){ individualCheck = true; } else if (args[i].equalsIgnoreCase("-mendel")){ mendel = true; } else if (args[i].equalsIgnoreCase("-malehets")){ malehets = true; } else if(args[i].equalsIgnoreCase("-m") || args[i].equalsIgnoreCase("-maxdistance")) { i++; maxDistance = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-batch")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(batchFileName != null){ argHandlerMessages.add("multiple " + args[i-1] + " arguments found. only last batch file listed will be used"); } batchFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-hapthresh")) { i++; hapThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-spacing")) { i++; spacingThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-minMAF")) { i++; minimumMAF = getDoubleArg(args,i,0,0.5); } else if(args[i].equalsIgnoreCase("-minGeno") || args[i].equalsIgnoreCase("-minGenoPercent")) { i++; minimumGenoPercent = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-hwcutoff")) { i++; hwCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-maxMendel") ) { i++; maxMendel = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-missingcutoff")) { i++; missingCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-assoctdt")) { assocTDT = true; } else if(args[i].equalsIgnoreCase("-assoccc")) { assocCC = true; } else if(args[i].equalsIgnoreCase("-randomcc")){ assocCC = true; randomizeAffection = true; } else if(args[i].equalsIgnoreCase("-ldcolorscheme")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(args[i].equalsIgnoreCase("default")){ Options.setLDColorScheme(STD_SCHEME); } else if(args[i].equalsIgnoreCase("RSQ")){ Options.setLDColorScheme(RSQ_SCHEME); } else if(args[i].equalsIgnoreCase("DPALT") ){ Options.setLDColorScheme(WMF_SCHEME); } else if(args[i].equalsIgnoreCase("GAB")) { Options.setLDColorScheme(GAB_SCHEME); } else if(args[i].equalsIgnoreCase("GAM")) { Options.setLDColorScheme(GAM_SCHEME); } else if(args[i].equalsIgnoreCase("GOLD")) { Options.setLDColorScheme(GOLD_SCHEME); } } else { //defaults to STD color scheme Options.setLDColorScheme(STD_SCHEME); i--; } } else if(args[i].equalsIgnoreCase("-blockCutHighCI")) { i++; cutHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockCutLowCI")) { i++; cutLowCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockMafThresh")) { i++; mafThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockRecHighCI")) { i++; recHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockInformFrac")) { i++; informFrac = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-block4GamCut")) { i++; fourGameteCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockSpineDP")) { i++; spineDP = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-permtests")) { i++; doPermutationTest = true; permutationCount = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-customassoc")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ customAssocTestsFileName = args[i]; }else{ die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-aggressiveTagging")) { tagging = Tagger.AGGRESSIVE_TRIPLE; } else if (args[i].equalsIgnoreCase("-pairwiseTagging")){ tagging = Tagger.PAIRWISE_ONLY; } else if (args[i].equalsIgnoreCase("-printalltags")){ Options.setPrintAllTags(true); } else if(args[i].equalsIgnoreCase("-maxNumTags")){ i++; maxNumTags = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-tagrSqCutoff")) { i++; tagRSquaredCutOff = getDoubleArg(args,i,0,1); } else if (args[i].equalsIgnoreCase("-dontaddtags")){ findTags = false; } else if(args[i].equalsIgnoreCase("-tagLODCutoff")) { i++; Options.setTaggerLODCutoff(getDoubleArg(args,i,0,100000)); } else if(args[i].equalsIgnoreCase("-includeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die(args[i-1] + " requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceIncludeTags = new Vector(); while(str.hasMoreTokens()) { forceIncludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-includeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceIncludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-excludeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die("-excludeTags requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceExcludeTags = new Vector(); while(str.hasMoreTokens()) { forceExcludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-excludeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceExcludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-captureAlleles")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { captureAllelesFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-designScores")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { designScoresFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-mintagdistance")){ i++; minTagDistance = args[i]; } else if(args[i].equalsIgnoreCase("-chromosome") || args[i].equalsIgnoreCase("-chr")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { chromosomeArg =args[i]; }else { die(args[i-1] + " requires a chromosome name"); } if(!(chromosomeArg.equalsIgnoreCase("x"))){ try{ if (Integer.parseInt(chromosomeArg) > 22){ die("-chromosome requires a chromsome name of 1-22 or X"); } }catch(NumberFormatException nfe){ die("-chromosome requires a chromsome name of 1-22 or X"); } } } else if(args[i].equalsIgnoreCase("-population")){ i++; if(!(i>=args.length) && !(args[i].charAt(0)== '-')) { populationArg = args[i]; }else { die(args[i-1] + "requires a population name"); } } else if(args[i].equalsIgnoreCase("-startpos")){ i++; startPos = args[i]; } else if(args[i].equalsIgnoreCase("-endPos")){ i++; endPos = args[i]; } else if(args[i].equalsIgnoreCase("-phase")){ i++; phase = args[i]; } else if(args[i].equalsIgnoreCase("-q") || args[i].equalsIgnoreCase("-quiet")) { quietMode = true; } else if(args[i].equalsIgnoreCase("-gzip")){ Options.setGzip(true); } else { die("invalid parameter specified: " + args[i]); } } int countOptions = 0; if(pedFileName != null) { countOptions++; } if(hapsFileName != null) { countOptions++; } if(hapmapFileName != null) { countOptions++; } if(phasedhmpdataFileName != null) { countOptions++; if(phasedhmpsampleFileName == null){ die("You must specify a sample file for phased hapmap input."); }else if(phasedhmplegendFileName == null){ die("You must specify a legend file for phased hapmap input."); } } if(phasedhapmapDownload) { countOptions++; } if(plinkFileName != null){ countOptions++; if(mapFileName == null){ die("You must specify a map file for plink format input."); } } if(batchFileName != null) { countOptions++; } if(countOptions > 1) { die("Only one genotype input file may be specified on the command line."); } else if(countOptions == 0 && nogui) { die("You must specify a genotype input file."); } //mess with vars, set defaults, etc if(skipCheck && !quietMode) { argHandlerMessages.add("Skipping genotype file check"); } if(maxDistance == -1){ maxDistance = MAXDIST_DEFAULT; }else{ if (!quietMode) argHandlerMessages.add("Max LD comparison distance = " +maxDistance + "kb"); } Options.setMaxDistance(maxDistance); if(hapThresh != -1) { Options.setHaplotypeDisplayThreshold(hapThresh); if (!quietMode) argHandlerMessages.add("Haplotype display threshold = " + hapThresh); } if(minimumMAF != -1) { CheckData.mafCut = minimumMAF; if (!quietMode) argHandlerMessages.add("Minimum MAF = " + minimumMAF); } if(minimumGenoPercent != -1) { CheckData.failedGenoCut = (int)(minimumGenoPercent*100); if (!quietMode) argHandlerMessages.add("Minimum SNP genotype % = " + minimumGenoPercent); } if(hwCutoff != -1) { CheckData.hwCut = hwCutoff; if (!quietMode) argHandlerMessages.add("Hardy Weinberg equilibrium p-value cutoff = " + hwCutoff); } if(maxMendel != -1) { CheckData.numMendErrCut = maxMendel; if (!quietMode) argHandlerMessages.add("Maximum number of Mendel errors = "+maxMendel); } if(spacingThresh != -1) { Options.setSpacingThreshold(spacingThresh); if (!quietMode) argHandlerMessages.add("LD display spacing value = "+spacingThresh); } if(missingCutoff != -1) { Options.setMissingThreshold(missingCutoff); if (!quietMode) argHandlerMessages.add("Maximum amount of missing data allowed per individual = "+missingCutoff); } if(cutHighCI != -1) { FindBlocks.cutHighCI = cutHighCI; } if(cutLowCI != -1) { FindBlocks.cutLowCI = cutLowCI; } if(mafThresh != -1) { FindBlocks.mafThresh = mafThresh; } if(recHighCI != -1) { FindBlocks.recHighCI = recHighCI; } if(informFrac != -1) { FindBlocks.informFrac = informFrac; } if(fourGameteCutoff != -1) { FindBlocks.fourGameteCutoff = fourGameteCutoff; } if(spineDP != -1) { FindBlocks.spineDP = spineDP; } if(assocTDT) { Options.setAssocTest(ASSOC_TRIO); }else if(assocCC) { Options.setAssocTest(ASSOC_CC); } if (Options.getAssocTest() != ASSOC_NONE && infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when performing association tests."); } if(doPermutationTest) { if(!assocCC && !assocTDT) { die("An association test type must be specified for permutation tests to be performed."); } } if(customAssocTestsFileName != null) { if(!assocCC && !assocTDT) { die("An association test type must be specified when using a custom association test file."); } if(infoFileName == null) { die("A marker info file must be specified when using a custom association test file."); } } if(tagging != Tagger.NONE) { if(infoFileName == null && hapmapFileName == null && batchFileName == null && phasedhmpdataFileName == null && !phasedhapmapDownload) { die("A marker info file must be specified when tagging."); } if(forceExcludeTags == null) { forceExcludeTags = new Vector(); } else if (forceExcludeFileName != null) { die("-excludeTags and -excludeTagsFile cannot both be used"); } if(forceExcludeFileName != null) { File excludeFile = new File(forceExcludeFileName); forceExcludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(excludeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceExcludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -excludeTagsFile."); } } if(forceIncludeTags == null ) { forceIncludeTags = new Vector(); } else if (forceIncludeFileName != null) { die("-includeTags and -includeTagsFile cannot both be used"); } if(forceIncludeFileName != null) { File includeFile = new File(forceIncludeFileName); forceIncludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(includeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceIncludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -includeTagsFile."); } } if (captureAllelesFileName != null) { File captureFile = new File(captureAllelesFileName); captureAlleleTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(captureFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ line = line.trim(); captureAlleleTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (designScoresFileName != null) { File designFile = new File(designScoresFileName); designScores = new Hashtable(1,1); try { BufferedReader br = new BufferedReader(new FileReader(designFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ StringTokenizer st = new StringTokenizer(line); String marker = st.nextToken(); Double score = new Double(st.nextToken()); designScores.put(marker,score); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (minTagDistance != null) { try{ if (Integer.parseInt(minTagDistance) < 0){ die("minimum tag distance cannot be negative"); } }catch(NumberFormatException nfe){ die("minimum tag distance must be a positive integer"); } Options.setTaggerMinDistance(Integer.parseInt(minTagDistance)); } //check that there isn't any overlap between include/exclude lists Vector tempInclude = (Vector) forceIncludeTags.clone(); tempInclude.retainAll(forceExcludeTags); if(tempInclude.size() > 0) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < tempInclude.size(); i++) { String s = (String) tempInclude.elementAt(i); sb.append(s).append(","); } die("The following markers appear in both the include and exclude lists: " + sb.toString()); } if(tagRSquaredCutOff != -1) { Options.setTaggerRsqCutoff(tagRSquaredCutOff); } } else if(forceExcludeTags != null || forceIncludeTags != null || tagRSquaredCutOff != -1) { die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without a tagging option"); } if(chromosomeArg != null && hapmapFileName != null) { argHandlerMessages.add("-chromosome flag ignored when loading hapmap file"); chromosomeArg = null; } if(chromosomeArg != null) { Chromosome.setDataChrom("chr" + chromosomeArg); } if (phasedhapmapDownload){ if (chromosomeArg == null){ die("-phasedhapmapdl requires a chromosome specification"); }else if (!(populationArg.equalsIgnoreCase("CEU") || populationArg.equalsIgnoreCase("YRI") || populationArg.equalsIgnoreCase("CHB+JPT"))){ die("-phasedhapmapdl requires a population specification of CEU, YRI, or CHB+JPT"); } if (Integer.parseInt(chromosomeArg) < 1 && Integer.parseInt(chromosomeArg) > 22){ if (!(chromosomeArg.equalsIgnoreCase("x"))){ die("chromsome specification must be betweeen 1 and 22 or X"); } } try{ if (Integer.parseInt(startPos) > Integer.parseInt(endPos)){ die("end position must be greater then start position"); } }catch(NumberFormatException nfe){ die("start and end positions must be integer values"); } if (phase == null){ phase = "2"; } try{ if (Integer.parseInt(phase) != 1 && Integer.parseInt(phase) != 2){ die("phase must be either 1 or 2"); } }catch(NumberFormatException nfe){ die("phase must be an integer value"); } } }
|
private void argHandler(String[] args){ argHandlerMessages = new Vector(); int maxDistance = -1; //this means that user didn't specify any output type if it doesn't get changed below blockOutputType = -1; double hapThresh = -1; double minimumMAF=-1; double spacingThresh = -1; double minimumGenoPercent = -1; double hwCutoff = -1; double missingCutoff = -1; int maxMendel = -1; boolean assocTDT = false; boolean assocCC = false; permutationCount = 0; tagging = Tagger.NONE; maxNumTags = Tagger.DEFAULT_MAXNUMTAGS; findTags = true; double cutHighCI = -1; double cutLowCI = -1; double mafThresh = -1; double recHighCI = -1; double informFrac = -1; double fourGameteCutoff = -1; double spineDP = -1; for(int i =0; i < args.length; i++) { if(args[i].equalsIgnoreCase("-help") || args[i].equalsIgnoreCase("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equalsIgnoreCase("-n") || args[i].equalsIgnoreCase("-nogui")) { nogui = true; } else if(args[i].equalsIgnoreCase("-p") || args[i].equalsIgnoreCase("-pedfile")) { i++; if( i>=args.length || (args[i].charAt(0) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(pedFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-pcloadletter")){ die("PC LOADLETTER?! What the fuck does that mean?!"); } else if (args[i].equalsIgnoreCase("-skipcheck") || args[i].equalsIgnoreCase("--skipcheck")){ skipCheck = true; } else if (args[i].equalsIgnoreCase("-excludeMarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ die("-excludeMarkers requires a list of markers"); } else { StringTokenizer str = new StringTokenizer(args[i],","); try { StringBuffer sb = new StringBuffer(); if (!quietMode) sb.append("Excluding markers: "); while(str.hasMoreTokens()) { String token = str.nextToken(); if(token.indexOf("..") != -1) { int lastIndex = token.indexOf(".."); int rangeStart = Integer.parseInt(token.substring(0,lastIndex)); int rangeEnd = Integer.parseInt(token.substring(lastIndex+2,token.length())); for(int j=rangeStart;j<=rangeEnd;j++) { if (!quietMode) sb.append(j+" "); excludedMarkers.add(new Integer(j)); } } else { if (!quietMode) sb.append(token+" "); excludedMarkers.add(new Integer(token)); } } if (!quietMode) argHandlerMessages.add(sb.toString()); } catch(NumberFormatException nfe) { die("-excludeMarkers argument should be of the format: 1,3,5..8,12"); } } } else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-haps")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapsFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-i") || args[i].equalsIgnoreCase("-info")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(infoFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-hapmap")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapmapFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpdata")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpdataFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap data file listed will be used"); } phasedhmpdataFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpsample")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpsampleFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap sample file listed will be used"); } phasedhmpsampleFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmplegend")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmplegendFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap legend file listed will be used"); } phasedhmplegendFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhapmapdl")){ phasedhapmapDownload = true; } else if (args[i].equalsIgnoreCase("-plink")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last PLINK file listed will be used"); } plinkFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-map")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last map file listed will be used"); } mapFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-k") || args[i].equalsIgnoreCase("-blocks")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; blockOutputType = BLOX_CUSTOM; }else{ die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-png")){ outputPNG = true; } else if (args[i].equalsIgnoreCase("-smallpng") || args[i].equalsIgnoreCase("-compressedPNG")){ outputCompressedPNG = true; } else if (args[i].equalsIgnoreCase("-track")){ i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ trackFileName = args[i]; }else{ die("-track requires a filename"); } } else if(args[i].equalsIgnoreCase("-o") || args[i].equalsIgnoreCase("-output") || args[i].equalsIgnoreCase("-blockoutput")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(blockOutputType != -1){ die("Only one block output type argument is allowed."); } if(args[i].equalsIgnoreCase("SFS") || args[i].equalsIgnoreCase("GAB")){ blockOutputType = BLOX_GABRIEL; } else if(args[i].equalsIgnoreCase("GAM")){ blockOutputType = BLOX_4GAM; } else if(args[i].equalsIgnoreCase("MJD") || args[i].equalsIgnoreCase("SPI")){ blockOutputType = BLOX_SPINE; } else if(args[i].equalsIgnoreCase("ALL")) { blockOutputType = BLOX_ALL; } } else { //defaults to SFS output blockOutputType = BLOX_GABRIEL; i--; } } else if(args[i].equalsIgnoreCase("-d") || args[i].equalsIgnoreCase("--dprime") || args[i].equalsIgnoreCase("-dprime")) { outputDprime = true; } else if (args[i].equalsIgnoreCase("-c") || args[i].equalsIgnoreCase("-check")){ outputCheck = true; } else if (args[i].equalsIgnoreCase("-indcheck")){ individualCheck = true; } else if (args[i].equalsIgnoreCase("-mendel")){ mendel = true; } else if (args[i].equalsIgnoreCase("-malehets")){ malehets = true; } else if(args[i].equalsIgnoreCase("-m") || args[i].equalsIgnoreCase("-maxdistance")) { i++; maxDistance = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-batch")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(batchFileName != null){ argHandlerMessages.add("multiple " + args[i-1] + " arguments found. only last batch file listed will be used"); } batchFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-hapthresh")) { i++; hapThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-spacing")) { i++; spacingThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-minMAF")) { i++; minimumMAF = getDoubleArg(args,i,0,0.5); } else if(args[i].equalsIgnoreCase("-minGeno") || args[i].equalsIgnoreCase("-minGenoPercent")) { i++; minimumGenoPercent = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-hwcutoff")) { i++; hwCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-maxMendel") ) { i++; maxMendel = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-missingcutoff")) { i++; missingCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-assoctdt")) { assocTDT = true; } else if(args[i].equalsIgnoreCase("-assoccc")) { assocCC = true; } else if(args[i].equalsIgnoreCase("-randomcc")){ assocCC = true; randomizeAffection = true; } else if(args[i].equalsIgnoreCase("-ldcolorscheme")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(args[i].equalsIgnoreCase("default")){ Options.setLDColorScheme(STD_SCHEME); } else if(args[i].equalsIgnoreCase("RSQ")){ Options.setLDColorScheme(RSQ_SCHEME); } else if(args[i].equalsIgnoreCase("DPALT") ){ Options.setLDColorScheme(WMF_SCHEME); } else if(args[i].equalsIgnoreCase("GAB")) { Options.setLDColorScheme(GAB_SCHEME); } else if(args[i].equalsIgnoreCase("GAM")) { Options.setLDColorScheme(GAM_SCHEME); } else if(args[i].equalsIgnoreCase("GOLD")) { Options.setLDColorScheme(GOLD_SCHEME); } } else { //defaults to STD color scheme Options.setLDColorScheme(STD_SCHEME); i--; } } else if(args[i].equalsIgnoreCase("-blockCutHighCI")) { i++; cutHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockCutLowCI")) { i++; cutLowCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockMafThresh")) { i++; mafThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockRecHighCI")) { i++; recHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockInformFrac")) { i++; informFrac = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-block4GamCut")) { i++; fourGameteCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockSpineDP")) { i++; spineDP = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-permtests")) { i++; doPermutationTest = true; permutationCount = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-customassoc")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ customAssocTestsFileName = args[i]; }else{ die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-aggressiveTagging")) { tagging = Tagger.AGGRESSIVE_TRIPLE; } else if (args[i].equalsIgnoreCase("-pairwiseTagging")){ tagging = Tagger.PAIRWISE_ONLY; } else if (args[i].equalsIgnoreCase("-printalltags")){ Options.setPrintAllTags(true); } else if(args[i].equalsIgnoreCase("-maxNumTags")){ i++; maxNumTags = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-tagrSqCutoff")) { i++; tagRSquaredCutOff = getDoubleArg(args,i,0,1); } else if (args[i].equalsIgnoreCase("-dontaddtags")){ findTags = false; } else if(args[i].equalsIgnoreCase("-tagLODCutoff")) { i++; Options.setTaggerLODCutoff(getDoubleArg(args,i,0,100000)); } else if(args[i].equalsIgnoreCase("-includeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die(args[i-1] + " requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceIncludeTags = new Vector(); while(str.hasMoreTokens()) { forceIncludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-includeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceIncludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-excludeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die("-excludeTags requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceExcludeTags = new Vector(); while(str.hasMoreTokens()) { forceExcludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-excludeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceExcludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-captureAlleles")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { captureAllelesFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-designScores")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { designScoresFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-mintagdistance")){ i++; minTagDistance = args[i]; } else if(args[i].equalsIgnoreCase("-chromosome") || args[i].equalsIgnoreCase("-chr")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { chromosomeArg =args[i]; }else { die(args[i-1] + " requires a chromosome name"); } if(!(chromosomeArg.equalsIgnoreCase("X")) && !(chromosomeArg.equalsIgnoreCase("Y"))){ try{ if (Integer.parseInt(chromosomeArg) > 22){ die("-chromosome requires a chromsome name of 1-22 or X"); } }catch(NumberFormatException nfe){ die("-chromosome requires a chromsome name of 1-22 or X"); } } } else if(args[i].equalsIgnoreCase("-population")){ i++; if(!(i>=args.length) && !(args[i].charAt(0)== '-')) { populationArg = args[i]; }else { die(args[i-1] + "requires a population name"); } } else if(args[i].equalsIgnoreCase("-startpos")){ i++; startPos = args[i]; } else if(args[i].equalsIgnoreCase("-endPos")){ i++; endPos = args[i]; } else if(args[i].equalsIgnoreCase("-phase")){ i++; phase = args[i]; } else if(args[i].equalsIgnoreCase("-q") || args[i].equalsIgnoreCase("-quiet")) { quietMode = true; } else if(args[i].equalsIgnoreCase("-gzip")){ Options.setGzip(true); } else { die("invalid parameter specified: " + args[i]); } } int countOptions = 0; if(pedFileName != null) { countOptions++; } if(hapsFileName != null) { countOptions++; } if(hapmapFileName != null) { countOptions++; } if(phasedhmpdataFileName != null) { countOptions++; if(phasedhmpsampleFileName == null){ die("You must specify a sample file for phased hapmap input."); }else if(phasedhmplegendFileName == null){ die("You must specify a legend file for phased hapmap input."); } } if(phasedhapmapDownload) { countOptions++; } if(plinkFileName != null){ countOptions++; if(mapFileName == null){ die("You must specify a map file for plink format input."); } } if(batchFileName != null) { countOptions++; } if(countOptions > 1) { die("Only one genotype input file may be specified on the command line."); } else if(countOptions == 0 && nogui) { die("You must specify a genotype input file."); } //mess with vars, set defaults, etc if(skipCheck && !quietMode) { argHandlerMessages.add("Skipping genotype file check"); } if(maxDistance == -1){ maxDistance = MAXDIST_DEFAULT; }else{ if (!quietMode) argHandlerMessages.add("Max LD comparison distance = " +maxDistance + "kb"); } Options.setMaxDistance(maxDistance); if(hapThresh != -1) { Options.setHaplotypeDisplayThreshold(hapThresh); if (!quietMode) argHandlerMessages.add("Haplotype display threshold = " + hapThresh); } if(minimumMAF != -1) { CheckData.mafCut = minimumMAF; if (!quietMode) argHandlerMessages.add("Minimum MAF = " + minimumMAF); } if(minimumGenoPercent != -1) { CheckData.failedGenoCut = (int)(minimumGenoPercent*100); if (!quietMode) argHandlerMessages.add("Minimum SNP genotype % = " + minimumGenoPercent); } if(hwCutoff != -1) { CheckData.hwCut = hwCutoff; if (!quietMode) argHandlerMessages.add("Hardy Weinberg equilibrium p-value cutoff = " + hwCutoff); } if(maxMendel != -1) { CheckData.numMendErrCut = maxMendel; if (!quietMode) argHandlerMessages.add("Maximum number of Mendel errors = "+maxMendel); } if(spacingThresh != -1) { Options.setSpacingThreshold(spacingThresh); if (!quietMode) argHandlerMessages.add("LD display spacing value = "+spacingThresh); } if(missingCutoff != -1) { Options.setMissingThreshold(missingCutoff); if (!quietMode) argHandlerMessages.add("Maximum amount of missing data allowed per individual = "+missingCutoff); } if(cutHighCI != -1) { FindBlocks.cutHighCI = cutHighCI; } if(cutLowCI != -1) { FindBlocks.cutLowCI = cutLowCI; } if(mafThresh != -1) { FindBlocks.mafThresh = mafThresh; } if(recHighCI != -1) { FindBlocks.recHighCI = recHighCI; } if(informFrac != -1) { FindBlocks.informFrac = informFrac; } if(fourGameteCutoff != -1) { FindBlocks.fourGameteCutoff = fourGameteCutoff; } if(spineDP != -1) { FindBlocks.spineDP = spineDP; } if(assocTDT) { Options.setAssocTest(ASSOC_TRIO); }else if(assocCC) { Options.setAssocTest(ASSOC_CC); } if (Options.getAssocTest() != ASSOC_NONE && infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when performing association tests."); } if(doPermutationTest) { if(!assocCC && !assocTDT) { die("An association test type must be specified for permutation tests to be performed."); } } if(customAssocTestsFileName != null) { if(!assocCC && !assocTDT) { die("An association test type must be specified when using a custom association test file."); } if(infoFileName == null) { die("A marker info file must be specified when using a custom association test file."); } } if(tagging != Tagger.NONE) { if(infoFileName == null && hapmapFileName == null && batchFileName == null && phasedhmpdataFileName == null && !phasedhapmapDownload) { die("A marker info file must be specified when tagging."); } if(forceExcludeTags == null) { forceExcludeTags = new Vector(); } else if (forceExcludeFileName != null) { die("-excludeTags and -excludeTagsFile cannot both be used"); } if(forceExcludeFileName != null) { File excludeFile = new File(forceExcludeFileName); forceExcludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(excludeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceExcludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -excludeTagsFile."); } } if(forceIncludeTags == null ) { forceIncludeTags = new Vector(); } else if (forceIncludeFileName != null) { die("-includeTags and -includeTagsFile cannot both be used"); } if(forceIncludeFileName != null) { File includeFile = new File(forceIncludeFileName); forceIncludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(includeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceIncludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -includeTagsFile."); } } if (captureAllelesFileName != null) { File captureFile = new File(captureAllelesFileName); captureAlleleTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(captureFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ line = line.trim(); captureAlleleTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (designScoresFileName != null) { File designFile = new File(designScoresFileName); designScores = new Hashtable(1,1); try { BufferedReader br = new BufferedReader(new FileReader(designFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ StringTokenizer st = new StringTokenizer(line); String marker = st.nextToken(); Double score = new Double(st.nextToken()); designScores.put(marker,score); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (minTagDistance != null) { try{ if (Integer.parseInt(minTagDistance) < 0){ die("minimum tag distance cannot be negative"); } }catch(NumberFormatException nfe){ die("minimum tag distance must be a positive integer"); } Options.setTaggerMinDistance(Integer.parseInt(minTagDistance)); } //check that there isn't any overlap between include/exclude lists Vector tempInclude = (Vector) forceIncludeTags.clone(); tempInclude.retainAll(forceExcludeTags); if(tempInclude.size() > 0) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < tempInclude.size(); i++) { String s = (String) tempInclude.elementAt(i); sb.append(s).append(","); } die("The following markers appear in both the include and exclude lists: " + sb.toString()); } if(tagRSquaredCutOff != -1) { Options.setTaggerRsqCutoff(tagRSquaredCutOff); } } else if(forceExcludeTags != null || forceIncludeTags != null || tagRSquaredCutOff != -1) { die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without a tagging option"); } if(chromosomeArg != null && hapmapFileName != null) { argHandlerMessages.add("-chromosome flag ignored when loading hapmap file"); chromosomeArg = null; } if(chromosomeArg != null) { Chromosome.setDataChrom("chr" + chromosomeArg); } if (phasedhapmapDownload){ if (chromosomeArg == null){ die("-phasedhapmapdl requires a chromosome specification"); }else if (!(populationArg.equalsIgnoreCase("CEU") || populationArg.equalsIgnoreCase("YRI") || populationArg.equalsIgnoreCase("CHB+JPT"))){ die("-phasedhapmapdl requires a population specification of CEU, YRI, or CHB+JPT"); } if (Integer.parseInt(chromosomeArg) < 1 && Integer.parseInt(chromosomeArg) > 22){ if (!(chromosomeArg.equalsIgnoreCase("x"))){ die("chromsome specification must be betweeen 1 and 22 or X"); } } try{ if (Integer.parseInt(startPos) > Integer.parseInt(endPos)){ die("end position must be greater then start position"); } }catch(NumberFormatException nfe){ die("start and end positions must be integer values"); } if (phase == null){ phase = "2"; } try{ if (Integer.parseInt(phase) != 1 && Integer.parseInt(phase) != 2){ die("phase must be either 1 or 2"); } }catch(NumberFormatException nfe){ die("phase must be an integer value"); } } }
| 1,108,296
|
private void argHandler(String[] args){ argHandlerMessages = new Vector(); int maxDistance = -1; //this means that user didn't specify any output type if it doesn't get changed below blockOutputType = -1; double hapThresh = -1; double minimumMAF=-1; double spacingThresh = -1; double minimumGenoPercent = -1; double hwCutoff = -1; double missingCutoff = -1; int maxMendel = -1; boolean assocTDT = false; boolean assocCC = false; permutationCount = 0; tagging = Tagger.NONE; maxNumTags = Tagger.DEFAULT_MAXNUMTAGS; findTags = true; double cutHighCI = -1; double cutLowCI = -1; double mafThresh = -1; double recHighCI = -1; double informFrac = -1; double fourGameteCutoff = -1; double spineDP = -1; for(int i =0; i < args.length; i++) { if(args[i].equalsIgnoreCase("-help") || args[i].equalsIgnoreCase("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equalsIgnoreCase("-n") || args[i].equalsIgnoreCase("-nogui")) { nogui = true; } else if(args[i].equalsIgnoreCase("-p") || args[i].equalsIgnoreCase("-pedfile")) { i++; if( i>=args.length || (args[i].charAt(0) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(pedFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-pcloadletter")){ die("PC LOADLETTER?! What the fuck does that mean?!"); } else if (args[i].equalsIgnoreCase("-skipcheck") || args[i].equalsIgnoreCase("--skipcheck")){ skipCheck = true; } else if (args[i].equalsIgnoreCase("-excludeMarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ die("-excludeMarkers requires a list of markers"); } else { StringTokenizer str = new StringTokenizer(args[i],","); try { StringBuffer sb = new StringBuffer(); if (!quietMode) sb.append("Excluding markers: "); while(str.hasMoreTokens()) { String token = str.nextToken(); if(token.indexOf("..") != -1) { int lastIndex = token.indexOf(".."); int rangeStart = Integer.parseInt(token.substring(0,lastIndex)); int rangeEnd = Integer.parseInt(token.substring(lastIndex+2,token.length())); for(int j=rangeStart;j<=rangeEnd;j++) { if (!quietMode) sb.append(j+" "); excludedMarkers.add(new Integer(j)); } } else { if (!quietMode) sb.append(token+" "); excludedMarkers.add(new Integer(token)); } } if (!quietMode) argHandlerMessages.add(sb.toString()); } catch(NumberFormatException nfe) { die("-excludeMarkers argument should be of the format: 1,3,5..8,12"); } } } else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-haps")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapsFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-i") || args[i].equalsIgnoreCase("-info")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(infoFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-hapmap")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapmapFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpdata")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpdataFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap data file listed will be used"); } phasedhmpdataFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpsample")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpsampleFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap sample file listed will be used"); } phasedhmpsampleFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmplegend")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmplegendFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap legend file listed will be used"); } phasedhmplegendFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhapmapdl")){ phasedhapmapDownload = true; } else if (args[i].equalsIgnoreCase("-plink")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last PLINK file listed will be used"); } plinkFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-map")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last map file listed will be used"); } mapFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-k") || args[i].equalsIgnoreCase("-blocks")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; blockOutputType = BLOX_CUSTOM; }else{ die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-png")){ outputPNG = true; } else if (args[i].equalsIgnoreCase("-smallpng") || args[i].equalsIgnoreCase("-compressedPNG")){ outputCompressedPNG = true; } else if (args[i].equalsIgnoreCase("-track")){ i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ trackFileName = args[i]; }else{ die("-track requires a filename"); } } else if(args[i].equalsIgnoreCase("-o") || args[i].equalsIgnoreCase("-output") || args[i].equalsIgnoreCase("-blockoutput")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(blockOutputType != -1){ die("Only one block output type argument is allowed."); } if(args[i].equalsIgnoreCase("SFS") || args[i].equalsIgnoreCase("GAB")){ blockOutputType = BLOX_GABRIEL; } else if(args[i].equalsIgnoreCase("GAM")){ blockOutputType = BLOX_4GAM; } else if(args[i].equalsIgnoreCase("MJD") || args[i].equalsIgnoreCase("SPI")){ blockOutputType = BLOX_SPINE; } else if(args[i].equalsIgnoreCase("ALL")) { blockOutputType = BLOX_ALL; } } else { //defaults to SFS output blockOutputType = BLOX_GABRIEL; i--; } } else if(args[i].equalsIgnoreCase("-d") || args[i].equalsIgnoreCase("--dprime") || args[i].equalsIgnoreCase("-dprime")) { outputDprime = true; } else if (args[i].equalsIgnoreCase("-c") || args[i].equalsIgnoreCase("-check")){ outputCheck = true; } else if (args[i].equalsIgnoreCase("-indcheck")){ individualCheck = true; } else if (args[i].equalsIgnoreCase("-mendel")){ mendel = true; } else if (args[i].equalsIgnoreCase("-malehets")){ malehets = true; } else if(args[i].equalsIgnoreCase("-m") || args[i].equalsIgnoreCase("-maxdistance")) { i++; maxDistance = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-batch")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(batchFileName != null){ argHandlerMessages.add("multiple " + args[i-1] + " arguments found. only last batch file listed will be used"); } batchFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-hapthresh")) { i++; hapThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-spacing")) { i++; spacingThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-minMAF")) { i++; minimumMAF = getDoubleArg(args,i,0,0.5); } else if(args[i].equalsIgnoreCase("-minGeno") || args[i].equalsIgnoreCase("-minGenoPercent")) { i++; minimumGenoPercent = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-hwcutoff")) { i++; hwCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-maxMendel") ) { i++; maxMendel = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-missingcutoff")) { i++; missingCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-assoctdt")) { assocTDT = true; } else if(args[i].equalsIgnoreCase("-assoccc")) { assocCC = true; } else if(args[i].equalsIgnoreCase("-randomcc")){ assocCC = true; randomizeAffection = true; } else if(args[i].equalsIgnoreCase("-ldcolorscheme")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(args[i].equalsIgnoreCase("default")){ Options.setLDColorScheme(STD_SCHEME); } else if(args[i].equalsIgnoreCase("RSQ")){ Options.setLDColorScheme(RSQ_SCHEME); } else if(args[i].equalsIgnoreCase("DPALT") ){ Options.setLDColorScheme(WMF_SCHEME); } else if(args[i].equalsIgnoreCase("GAB")) { Options.setLDColorScheme(GAB_SCHEME); } else if(args[i].equalsIgnoreCase("GAM")) { Options.setLDColorScheme(GAM_SCHEME); } else if(args[i].equalsIgnoreCase("GOLD")) { Options.setLDColorScheme(GOLD_SCHEME); } } else { //defaults to STD color scheme Options.setLDColorScheme(STD_SCHEME); i--; } } else if(args[i].equalsIgnoreCase("-blockCutHighCI")) { i++; cutHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockCutLowCI")) { i++; cutLowCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockMafThresh")) { i++; mafThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockRecHighCI")) { i++; recHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockInformFrac")) { i++; informFrac = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-block4GamCut")) { i++; fourGameteCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockSpineDP")) { i++; spineDP = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-permtests")) { i++; doPermutationTest = true; permutationCount = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-customassoc")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ customAssocTestsFileName = args[i]; }else{ die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-aggressiveTagging")) { tagging = Tagger.AGGRESSIVE_TRIPLE; } else if (args[i].equalsIgnoreCase("-pairwiseTagging")){ tagging = Tagger.PAIRWISE_ONLY; } else if (args[i].equalsIgnoreCase("-printalltags")){ Options.setPrintAllTags(true); } else if(args[i].equalsIgnoreCase("-maxNumTags")){ i++; maxNumTags = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-tagrSqCutoff")) { i++; tagRSquaredCutOff = getDoubleArg(args,i,0,1); } else if (args[i].equalsIgnoreCase("-dontaddtags")){ findTags = false; } else if(args[i].equalsIgnoreCase("-tagLODCutoff")) { i++; Options.setTaggerLODCutoff(getDoubleArg(args,i,0,100000)); } else if(args[i].equalsIgnoreCase("-includeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die(args[i-1] + " requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceIncludeTags = new Vector(); while(str.hasMoreTokens()) { forceIncludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-includeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceIncludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-excludeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die("-excludeTags requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceExcludeTags = new Vector(); while(str.hasMoreTokens()) { forceExcludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-excludeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceExcludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-captureAlleles")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { captureAllelesFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-designScores")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { designScoresFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-mintagdistance")){ i++; minTagDistance = args[i]; } else if(args[i].equalsIgnoreCase("-chromosome") || args[i].equalsIgnoreCase("-chr")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { chromosomeArg =args[i]; }else { die(args[i-1] + " requires a chromosome name"); } if(!(chromosomeArg.equalsIgnoreCase("x"))){ try{ if (Integer.parseInt(chromosomeArg) > 22){ die("-chromosome requires a chromsome name of 1-22 or X"); } }catch(NumberFormatException nfe){ die("-chromosome requires a chromsome name of 1-22 or X"); } } } else if(args[i].equalsIgnoreCase("-population")){ i++; if(!(i>=args.length) && !(args[i].charAt(0)== '-')) { populationArg = args[i]; }else { die(args[i-1] + "requires a population name"); } } else if(args[i].equalsIgnoreCase("-startpos")){ i++; startPos = args[i]; } else if(args[i].equalsIgnoreCase("-endPos")){ i++; endPos = args[i]; } else if(args[i].equalsIgnoreCase("-phase")){ i++; phase = args[i]; } else if(args[i].equalsIgnoreCase("-q") || args[i].equalsIgnoreCase("-quiet")) { quietMode = true; } else if(args[i].equalsIgnoreCase("-gzip")){ Options.setGzip(true); } else { die("invalid parameter specified: " + args[i]); } } int countOptions = 0; if(pedFileName != null) { countOptions++; } if(hapsFileName != null) { countOptions++; } if(hapmapFileName != null) { countOptions++; } if(phasedhmpdataFileName != null) { countOptions++; if(phasedhmpsampleFileName == null){ die("You must specify a sample file for phased hapmap input."); }else if(phasedhmplegendFileName == null){ die("You must specify a legend file for phased hapmap input."); } } if(phasedhapmapDownload) { countOptions++; } if(plinkFileName != null){ countOptions++; if(mapFileName == null){ die("You must specify a map file for plink format input."); } } if(batchFileName != null) { countOptions++; } if(countOptions > 1) { die("Only one genotype input file may be specified on the command line."); } else if(countOptions == 0 && nogui) { die("You must specify a genotype input file."); } //mess with vars, set defaults, etc if(skipCheck && !quietMode) { argHandlerMessages.add("Skipping genotype file check"); } if(maxDistance == -1){ maxDistance = MAXDIST_DEFAULT; }else{ if (!quietMode) argHandlerMessages.add("Max LD comparison distance = " +maxDistance + "kb"); } Options.setMaxDistance(maxDistance); if(hapThresh != -1) { Options.setHaplotypeDisplayThreshold(hapThresh); if (!quietMode) argHandlerMessages.add("Haplotype display threshold = " + hapThresh); } if(minimumMAF != -1) { CheckData.mafCut = minimumMAF; if (!quietMode) argHandlerMessages.add("Minimum MAF = " + minimumMAF); } if(minimumGenoPercent != -1) { CheckData.failedGenoCut = (int)(minimumGenoPercent*100); if (!quietMode) argHandlerMessages.add("Minimum SNP genotype % = " + minimumGenoPercent); } if(hwCutoff != -1) { CheckData.hwCut = hwCutoff; if (!quietMode) argHandlerMessages.add("Hardy Weinberg equilibrium p-value cutoff = " + hwCutoff); } if(maxMendel != -1) { CheckData.numMendErrCut = maxMendel; if (!quietMode) argHandlerMessages.add("Maximum number of Mendel errors = "+maxMendel); } if(spacingThresh != -1) { Options.setSpacingThreshold(spacingThresh); if (!quietMode) argHandlerMessages.add("LD display spacing value = "+spacingThresh); } if(missingCutoff != -1) { Options.setMissingThreshold(missingCutoff); if (!quietMode) argHandlerMessages.add("Maximum amount of missing data allowed per individual = "+missingCutoff); } if(cutHighCI != -1) { FindBlocks.cutHighCI = cutHighCI; } if(cutLowCI != -1) { FindBlocks.cutLowCI = cutLowCI; } if(mafThresh != -1) { FindBlocks.mafThresh = mafThresh; } if(recHighCI != -1) { FindBlocks.recHighCI = recHighCI; } if(informFrac != -1) { FindBlocks.informFrac = informFrac; } if(fourGameteCutoff != -1) { FindBlocks.fourGameteCutoff = fourGameteCutoff; } if(spineDP != -1) { FindBlocks.spineDP = spineDP; } if(assocTDT) { Options.setAssocTest(ASSOC_TRIO); }else if(assocCC) { Options.setAssocTest(ASSOC_CC); } if (Options.getAssocTest() != ASSOC_NONE && infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when performing association tests."); } if(doPermutationTest) { if(!assocCC && !assocTDT) { die("An association test type must be specified for permutation tests to be performed."); } } if(customAssocTestsFileName != null) { if(!assocCC && !assocTDT) { die("An association test type must be specified when using a custom association test file."); } if(infoFileName == null) { die("A marker info file must be specified when using a custom association test file."); } } if(tagging != Tagger.NONE) { if(infoFileName == null && hapmapFileName == null && batchFileName == null && phasedhmpdataFileName == null && !phasedhapmapDownload) { die("A marker info file must be specified when tagging."); } if(forceExcludeTags == null) { forceExcludeTags = new Vector(); } else if (forceExcludeFileName != null) { die("-excludeTags and -excludeTagsFile cannot both be used"); } if(forceExcludeFileName != null) { File excludeFile = new File(forceExcludeFileName); forceExcludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(excludeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceExcludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -excludeTagsFile."); } } if(forceIncludeTags == null ) { forceIncludeTags = new Vector(); } else if (forceIncludeFileName != null) { die("-includeTags and -includeTagsFile cannot both be used"); } if(forceIncludeFileName != null) { File includeFile = new File(forceIncludeFileName); forceIncludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(includeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceIncludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -includeTagsFile."); } } if (captureAllelesFileName != null) { File captureFile = new File(captureAllelesFileName); captureAlleleTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(captureFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ line = line.trim(); captureAlleleTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (designScoresFileName != null) { File designFile = new File(designScoresFileName); designScores = new Hashtable(1,1); try { BufferedReader br = new BufferedReader(new FileReader(designFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ StringTokenizer st = new StringTokenizer(line); String marker = st.nextToken(); Double score = new Double(st.nextToken()); designScores.put(marker,score); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (minTagDistance != null) { try{ if (Integer.parseInt(minTagDistance) < 0){ die("minimum tag distance cannot be negative"); } }catch(NumberFormatException nfe){ die("minimum tag distance must be a positive integer"); } Options.setTaggerMinDistance(Integer.parseInt(minTagDistance)); } //check that there isn't any overlap between include/exclude lists Vector tempInclude = (Vector) forceIncludeTags.clone(); tempInclude.retainAll(forceExcludeTags); if(tempInclude.size() > 0) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < tempInclude.size(); i++) { String s = (String) tempInclude.elementAt(i); sb.append(s).append(","); } die("The following markers appear in both the include and exclude lists: " + sb.toString()); } if(tagRSquaredCutOff != -1) { Options.setTaggerRsqCutoff(tagRSquaredCutOff); } } else if(forceExcludeTags != null || forceIncludeTags != null || tagRSquaredCutOff != -1) { die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without a tagging option"); } if(chromosomeArg != null && hapmapFileName != null) { argHandlerMessages.add("-chromosome flag ignored when loading hapmap file"); chromosomeArg = null; } if(chromosomeArg != null) { Chromosome.setDataChrom("chr" + chromosomeArg); } if (phasedhapmapDownload){ if (chromosomeArg == null){ die("-phasedhapmapdl requires a chromosome specification"); }else if (!(populationArg.equalsIgnoreCase("CEU") || populationArg.equalsIgnoreCase("YRI") || populationArg.equalsIgnoreCase("CHB+JPT"))){ die("-phasedhapmapdl requires a population specification of CEU, YRI, or CHB+JPT"); } if (Integer.parseInt(chromosomeArg) < 1 && Integer.parseInt(chromosomeArg) > 22){ if (!(chromosomeArg.equalsIgnoreCase("x"))){ die("chromsome specification must be betweeen 1 and 22 or X"); } } try{ if (Integer.parseInt(startPos) > Integer.parseInt(endPos)){ die("end position must be greater then start position"); } }catch(NumberFormatException nfe){ die("start and end positions must be integer values"); } if (phase == null){ phase = "2"; } try{ if (Integer.parseInt(phase) != 1 && Integer.parseInt(phase) != 2){ die("phase must be either 1 or 2"); } }catch(NumberFormatException nfe){ die("phase must be an integer value"); } } }
|
private void argHandler(String[] args){ argHandlerMessages = new Vector(); int maxDistance = -1; //this means that user didn't specify any output type if it doesn't get changed below blockOutputType = -1; double hapThresh = -1; double minimumMAF=-1; double spacingThresh = -1; double minimumGenoPercent = -1; double hwCutoff = -1; double missingCutoff = -1; int maxMendel = -1; boolean assocTDT = false; boolean assocCC = false; permutationCount = 0; tagging = Tagger.NONE; maxNumTags = Tagger.DEFAULT_MAXNUMTAGS; findTags = true; double cutHighCI = -1; double cutLowCI = -1; double mafThresh = -1; double recHighCI = -1; double informFrac = -1; double fourGameteCutoff = -1; double spineDP = -1; for(int i =0; i < args.length; i++) { if(args[i].equalsIgnoreCase("-help") || args[i].equalsIgnoreCase("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equalsIgnoreCase("-n") || args[i].equalsIgnoreCase("-nogui")) { nogui = true; } else if(args[i].equalsIgnoreCase("-p") || args[i].equalsIgnoreCase("-pedfile")) { i++; if( i>=args.length || (args[i].charAt(0) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(pedFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-pcloadletter")){ die("PC LOADLETTER?! What the fuck does that mean?!"); } else if (args[i].equalsIgnoreCase("-skipcheck") || args[i].equalsIgnoreCase("--skipcheck")){ skipCheck = true; } else if (args[i].equalsIgnoreCase("-excludeMarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ die("-excludeMarkers requires a list of markers"); } else { StringTokenizer str = new StringTokenizer(args[i],","); try { StringBuffer sb = new StringBuffer(); if (!quietMode) sb.append("Excluding markers: "); while(str.hasMoreTokens()) { String token = str.nextToken(); if(token.indexOf("..") != -1) { int lastIndex = token.indexOf(".."); int rangeStart = Integer.parseInt(token.substring(0,lastIndex)); int rangeEnd = Integer.parseInt(token.substring(lastIndex+2,token.length())); for(int j=rangeStart;j<=rangeEnd;j++) { if (!quietMode) sb.append(j+" "); excludedMarkers.add(new Integer(j)); } } else { if (!quietMode) sb.append(token+" "); excludedMarkers.add(new Integer(token)); } } if (!quietMode) argHandlerMessages.add(sb.toString()); } catch(NumberFormatException nfe) { die("-excludeMarkers argument should be of the format: 1,3,5..8,12"); } } } else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-haps")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapsFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-i") || args[i].equalsIgnoreCase("-info")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(infoFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-hapmap")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapmapFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpdata")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpdataFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap data file listed will be used"); } phasedhmpdataFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpsample")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpsampleFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap sample file listed will be used"); } phasedhmpsampleFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmplegend")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmplegendFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap legend file listed will be used"); } phasedhmplegendFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhapmapdl")){ phasedhapmapDownload = true; } else if (args[i].equalsIgnoreCase("-plink")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last PLINK file listed will be used"); } plinkFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-map")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last map file listed will be used"); } mapFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-k") || args[i].equalsIgnoreCase("-blocks")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; blockOutputType = BLOX_CUSTOM; }else{ die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-png")){ outputPNG = true; } else if (args[i].equalsIgnoreCase("-smallpng") || args[i].equalsIgnoreCase("-compressedPNG")){ outputCompressedPNG = true; } else if (args[i].equalsIgnoreCase("-track")){ i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ trackFileName = args[i]; }else{ die("-track requires a filename"); } } else if(args[i].equalsIgnoreCase("-o") || args[i].equalsIgnoreCase("-output") || args[i].equalsIgnoreCase("-blockoutput")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(blockOutputType != -1){ die("Only one block output type argument is allowed."); } if(args[i].equalsIgnoreCase("SFS") || args[i].equalsIgnoreCase("GAB")){ blockOutputType = BLOX_GABRIEL; } else if(args[i].equalsIgnoreCase("GAM")){ blockOutputType = BLOX_4GAM; } else if(args[i].equalsIgnoreCase("MJD") || args[i].equalsIgnoreCase("SPI")){ blockOutputType = BLOX_SPINE; } else if(args[i].equalsIgnoreCase("ALL")) { blockOutputType = BLOX_ALL; } } else { //defaults to SFS output blockOutputType = BLOX_GABRIEL; i--; } } else if(args[i].equalsIgnoreCase("-d") || args[i].equalsIgnoreCase("--dprime") || args[i].equalsIgnoreCase("-dprime")) { outputDprime = true; } else if (args[i].equalsIgnoreCase("-c") || args[i].equalsIgnoreCase("-check")){ outputCheck = true; } else if (args[i].equalsIgnoreCase("-indcheck")){ individualCheck = true; } else if (args[i].equalsIgnoreCase("-mendel")){ mendel = true; } else if (args[i].equalsIgnoreCase("-malehets")){ malehets = true; } else if(args[i].equalsIgnoreCase("-m") || args[i].equalsIgnoreCase("-maxdistance")) { i++; maxDistance = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-batch")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(batchFileName != null){ argHandlerMessages.add("multiple " + args[i-1] + " arguments found. only last batch file listed will be used"); } batchFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-hapthresh")) { i++; hapThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-spacing")) { i++; spacingThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-minMAF")) { i++; minimumMAF = getDoubleArg(args,i,0,0.5); } else if(args[i].equalsIgnoreCase("-minGeno") || args[i].equalsIgnoreCase("-minGenoPercent")) { i++; minimumGenoPercent = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-hwcutoff")) { i++; hwCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-maxMendel") ) { i++; maxMendel = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-missingcutoff")) { i++; missingCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-assoctdt")) { assocTDT = true; } else if(args[i].equalsIgnoreCase("-assoccc")) { assocCC = true; } else if(args[i].equalsIgnoreCase("-randomcc")){ assocCC = true; randomizeAffection = true; } else if(args[i].equalsIgnoreCase("-ldcolorscheme")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(args[i].equalsIgnoreCase("default")){ Options.setLDColorScheme(STD_SCHEME); } else if(args[i].equalsIgnoreCase("RSQ")){ Options.setLDColorScheme(RSQ_SCHEME); } else if(args[i].equalsIgnoreCase("DPALT") ){ Options.setLDColorScheme(WMF_SCHEME); } else if(args[i].equalsIgnoreCase("GAB")) { Options.setLDColorScheme(GAB_SCHEME); } else if(args[i].equalsIgnoreCase("GAM")) { Options.setLDColorScheme(GAM_SCHEME); } else if(args[i].equalsIgnoreCase("GOLD")) { Options.setLDColorScheme(GOLD_SCHEME); } } else { //defaults to STD color scheme Options.setLDColorScheme(STD_SCHEME); i--; } } else if(args[i].equalsIgnoreCase("-blockCutHighCI")) { i++; cutHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockCutLowCI")) { i++; cutLowCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockMafThresh")) { i++; mafThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockRecHighCI")) { i++; recHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockInformFrac")) { i++; informFrac = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-block4GamCut")) { i++; fourGameteCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockSpineDP")) { i++; spineDP = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-permtests")) { i++; doPermutationTest = true; permutationCount = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-customassoc")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ customAssocTestsFileName = args[i]; }else{ die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-aggressiveTagging")) { tagging = Tagger.AGGRESSIVE_TRIPLE; } else if (args[i].equalsIgnoreCase("-pairwiseTagging")){ tagging = Tagger.PAIRWISE_ONLY; } else if (args[i].equalsIgnoreCase("-printalltags")){ Options.setPrintAllTags(true); } else if(args[i].equalsIgnoreCase("-maxNumTags")){ i++; maxNumTags = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-tagrSqCutoff")) { i++; tagRSquaredCutOff = getDoubleArg(args,i,0,1); } else if (args[i].equalsIgnoreCase("-dontaddtags")){ findTags = false; } else if(args[i].equalsIgnoreCase("-tagLODCutoff")) { i++; Options.setTaggerLODCutoff(getDoubleArg(args,i,0,100000)); } else if(args[i].equalsIgnoreCase("-includeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die(args[i-1] + " requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceIncludeTags = new Vector(); while(str.hasMoreTokens()) { forceIncludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-includeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceIncludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-excludeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die("-excludeTags requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceExcludeTags = new Vector(); while(str.hasMoreTokens()) { forceExcludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-excludeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceExcludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-captureAlleles")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { captureAllelesFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-designScores")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { designScoresFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-mintagdistance")){ i++; minTagDistance = args[i]; } else if(args[i].equalsIgnoreCase("-chromosome") || args[i].equalsIgnoreCase("-chr")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { chromosomeArg =args[i]; }else { die(args[i-1] + " requires a chromosome name"); } if(!(chromosomeArg.equalsIgnoreCase("x"))){ try{ if (Integer.parseInt(chromosomeArg) > 22){ die("-chromosome requires a chromsome name of 1-22, X, or Y"); } }catch(NumberFormatException nfe){ die("-chromosome requires a chromsome name of 1-22, X, or Y"); } } } else if(args[i].equalsIgnoreCase("-population")){ i++; if(!(i>=args.length) && !(args[i].charAt(0)== '-')) { populationArg = args[i]; }else { die(args[i-1] + "requires a population name"); } } else if(args[i].equalsIgnoreCase("-startpos")){ i++; startPos = args[i]; } else if(args[i].equalsIgnoreCase("-endPos")){ i++; endPos = args[i]; } else if(args[i].equalsIgnoreCase("-phase")){ i++; phase = args[i]; } else if(args[i].equalsIgnoreCase("-q") || args[i].equalsIgnoreCase("-quiet")) { quietMode = true; } else if(args[i].equalsIgnoreCase("-gzip")){ Options.setGzip(true); } else { die("invalid parameter specified: " + args[i]); } } int countOptions = 0; if(pedFileName != null) { countOptions++; } if(hapsFileName != null) { countOptions++; } if(hapmapFileName != null) { countOptions++; } if(phasedhmpdataFileName != null) { countOptions++; if(phasedhmpsampleFileName == null){ die("You must specify a sample file for phased hapmap input."); }else if(phasedhmplegendFileName == null){ die("You must specify a legend file for phased hapmap input."); } } if(phasedhapmapDownload) { countOptions++; } if(plinkFileName != null){ countOptions++; if(mapFileName == null){ die("You must specify a map file for plink format input."); } } if(batchFileName != null) { countOptions++; } if(countOptions > 1) { die("Only one genotype input file may be specified on the command line."); } else if(countOptions == 0 && nogui) { die("You must specify a genotype input file."); } //mess with vars, set defaults, etc if(skipCheck && !quietMode) { argHandlerMessages.add("Skipping genotype file check"); } if(maxDistance == -1){ maxDistance = MAXDIST_DEFAULT; }else{ if (!quietMode) argHandlerMessages.add("Max LD comparison distance = " +maxDistance + "kb"); } Options.setMaxDistance(maxDistance); if(hapThresh != -1) { Options.setHaplotypeDisplayThreshold(hapThresh); if (!quietMode) argHandlerMessages.add("Haplotype display threshold = " + hapThresh); } if(minimumMAF != -1) { CheckData.mafCut = minimumMAF; if (!quietMode) argHandlerMessages.add("Minimum MAF = " + minimumMAF); } if(minimumGenoPercent != -1) { CheckData.failedGenoCut = (int)(minimumGenoPercent*100); if (!quietMode) argHandlerMessages.add("Minimum SNP genotype % = " + minimumGenoPercent); } if(hwCutoff != -1) { CheckData.hwCut = hwCutoff; if (!quietMode) argHandlerMessages.add("Hardy Weinberg equilibrium p-value cutoff = " + hwCutoff); } if(maxMendel != -1) { CheckData.numMendErrCut = maxMendel; if (!quietMode) argHandlerMessages.add("Maximum number of Mendel errors = "+maxMendel); } if(spacingThresh != -1) { Options.setSpacingThreshold(spacingThresh); if (!quietMode) argHandlerMessages.add("LD display spacing value = "+spacingThresh); } if(missingCutoff != -1) { Options.setMissingThreshold(missingCutoff); if (!quietMode) argHandlerMessages.add("Maximum amount of missing data allowed per individual = "+missingCutoff); } if(cutHighCI != -1) { FindBlocks.cutHighCI = cutHighCI; } if(cutLowCI != -1) { FindBlocks.cutLowCI = cutLowCI; } if(mafThresh != -1) { FindBlocks.mafThresh = mafThresh; } if(recHighCI != -1) { FindBlocks.recHighCI = recHighCI; } if(informFrac != -1) { FindBlocks.informFrac = informFrac; } if(fourGameteCutoff != -1) { FindBlocks.fourGameteCutoff = fourGameteCutoff; } if(spineDP != -1) { FindBlocks.spineDP = spineDP; } if(assocTDT) { Options.setAssocTest(ASSOC_TRIO); }else if(assocCC) { Options.setAssocTest(ASSOC_CC); } if (Options.getAssocTest() != ASSOC_NONE && infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when performing association tests."); } if(doPermutationTest) { if(!assocCC && !assocTDT) { die("An association test type must be specified for permutation tests to be performed."); } } if(customAssocTestsFileName != null) { if(!assocCC && !assocTDT) { die("An association test type must be specified when using a custom association test file."); } if(infoFileName == null) { die("A marker info file must be specified when using a custom association test file."); } } if(tagging != Tagger.NONE) { if(infoFileName == null && hapmapFileName == null && batchFileName == null && phasedhmpdataFileName == null && !phasedhapmapDownload) { die("A marker info file must be specified when tagging."); } if(forceExcludeTags == null) { forceExcludeTags = new Vector(); } else if (forceExcludeFileName != null) { die("-excludeTags and -excludeTagsFile cannot both be used"); } if(forceExcludeFileName != null) { File excludeFile = new File(forceExcludeFileName); forceExcludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(excludeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceExcludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -excludeTagsFile."); } } if(forceIncludeTags == null ) { forceIncludeTags = new Vector(); } else if (forceIncludeFileName != null) { die("-includeTags and -includeTagsFile cannot both be used"); } if(forceIncludeFileName != null) { File includeFile = new File(forceIncludeFileName); forceIncludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(includeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceIncludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -includeTagsFile."); } } if (captureAllelesFileName != null) { File captureFile = new File(captureAllelesFileName); captureAlleleTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(captureFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ line = line.trim(); captureAlleleTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (designScoresFileName != null) { File designFile = new File(designScoresFileName); designScores = new Hashtable(1,1); try { BufferedReader br = new BufferedReader(new FileReader(designFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ StringTokenizer st = new StringTokenizer(line); String marker = st.nextToken(); Double score = new Double(st.nextToken()); designScores.put(marker,score); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (minTagDistance != null) { try{ if (Integer.parseInt(minTagDistance) < 0){ die("minimum tag distance cannot be negative"); } }catch(NumberFormatException nfe){ die("minimum tag distance must be a positive integer"); } Options.setTaggerMinDistance(Integer.parseInt(minTagDistance)); } //check that there isn't any overlap between include/exclude lists Vector tempInclude = (Vector) forceIncludeTags.clone(); tempInclude.retainAll(forceExcludeTags); if(tempInclude.size() > 0) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < tempInclude.size(); i++) { String s = (String) tempInclude.elementAt(i); sb.append(s).append(","); } die("The following markers appear in both the include and exclude lists: " + sb.toString()); } if(tagRSquaredCutOff != -1) { Options.setTaggerRsqCutoff(tagRSquaredCutOff); } } else if(forceExcludeTags != null || forceIncludeTags != null || tagRSquaredCutOff != -1) { die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without a tagging option"); } if(chromosomeArg != null && hapmapFileName != null) { argHandlerMessages.add("-chromosome flag ignored when loading hapmap file"); chromosomeArg = null; } if(chromosomeArg != null) { Chromosome.setDataChrom("chr" + chromosomeArg); } if (phasedhapmapDownload){ if (chromosomeArg == null){ die("-phasedhapmapdl requires a chromosome specification"); }else if (!(populationArg.equalsIgnoreCase("CEU") || populationArg.equalsIgnoreCase("YRI") || populationArg.equalsIgnoreCase("CHB+JPT"))){ die("-phasedhapmapdl requires a population specification of CEU, YRI, or CHB+JPT"); } if (Integer.parseInt(chromosomeArg) < 1 && Integer.parseInt(chromosomeArg) > 22){ if (!(chromosomeArg.equalsIgnoreCase("x"))){ die("chromsome specification must be betweeen 1 and 22 or X"); } } try{ if (Integer.parseInt(startPos) > Integer.parseInt(endPos)){ die("end position must be greater then start position"); } }catch(NumberFormatException nfe){ die("start and end positions must be integer values"); } if (phase == null){ phase = "2"; } try{ if (Integer.parseInt(phase) != 1 && Integer.parseInt(phase) != 2){ die("phase must be either 1 or 2"); } }catch(NumberFormatException nfe){ die("phase must be an integer value"); } } }
| 1,108,297
|
private void argHandler(String[] args){ argHandlerMessages = new Vector(); int maxDistance = -1; //this means that user didn't specify any output type if it doesn't get changed below blockOutputType = -1; double hapThresh = -1; double minimumMAF=-1; double spacingThresh = -1; double minimumGenoPercent = -1; double hwCutoff = -1; double missingCutoff = -1; int maxMendel = -1; boolean assocTDT = false; boolean assocCC = false; permutationCount = 0; tagging = Tagger.NONE; maxNumTags = Tagger.DEFAULT_MAXNUMTAGS; findTags = true; double cutHighCI = -1; double cutLowCI = -1; double mafThresh = -1; double recHighCI = -1; double informFrac = -1; double fourGameteCutoff = -1; double spineDP = -1; for(int i =0; i < args.length; i++) { if(args[i].equalsIgnoreCase("-help") || args[i].equalsIgnoreCase("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equalsIgnoreCase("-n") || args[i].equalsIgnoreCase("-nogui")) { nogui = true; } else if(args[i].equalsIgnoreCase("-p") || args[i].equalsIgnoreCase("-pedfile")) { i++; if( i>=args.length || (args[i].charAt(0) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(pedFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-pcloadletter")){ die("PC LOADLETTER?! What the fuck does that mean?!"); } else if (args[i].equalsIgnoreCase("-skipcheck") || args[i].equalsIgnoreCase("--skipcheck")){ skipCheck = true; } else if (args[i].equalsIgnoreCase("-excludeMarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ die("-excludeMarkers requires a list of markers"); } else { StringTokenizer str = new StringTokenizer(args[i],","); try { StringBuffer sb = new StringBuffer(); if (!quietMode) sb.append("Excluding markers: "); while(str.hasMoreTokens()) { String token = str.nextToken(); if(token.indexOf("..") != -1) { int lastIndex = token.indexOf(".."); int rangeStart = Integer.parseInt(token.substring(0,lastIndex)); int rangeEnd = Integer.parseInt(token.substring(lastIndex+2,token.length())); for(int j=rangeStart;j<=rangeEnd;j++) { if (!quietMode) sb.append(j+" "); excludedMarkers.add(new Integer(j)); } } else { if (!quietMode) sb.append(token+" "); excludedMarkers.add(new Integer(token)); } } if (!quietMode) argHandlerMessages.add(sb.toString()); } catch(NumberFormatException nfe) { die("-excludeMarkers argument should be of the format: 1,3,5..8,12"); } } } else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-haps")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapsFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-i") || args[i].equalsIgnoreCase("-info")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(infoFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-hapmap")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapmapFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpdata")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpdataFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap data file listed will be used"); } phasedhmpdataFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpsample")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpsampleFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap sample file listed will be used"); } phasedhmpsampleFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmplegend")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmplegendFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap legend file listed will be used"); } phasedhmplegendFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhapmapdl")){ phasedhapmapDownload = true; } else if (args[i].equalsIgnoreCase("-plink")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last PLINK file listed will be used"); } plinkFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-map")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last map file listed will be used"); } mapFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-k") || args[i].equalsIgnoreCase("-blocks")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; blockOutputType = BLOX_CUSTOM; }else{ die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-png")){ outputPNG = true; } else if (args[i].equalsIgnoreCase("-smallpng") || args[i].equalsIgnoreCase("-compressedPNG")){ outputCompressedPNG = true; } else if (args[i].equalsIgnoreCase("-track")){ i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ trackFileName = args[i]; }else{ die("-track requires a filename"); } } else if(args[i].equalsIgnoreCase("-o") || args[i].equalsIgnoreCase("-output") || args[i].equalsIgnoreCase("-blockoutput")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(blockOutputType != -1){ die("Only one block output type argument is allowed."); } if(args[i].equalsIgnoreCase("SFS") || args[i].equalsIgnoreCase("GAB")){ blockOutputType = BLOX_GABRIEL; } else if(args[i].equalsIgnoreCase("GAM")){ blockOutputType = BLOX_4GAM; } else if(args[i].equalsIgnoreCase("MJD") || args[i].equalsIgnoreCase("SPI")){ blockOutputType = BLOX_SPINE; } else if(args[i].equalsIgnoreCase("ALL")) { blockOutputType = BLOX_ALL; } } else { //defaults to SFS output blockOutputType = BLOX_GABRIEL; i--; } } else if(args[i].equalsIgnoreCase("-d") || args[i].equalsIgnoreCase("--dprime") || args[i].equalsIgnoreCase("-dprime")) { outputDprime = true; } else if (args[i].equalsIgnoreCase("-c") || args[i].equalsIgnoreCase("-check")){ outputCheck = true; } else if (args[i].equalsIgnoreCase("-indcheck")){ individualCheck = true; } else if (args[i].equalsIgnoreCase("-mendel")){ mendel = true; } else if (args[i].equalsIgnoreCase("-malehets")){ malehets = true; } else if(args[i].equalsIgnoreCase("-m") || args[i].equalsIgnoreCase("-maxdistance")) { i++; maxDistance = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-batch")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(batchFileName != null){ argHandlerMessages.add("multiple " + args[i-1] + " arguments found. only last batch file listed will be used"); } batchFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-hapthresh")) { i++; hapThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-spacing")) { i++; spacingThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-minMAF")) { i++; minimumMAF = getDoubleArg(args,i,0,0.5); } else if(args[i].equalsIgnoreCase("-minGeno") || args[i].equalsIgnoreCase("-minGenoPercent")) { i++; minimumGenoPercent = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-hwcutoff")) { i++; hwCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-maxMendel") ) { i++; maxMendel = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-missingcutoff")) { i++; missingCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-assoctdt")) { assocTDT = true; } else if(args[i].equalsIgnoreCase("-assoccc")) { assocCC = true; } else if(args[i].equalsIgnoreCase("-randomcc")){ assocCC = true; randomizeAffection = true; } else if(args[i].equalsIgnoreCase("-ldcolorscheme")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(args[i].equalsIgnoreCase("default")){ Options.setLDColorScheme(STD_SCHEME); } else if(args[i].equalsIgnoreCase("RSQ")){ Options.setLDColorScheme(RSQ_SCHEME); } else if(args[i].equalsIgnoreCase("DPALT") ){ Options.setLDColorScheme(WMF_SCHEME); } else if(args[i].equalsIgnoreCase("GAB")) { Options.setLDColorScheme(GAB_SCHEME); } else if(args[i].equalsIgnoreCase("GAM")) { Options.setLDColorScheme(GAM_SCHEME); } else if(args[i].equalsIgnoreCase("GOLD")) { Options.setLDColorScheme(GOLD_SCHEME); } } else { //defaults to STD color scheme Options.setLDColorScheme(STD_SCHEME); i--; } } else if(args[i].equalsIgnoreCase("-blockCutHighCI")) { i++; cutHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockCutLowCI")) { i++; cutLowCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockMafThresh")) { i++; mafThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockRecHighCI")) { i++; recHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockInformFrac")) { i++; informFrac = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-block4GamCut")) { i++; fourGameteCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockSpineDP")) { i++; spineDP = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-permtests")) { i++; doPermutationTest = true; permutationCount = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-customassoc")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ customAssocTestsFileName = args[i]; }else{ die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-aggressiveTagging")) { tagging = Tagger.AGGRESSIVE_TRIPLE; } else if (args[i].equalsIgnoreCase("-pairwiseTagging")){ tagging = Tagger.PAIRWISE_ONLY; } else if (args[i].equalsIgnoreCase("-printalltags")){ Options.setPrintAllTags(true); } else if(args[i].equalsIgnoreCase("-maxNumTags")){ i++; maxNumTags = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-tagrSqCutoff")) { i++; tagRSquaredCutOff = getDoubleArg(args,i,0,1); } else if (args[i].equalsIgnoreCase("-dontaddtags")){ findTags = false; } else if(args[i].equalsIgnoreCase("-tagLODCutoff")) { i++; Options.setTaggerLODCutoff(getDoubleArg(args,i,0,100000)); } else if(args[i].equalsIgnoreCase("-includeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die(args[i-1] + " requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceIncludeTags = new Vector(); while(str.hasMoreTokens()) { forceIncludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-includeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceIncludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-excludeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die("-excludeTags requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceExcludeTags = new Vector(); while(str.hasMoreTokens()) { forceExcludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-excludeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceExcludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-captureAlleles")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { captureAllelesFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-designScores")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { designScoresFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-mintagdistance")){ i++; minTagDistance = args[i]; } else if(args[i].equalsIgnoreCase("-chromosome") || args[i].equalsIgnoreCase("-chr")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { chromosomeArg =args[i]; }else { die(args[i-1] + " requires a chromosome name"); } if(!(chromosomeArg.equalsIgnoreCase("x"))){ try{ if (Integer.parseInt(chromosomeArg) > 22){ die("-chromosome requires a chromsome name of 1-22 or X"); } }catch(NumberFormatException nfe){ die("-chromosome requires a chromsome name of 1-22 or X"); } } } else if(args[i].equalsIgnoreCase("-population")){ i++; if(!(i>=args.length) && !(args[i].charAt(0)== '-')) { populationArg = args[i]; }else { die(args[i-1] + "requires a population name"); } } else if(args[i].equalsIgnoreCase("-startpos")){ i++; startPos = args[i]; } else if(args[i].equalsIgnoreCase("-endPos")){ i++; endPos = args[i]; } else if(args[i].equalsIgnoreCase("-phase")){ i++; phase = args[i]; } else if(args[i].equalsIgnoreCase("-q") || args[i].equalsIgnoreCase("-quiet")) { quietMode = true; } else if(args[i].equalsIgnoreCase("-gzip")){ Options.setGzip(true); } else { die("invalid parameter specified: " + args[i]); } } int countOptions = 0; if(pedFileName != null) { countOptions++; } if(hapsFileName != null) { countOptions++; } if(hapmapFileName != null) { countOptions++; } if(phasedhmpdataFileName != null) { countOptions++; if(phasedhmpsampleFileName == null){ die("You must specify a sample file for phased hapmap input."); }else if(phasedhmplegendFileName == null){ die("You must specify a legend file for phased hapmap input."); } } if(phasedhapmapDownload) { countOptions++; } if(plinkFileName != null){ countOptions++; if(mapFileName == null){ die("You must specify a map file for plink format input."); } } if(batchFileName != null) { countOptions++; } if(countOptions > 1) { die("Only one genotype input file may be specified on the command line."); } else if(countOptions == 0 && nogui) { die("You must specify a genotype input file."); } //mess with vars, set defaults, etc if(skipCheck && !quietMode) { argHandlerMessages.add("Skipping genotype file check"); } if(maxDistance == -1){ maxDistance = MAXDIST_DEFAULT; }else{ if (!quietMode) argHandlerMessages.add("Max LD comparison distance = " +maxDistance + "kb"); } Options.setMaxDistance(maxDistance); if(hapThresh != -1) { Options.setHaplotypeDisplayThreshold(hapThresh); if (!quietMode) argHandlerMessages.add("Haplotype display threshold = " + hapThresh); } if(minimumMAF != -1) { CheckData.mafCut = minimumMAF; if (!quietMode) argHandlerMessages.add("Minimum MAF = " + minimumMAF); } if(minimumGenoPercent != -1) { CheckData.failedGenoCut = (int)(minimumGenoPercent*100); if (!quietMode) argHandlerMessages.add("Minimum SNP genotype % = " + minimumGenoPercent); } if(hwCutoff != -1) { CheckData.hwCut = hwCutoff; if (!quietMode) argHandlerMessages.add("Hardy Weinberg equilibrium p-value cutoff = " + hwCutoff); } if(maxMendel != -1) { CheckData.numMendErrCut = maxMendel; if (!quietMode) argHandlerMessages.add("Maximum number of Mendel errors = "+maxMendel); } if(spacingThresh != -1) { Options.setSpacingThreshold(spacingThresh); if (!quietMode) argHandlerMessages.add("LD display spacing value = "+spacingThresh); } if(missingCutoff != -1) { Options.setMissingThreshold(missingCutoff); if (!quietMode) argHandlerMessages.add("Maximum amount of missing data allowed per individual = "+missingCutoff); } if(cutHighCI != -1) { FindBlocks.cutHighCI = cutHighCI; } if(cutLowCI != -1) { FindBlocks.cutLowCI = cutLowCI; } if(mafThresh != -1) { FindBlocks.mafThresh = mafThresh; } if(recHighCI != -1) { FindBlocks.recHighCI = recHighCI; } if(informFrac != -1) { FindBlocks.informFrac = informFrac; } if(fourGameteCutoff != -1) { FindBlocks.fourGameteCutoff = fourGameteCutoff; } if(spineDP != -1) { FindBlocks.spineDP = spineDP; } if(assocTDT) { Options.setAssocTest(ASSOC_TRIO); }else if(assocCC) { Options.setAssocTest(ASSOC_CC); } if (Options.getAssocTest() != ASSOC_NONE && infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when performing association tests."); } if(doPermutationTest) { if(!assocCC && !assocTDT) { die("An association test type must be specified for permutation tests to be performed."); } } if(customAssocTestsFileName != null) { if(!assocCC && !assocTDT) { die("An association test type must be specified when using a custom association test file."); } if(infoFileName == null) { die("A marker info file must be specified when using a custom association test file."); } } if(tagging != Tagger.NONE) { if(infoFileName == null && hapmapFileName == null && batchFileName == null && phasedhmpdataFileName == null && !phasedhapmapDownload) { die("A marker info file must be specified when tagging."); } if(forceExcludeTags == null) { forceExcludeTags = new Vector(); } else if (forceExcludeFileName != null) { die("-excludeTags and -excludeTagsFile cannot both be used"); } if(forceExcludeFileName != null) { File excludeFile = new File(forceExcludeFileName); forceExcludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(excludeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceExcludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -excludeTagsFile."); } } if(forceIncludeTags == null ) { forceIncludeTags = new Vector(); } else if (forceIncludeFileName != null) { die("-includeTags and -includeTagsFile cannot both be used"); } if(forceIncludeFileName != null) { File includeFile = new File(forceIncludeFileName); forceIncludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(includeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceIncludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -includeTagsFile."); } } if (captureAllelesFileName != null) { File captureFile = new File(captureAllelesFileName); captureAlleleTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(captureFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ line = line.trim(); captureAlleleTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (designScoresFileName != null) { File designFile = new File(designScoresFileName); designScores = new Hashtable(1,1); try { BufferedReader br = new BufferedReader(new FileReader(designFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ StringTokenizer st = new StringTokenizer(line); String marker = st.nextToken(); Double score = new Double(st.nextToken()); designScores.put(marker,score); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (minTagDistance != null) { try{ if (Integer.parseInt(minTagDistance) < 0){ die("minimum tag distance cannot be negative"); } }catch(NumberFormatException nfe){ die("minimum tag distance must be a positive integer"); } Options.setTaggerMinDistance(Integer.parseInt(minTagDistance)); } //check that there isn't any overlap between include/exclude lists Vector tempInclude = (Vector) forceIncludeTags.clone(); tempInclude.retainAll(forceExcludeTags); if(tempInclude.size() > 0) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < tempInclude.size(); i++) { String s = (String) tempInclude.elementAt(i); sb.append(s).append(","); } die("The following markers appear in both the include and exclude lists: " + sb.toString()); } if(tagRSquaredCutOff != -1) { Options.setTaggerRsqCutoff(tagRSquaredCutOff); } } else if(forceExcludeTags != null || forceIncludeTags != null || tagRSquaredCutOff != -1) { die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without a tagging option"); } if(chromosomeArg != null && hapmapFileName != null) { argHandlerMessages.add("-chromosome flag ignored when loading hapmap file"); chromosomeArg = null; } if(chromosomeArg != null) { Chromosome.setDataChrom("chr" + chromosomeArg); } if (phasedhapmapDownload){ if (chromosomeArg == null){ die("-phasedhapmapdl requires a chromosome specification"); }else if (!(populationArg.equalsIgnoreCase("CEU") || populationArg.equalsIgnoreCase("YRI") || populationArg.equalsIgnoreCase("CHB+JPT"))){ die("-phasedhapmapdl requires a population specification of CEU, YRI, or CHB+JPT"); } if (Integer.parseInt(chromosomeArg) < 1 && Integer.parseInt(chromosomeArg) > 22){ if (!(chromosomeArg.equalsIgnoreCase("x"))){ die("chromsome specification must be betweeen 1 and 22 or X"); } } try{ if (Integer.parseInt(startPos) > Integer.parseInt(endPos)){ die("end position must be greater then start position"); } }catch(NumberFormatException nfe){ die("start and end positions must be integer values"); } if (phase == null){ phase = "2"; } try{ if (Integer.parseInt(phase) != 1 && Integer.parseInt(phase) != 2){ die("phase must be either 1 or 2"); } }catch(NumberFormatException nfe){ die("phase must be an integer value"); } } }
|
private void argHandler(String[] args){ argHandlerMessages = new Vector(); int maxDistance = -1; //this means that user didn't specify any output type if it doesn't get changed below blockOutputType = -1; double hapThresh = -1; double minimumMAF=-1; double spacingThresh = -1; double minimumGenoPercent = -1; double hwCutoff = -1; double missingCutoff = -1; int maxMendel = -1; boolean assocTDT = false; boolean assocCC = false; permutationCount = 0; tagging = Tagger.NONE; maxNumTags = Tagger.DEFAULT_MAXNUMTAGS; findTags = true; double cutHighCI = -1; double cutLowCI = -1; double mafThresh = -1; double recHighCI = -1; double informFrac = -1; double fourGameteCutoff = -1; double spineDP = -1; for(int i =0; i < args.length; i++) { if(args[i].equalsIgnoreCase("-help") || args[i].equalsIgnoreCase("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equalsIgnoreCase("-n") || args[i].equalsIgnoreCase("-nogui")) { nogui = true; } else if(args[i].equalsIgnoreCase("-p") || args[i].equalsIgnoreCase("-pedfile")) { i++; if( i>=args.length || (args[i].charAt(0) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(pedFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-pcloadletter")){ die("PC LOADLETTER?! What the fuck does that mean?!"); } else if (args[i].equalsIgnoreCase("-skipcheck") || args[i].equalsIgnoreCase("--skipcheck")){ skipCheck = true; } else if (args[i].equalsIgnoreCase("-excludeMarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ die("-excludeMarkers requires a list of markers"); } else { StringTokenizer str = new StringTokenizer(args[i],","); try { StringBuffer sb = new StringBuffer(); if (!quietMode) sb.append("Excluding markers: "); while(str.hasMoreTokens()) { String token = str.nextToken(); if(token.indexOf("..") != -1) { int lastIndex = token.indexOf(".."); int rangeStart = Integer.parseInt(token.substring(0,lastIndex)); int rangeEnd = Integer.parseInt(token.substring(lastIndex+2,token.length())); for(int j=rangeStart;j<=rangeEnd;j++) { if (!quietMode) sb.append(j+" "); excludedMarkers.add(new Integer(j)); } } else { if (!quietMode) sb.append(token+" "); excludedMarkers.add(new Integer(token)); } } if (!quietMode) argHandlerMessages.add(sb.toString()); } catch(NumberFormatException nfe) { die("-excludeMarkers argument should be of the format: 1,3,5..8,12"); } } } else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-haps")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapsFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-i") || args[i].equalsIgnoreCase("-info")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(infoFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-hapmap")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapmapFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpdata")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpdataFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap data file listed will be used"); } phasedhmpdataFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpsample")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpsampleFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap sample file listed will be used"); } phasedhmpsampleFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmplegend")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmplegendFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap legend file listed will be used"); } phasedhmplegendFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhapmapdl")){ phasedhapmapDownload = true; } else if (args[i].equalsIgnoreCase("-plink")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last PLINK file listed will be used"); } plinkFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-map")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last map file listed will be used"); } mapFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-k") || args[i].equalsIgnoreCase("-blocks")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; blockOutputType = BLOX_CUSTOM; }else{ die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-png")){ outputPNG = true; } else if (args[i].equalsIgnoreCase("-smallpng") || args[i].equalsIgnoreCase("-compressedPNG")){ outputCompressedPNG = true; } else if (args[i].equalsIgnoreCase("-track")){ i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ trackFileName = args[i]; }else{ die("-track requires a filename"); } } else if(args[i].equalsIgnoreCase("-o") || args[i].equalsIgnoreCase("-output") || args[i].equalsIgnoreCase("-blockoutput")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(blockOutputType != -1){ die("Only one block output type argument is allowed."); } if(args[i].equalsIgnoreCase("SFS") || args[i].equalsIgnoreCase("GAB")){ blockOutputType = BLOX_GABRIEL; } else if(args[i].equalsIgnoreCase("GAM")){ blockOutputType = BLOX_4GAM; } else if(args[i].equalsIgnoreCase("MJD") || args[i].equalsIgnoreCase("SPI")){ blockOutputType = BLOX_SPINE; } else if(args[i].equalsIgnoreCase("ALL")) { blockOutputType = BLOX_ALL; } } else { //defaults to SFS output blockOutputType = BLOX_GABRIEL; i--; } } else if(args[i].equalsIgnoreCase("-d") || args[i].equalsIgnoreCase("--dprime") || args[i].equalsIgnoreCase("-dprime")) { outputDprime = true; } else if (args[i].equalsIgnoreCase("-c") || args[i].equalsIgnoreCase("-check")){ outputCheck = true; } else if (args[i].equalsIgnoreCase("-indcheck")){ individualCheck = true; } else if (args[i].equalsIgnoreCase("-mendel")){ mendel = true; } else if (args[i].equalsIgnoreCase("-malehets")){ malehets = true; } else if(args[i].equalsIgnoreCase("-m") || args[i].equalsIgnoreCase("-maxdistance")) { i++; maxDistance = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-batch")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(batchFileName != null){ argHandlerMessages.add("multiple " + args[i-1] + " arguments found. only last batch file listed will be used"); } batchFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-hapthresh")) { i++; hapThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-spacing")) { i++; spacingThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-minMAF")) { i++; minimumMAF = getDoubleArg(args,i,0,0.5); } else if(args[i].equalsIgnoreCase("-minGeno") || args[i].equalsIgnoreCase("-minGenoPercent")) { i++; minimumGenoPercent = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-hwcutoff")) { i++; hwCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-maxMendel") ) { i++; maxMendel = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-missingcutoff")) { i++; missingCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-assoctdt")) { assocTDT = true; } else if(args[i].equalsIgnoreCase("-assoccc")) { assocCC = true; } else if(args[i].equalsIgnoreCase("-randomcc")){ assocCC = true; randomizeAffection = true; } else if(args[i].equalsIgnoreCase("-ldcolorscheme")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(args[i].equalsIgnoreCase("default")){ Options.setLDColorScheme(STD_SCHEME); } else if(args[i].equalsIgnoreCase("RSQ")){ Options.setLDColorScheme(RSQ_SCHEME); } else if(args[i].equalsIgnoreCase("DPALT") ){ Options.setLDColorScheme(WMF_SCHEME); } else if(args[i].equalsIgnoreCase("GAB")) { Options.setLDColorScheme(GAB_SCHEME); } else if(args[i].equalsIgnoreCase("GAM")) { Options.setLDColorScheme(GAM_SCHEME); } else if(args[i].equalsIgnoreCase("GOLD")) { Options.setLDColorScheme(GOLD_SCHEME); } } else { //defaults to STD color scheme Options.setLDColorScheme(STD_SCHEME); i--; } } else if(args[i].equalsIgnoreCase("-blockCutHighCI")) { i++; cutHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockCutLowCI")) { i++; cutLowCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockMafThresh")) { i++; mafThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockRecHighCI")) { i++; recHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockInformFrac")) { i++; informFrac = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-block4GamCut")) { i++; fourGameteCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockSpineDP")) { i++; spineDP = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-permtests")) { i++; doPermutationTest = true; permutationCount = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-customassoc")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ customAssocTestsFileName = args[i]; }else{ die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-aggressiveTagging")) { tagging = Tagger.AGGRESSIVE_TRIPLE; } else if (args[i].equalsIgnoreCase("-pairwiseTagging")){ tagging = Tagger.PAIRWISE_ONLY; } else if (args[i].equalsIgnoreCase("-printalltags")){ Options.setPrintAllTags(true); } else if(args[i].equalsIgnoreCase("-maxNumTags")){ i++; maxNumTags = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-tagrSqCutoff")) { i++; tagRSquaredCutOff = getDoubleArg(args,i,0,1); } else if (args[i].equalsIgnoreCase("-dontaddtags")){ findTags = false; } else if(args[i].equalsIgnoreCase("-tagLODCutoff")) { i++; Options.setTaggerLODCutoff(getDoubleArg(args,i,0,100000)); } else if(args[i].equalsIgnoreCase("-includeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die(args[i-1] + " requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceIncludeTags = new Vector(); while(str.hasMoreTokens()) { forceIncludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-includeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceIncludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-excludeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die("-excludeTags requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceExcludeTags = new Vector(); while(str.hasMoreTokens()) { forceExcludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-excludeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceExcludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-captureAlleles")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { captureAllelesFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-designScores")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { designScoresFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-mintagdistance")){ i++; minTagDistance = args[i]; } else if(args[i].equalsIgnoreCase("-chromosome") || args[i].equalsIgnoreCase("-chr")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { chromosomeArg =args[i]; }else { die(args[i-1] + " requires a chromosome name"); } if(!(chromosomeArg.equalsIgnoreCase("x"))){ try{ if (Integer.parseInt(chromosomeArg) > 22){ die("-chromosome requires a chromsome name of 1-22 or X"); } }catch(NumberFormatException nfe){ die("-chromosome requires a chromsome name of 1-22 or X"); } } } else if(args[i].equalsIgnoreCase("-population")){ i++; if(!(i>=args.length) && !(args[i].charAt(0)== '-')) { populationArg = args[i]; }else { die(args[i-1] + "requires a population name"); } } else if(args[i].equalsIgnoreCase("-startpos")){ i++; startPos = args[i]; } else if(args[i].equalsIgnoreCase("-endPos")){ i++; endPos = args[i]; } else if(args[i].equalsIgnoreCase("-phase")){ i++; phase = args[i]; } else if(args[i].equalsIgnoreCase("-q") || args[i].equalsIgnoreCase("-quiet")) { quietMode = true; } else if(args[i].equalsIgnoreCase("-gzip")){ Options.setGzip(true); } else { die("invalid parameter specified: " + args[i]); } } int countOptions = 0; if(pedFileName != null) { countOptions++; } if(hapsFileName != null) { countOptions++; } if(hapmapFileName != null) { countOptions++; } if(phasedhmpdataFileName != null) { countOptions++; if(phasedhmpsampleFileName == null){ die("You must specify a sample file for phased hapmap input."); }else if(phasedhmplegendFileName == null){ die("You must specify a legend file for phased hapmap input."); } } if(phasedhapmapDownload) { countOptions++; } if(plinkFileName != null){ countOptions++; if(mapFileName == null){ die("You must specify a map file for plink format input."); } } if(batchFileName != null) { countOptions++; } if(countOptions > 1) { die("Only one genotype input file may be specified on the command line."); } else if(countOptions == 0 && nogui) { die("You must specify a genotype input file."); } //mess with vars, set defaults, etc if(skipCheck && !quietMode) { argHandlerMessages.add("Skipping genotype file check"); } if(maxDistance == -1){ maxDistance = MAXDIST_DEFAULT; }else{ if (!quietMode) argHandlerMessages.add("Max LD comparison distance = " +maxDistance + "kb"); } Options.setMaxDistance(maxDistance); if(hapThresh != -1) { Options.setHaplotypeDisplayThreshold(hapThresh); if (!quietMode) argHandlerMessages.add("Haplotype display threshold = " + hapThresh); } if(minimumMAF != -1) { CheckData.mafCut = minimumMAF; if (!quietMode) argHandlerMessages.add("Minimum MAF = " + minimumMAF); } if(minimumGenoPercent != -1) { CheckData.failedGenoCut = (int)(minimumGenoPercent*100); if (!quietMode) argHandlerMessages.add("Minimum SNP genotype % = " + minimumGenoPercent); } if(hwCutoff != -1) { CheckData.hwCut = hwCutoff; if (!quietMode) argHandlerMessages.add("Hardy Weinberg equilibrium p-value cutoff = " + hwCutoff); } if(maxMendel != -1) { CheckData.numMendErrCut = maxMendel; if (!quietMode) argHandlerMessages.add("Maximum number of Mendel errors = "+maxMendel); } if(spacingThresh != -1) { Options.setSpacingThreshold(spacingThresh); if (!quietMode) argHandlerMessages.add("LD display spacing value = "+spacingThresh); } if(missingCutoff != -1) { Options.setMissingThreshold(missingCutoff); if (!quietMode) argHandlerMessages.add("Maximum amount of missing data allowed per individual = "+missingCutoff); } if(cutHighCI != -1) { FindBlocks.cutHighCI = cutHighCI; } if(cutLowCI != -1) { FindBlocks.cutLowCI = cutLowCI; } if(mafThresh != -1) { FindBlocks.mafThresh = mafThresh; } if(recHighCI != -1) { FindBlocks.recHighCI = recHighCI; } if(informFrac != -1) { FindBlocks.informFrac = informFrac; } if(fourGameteCutoff != -1) { FindBlocks.fourGameteCutoff = fourGameteCutoff; } if(spineDP != -1) { FindBlocks.spineDP = spineDP; } if(assocTDT) { Options.setAssocTest(ASSOC_TRIO); }else if(assocCC) { Options.setAssocTest(ASSOC_CC); } if (Options.getAssocTest() != ASSOC_NONE && infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when performing association tests."); } if(doPermutationTest) { if(!assocCC && !assocTDT) { die("An association test type must be specified for permutation tests to be performed."); } } if(customAssocTestsFileName != null) { if(!assocCC && !assocTDT) { die("An association test type must be specified when using a custom association test file."); } if(infoFileName == null) { die("A marker info file must be specified when using a custom association test file."); } } if(tagging != Tagger.NONE) { if(infoFileName == null && hapmapFileName == null && batchFileName == null && phasedhmpdataFileName == null && !phasedhapmapDownload) { die("A marker info file must be specified when tagging."); } if(forceExcludeTags == null) { forceExcludeTags = new Vector(); } else if (forceExcludeFileName != null) { die("-excludeTags and -excludeTagsFile cannot both be used"); } if(forceExcludeFileName != null) { File excludeFile = new File(forceExcludeFileName); forceExcludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(excludeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceExcludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -excludeTagsFile."); } } if(forceIncludeTags == null ) { forceIncludeTags = new Vector(); } else if (forceIncludeFileName != null) { die("-includeTags and -includeTagsFile cannot both be used"); } if(forceIncludeFileName != null) { File includeFile = new File(forceIncludeFileName); forceIncludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(includeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceIncludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -includeTagsFile."); } } if (captureAllelesFileName != null) { File captureFile = new File(captureAllelesFileName); captureAlleleTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(captureFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ line = line.trim(); captureAlleleTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (designScoresFileName != null) { File designFile = new File(designScoresFileName); designScores = new Hashtable(1,1); try { BufferedReader br = new BufferedReader(new FileReader(designFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ StringTokenizer st = new StringTokenizer(line); String marker = st.nextToken(); Double score = new Double(st.nextToken()); designScores.put(marker,score); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (minTagDistance != null) { try{ if (Integer.parseInt(minTagDistance) < 0){ die("minimum tag distance cannot be negative"); } }catch(NumberFormatException nfe){ die("minimum tag distance must be a positive integer"); } Options.setTaggerMinDistance(Integer.parseInt(minTagDistance)); } //check that there isn't any overlap between include/exclude lists Vector tempInclude = (Vector) forceIncludeTags.clone(); tempInclude.retainAll(forceExcludeTags); if(tempInclude.size() > 0) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < tempInclude.size(); i++) { String s = (String) tempInclude.elementAt(i); sb.append(s).append(","); } die("The following markers appear in both the include and exclude lists: " + sb.toString()); } if(tagRSquaredCutOff != -1) { Options.setTaggerRsqCutoff(tagRSquaredCutOff); } } else if(forceExcludeTags != null || forceIncludeTags != null || tagRSquaredCutOff != -1) { die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without a tagging option"); } if(chromosomeArg != null && hapmapFileName != null) { argHandlerMessages.add("-chromosome flag ignored when loading hapmap file"); chromosomeArg = null; } if(chromosomeArg != null) { Chromosome.setDataChrom("chr" + chromosomeArg); } if (phasedhapmapDownload){ if (chromosomeArg == null){ die("-phasedhapmapdl requires a chromosome specification"); }else if (!(populationArg.equalsIgnoreCase("CEU") || populationArg.equalsIgnoreCase("YRI") || populationArg.equalsIgnoreCase("CHB+JPT"))){ die("-phasedhapmapdl requires a population specification of CEU, YRI, or CHB+JPT"); } if (Integer.parseInt(chromosomeArg) < 1 && Integer.parseInt(chromosomeArg) > 22){ if (!(chromosomeArg.equalsIgnoreCase("x"))){ die("chromsome specification must be betweeen 1 and 22 or X"); } } try{ if (Integer.parseInt(startPos) > Integer.parseInt(endPos)){ die("end position must be greater then start position"); } }catch(NumberFormatException nfe){ die("start and end positions must be integer values"); } if (phase == null){ phase = "2"; } try{ if (Integer.parseInt(phase) != 1 && Integer.parseInt(phase) != 2){ die("phase must be either 1 or 2"); } }catch(NumberFormatException nfe){ die("phase must be an integer value"); } } }
| 1,108,298
|
public AssociationTestSet(String fileName) throws IOException, HaploViewException{ tests = new Vector(); whitelist = new HashSet(); File testListFile = new File(fileName); BufferedReader in = new BufferedReader(new FileReader(testListFile)); String currentLine; int lineCount = 0; //we need to be able to identify marker index by name Hashtable indicesByName = new Hashtable(); Iterator mitr = Chromosome.getAllMarkers().iterator(); int count = 0; while (mitr.hasNext()){ SNP n = (SNP) mitr.next(); indicesByName.put(n.getDisplayName(),new Integer(count)); count++; } while ((currentLine = in.readLine()) != null){ lineCount++; //first determine if a tab specifies a specific allele for a multi-marker test StringTokenizer st = new StringTokenizer(currentLine, "\t"); String markerNames; String alleles; if (st.countTokens() == 0){ //skip blank lines continue; }else if (st.countTokens() == 1){ //this is just a list of markers markerNames = st.nextToken(); alleles = null; }else if (st.countTokens() == 2){ //this has markers and alleles markerNames = st.nextToken(); alleles = st.nextToken(); }else{ //this is *!&#ed up markerNames = null; alleles = null; throw new HaploViewException("Format error on line " + lineCount + " of tests file."); } StringTokenizer mst = new StringTokenizer(markerNames, ", "); AssociationTest t = new AssociationTest(); while (mst.hasMoreTokens()) { String currentToken = mst.nextToken(); if (!indicesByName.containsKey(currentToken)){ throw new HaploViewException("I don't know anything about marker " + currentToken + " in custom tests file."); } Integer nt = (Integer) indicesByName.get(currentToken); t.addMarker(nt); } tests.add(t); if (alleles != null){ //we have alleles StringBuffer asb = new StringBuffer(); StringTokenizer ast = new StringTokenizer(alleles, ", "); if (ast.countTokens() != t.getNumMarkers()){ throw new HaploViewException("Allele and marker name mismatch on line " + lineCount + " of tests file."); } while (ast.hasMoreTokens()){ asb.append(ast.nextToken()); } t.specifyAllele(asb.toString()); } } }
|
public AssociationTestSet(String fileName) throws IOException, HaploViewException{ tests = new Vector(); whitelist = new HashSet(); File testListFile = new File(fileName); BufferedReader in = new BufferedReader(new FileReader(testListFile)); String currentLine; int lineCount = 0; //we need to be able to identify marker index by name Hashtable indicesByName = new Hashtable(); Iterator mitr = Chromosome.getAllMarkers().iterator(); int count = 0; while (mitr.hasNext()){ SNP n = (SNP) mitr.next(); indicesByName.put(n.getDisplayName(),new Integer(count)); count++; } while ((currentLine = in.readLine()) != null){ lineCount++; //first determine if a tab specifies a specific allele for a multi-marker test StringTokenizer st = new StringTokenizer(currentLine, "\t"); String markerNames; String alleles; if (st.countTokens() == 0){ //skip blank lines continue; }else if (st.countTokens() == 1){ //this is just a list of markers markerNames = st.nextToken(); alleles = null; }else if (st.countTokens() == 2){ //this has markers and alleles markerNames = st.nextToken(); alleles = st.nextToken(); }else{ //this is *!&#ed up markerNames = null; alleles = null; throw new HaploViewException("Format error on line " + lineCount + " of tests file."); } StringTokenizer mst = new StringTokenizer(markerNames, ", "); AssociationTest t = new AssociationTest(); while (mst.hasMoreTokens()) { String currentToken = mst.nextToken(); if (!indicesByName.containsKey(currentToken)){ throw new HaploViewException("I don't know anything about marker " + currentToken + " in custom tests file."); } Integer nt = (Integer) indicesByName.get(currentToken); t.addMarker(nt); } tests.add(t); if (alleles != null){ //we have alleles StringBuffer asb = new StringBuffer(); StringTokenizer ast = new StringTokenizer(alleles, ", "); if (ast.countTokens() != t.getNumMarkers()){ throw new HaploViewException("Allele and marker name mismatch on line " + lineCount + " of tests file."); } while (ast.hasMoreTokens()){ asb.append(ast.nextToken()); } t.specifyAllele(asb.toString()); } } }
| 1,108,299
|
public AssociationTestSet(String fileName) throws IOException, HaploViewException{ tests = new Vector(); whitelist = new HashSet(); File testListFile = new File(fileName); BufferedReader in = new BufferedReader(new FileReader(testListFile)); String currentLine; int lineCount = 0; //we need to be able to identify marker index by name Hashtable indicesByName = new Hashtable(); Iterator mitr = Chromosome.getAllMarkers().iterator(); int count = 0; while (mitr.hasNext()){ SNP n = (SNP) mitr.next(); indicesByName.put(n.getDisplayName(),new Integer(count)); count++; } while ((currentLine = in.readLine()) != null){ lineCount++; //first determine if a tab specifies a specific allele for a multi-marker test StringTokenizer st = new StringTokenizer(currentLine, "\t"); String markerNames; String alleles; if (st.countTokens() == 0){ //skip blank lines continue; }else if (st.countTokens() == 1){ //this is just a list of markers markerNames = st.nextToken(); alleles = null; }else if (st.countTokens() == 2){ //this has markers and alleles markerNames = st.nextToken(); alleles = st.nextToken(); }else{ //this is *!&#ed up markerNames = null; alleles = null; throw new HaploViewException("Format error on line " + lineCount + " of tests file."); } StringTokenizer mst = new StringTokenizer(markerNames, ", "); AssociationTest t = new AssociationTest(); while (mst.hasMoreTokens()) { String currentToken = mst.nextToken(); if (!indicesByName.containsKey(currentToken)){ throw new HaploViewException("I don't know anything about marker " + currentToken + " in custom tests file."); } Integer nt = (Integer) indicesByName.get(currentToken); t.addMarker(nt); } tests.add(t); if (alleles != null){ //we have alleles StringBuffer asb = new StringBuffer(); StringTokenizer ast = new StringTokenizer(alleles, ", "); if (ast.countTokens() != t.getNumMarkers()){ throw new HaploViewException("Allele and marker name mismatch on line " + lineCount + " of tests file."); } while (ast.hasMoreTokens()){ asb.append(ast.nextToken()); } t.specifyAllele(asb.toString()); } } }
|
public AssociationTestSet(String fileName) throws IOException, HaploViewException{ tests = new Vector(); whitelist = new HashSet(); File testListFile = new File(fileName); BufferedReader in = new BufferedReader(new FileReader(testListFile)); String currentLine; int lineCount = 0; //we need to be able to identify marker index by name Hashtable indicesByName = new Hashtable(); Iterator mitr = Chromosome.getAllMarkers().iterator(); int count = 0; while (mitr.hasNext()){ SNP n = (SNP) mitr.next(); indicesByName.put(n.getDisplayName(),new Integer(count)); count++; } while ((currentLine = in.readLine()) != null){ lineCount++; //first determine if a tab specifies a specific allele for a multi-marker test StringTokenizer st = new StringTokenizer(currentLine, "\t"); String markerNames; String alleles; if (st.countTokens() == 0){ //skip blank lines continue; }else if (st.countTokens() == 1){ //this is just a list of markers markerNames = st.nextToken(); alleles = null; }else if (st.countTokens() == 2){ //this has markers and alleles markerNames = st.nextToken(); alleles = st.nextToken(); }else{ //this is *!&#ed up markerNames = null; alleles = null; throw new HaploViewException("Format error on line " + lineCount + " of tests file."); } StringTokenizer mst = new StringTokenizer(markerNames, ", "); AssociationTest t = new AssociationTest(); while (mst.hasMoreTokens()) { String currentToken = mst.nextToken(); if (!indicesByName.containsKey(currentToken)){ throw new HaploViewException("I don't know anything about marker " + currentToken + " in custom tests file."); } Integer nt = (Integer) indicesByName.get(currentToken); t.addMarker(nt); } tests.add(t); if (alleles != null){ //we have alleles StringBuffer asb = new StringBuffer(); StringTokenizer ast = new StringTokenizer(alleles, ", "); if (ast.countTokens() != t.getNumMarkers()){ throw new HaploViewException("Allele and marker name mismatch on line " + lineCount + " of tests file."); } while (ast.hasMoreTokens()){ asb.append(ast.nextToken()); } t.specifyAllele(asb.toString()); } } }
| 1,108,300
|
public IndividualDialog (HaploData hd){ Vector people = hd.getPedFile().getAllIndividuals(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("IndividualID"); colNames.add("Geno%"); Vector data = new Vector(); for(int i=0;i<people.size();i++) { Vector tmpVec = new Vector(); Individual currentInd = (Individual)people.get(i); tmpVec.add(currentInd.getFamilyID()); tmpVec.add(currentInd.getIndividualID()); tmpVec.add(new Double(currentInd.getGenoPC()*100)); data.add(tmpVec); } tableModel = new BasicTableModel(colNames, data); }
|
public IndividualDialog (HaploView h, String title) { super(h,title); Vector people = hd.getPedFile().getAllIndividuals(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("IndividualID"); colNames.add("Geno%"); Vector data = new Vector(); for(int i=0;i<people.size();i++) { Vector tmpVec = new Vector(); Individual currentInd = (Individual)people.get(i); tmpVec.add(currentInd.getFamilyID()); tmpVec.add(currentInd.getIndividualID()); tmpVec.add(new Double(currentInd.getGenoPC()*100)); data.add(tmpVec); } tableModel = new BasicTableModel(colNames, data); }
| 1,108,301
|
public IndividualDialog (HaploData hd){ Vector people = hd.getPedFile().getAllIndividuals(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("IndividualID"); colNames.add("Geno%"); Vector data = new Vector(); for(int i=0;i<people.size();i++) { Vector tmpVec = new Vector(); Individual currentInd = (Individual)people.get(i); tmpVec.add(currentInd.getFamilyID()); tmpVec.add(currentInd.getIndividualID()); tmpVec.add(new Double(currentInd.getGenoPC()*100)); data.add(tmpVec); } tableModel = new BasicTableModel(colNames, data); }
|
public IndividualDialog (HaploData hd){ JPanel contents = new JPanel(); JTable table; contents.setLayout(new BoxLayout(contents,BoxLayout.Y_AXIS)); Vector people = h.theData.getPedFile().getAllIndividuals(); Vector excludedPeople = h.theData.getPedFile().getAxedPeople(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("IndividualID"); colNames.add("Geno%"); Vector data = new Vector(); for(int i=0;i<people.size();i++) { Vector tmpVec = new Vector(); Individual currentInd = (Individual)people.get(i); tmpVec.add(currentInd.getFamilyID()); tmpVec.add(currentInd.getIndividualID()); tmpVec.add(new Double(currentInd.getGenoPC()*100)); data.add(tmpVec); } tableModel = new BasicTableModel(colNames, data); }
| 1,108,302
|
public MendelDialog(HaploData hd){ Vector results = hd.getPedFile().getResults(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("ChildID"); colNames.add("Marker"); colNames.add("Position"); Vector data = new Vector(); for(int i=0;i<results.size();i++) { MarkerResult currentResult = (MarkerResult)results.get(i); if (currentResult.getMendErrNum() > 0){ Vector tmpVec = new Vector(); Vector mendelErrors = currentResult.getMendelErrors(); for (int j = 0; j < mendelErrors.size(); j++){ MendelError error = (MendelError)mendelErrors.get(j); tmpVec.add(error.getFamilyID()); tmpVec.add(error.getChildID()); tmpVec.add(Chromosome.getUnfilteredMarker(i).getDisplayName()); tmpVec.add(new Long(Chromosome.getUnfilteredMarker(i).getPosition())); data.add(tmpVec); } } } tableModel = new BasicTableModel(colNames, data); }
|
public MendelDialog(HaploData hd){ Vector results = hd.getPedFile().getResults(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("ChildID"); colNames.add("Marker"); colNames.add("Position"); Vector data = new Vector(); for(int i=0;i<results.size();i++) { MarkerResult currentResult = (MarkerResult)results.get(i); if (currentResult.getMendErrNum() > 0){ Vector tmpVec = new Vector(); Vector mendelErrors = currentResult.getMendelErrors(); for (int j = 0; j < mendelErrors.size(); j++){ MendelError error = (MendelError)mendelErrors.get(j); tmpVec.add(error.getFamilyID()); tmpVec.add(error.getChildID()); tmpVec.add(Chromosome.getUnfilteredMarker(i).getDisplayName()); tmpVec.add(new Long(Chromosome.getUnfilteredMarker(i).getPosition())); data.add(tmpVec); } } } tableModel = new BasicTableModel(colNames, data); }
| 1,108,304
|
public MendelDialog(HaploData hd){ Vector results = hd.getPedFile().getResults(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("ChildID"); colNames.add("Marker"); colNames.add("Position"); Vector data = new Vector(); for(int i=0;i<results.size();i++) { MarkerResult currentResult = (MarkerResult)results.get(i); if (currentResult.getMendErrNum() > 0){ Vector tmpVec = new Vector(); Vector mendelErrors = currentResult.getMendelErrors(); for (int j = 0; j < mendelErrors.size(); j++){ MendelError error = (MendelError)mendelErrors.get(j); tmpVec.add(error.getFamilyID()); tmpVec.add(error.getChildID()); tmpVec.add(Chromosome.getUnfilteredMarker(i).getDisplayName()); tmpVec.add(new Long(Chromosome.getUnfilteredMarker(i).getPosition())); data.add(tmpVec); } } } tableModel = new BasicTableModel(colNames, data); }
|
public MendelDialog(HaploData hd){ Vector results = hd.getPedFile().getResults(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("ChildID"); colNames.add("Marker"); colNames.add("Position"); Vector data = new Vector(); for(int i=0;i<results.size();i++) { MarkerResult currentResult = (MarkerResult)results.get(i); if (currentResult.getMendErrNum() > 0){ Vector mendelErrors = currentResult.getMendelErrors(); for (int j = 0; j < mendelErrors.size(); j++){ MendelError error = (MendelError)mendelErrors.get(j); tmpVec.add(error.getFamilyID()); tmpVec.add(error.getChildID()); tmpVec.add(Chromosome.getUnfilteredMarker(i).getDisplayName()); tmpVec.add(new Long(Chromosome.getUnfilteredMarker(i).getPosition())); data.add(tmpVec); } } } tableModel = new BasicTableModel(colNames, data); }
| 1,108,305
|
public MendelDialog(HaploData hd){ Vector results = hd.getPedFile().getResults(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("ChildID"); colNames.add("Marker"); colNames.add("Position"); Vector data = new Vector(); for(int i=0;i<results.size();i++) { MarkerResult currentResult = (MarkerResult)results.get(i); if (currentResult.getMendErrNum() > 0){ Vector tmpVec = new Vector(); Vector mendelErrors = currentResult.getMendelErrors(); for (int j = 0; j < mendelErrors.size(); j++){ MendelError error = (MendelError)mendelErrors.get(j); tmpVec.add(error.getFamilyID()); tmpVec.add(error.getChildID()); tmpVec.add(Chromosome.getUnfilteredMarker(i).getDisplayName()); tmpVec.add(new Long(Chromosome.getUnfilteredMarker(i).getPosition())); data.add(tmpVec); } } } tableModel = new BasicTableModel(colNames, data); }
|
public MendelDialog(HaploData hd){ Vector results = hd.getPedFile().getResults(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("ChildID"); colNames.add("Marker"); colNames.add("Position"); Vector data = new Vector(); for(int i=0;i<results.size();i++) { MarkerResult currentResult = (MarkerResult)results.get(i); if (currentResult.getMendErrNum() > 0){ Vector tmpVec = new Vector(); Vector mendelErrors = currentResult.getMendelErrors(); for (int j = 0; j < mendelErrors.size(); j++){ MendelError error = (MendelError)mendelErrors.get(j); tmpVec.add(error.getFamilyID()); tmpVec.add(error.getChildID()); tmpVec.add(Chromosome.getUnfilteredMarker(i).getDisplayName()); tmpVec.add(new Long(Chromosome.getUnfilteredMarker(i).getPosition())); data.add(tmpVec); } } } TableSorter sorter = new TableSorter(new BasicTableModel(colNames, data)); table = new JTable(sorter); sorter.setTableHeader(table.getTableHeader()); table.getColumnModel().getColumn(2).setPreferredWidth(30); JScrollPane tableScroller = new JScrollPane(table); int tableHeight = (table.getRowHeight()+table.getRowMargin())*(table.getRowCount()+2); if (tableHeight > 300){ tableScroller.setPreferredSize(new Dimension(400, 300)); }else{ tableScroller.setPreferredSize(new Dimension(400, tableHeight)); } tableScroller.setBorder(BorderFactory.createEmptyBorder(2,5,2,5)); contents.add(tableScroller); JButton okButton = new JButton("Close"); okButton.addActionListener(this); okButton.setAlignmentX(Component.CENTER_ALIGNMENT); contents.add(okButton); setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
| 1,108,306
|
DPrimeDisplay(HaploData hd){ //called when in cmd line mode, used to dump pngs theData = hd; this.computePreferredSize(); this.colorDPrime(); }
|
DPrimeDisplay(HaploData hd){ //called when in cmd line mode, used to dump pngs theData = hd; this.computePreferredSize(); this.colorDPrime(); }
| 1,108,307
|
public BufferedImage export(int start, int stop, boolean compress) throws HaploViewException { forExport = true; exportStart = start; if (exportStart < 0){ exportStart = 0; } exportStop = stop; if (exportStop > Chromosome.getSize()){ exportStop = Chromosome.getSize(); } int startBS = boxSize; int startBR = boxRadius; boolean startPD = printDPrimeValues; boolean startMN = printMarkerNames; int startZL = zoomLevel; if (compress){ zoomLevel = 2; printDPrimeValues = false; printMarkerNames = false; if (boxSize > (1200/(stop - start))){ boxSize = 1200/(stop - start); if (boxSize < 2){ boxSize = 2; } //to make picture not look dumb we need to avoid odd numbers for really teeny boxes if (boxSize < 10){ if (boxSize%2 != 0){ boxSize++; } } boxRadius = boxSize/2; } this.computePreferredSize(); } Dimension pref = getPreferredSize(); if(pref.width > 10000 || pref.height > 10000) { throw new HaploViewException("Image too large. Try saving as compressed PNG."); } BufferedImage i = new BufferedImage(pref.width, pref.height, BufferedImage.TYPE_3BYTE_BGR); paintComponent(i.getGraphics()); boxSize = startBS; boxRadius = startBR; zoomLevel = startZL; printMarkerNames = startMN; printDPrimeValues = startPD; forExport = false; this.computePreferredSize(); return i; }
|
public BufferedImage export(int start, int stop, boolean compress) throws HaploViewException { forExport = true; exportStart = Chromosome.filterIndex[start]; if (exportStart < 0){ exportStart = 0; } exportStop = stop; if (exportStop > Chromosome.getSize()){ exportStop = Chromosome.getSize(); } int startBS = boxSize; int startBR = boxRadius; boolean startPD = printDPrimeValues; boolean startMN = printMarkerNames; int startZL = zoomLevel; if (compress){ zoomLevel = 2; printDPrimeValues = false; printMarkerNames = false; if (boxSize > (1200/(stop - start))){ boxSize = 1200/(stop - start); if (boxSize < 2){ boxSize = 2; } //to make picture not look dumb we need to avoid odd numbers for really teeny boxes if (boxSize < 10){ if (boxSize%2 != 0){ boxSize++; } } boxRadius = boxSize/2; } this.computePreferredSize(); } Dimension pref = getPreferredSize(); if(pref.width > 10000 || pref.height > 10000) { throw new HaploViewException("Image too large. Try saving as compressed PNG."); } BufferedImage i = new BufferedImage(pref.width, pref.height, BufferedImage.TYPE_3BYTE_BGR); paintComponent(i.getGraphics()); boxSize = startBS; boxRadius = startBR; zoomLevel = startZL; printMarkerNames = startMN; printDPrimeValues = startPD; forExport = false; this.computePreferredSize(); return i; }
| 1,108,309
|
public BufferedImage export(int start, int stop, boolean compress) throws HaploViewException { forExport = true; exportStart = start; if (exportStart < 0){ exportStart = 0; } exportStop = stop; if (exportStop > Chromosome.getSize()){ exportStop = Chromosome.getSize(); } int startBS = boxSize; int startBR = boxRadius; boolean startPD = printDPrimeValues; boolean startMN = printMarkerNames; int startZL = zoomLevel; if (compress){ zoomLevel = 2; printDPrimeValues = false; printMarkerNames = false; if (boxSize > (1200/(stop - start))){ boxSize = 1200/(stop - start); if (boxSize < 2){ boxSize = 2; } //to make picture not look dumb we need to avoid odd numbers for really teeny boxes if (boxSize < 10){ if (boxSize%2 != 0){ boxSize++; } } boxRadius = boxSize/2; } this.computePreferredSize(); } Dimension pref = getPreferredSize(); if(pref.width > 10000 || pref.height > 10000) { throw new HaploViewException("Image too large. Try saving as compressed PNG."); } BufferedImage i = new BufferedImage(pref.width, pref.height, BufferedImage.TYPE_3BYTE_BGR); paintComponent(i.getGraphics()); boxSize = startBS; boxRadius = startBR; zoomLevel = startZL; printMarkerNames = startMN; printDPrimeValues = startPD; forExport = false; this.computePreferredSize(); return i; }
|
public BufferedImage export(int start, int stop, boolean compress) throws HaploViewException { forExport = true; exportStart = start; if (exportStart < 0){ exportStart = 0; } exportStop = stop; if (exportStop > Chromosome.getSize()){ exportStop = Chromosome.getSize(); } int startBS = boxSize; int startBR = boxRadius; boolean startPD = printDPrimeValues; boolean startMN = printMarkerNames; int startZL = zoomLevel; if (compress){ zoomLevel = 2; printDPrimeValues = false; printMarkerNames = false; if (boxSize > (1200/(stop - start))){ boxSize = 1200/(stop - start); if (boxSize < 2){ boxSize = 2; } //to make picture not look dumb we need to avoid odd numbers for really teeny boxes if (boxSize < 10){ if (boxSize%2 != 0){ boxSize++; } } boxRadius = boxSize/2; } this.computePreferredSize(); } Dimension pref = getPreferredSize(); if(pref.width > 10000 || pref.height > 10000) { throw new HaploViewException("Image too large. Try saving as compressed PNG."); } BufferedImage i = new BufferedImage(pref.width, pref.height, BufferedImage.TYPE_3BYTE_BGR); paintComponent(i.getGraphics()); boxSize = startBS; boxRadius = startBR; zoomLevel = startZL; printMarkerNames = startMN; printDPrimeValues = startPD; forExport = false; this.computePreferredSize(); return i; }
| 1,108,310
|
public void doPermutations(int selection) { selectionType = selection; stopProcessing = false; Vector curResults = null; if (selectionType == CUSTOM){ activeAssocTestSet = custAssocTestSet; }else{ activeAssocTestSet = defaultAssocTestSet; } double curBest = 0; String curName = ""; for(int i=0;i<activeAssocTestSet.getFilteredResults().size();i++) { AssociationResult tmpRes = (AssociationResult) activeAssocTestSet.getFilteredResults().get(i); for (int j = 0; j < tmpRes.getAlleleCount(); j++){ if (tmpRes.getChiSquare(j) > curBest){ curName = tmpRes.getDisplayName(j); curBest = tmpRes.getChiSquare(j); } } } bestObsChiSq = curBest; bestObsName = curName; Haplotype[][] haplotypes = new Haplotype[activeAssocTestSet.getHaplotypeAssociationResults().size()][]; Iterator hitr = activeAssocTestSet.getHaplotypeAssociationResults().iterator(); int count = 0; while (hitr.hasNext()){ haplotypes[count] = ((HaplotypeAssociationResult)hitr.next()).getHaps(); count++; } Vector snpSet = new Vector(); Iterator sitr = activeAssocTestSet.getFilteredResults().iterator(); while (sitr.hasNext()){ Object o = sitr.next(); if (o instanceof MarkerAssociationResult){ SNP snp = ((MarkerAssociationResult)o).getSnp(); snpSet.add(snp); } } //we need to make fake Haplotype objects so that we can use the getcounts() and getChiSq() methods of //AssociationResult. kludgetastic! Haplotype[][] fakeHaplos; if(haplotypes != null) { fakeHaplos = new Haplotype[haplotypes.length][]; for(int j=0;j<haplotypes.length;j++) { fakeHaplos[j] = new Haplotype[haplotypes[j].length]; for(int k=0;k<haplotypes[j].length;k++) { fakeHaplos[j][k] = new Haplotype(haplotypes[j][k].getGeno(),haplotypes[j][k].getPercentage(), haplotypes[j][k].getMarkers(), haplotypes[j][k].getEM()); } } } else { fakeHaplos = new Haplotype[0][0]; } //need to use the same affected status for marker and haplotype association tests in case control, //so affectedStatus stores the shuffled affected status Vector affectedStatus = null; if(Options.getAssocTest() == ASSOC_CC) { Vector indList = pedFile.getUnrelatedIndividuals(); affectedStatus = new Vector(); for(int j=0;j<indList.size();j++) { affectedStatus.add(new Integer(((Individual)indList.elementAt(j)).getAffectedStatus())); } } //need to use the same coin toss for marker and haplotype association tests in trio tdt, //so permuteInd stores whether each individual is permuted Vector permuteInd = new Vector(pedFile.getAllIndividuals().size()); permutationsPerformed = 0; bestExceededCount = 0; double[] chiSqs = new double[permutationCount]; permBestOverallChiSq = 0; //start the permuting! for(int i=0;i<permutationCount; i++) { //this variable gets set by the thread we're running if it wants us to stop if(stopProcessing) { break; } //begin single marker association test if (Options.getAssocTest() == ASSOC_TRIO){ try { for(int j =0;j<pedFile.getAllIndividuals().size();j++) { if(Math.random() < .5) { permuteInd.set(j,Boolean.valueOf(true)); } else { permuteInd.set(j,Boolean.valueOf(false)); } } curResults = new AssociationTestSet(pedFile, permuteInd, snpSet).getMarkerAssociationResults(); } catch(PedFileException pfe) { } }else if (Options.getAssocTest() == ASSOC_CC){ Collections.shuffle(affectedStatus); try{ curResults = new AssociationTestSet(pedFile,affectedStatus, snpSet).getMarkerAssociationResults(); }catch (PedFileException pfe){ } } //end of marker association test if (selectionType != SINGLE_ONLY){ //begin haplotype association test if(Options.getAssocTest() == ASSOC_TRIO) { for(int j=0;j<fakeHaplos.length;j++) { EM curEM = fakeHaplos[j][0].getEM(); curEM.doAssociationTests(null,permuteInd); for(int k=0;k<fakeHaplos[j].length;k++) { fakeHaplos[j][k].setTransCount(curEM.getTransCount(k)); fakeHaplos[j][k].setUntransCount(curEM.getUntransCount(k)); } } } else if(Options.getAssocTest() == ASSOC_CC) { for(int j=0;j<fakeHaplos.length;j++) { EM curEM = fakeHaplos[j][0].getEM(); curEM.doAssociationTests(affectedStatus,null); for(int k=0;k<fakeHaplos[j].length;k++) { fakeHaplos[j][k].setCaseCount(curEM.getCaseCount(k)); fakeHaplos[j][k].setControlCount(curEM.getControlCount(k)); } } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { AssociationTestSet ats = null; if (activeAssocTestSet.getFilterAlleles() == null){ ats = new AssociationTestSet(fakeHaplos, null); }else{ try{ ats = new AssociationTestSet(fakeHaplos,null,activeAssocTestSet.getFilterAlleles()); }catch (HaploViewException hve){ } } curResults.addAll(ats.getResults()); } //end of haplotype association test } //find the best chi square from all the tests double tempBestChiSquare = 0; for(int j=0; j<curResults.size();j++) { AssociationResult tempResult = (AssociationResult) curResults.elementAt(j); for (int k = 0; k < tempResult.getAlleleCount(); k++){ if(tempResult.getChiSquare(k) > tempBestChiSquare) { tempBestChiSquare = tempResult.getChiSquare(k); } } } chiSqs[i] = tempBestChiSquare; if (chiSqs[i] >= bestObsChiSq){ bestExceededCount++; } if(chiSqs[i] > permBestOverallChiSq){ permBestOverallChiSq = chiSqs[i]; } permutationsPerformed++; } permBestChiSq = new double[permutationsPerformed]; for (int i = 0; i < permutationsPerformed; i++){ permBestChiSq[i] = chiSqs[i]; } Arrays.sort(permBestChiSq); }
|
public void doPermutations(int selection) { selectionType = selection; stopProcessing = false; Vector curResults = null; if (selectionType == CUSTOM){ activeAssocTestSet = custAssocTestSet; }else{ activeAssocTestSet = defaultAssocTestSet; } double curBest = 0; String curName = ""; for(int i=0;i<activeAssocTestSet.getFilteredResults().size();i++) { AssociationResult tmpRes = (AssociationResult) activeAssocTestSet.getFilteredResults().get(i); for (int j = 0; j < tmpRes.getAlleleCount(); j++){ if (tmpRes.getChiSquare(j) > curBest){ curName = tmpRes.getDisplayName(j); curBest = tmpRes.getChiSquare(j); } } } bestObsChiSq = curBest; bestObsName = curName; Haplotype[][] haplotypes = new Haplotype[activeAssocTestSet.getHaplotypeAssociationResults().size()][]; Iterator hitr = activeAssocTestSet.getHaplotypeAssociationResults().iterator(); int count = 0; while (hitr.hasNext()){ haplotypes[count] = ((HaplotypeAssociationResult)hitr.next()).getHaps(); count++; } Vector snpSet = new Vector(); Iterator sitr = activeAssocTestSet.getFilteredResults().iterator(); while (sitr.hasNext()){ Object o = sitr.next(); if (o instanceof MarkerAssociationResult){ SNP snp = ((MarkerAssociationResult)o).getSnp(); snpSet.add(snp); } } //we need to make fake Haplotype objects so that we can use the getcounts() and getChiSq() methods of //AssociationResult. kludgetastic! Haplotype[][] fakeHaplos; if(haplotypes != null) { fakeHaplos = new Haplotype[haplotypes.length][]; for(int j=0;j<haplotypes.length;j++) { fakeHaplos[j] = new Haplotype[haplotypes[j].length]; for(int k=0;k<haplotypes[j].length;k++) { fakeHaplos[j][k] = new Haplotype(haplotypes[j][k].getGeno(),haplotypes[j][k].getPercentage(), haplotypes[j][k].getMarkers(), haplotypes[j][k].getEM()); } } } else { fakeHaplos = new Haplotype[0][0]; } //need to use the same affected status for marker and haplotype association tests in case control, //so affectedStatus stores the shuffled affected status Vector affectedStatus = null; if(Options.getAssocTest() == ASSOC_CC) { Vector indList = pedFile.getUnrelatedIndividuals(); affectedStatus = new Vector(); for(int j=0;j<indList.size();j++) { affectedStatus.add(new Integer(((Individual)indList.elementAt(j)).getAffectedStatus())); } } //need to use the same coin toss for marker and haplotype association tests in trio tdt, //so permuteInd stores whether each individual is permuted Vector permuteInd = new Vector(); for (int i = 0; i < pedFile.getAllIndividuals().size(); i++){ permuteInd.add(null); } permutationsPerformed = 0; bestExceededCount = 0; double[] chiSqs = new double[permutationCount]; permBestOverallChiSq = 0; //start the permuting! for(int i=0;i<permutationCount; i++) { //this variable gets set by the thread we're running if it wants us to stop if(stopProcessing) { break; } //begin single marker association test if (Options.getAssocTest() == ASSOC_TRIO){ try { for(int j =0;j<pedFile.getAllIndividuals().size();j++) { if(Math.random() < .5) { permuteInd.set(j,Boolean.valueOf(true)); } else { permuteInd.set(j,Boolean.valueOf(false)); } } curResults = new AssociationTestSet(pedFile, permuteInd, snpSet).getMarkerAssociationResults(); } catch(PedFileException pfe) { } }else if (Options.getAssocTest() == ASSOC_CC){ Collections.shuffle(affectedStatus); try{ curResults = new AssociationTestSet(pedFile,affectedStatus, snpSet).getMarkerAssociationResults(); }catch (PedFileException pfe){ } } //end of marker association test if (selectionType != SINGLE_ONLY){ //begin haplotype association test if(Options.getAssocTest() == ASSOC_TRIO) { for(int j=0;j<fakeHaplos.length;j++) { EM curEM = fakeHaplos[j][0].getEM(); curEM.doAssociationTests(null,permuteInd); for(int k=0;k<fakeHaplos[j].length;k++) { fakeHaplos[j][k].setTransCount(curEM.getTransCount(k)); fakeHaplos[j][k].setUntransCount(curEM.getUntransCount(k)); } } } else if(Options.getAssocTest() == ASSOC_CC) { for(int j=0;j<fakeHaplos.length;j++) { EM curEM = fakeHaplos[j][0].getEM(); curEM.doAssociationTests(affectedStatus,null); for(int k=0;k<fakeHaplos[j].length;k++) { fakeHaplos[j][k].setCaseCount(curEM.getCaseCount(k)); fakeHaplos[j][k].setControlCount(curEM.getControlCount(k)); } } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { AssociationTestSet ats = null; if (activeAssocTestSet.getFilterAlleles() == null){ ats = new AssociationTestSet(fakeHaplos, null); }else{ try{ ats = new AssociationTestSet(fakeHaplos,null,activeAssocTestSet.getFilterAlleles()); }catch (HaploViewException hve){ } } curResults.addAll(ats.getResults()); } //end of haplotype association test } //find the best chi square from all the tests double tempBestChiSquare = 0; for(int j=0; j<curResults.size();j++) { AssociationResult tempResult = (AssociationResult) curResults.elementAt(j); for (int k = 0; k < tempResult.getAlleleCount(); k++){ if(tempResult.getChiSquare(k) > tempBestChiSquare) { tempBestChiSquare = tempResult.getChiSquare(k); } } } chiSqs[i] = tempBestChiSquare; if (chiSqs[i] >= bestObsChiSq){ bestExceededCount++; } if(chiSqs[i] > permBestOverallChiSq){ permBestOverallChiSq = chiSqs[i]; } permutationsPerformed++; } permBestChiSq = new double[permutationsPerformed]; for (int i = 0; i < permutationsPerformed; i++){ permBestChiSq[i] = chiSqs[i]; } Arrays.sort(permBestChiSq); }
| 1,108,312
|
protected void indexDir() { IndexerFileChooser fc = new IndexerFileChooser(); fc.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY ); int retval = fc.showDialog( this, "Select directory to index" ); if ( retval == JFileChooser.APPROVE_OPTION ) { File dir = fc.getSelectedFile(); // First check that this directory has not been indexed previously VolumeBase prevVolume = null; try { prevVolume = VolumeBase.getVolumeOfFile( dir ); } catch (IOException ex) { JOptionPane.showMessageDialog( this, "Problem reading directory: " + ex.getMessage(), "Photovault error", JOptionPane.ERROR_MESSAGE ); return; } if ( prevVolume != null ) { JOptionPane.showMessageDialog( this, "Directory " + dir.getAbsolutePath() + "\n has already been indexed to Photovault.", "Already indexed", JOptionPane.ERROR_MESSAGE ); return; } // Generate a unique name for the new volume String extVolName = "extvol_" + dir.getName(); if ( VolumeBase.getVolume( extVolName ) != null ) { int n = 2; while ( VolumeBase.getVolume( extVolName + n ) != null ) { n++; } extVolName += n; } ExternalVolume v = new ExternalVolume( extVolName, dir.getAbsolutePath() ); PhotovaultSettings settings = PhotovaultSettings.getSettings(); PVDatabase db = settings.getCurrentDatabase(); db.addVolume( v ); // Set up the indexer ExtVolIndexer indexer = new ExtVolIndexer( v ); PhotoFolder parentFolder = fc.getExtvolParentFolder(); if ( parentFolder == null ) { parentFolder = PhotoFolder.getRoot(); } String rootFolderName = "extvol_" + dir.getName(); if ( rootFolderName.length() > PhotoFolder.NAME_LENGTH ) { rootFolderName = rootFolderName.substring( 0, PhotoFolder.NAME_LENGTH ); } PhotoFolder topFolder = PhotoFolder.create( rootFolderName, parentFolder ); topFolder.setDescription( "Indexed from " + dir.getAbsolutePath() ); indexer.setTopFolder( topFolder ); // Save the configuration of the new volume settings.saveConfig(); // Show status dialog & index the directory IndexerStatusDlg statusDlg = new IndexerStatusDlg( this, false ); statusDlg.setVisible( true ); statusDlg.runIndexer( indexer ); } }
|
protected void indexDir() { IndexerFileChooser fc = new IndexerFileChooser(); fc.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY ); int retval = fc.showDialog( this, "Select directory to index" ); if ( retval == JFileChooser.APPROVE_OPTION ) { File dir = fc.getSelectedFile(); // First check that this directory has not been indexed previously VolumeBase prevVolume = null; try { prevVolume = VolumeBase.getVolumeOfFile( dir ); } catch (IOException ex) { JOptionPane.showMessageDialog( this, "Problem reading directory: " + ex.getMessage(), "Photovault error", JOptionPane.ERROR_MESSAGE ); return; } if ( prevVolume != null ) { JOptionPane.showMessageDialog( this, "Directory " + dir.getAbsolutePath() + "\n has already been indexed to Photovault.", "Already indexed", JOptionPane.ERROR_MESSAGE ); return; } // Generate a unique name for the new volume String extVolName = "extvol_" + dir.getName(); if ( VolumeBase.getVolume( extVolName ) != null ) { int n = 2; while ( VolumeBase.getVolume( extVolName + n ) != null ) { n++; } extVolName += n; } ExternalVolume v = new ExternalVolume( extVolName, dir.getAbsolutePath() ); PhotovaultSettings settings = PhotovaultSettings.getSettings(); PVDatabase db = settings.getCurrentDatabase(); try { db.addVolume( v ); } catch (PhotovaultException ex) { } // Set up the indexer ExtVolIndexer indexer = new ExtVolIndexer( v ); PhotoFolder parentFolder = fc.getExtvolParentFolder(); if ( parentFolder == null ) { parentFolder = PhotoFolder.getRoot(); } String rootFolderName = "extvol_" + dir.getName(); if ( rootFolderName.length() > PhotoFolder.NAME_LENGTH ) { rootFolderName = rootFolderName.substring( 0, PhotoFolder.NAME_LENGTH ); } PhotoFolder topFolder = PhotoFolder.create( rootFolderName, parentFolder ); topFolder.setDescription( "Indexed from " + dir.getAbsolutePath() ); indexer.setTopFolder( topFolder ); // Save the configuration of the new volume settings.saveConfig(); // Show status dialog & index the directory IndexerStatusDlg statusDlg = new IndexerStatusDlg( this, false ); statusDlg.setVisible( true ); statusDlg.runIndexer( indexer ); } }
| 1,108,314
|
public void setPhoto( PhotoInfo photo ) throws FileNotFoundException { if ( this.photo != null ) { this.photo.removeChangeListener( this ); } this.photo = photo; if ( photo == null ) { setImage( null ); return; } log.debug( "JAIPhotoViewer.setPhoto() photo=" + photo.getUid() ); photo.addChangeListener( this ); // Find the original file ImageInstance original = null; Vector instances = photo.getInstances(); for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; break; } } if ( original == null ) { log.debug( "Error - no original image was found!!!" ); } else { File imageFile = original.getImageFile(); if ( imageFile == null ) { throw new FileNotFoundException( ); } final String imageFilePath = original.getImageFile().getAbsolutePath(); log.debug( "loading image " + imageFilePath ); PlanarImage origImage = JAI.create( "fileload", imageFilePath ); log.debug( "image " + imageFilePath + " loaded"); setImage( origImage ); instanceRotation = original.getRotated(); double rot = photo.getPrefRotation() - instanceRotation; imageView.setRotation( rot ); imageView.setCrop( photo.getCropBounds() ); } }
|
public void setPhoto( PhotoInfo photo ) throws FileNotFoundException { if ( this.photo != null ) { this.photo.removeChangeListener( this ); } this.photo = photo; if ( photo == null ) { setImage( null ); return; } log.debug( "JAIPhotoViewer.setPhoto() photo=" + photo.getUid() ); photo.addChangeListener( this ); // Find the original file ImageInstance original = null; Vector instances = photo.getInstances(); for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; break; } } if ( original == null ) { log.debug( "Error - no original image was found!!!" ); } else { File imageFile = original.getImageFile(); if ( imageFile == null ) { throw new FileNotFoundException( ); } final String imageFilePath = original.getImageFile().getAbsolutePath(); log.debug( "loading image " + imageFilePath ); PlanarImage origImage = JAI.create( "fileload", imageFilePath ); log.debug( "image " + imageFilePath + " loaded"); setImage( origImage ); instanceRotation = original.getRotated(); double rot = photo.getPrefRotation() - instanceRotation; imageView.setRotation( rot ); imageView.setCrop( photo.getCropBounds() ); } }
| 1,108,316
|
public void setPhoto( PhotoInfo photo ) throws FileNotFoundException { if ( this.photo != null ) { this.photo.removeChangeListener( this ); } this.photo = photo; if ( photo == null ) { setImage( null ); return; } log.debug( "JAIPhotoViewer.setPhoto() photo=" + photo.getUid() ); photo.addChangeListener( this ); // Find the original file ImageInstance original = null; Vector instances = photo.getInstances(); for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; break; } } if ( original == null ) { log.debug( "Error - no original image was found!!!" ); } else { File imageFile = original.getImageFile(); if ( imageFile == null ) { throw new FileNotFoundException( ); } final String imageFilePath = original.getImageFile().getAbsolutePath(); log.debug( "loading image " + imageFilePath ); PlanarImage origImage = JAI.create( "fileload", imageFilePath ); log.debug( "image " + imageFilePath + " loaded"); setImage( origImage ); instanceRotation = original.getRotated(); double rot = photo.getPrefRotation() - instanceRotation; imageView.setRotation( rot ); imageView.setCrop( photo.getCropBounds() ); } }
|
public void setPhoto( PhotoInfo photo ) throws FileNotFoundException { if ( this.photo != null ) { this.photo.removeChangeListener( this ); } this.photo = photo; if ( photo == null ) { setImage( null ); return; } log.debug( "JAIPhotoViewer.setPhoto() photo=" + photo.getUid() ); photo.addChangeListener( this ); // Find the original file ImageInstance original = null; Vector instances = photo.getInstances(); for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; break; } } if ( original == null ) { log.debug( "Error - no original image was found!!!" ); } else { File imageFile = original.getImageFile(); if ( imageFile == null ) { throw new FileNotFoundException( ); } final String imageFilePath = original.getImageFile().getAbsolutePath(); log.debug( "loading image " + imageFilePath ); PlanarImage origImage = JAI.create( "fileload", imageFilePath ); log.debug( "image " + imageFilePath + " loaded"); setImage( origImage ); instanceRotation = original.getRotated(); double rot = photo.getPrefRotation() - instanceRotation; imageView.setRotation( rot ); imageView.setCrop( photo.getCropBounds() ); } }
| 1,108,317
|
public DelegatedQueryExecutor(Storage<S> rootStorage, Filter<S> filter, OrderingList<S> ordering) throws FetchException { check(rootStorage); Query<S> query; if (filter == null) { query = rootStorage.query(); } else { query = rootStorage.query(filter); } if (ordering == null) { ordering = OrderingList.emptyList(); } else if (ordering.size() > 0) { query = query.orderBy(ordering.asStringArray()); } mFilter = filter; mOrdering = ordering; mQuery = query; }
|
public DelegatedQueryExecutor(Storage<S> rootStorage, Filter<S> filter, OrderingList<S> ordering) throws FetchException { check(rootStorage); Query<S> query; if (filter == null) { query = rootStorage.query(); } else { query = rootStorage.query(filter); } if (ordering == null) { ordering = OrderingList.emptyList(); } else if (ordering.size() > 0) { query = query.orderBy(ordering.asStringArray()); } mFilter = filter; mOrdering = ordering; mQuery = query; }
| 1,108,318
|
public DelegatedQueryExecutor(Storage<S> rootStorage, Filter<S> filter, OrderingList<S> ordering) throws FetchException { check(rootStorage); Query<S> query; if (filter == null) { query = rootStorage.query(); } else { query = rootStorage.query(filter); } if (ordering == null) { ordering = OrderingList.emptyList(); } else if (ordering.size() > 0) { query = query.orderBy(ordering.asStringArray()); } mFilter = filter; mOrdering = ordering; mQuery = query; }
|
public DelegatedQueryExecutor(Storage<S> rootStorage, Filter<S> filter, OrderingList<S> ordering) throws FetchException { check(rootStorage); Query<S> query; if (filter == null) { query = rootStorage.query(); } else { query = rootStorage.query(filter); } if (ordering == null) { ordering = OrderingList.emptyList(); } else if (ordering.size() > 0) { query = query.orderBy(ordering.asStringArray()); } mFilter = filter; mOrdering = ordering; mQuery = query; }
| 1,108,319
|
public JoinedQueryExecutor(Repository repo, ChainedProperty<B> bToAProperty, QueryExecutor<A> aExecutor) throws SupportException, FetchException, RepositoryException { mFactory = new JoinedCursorFactory<A, B> (repo, bToAProperty, aExecutor.getStorableType()); mAExecutor = aExecutor; Filter<A> aFilter = aExecutor.getFilter(); mAFilterValues = aFilter.initialFilterValues(); mBFilter = aFilter.accept(new FilterTransformer(bToAProperty), null); mBOrdering = transformOrdering(bToAProperty.getPrimeProperty().getEnclosingType(), bToAProperty.toString(), aExecutor); }
|
public JoinedQueryExecutor(Repository repo, Class<B> bType, String bToAProperty, QueryExecutor<A> aExecutor) throws SupportException, FetchException, RepositoryException { mFactory = new JoinedCursorFactory<A, B> (repo, bToAProperty, aExecutor.getStorableType()); mAExecutor = aExecutor; Filter<A> aFilter = aExecutor.getFilter(); mAFilterValues = aFilter.initialFilterValues(); mBFilter = aFilter.accept(new FilterTransformer(bToAProperty), null); mBOrdering = transformOrdering(bToAProperty.getPrimeProperty().getEnclosingType(), bToAProperty.toString(), aExecutor); }
| 1,108,320
|
public JoinedQueryExecutor(Repository repo, ChainedProperty<B> bToAProperty, QueryExecutor<A> aExecutor) throws SupportException, FetchException, RepositoryException { mFactory = new JoinedCursorFactory<A, B> (repo, bToAProperty, aExecutor.getStorableType()); mAExecutor = aExecutor; Filter<A> aFilter = aExecutor.getFilter(); mAFilterValues = aFilter.initialFilterValues(); mBFilter = aFilter.accept(new FilterTransformer(bToAProperty), null); mBOrdering = transformOrdering(bToAProperty.getPrimeProperty().getEnclosingType(), bToAProperty.toString(), aExecutor); }
|
public JoinedQueryExecutor(Repository repo, ChainedProperty<B> bToAProperty, QueryExecutor<A> aExecutor) throws SupportException, FetchException, RepositoryException { mFactory = new JoinedCursorFactory<A, B> (repo, bType, bToAProperty, aExecutor.getStorableType()); mAExecutor = aExecutor; Filter<A> aFilter = aExecutor.getFilter(); mAFilterValues = aFilter.initialFilterValues(); mBFilter = aFilter.accept(new FilterTransformer(bToAProperty), null); mBOrdering = transformOrdering(bToAProperty.getPrimeProperty().getEnclosingType(), bToAProperty.toString(), aExecutor); }
| 1,108,321
|
public JoinedQueryExecutor(Repository repo, ChainedProperty<B> bToAProperty, QueryExecutor<A> aExecutor) throws SupportException, FetchException, RepositoryException { mFactory = new JoinedCursorFactory<A, B> (repo, bToAProperty, aExecutor.getStorableType()); mAExecutor = aExecutor; Filter<A> aFilter = aExecutor.getFilter(); mAFilterValues = aFilter.initialFilterValues(); mBFilter = aFilter.accept(new FilterTransformer(bToAProperty), null); mBOrdering = transformOrdering(bToAProperty.getPrimeProperty().getEnclosingType(), bToAProperty.toString(), aExecutor); }
|
public JoinedQueryExecutor(Repository repo, ChainedProperty<B> bToAProperty, QueryExecutor<A> aExecutor) throws SupportException, FetchException, RepositoryException { mFactory = new JoinedCursorFactory<A, B> (repo, bToAProperty, aExecutor.getStorableType()); mAExecutor = aExecutor; Filter<A> aFilter = aExecutor.getFilter(); mAFilterValues = aFilter.initialFilterValues(); mBFilter = aFilter.accept(new FilterTransformer(bType, bToAProperty), null); mBOrdering = transformOrdering(bToAProperty.getPrimeProperty().getEnclosingType(), bToAProperty.toString(), aExecutor); }
| 1,108,322
|
public JoinedQueryExecutor(Repository repo, ChainedProperty<B> bToAProperty, QueryExecutor<A> aExecutor) throws SupportException, FetchException, RepositoryException { mFactory = new JoinedCursorFactory<A, B> (repo, bToAProperty, aExecutor.getStorableType()); mAExecutor = aExecutor; Filter<A> aFilter = aExecutor.getFilter(); mAFilterValues = aFilter.initialFilterValues(); mBFilter = aFilter.accept(new FilterTransformer(bToAProperty), null); mBOrdering = transformOrdering(bToAProperty.getPrimeProperty().getEnclosingType(), bToAProperty.toString(), aExecutor); }
|
public JoinedQueryExecutor(Repository repo, ChainedProperty<B> bToAProperty, QueryExecutor<A> aExecutor) throws SupportException, FetchException, RepositoryException { mFactory = new JoinedCursorFactory<A, B> (repo, bToAProperty, aExecutor.getStorableType()); mAExecutor = aExecutor; Filter<A> aFilter = aExecutor.getFilter(); mAFilterValues = aFilter.initialFilterValues(); mBFilter = aFilter.accept(new FilterTransformer(bToAProperty), null); mBOrdering = transformOrdering(bToAProperty.getPrimeProperty().getEnclosingType(), bToAProperty.toString(), aExecutor); }
| 1,108,323
|
public ServerConnection getServerConnection(ApplicationConfig config) throws ConnectionFailedException { try { MBeanHome home = findExternal(config.getURL(), config.getUsername(), config.getPassword()); return new WLServerConnection(home.getMBeanServer()); } catch (Throwable e) { throw new ConnectionFailedException(e); } }
|
public ServerConnection getServerConnection(ApplicationConfig config) throws ConnectionFailedException { try { MBeanHome home = findExternal(config.getURL(), config.getUsername(), config.getPassword()); return new WLServerConnection(home.getMBeanServer()); } catch (Throwable e) { throw new ConnectionFailedException(e); } }
| 1,108,324
|
public WLServerConnection(MBeanServer mbeanServer){ super(mbeanServer, MBeanServer.class); assert mbeanServer != null; this.mbeanServer = (RemoteMBeanServer)mbeanServer; }
|
public WLServerConnection(MBeanServer mbeanServer, Context ctx){ super(mbeanServer, MBeanServer.class); assert mbeanServer != null; this.mbeanServer = (RemoteMBeanServer)mbeanServer; }
| 1,108,325
|
public TagScript createTagScript(String name, Attributes attributes) throws Exception { TagScript answer = super.createTagScript(name, attributes); if ( answer == null ) { final Factory factory = getFactory( name ); if ( factory != null ) { return new DynaTagScript( new TagFactory() { public Tag createTag() throws Exception { return new ComponentTag(factory); } } ); } } return answer; }
|
public TagScript createTagScript(String name, Attributes attributes) throws Exception { TagScript answer = super.createTagScript(name, attributes); if ( answer == null ) { final Factory factory = getFactory( name ); if ( factory != null ) { return new DynaTagScript( new TagFactory() { public Tag createTag() throws Exception { if ( factory instanceof TagFactory ) { return ((TagFactory) factory).createTag(); } else { return new ComponentTag(factory); } } } ); } } return answer; }
| 1,108,329
|
public Tag createTag() throws Exception { return new ComponentTag(factory); }
|
public Tag createTag() throws Exception { if ( factory instanceof TagFactory ) { return ((TagFactory) factory).createTag(); } else { return new ComponentTag(factory); } }
| 1,108,330
|
public DynaTagScript(TagFactory tagFactory) { super(tagFactory); }
|
public DynaTagScript(TagFactory tagFactory) { super(tagFactory); }
| 1,108,331
|
public void testJDBCClassLoader() throws Exception { // Side effect is to load my prefs; needed to avoid having to manually add jar to session. ArchitectFrame.getMainInstance(); ArchitectSession sess = ArchitectSession.getInstance(); JDBCClassLoader cl = sess.getJDBCClassLoader(); System.out.println("If this throws a ClassNotFoundException, update your Architect Preferences to include the PostGreSQL driver jar"); Class clazz = cl.findClass(PGSQL_DRIVER); // If we get here, this test has passed. assertNotNull("Loaded JDBC class %s%n", clazz); }
|
public void testJDBCClassLoader() throws Exception { // Side effect is to load my prefs; needed to avoid having to manually add jar to session. ArchitectFrame.getMainInstance(); ArchitectSession sess = ArchitectSessionImpl.getInstance(); JDBCClassLoader cl = sess.getJDBCClassLoader(); System.out.println("If this throws a ClassNotFoundException, update your Architect Preferences to include the PostGreSQL driver jar"); Class clazz = cl.findClass(PGSQL_DRIVER); // If we get here, this test has passed. assertNotNull("Loaded JDBC class %s%n", clazz); }
| 1,108,332
|
public JDBCClassLoader getJDBCClassLoader() { return jdbcClassLoader; }
|
public JDBCClassLoader getJDBCClassLoader() { return jdbcClassLoader; }
| 1,108,333
|
public void dbChildrenInserted(SQLObjectEvent e) { try { SQLObject[] newEventSources = e.getChildren(); for (int i = 0; i < newEventSources.length; i++) { listenToSQLObjectAndChildren(newEventSources[i]); } } catch (ArchitectException ex) { ex.printStackTrace(); } TreeModelEvent tme = new TreeModelEvent(this, getPathToNode(e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesInserted(tme); }
|
public void dbChildrenInserted(SQLObjectEvent e) { try { SQLObject[] newEventSources = e.getChildren(); for (int i = 0; i < newEventSources.length; i++) { listenToSQLObjectAndChildren(newEventSources[i]); } } catch (ArchitectException ex) { logger.error("Error listening to added object", ex); } TreeModelEvent tme = new TreeModelEvent(this, getPathToNode(e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesInserted(tme); }
| 1,108,334
|
public void dbChildrenRemoved(SQLObjectEvent e) { try { SQLObject[] oldEventSources = e.getChildren(); for (int i = 0; i < oldEventSources.length; i++) { unlistenToSQLObjectAndChildren(oldEventSources[i]); } } catch (ArchitectException ex) { ex.printStackTrace(); } TreeModelEvent tme = new TreeModelEvent(this, getPathToNode(e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesRemoved(tme); }
|
public void dbChildrenRemoved(SQLObjectEvent e) { try { SQLObject[] oldEventSources = e.getChildren(); for (int i = 0; i < oldEventSources.length; i++) { unlistenToSQLObjectAndChildren(oldEventSources[i]); } } catch (ArchitectException ex) { logger.error("Error unlistening to removed object", ex); } TreeModelEvent tme = new TreeModelEvent(this, getPathToNode(e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesRemoved(tme); }
| 1,108,335
|
public static SQLObject[] getPathToNode(SQLObject node) { LinkedList path = new LinkedList(); while (node != null) { path.add(0, node); node = node.getParent(); } return (SQLObject[]) path.toArray(new SQLObject[path.size()]); }
|
public SQLObject[] getPathToNode(SQLObject node) { LinkedList path = new LinkedList(); while (node != null) { path.add(0, node); node = node.getParent(); } return (SQLObject[]) path.toArray(new SQLObject[path.size()]); }
| 1,108,338
|
protected void listenToSQLObjectAndChildren(SQLObject o) throws ArchitectException { o.addSQLObjectListener(this); if (o.isPopulated()) { Iterator it = o.getChildren().iterator(); while (it.hasNext()) { listenToSQLObjectAndChildren((SQLObject) it.next()); } } }
|
protected void listenToSQLObjectAndChildren(SQLObject o) throws ArchitectException { o.addSQLObjectListener(this); if (o.isPopulated() && o.allowsChildren()) { Iterator it = o.getChildren().iterator(); while (it.hasNext()) { listenToSQLObjectAndChildren((SQLObject) it.next()); } } }
| 1,108,340
|
protected void unlistenToSQLObjectAndChildren(SQLObject o) throws ArchitectException { o.removeSQLObjectListener(this); if (o.isPopulated()) { Iterator it = o.getChildren().iterator(); while (it.hasNext()) { SQLObject ob = (SQLObject) it.next(); unlistenToSQLObjectAndChildren(ob); } } }
|
protected void unlistenToSQLObjectAndChildren(SQLObject o) throws ArchitectException { o.removeSQLObjectListener(this); if (o.isPopulated() && o.allowsChildren()) { Iterator it = o.getChildren().iterator(); while (it.hasNext()) { SQLObject ob = (SQLObject) it.next(); unlistenToSQLObjectAndChildren(ob); } } }
| 1,108,341
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals("Filter")){ chromChoice = (String)chromChooser.getSelectedItem(); if (chromStart.getText().equals("")){ startPos = -1; }else{ startPos = (Long.parseLong(chromStart.getText()))*1000; } if (chromEnd.getText().equals("")){ endPos = -1; }else{ endPos = (Long.parseLong(chromEnd.getText()))*1000; } if (startPos > endPos){ JOptionPane.showMessageDialog(this.getParent(), "End position must be greater then start position.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } if (chiField.getText().equals("")){ chisq = -1; }else{ chisq = Double.parseDouble(chiField.getText()); } if (pvalChooser.getSelectedIndex() == 0){ pval = -1; }else if (pvalChooser.getSelectedIndex() == 1){ pval = .01; }else if (pvalChooser.getSelectedIndex() == 2){ pval = .001; }else if (pvalChooser.getSelectedIndex() == 3){ pval = .0001; }else if (pvalChooser.getSelectedIndex() == 4){ pval = .00001; } doFilters(); }else if (command.equals("generic filter")){ if (genericChooser.getSelectedIndex() == -1){ JOptionPane.showMessageDialog(this.getParent(), "Please select a column to filter on.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } columnChoice = (String)genericChooser.getSelectedItem(); if (signChooser.getSelectedIndex() == -1){ JOptionPane.showMessageDialog(this.getParent(), "Please choose >=, <=, or =.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } signChoice = (String)signChooser.getSelectedItem(); if (valueField.getText().equals("")){ JOptionPane.showMessageDialog(this.getParent(), "Please enter a value to filter on.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } value = valueField.getText(); doGenericFilter(); }else if (command.equals("top filter")){ numResults = Integer.parseInt(topField.getText()); doTopFilter(); }else if (command.equals("Reset Filters")){ clearFilters(); }else if (command.equals("Load Additional Results")){ HaploView.fc.setSelectedFile(new File("")); int returned = HaploView.fc.showOpenDialog(this); if (returned != JFileChooser.APPROVE_OPTION) return; File file = HaploView.fc.getSelectedFile(); String name = file.getName(); String[] inputs = {null,null,name}; hv.readWGA(inputs); }else if (command.equals("Go to Selected Region")){ gotoRegion(); } }
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals("Filter")){ chromChoice = (String)chromChooser.getSelectedItem(); if (chromStart.getText().equals("")){ startPos = -1; }else{ startPos = (Long.parseLong(chromStart.getText()))*1000; } if (chromEnd.getText().equals("")){ endPos = -1; }else{ endPos = (Long.parseLong(chromEnd.getText()))*1000; } if (startPos > endPos){ JOptionPane.showMessageDialog(this.getParent(), "End position must be greater then start position.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } if (chiField.getText().equals("")){ chisq = -1; }else{ chisq = Double.parseDouble(chiField.getText()); } if (pvalChooser.getSelectedIndex() == 0){ pval = -1; }else if (pvalChooser.getSelectedIndex() == 1){ pval = .01; }else if (pvalChooser.getSelectedIndex() == 2){ pval = .001; }else if (pvalChooser.getSelectedIndex() == 3){ pval = .0001; }else if (pvalChooser.getSelectedIndex() == 4){ pval = .00001; } doFilters(); }else if (command.equals("generic filter")){ if (genericChooser.getSelectedIndex() == -1){ JOptionPane.showMessageDialog(this.getParent(), "Please select a column to filter on.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } columnChoice = (String)genericChooser.getSelectedItem(); if (signChooser.getSelectedIndex() == -1){ JOptionPane.showMessageDialog(this.getParent(), "Please choose >=, <=, or =.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } signChoice = (String)signChooser.getSelectedItem(); if (valueField.getText().equals("")){ JOptionPane.showMessageDialog(this.getParent(), "Please enter a value to filter on.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } value = valueField.getText(); doGenericFilter(); }else if (command.equals("top filter")){ numResults = Integer.parseInt(topField.getText()); doTopFilter(); }else if (command.equals("Reset Filters")){ clearFilters(); }else if (command.equals("Load Additional Results")){ HaploView.fc.setSelectedFile(new File("")); int returned = HaploView.fc.showOpenDialog(this); if (returned != JFileChooser.APPROVE_OPTION) return; File file = HaploView.fc.getSelectedFile(); String name = file.getName(); String[] inputs = {null,null,name}; hv.readWGA(inputs); }else if (command.equals("Go to Selected Region")){ gotoRegion(); } }
| 1,108,342
|
public void filterAll(String chr, int start, int end, String column, String s, String value){ resetFilters(); int rows = getRowCount(); Vector newFiltered = new Vector(); boolean chromPass = false; boolean genericPass = false; long realStart = start*1000; long realEnd = end*1000; int col = -1; for (int i = 0; i < rows; i++){ if (!(chr.equals(""))){ if (((String)getValueAt(i,1)).equalsIgnoreCase(chr)){ if ((((Long)getValueAt(i,3)).longValue() >= realStart) || (start == -1)){ if ((((Long)getValueAt(i,3)).longValue() <= realEnd) || (end == -1)){ chromPass = true; } } } }else{ chromPass = true; } if (column != null && s != null && value != null){ double rowVal; double val = 0; String stringVal = null; try{ val = Double.parseDouble(value); }catch (NumberFormatException nfe){ stringVal = value; } if (col == -1){ for (int j = 0; j < columnNames.size(); j++){ if(column.equalsIgnoreCase((String)columnNames.get(j))){ col = j; break; } } } if (getValueAt(i,col) != null){ if (stringVal != null){ if (((String)getValueAt(i,col)).equalsIgnoreCase(stringVal)){ genericPass = true; } }else{ try{ rowVal = ((Double)getValueAt(i,col)).doubleValue(); }catch (ClassCastException cce){ rowVal = Double.NaN; } if (s.equals(">=")){ if (rowVal >= val){ genericPass = true; } }else if (s.equals("<=")){ if (rowVal <= val){ genericPass = true; } }else{ if (rowVal == val){ genericPass = true; } } } }else{ genericPass = true; } }else{ genericPass = true; } if (chromPass && genericPass){ newFiltered.add(new Integer(i)); } chromPass = false; genericPass = false; } filtered = newFiltered; }
|
public void filterAll(String chr, int start, int end, String column, String s, String value){ resetFilters(); int rows = getRowCount(); Vector newFiltered = new Vector(); boolean chromPass = false; boolean genericPass = false; long realStart = start*1000; long realEnd = end*1000; int col = -1; for (int i = 0; i < rows; i++){ if (!(chr.equals(""))){ if (((String)getValueAt(i,1)).equalsIgnoreCase(chr)){ if ((((Long)getValueAt(i,3)).longValue() >= realStart) || (start == -1)){ if ((((Long)getValueAt(i,3)).longValue() <= realEnd) || (end == -1)){ chromPass = true; } } } }else{ chromPass = true; } if (column != null && s != null && value != null){ double rowVal; double val = 0; String stringVal = null; try{ val = Double.parseDouble(value); }catch (NumberFormatException nfe){ stringVal = value; } if (col == -1){ for (int j = 0; j < columnNames.size(); j++){ if(column.equalsIgnoreCase((String)columnNames.get(j))){ col = j; break; } } } if (getValueAt(i,col) != null){ if (stringVal != null){ if (((String)getValueAt(i,col)).equalsIgnoreCase(stringVal)){ genericPass = true; } }else{ try{ rowVal = ((Double)getValueAt(i,col)).doubleValue(); }catch (ClassCastException cce){ rowVal = Double.NaN; } if (s.equals(">=")){ if (rowVal >= val){ genericPass = true; } }else if (s.equals("<=")){ if (rowVal <= val){ genericPass = true; } }else{ if (rowVal == val){ genericPass = true; } } } }else{ genericPass = true; } }else{ genericPass = true; } if (chromPass && genericPass){ newFiltered.add(new Integer(i)); } chromPass = false; genericPass = false; } filtered = newFiltered; }
| 1,108,343
|
public void doTag(XMLOutput output) throws Exception { TaskSource tag = (TaskSource) findAncestorWithClass( TaskSource.class ); if ( tag == null ) { throw new JellyException( "You should only use Ant DataType tags within an Ant Task" ); } Object task = tag.getTaskObject(); Object dataType = getDataType(); // now we need to configure the task with the data type // first try setting a property on the DynaBean wrapper of the task DynaBean dynaBean = tag.getDynaBean(); DynaClass dynaClass = dynaBean.getDynaClass(); DynaProperty dynaProperty = dynaClass.getDynaProperty(name); if ( dynaProperty != null ) { // lets set the bean property dynaBean.set( name, dataType ); } else { // lets invoke the addFoo() method instead String methodName = "add" + name.substring(0,1).toUpperCase() + name.substring(1); Class taskClass = task.getClass(); Class[] parameterTypes = new Class[] { dataType.getClass() }; Method method = taskClass.getMethod( methodName, parameterTypes ); if ( method == null ) { throw new JellyException( "Cannot add dataType: " + dataType + " to Ant task: " + task + " as no method called: " + methodName + " could be found" ); } Object[] parameters = new Object[] { dataType }; method.invoke( task, parameters ); } // run the body first to configure any nested DataType instances getBody().run(context, output); }
|
public void doTag(XMLOutput output) throws Exception { TaskSource tag = (TaskSource) findAncestorWithClass( TaskSource.class ); if ( tag == null ) { throw new JellyException( "You should only use Ant DataType tags within an Ant Task" ); } Object task = tag.getTaskObject(); Object dataType = getDataType(); // now we need to configure the task with the data type // first try setting a property on the DynaBean wrapper of the task DynaBean dynaBean = tag.getDynaBean(); DynaClass dynaClass = dynaBean.getDynaClass(); DynaProperty dynaProperty = dynaClass.getDynaProperty(name); if ( dynaProperty != null ) { // lets set the bean property dynaBean.set( name, dataType ); } else { // lets invoke the addFoo() method instead String methodName = "add" + name.substring(0,1).toUpperCase() + name.substring(1); Class taskClass = task.getClass(); Class[] parameterTypes = new Class[] { dataType.getClass() }; Method method = MethodUtils.getAccessibleMethod( taskClass, methodName, parameterTypes ); if ( method == null ) { throw new JellyException( "Cannot add dataType: " + dataType + " to Ant task: " + task + " as no method called: " + methodName + " could be found" ); } Object[] parameters = new Object[] { dataType }; method.invoke( task, parameters ); } // run the body first to configure any nested DataType instances getBody().run(context, output); }
| 1,108,344
|
public void run(JellyContext context, XMLOutput output) throws Exception { // initialize all the properties of the tag before its used // if there is a problem abort this tag for (int i = 0, size = expressions.length; i < size; i++) { Expression expression = expressions[i]; Method method = methods[i]; Class type = types[i]; // some types are Expression objects so let the tag // evaluate them Object value = null; if (type.isAssignableFrom(Expression.class) && !type.isAssignableFrom(Object.class)) { value = expression; } else { value = expression.evaluate(context); } // convert value to correct type if (value != null) { value = convertType(value, type); } Object[] arguments = { value }; method.invoke(tag, arguments); } tag.setContext(context); tag.doTag(output); }
|
public void run(JellyContext context, XMLOutput output) throws Exception { // initialize all the properties of the tag before its used // if there is a problem abort this tag for (int i = 0, size = expressions.length; i < size; i++) { Expression expression = expressions[i]; Method method = methods[i]; Class type = types[i]; // some types are Expression objects so let the tag // evaluate them Object value = null; if (type.isAssignableFrom(Expression.class) && !type.isAssignableFrom(Object.class)) { value = expression; } else { value = expression.evaluate(context); } // convert value to correct type if (value != null) { value = convertType(value, type); } Object[] arguments = { value }; method.invoke(tag, arguments); } tag.doTag(output); }
| 1,108,345
|
public TagScript(TagFactory tagFactory) { this.tagFactory = tagFactory; }
|
public TagScript(TagFactory tagFactory) { this.tagFactory = tagFactory; }
| 1,108,346
|
public TablePane(SQLTable m, PlayPen parentPP) { super(parentPP.getPlayPenContentPane()); setModel(m); setOpaque(true); setInsertionPoint(COLUMN_INDEX_NONE); //dt = new DropTarget(parentPP, new TablePaneDropListener(this)); dtl = new TablePaneDropListener(this); updateUI(); }
|
public TablePane(SQLTable m, PlayPen parentPP) { super(parentPP.getPlayPenContentPane()); setModel(m); setOpaque(true); setInsertionPoint(COLUMN_INDEX_NONE); //dt = new DropTarget(parentPP, new TablePaneDropListener(this)); dtl = new TablePaneDropListener(this); updateUI(); }
| 1,108,348
|
public TablePane(SQLTable m, PlayPen parentPP) { super(parentPP.getPlayPenContentPane()); setModel(m); setOpaque(true); setInsertionPoint(COLUMN_INDEX_NONE); //dt = new DropTarget(parentPP, new TablePaneDropListener(this)); dtl = new TablePaneDropListener(this); updateUI(); }
|
public TablePane(SQLTable m, PlayPen parentPP) { super(parentPP.getPlayPenContentPane()); setModel(m); setOpaque(true); setInsertionPoint(COLUMN_INDEX_NONE); //dt = new DropTarget(parentPP, new TablePaneDropListener(this)); dtl = new TablePaneDropListener(this); updateUI(); }
| 1,108,349
|
public JellyAssertionFailedError(String message) { super(message); }
|
public JellyAssertionFailedError(String message) { super(message); }
| 1,108,350
|
public static void copyFile( File src, File dst ) throws IOException { FileInputStream in = new FileInputStream( src ); FileOutputStream out = new FileOutputStream( dst ); byte buf[] = new byte[1024]; int nRead = 0; int offset = 0; while ( (nRead = in.read( buf )) > 0 ) { out.write( buf, 0, nRead ); offset += nRead; } out.close(); in.close(); }
|
public static void copyFile( File src, File dst ) throws IOException { FileInputStream in = new FileInputStream( src ); FileOutputStream out = new FileOutputStream( dst ); byte buf[] = new byte[1024]; int nRead = 0; int offset = 0; while ( (nRead = in.read( buf )) > 0 ) { out.write( buf, 0, nRead ); offset += nRead; } out.close(); in.close(); }
| 1,108,354
|
public static byte[] calcHash( File f ) { FileInputStream is = null; byte hash[] = null; try { is = new FileInputStream( f ); byte readBuffer[] = new byte[4096]; MessageDigest md = MessageDigest.getInstance("MD5"); int bytesRead = -1; while( ( bytesRead = is.read( readBuffer ) ) > 0 ) { md.update( readBuffer, 0, bytesRead ); } hash = md.digest(); } catch (NoSuchAlgorithmException ex) { log.error( "MD5 algorithm not found" ); } catch (FileNotFoundException ex) { log.error( f.getAbsolutePath() + "not found" ); } catch (IOException ex) { log.error( "IOException while calculating hash: " + ex.getMessage() ); } finally { try { is.close(); } catch (IOException ex) { log.error( "Cannot close stream after calculating hash" ); } } return hash; }
|
public static byte[] calcHash( File f ) { FileInputStream is = null; byte hash[] = null; try { is = new FileInputStream( f ); byte readBuffer[] = new byte[4096]; MessageDigest md = MessageDigest.getInstance("MD5"); int bytesRead = -1; while( ( bytesRead = is.read( readBuffer ) ) > 0 ) { md.update( readBuffer, 0, bytesRead ); } hash = md.digest(); } catch (NoSuchAlgorithmException ex) { log.error( "MD5 algorithm not found" ); } catch (FileNotFoundException ex) { log.error( f.getAbsolutePath() + "not found" ); } catch (IOException ex) { log.error( "IOException while calculating hash: " + ex.getMessage() ); } finally { try { is.close(); } catch (IOException ex) { log.error( "Cannot close stream after calculating hash" ); } } return hash; }
| 1,108,355
|
public static byte[] calcHash( File f ) { FileInputStream is = null; byte hash[] = null; try { is = new FileInputStream( f ); byte readBuffer[] = new byte[4096]; MessageDigest md = MessageDigest.getInstance("MD5"); int bytesRead = -1; while( ( bytesRead = is.read( readBuffer ) ) > 0 ) { md.update( readBuffer, 0, bytesRead ); } hash = md.digest(); } catch (NoSuchAlgorithmException ex) { log.error( "MD5 algorithm not found" ); } catch (FileNotFoundException ex) { log.error( f.getAbsolutePath() + "not found" ); } catch (IOException ex) { log.error( "IOException while calculating hash: " + ex.getMessage() ); } finally { try { is.close(); } catch (IOException ex) { log.error( "Cannot close stream after calculating hash" ); } } return hash; }
|
public static byte[] calcHash( File f ) { FileInputStream is = null; byte hash[] = null; try { is = new FileInputStream( f ); byte readBuffer[] = new byte[4096]; MessageDigest md = MessageDigest.getInstance("MD5"); int bytesRead = -1; while( ( bytesRead = is.read( readBuffer ) ) > 0 ) { md.update( readBuffer, 0, bytesRead ); } hash = md.digest(); } catch (NoSuchAlgorithmException ex) { log.error( "MD5 algorithm not found" ); } catch (FileNotFoundException ex) { log.error( f.getAbsolutePath() + "not found" ); } catch (IOException ex) { log.error( "IOException while calculating hash: " + ex.getMessage() ); } finally { try { is.close(); } catch (IOException ex) { log.error( "Cannot close stream after calculating hash" ); } } return hash; }
| 1,108,356
|
public static byte[] calcHash( File f ) { FileInputStream is = null; byte hash[] = null; try { is = new FileInputStream( f ); byte readBuffer[] = new byte[4096]; MessageDigest md = MessageDigest.getInstance("MD5"); int bytesRead = -1; while( ( bytesRead = is.read( readBuffer ) ) > 0 ) { md.update( readBuffer, 0, bytesRead ); } hash = md.digest(); } catch (NoSuchAlgorithmException ex) { log.error( "MD5 algorithm not found" ); } catch (FileNotFoundException ex) { log.error( f.getAbsolutePath() + "not found" ); } catch (IOException ex) { log.error( "IOException while calculating hash: " + ex.getMessage() ); } finally { try { is.close(); } catch (IOException ex) { log.error( "Cannot close stream after calculating hash" ); } } return hash; }
|
public static byte[] calcHash( File f ) { FileInputStream is = null; byte hash[] = null; try { is = new FileInputStream( f ); byte readBuffer[] = new byte[4096]; MessageDigest md = MessageDigest.getInstance("MD5"); int bytesRead = -1; while( ( bytesRead = is.read( readBuffer ) ) > 0 ) { md.update( readBuffer, 0, bytesRead ); } hash = md.digest(); } catch (NoSuchAlgorithmException ex) { log.error( "MD5 algorithm not found" ); } catch (FileNotFoundException ex) { log.error( f.getAbsolutePath() + "not found" ); } catch (IOException ex) { log.error( "IOException while calculating hash: " + ex.getMessage() ); } finally { try { is.close(); } catch (IOException ex) { log.error( "Cannot close stream after calculating hash" ); } } }
| 1,108,357
|
public void save(ProgressMonitor pm) throws IOException, ArchitectException { // write to temp file and then rename (this preserves old project file // when there's problems) if (file.exists() && !file.canWrite()) { // write problems with architect file will muck up the save process throw new ArchitectException("problem saving project -- " + "cannot write to architect file: " + file.getAbsolutePath()); } File tempFile = new File (file.getParent(),"tmp___" + file.getName()); File backupFile = new File (file.getParent(), file.getName()+"~"); out = new PrintWriter(new BufferedWriter(new FileWriter(tempFile))); objectIdMap = new HashMap(); dbcsIdMap = new HashMap(); indent = 0; progress = 0; boolean saveOk = false; // use this to determine if save process worked this.pm = pm; if (pm != null) { pm.setMinimum(0); int pmMax = countSourceTables((SQLObject) sourceDatabases.getModel().getRoot()) + playPen.getPPComponentCount() * 2; logger.debug("Setting progress monitor maximum to "+pmMax); pm.setMaximum(pmMax); pm.setProgress(progress); pm.setMillisToDecideToPopup(500); } try { println("<?xml version=\"1.0\"?>"); println("<architect-project version=\"0.1\">"); indent++; println("<project-name>"+name+"</project-name>"); saveDataSources(); saveSourceDatabases(); saveTargetDatabase(); saveDDLGenerator(); savePlayPen(); indent--; println("</architect-project>"); setModified(false); saveOk = true; } finally { if (out != null) out.close(); out = null; if (pm != null) pm.close(); pm = null; } // do the rename dance if (saveOk) { backupFile.delete(); file.renameTo(backupFile); tempFile.renameTo(file); file = tempFile; } }
|
public void save(ProgressMonitor pm) throws IOException, ArchitectException { // write to temp file and then rename (this preserves old project file // when there's problems) if (file.exists() && !file.canWrite()) { // write problems with architect file will muck up the save process throw new ArchitectException("problem saving project -- " + "cannot write to architect file: " + file.getAbsolutePath()); } File tempFile = new File (file.getParent(),"tmp___" + file.getName()); File backupFile = new File (file.getParent(), file.getName()+"~"); out = new PrintWriter(new BufferedWriter(new FileWriter(tempFile))); objectIdMap = new HashMap(); dbcsIdMap = new HashMap(); indent = 0; progress = 0; boolean saveOk = false; // use this to determine if save process worked this.pm = pm; if (pm != null) { pm.setMinimum(0); int pmMax = countSourceTables((SQLObject) sourceDatabases.getModel().getRoot()) + playPen.getPPComponentCount() * 2; logger.debug("Setting progress monitor maximum to "+pmMax); pm.setMaximum(pmMax); pm.setProgress(progress); pm.setMillisToDecideToPopup(500); } try { println("<?xml version=\"1.0\"?>"); println("<architect-project version=\"0.1\">"); indent++; println("<project-name>"+name+"</project-name>"); saveDataSources(); saveSourceDatabases(); saveTargetDatabase(); saveDDLGenerator(); savePlayPen(); indent--; println("</architect-project>"); setModified(false); saveOk = true; } finally { if (out != null) out.close(); out = null; if (pm != null) pm.close(); pm = null; } // do the rename dance if (saveOk) { backupFile.delete(); file.renameTo(backupFile); tempFile.renameTo(file); file = tempFile; } }
| 1,108,360
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.