rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
Iterator it = columnsFolder.children.iterator(); int colIdx = 0; while (it.hasNext()) { if (it.next() == col) { return colIdx;
Iterator it; try { it = getColumns().iterator(); int colIdx = 0; while (it.hasNext()) { if (it.next() == col) { return colIdx; } colIdx++;
public int getColumnIndex(SQLColumn col) { logger.debug("Looking for column index of: " + col); Iterator it = columnsFolder.children.iterator(); int colIdx = 0; while (it.hasNext()) { if (it.next() == col) { return colIdx; } colIdx++; } logger.debug("NOT FOUND"); return -1; }
colIdx++;
} catch (ArchitectException e) { logger.warn("Unexpected ArchitectException in getColumnIndex on " +col.toString());
public int getColumnIndex(SQLColumn col) { logger.debug("Looking for column index of: " + col); Iterator it = columnsFolder.children.iterator(); int colIdx = 0; while (it.hasNext()) { if (it.next() == col) { return colIdx; } colIdx++; } logger.debug("NOT FOUND"); return -1; }
public List keysOfColumn(SQLColumn col) {
public List keysOfColumn(SQLColumn col) throws ArchitectException {
public List keysOfColumn(SQLColumn col) { LinkedList keys = new LinkedList(); Iterator it = exportedKeysFolder.children.iterator(); while (it.hasNext()) { SQLRelationship r = (SQLRelationship) it.next(); if (r.containsPkColumn(col)) { keys.add(r); } } it = importedKeysFolder.children.iterator(); while (it.hasNext()) { SQLRelationship r = (SQLRelationship) it.next(); if (r.containsFkColumn(col)) { keys.add(r); } } return keys; }
Iterator it = exportedKeysFolder.children.iterator();
Iterator it = getExportedKeys().iterator();
public List keysOfColumn(SQLColumn col) { LinkedList keys = new LinkedList(); Iterator it = exportedKeysFolder.children.iterator(); while (it.hasNext()) { SQLRelationship r = (SQLRelationship) it.next(); if (r.containsPkColumn(col)) { keys.add(r); } } it = importedKeysFolder.children.iterator(); while (it.hasNext()) { SQLRelationship r = (SQLRelationship) it.next(); if (r.containsFkColumn(col)) { keys.add(r); } } return keys; }
it = importedKeysFolder.children.iterator();
it = getExportedKeys().iterator();
public List keysOfColumn(SQLColumn col) { LinkedList keys = new LinkedList(); Iterator it = exportedKeysFolder.children.iterator(); while (it.hasNext()) { SQLRelationship r = (SQLRelationship) it.next(); if (r.containsPkColumn(col)) { keys.add(r); } } it = importedKeysFolder.children.iterator(); while (it.hasNext()) { SQLRelationship r = (SQLRelationship) it.next(); if (r.containsFkColumn(col)) { keys.add(r); } } return keys; }
if (columnsFolder.children.isEmpty()) return; boolean donePk = false; int i = 0; Iterator it = columnsFolder.children.iterator(); while (it.hasNext()) { SQLColumn col = (SQLColumn) it.next(); if (col.getPrimaryKeySeq() == null) donePk = true; if (!donePk) { col.primaryKeySeq = new Integer(i); } else { col.primaryKeySeq = null;
try { if (getColumns().isEmpty()) return; boolean donePk = false; int i = 0; Iterator it = getColumns().iterator(); while (it.hasNext()) { SQLColumn col = (SQLColumn) it.next(); if (col.getPrimaryKeySeq() == null) donePk = true; if (!donePk) { col.primaryKeySeq = new Integer(i); } else { col.primaryKeySeq = null; } i++;
public void normalizePrimaryKey() { if (columnsFolder.children.isEmpty()) return; boolean donePk = false; int i = 0; Iterator it = columnsFolder.children.iterator(); while (it.hasNext()) { SQLColumn col = (SQLColumn) it.next(); if (col.getPrimaryKeySeq() == null) donePk = true; if (!donePk) { col.primaryKeySeq = new Integer(i); } else { col.primaryKeySeq = null; } i++; } }
i++;
} catch (ArchitectException e) { logger.warn("Unexpected ArchitectException in normalizePrimaryKey "+e);
public void normalizePrimaryKey() { if (columnsFolder.children.isEmpty()) return; boolean donePk = false; int i = 0; Iterator it = columnsFolder.children.iterator(); while (it.hasNext()) { SQLColumn col = (SQLColumn) it.next(); if (col.getPrimaryKeySeq() == null) donePk = true; if (!donePk) { col.primaryKeySeq = new Integer(i); } else { col.primaryKeySeq = null; } i++; } }
protected synchronized void populateColumns() throws ArchitectException {
private synchronized void populateColumns() throws ArchitectException {
protected synchronized void populateColumns() throws ArchitectException { if (columnsFolder.isPopulated()) return; if (columnsFolder.children.size() > 0) throw new IllegalStateException("Can't populate table because it already contains columns"); try { SQLColumn.addColumnsToTable(this, getCatalogName(), getSchemaName(), tableName); } catch (SQLException e) { throw new ArchitectException("Failed to populate columns of table "+getName(), e); } finally { columnsFolder.populated = true; Collections.sort(columnsFolder.children, new SQLColumn.SortByPKSeq()); normalizePrimaryKey(); int newSize = columnsFolder.children.size(); int[] changedIndices = new int[newSize]; for (int i = 0; i < newSize; i++) { changedIndices[i] = i; } columnsFolder.fireDbChildrenInserted(changedIndices, columnsFolder.children); } }
public synchronized void populateRelationships() throws ArchitectException {
private synchronized void populateRelationships() throws ArchitectException {
public synchronized void populateRelationships() throws ArchitectException { if (!columnsFolder.isPopulated()) throw new IllegalStateException("Table must be populated before relationships are added"); if (importedKeysFolder.isPopulated()) return; int oldSize = importedKeysFolder.children.size(); /* this must come before * SQLRelationship.addImportedRelationshipsToTable because * addImportedRelationshipsToTable causes SQLObjectEvents to be fired, * which in turn could cause infinite recursion when listeners * query the size of the relationships folder. */ importedKeysFolder.populated = true; try { SQLRelationship.addImportedRelationshipsToTable(this); } finally { int newSize = importedKeysFolder.children.size(); if (newSize > oldSize) { int[] changedIndices = new int[newSize - oldSize]; for (int i = 0, n = newSize - oldSize; i < n; i++) { changedIndices[i] = oldSize + i; } try { importedKeysFolder.fireDbChildrenInserted (changedIndices, importedKeysFolder.children.subList(oldSize, newSize)); } catch (IndexOutOfBoundsException ex) { logger.error("Index out of bounds while adding imported keys to table " +getName()+" where oldSize="+oldSize+"; newSize="+newSize +"; imported keys="+importedKeysFolder.children); } } } }
if (plPanel.historyBox.getSelectedIndex() == 0) {
if (plPanel.getTargetDBCS() == null) {
public void actionPerformed(ActionEvent e) { final SQLDatabase souDB =playpen.getDatabase(); final PLExport plexp = new PLExport(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "PL Repository"); JPanel plp = new JPanel(new BorderLayout(12,12)); plp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final PLExportPanel plPanel = new PLExportPanel(); plp.add(plPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (plPanel.historyBox.getSelectedIndex() == 0) { JOptionPane.showMessageDialog(plPanel, "You have to select a target database from the list.", "Error", JOptionPane.ERROR_MESSAGE); return; } try { //plPanel.applyChanges(); plexp.setJobId(plPanel.getPlJobId()); plexp.setFolderName(plPanel.getPlFolderName()); plexp.setJobDescription(plPanel.getPlJobDescription()); plexp.setJobComment(plPanel.getPlJobComment()); plexp.setPlDBCS(plPanel.getDbcs()); plexp.setOutputTableOwner(plPanel.getPlOutputTableOwner()); plexp.setPlUsername(plPanel.getPlUserName()); plexp.setPlPassword(plPanel.getPlPassword()); } catch (Exception ex) { String message = "Can't export Transaction: "+ex.getMessage(); if (plPanel.isSelectedRunPLEngine()) { message += "\nThe engine will not run"; } JOptionPane.showMessageDialog(architectFrame, message); logger.error("Got exception while exporting Trans", ex); return; } d.setVisible(false); try { plexp.export(souDB); if (plPanel.isSelectedRunPLEngine()) { logger.debug("run PL LOADER Engine"); File plIni = new File(architectFrame.getUserSettings().getETLUserSettings().getPlDotIniPath()); File plDir = plIni.getParentFile(); File engineExe = new File(plDir, plPanel.getSelectedPlDatabase().getEngineExeutableName()); StringBuffer wcomm = new StringBuffer(1000); wcomm.append(engineExe.getPath()); wcomm.append(" USER_PROMPT=N"); wcomm.append(" JOB=").append(plPanel.getPlJobId()); wcomm.append(" USER=").append((plPanel.getDbcs()).getUser()).append("/").append((plPanel.getDbcs()).getPass()); wcomm.append("@").append(plPanel.getSelectedPlDatabase().getTNSName()); wcomm.append(" DEBUG=N SEND_EMAIL=N SKIP_PACKAGES=N CALC_DETAIL_STATS=N COMMIT_FREQ=100 APPEND_TO_JOB_LOG_IND=N"); wcomm.append(" APPEND_TO_JOB_ERR_IND=N"); wcomm.append(" SHOW_PROGRESS=100" ); System.out.println(wcomm.toString()); try { Process proc = Runtime.getRuntime().exec(wcomm.toString()); JDialog d = new JDialog(architectFrame, "Power*Loader Engine"); d.setContentPane(new EngineExecPanel(proc)); d.pack(); d.setVisible(true); } catch (IOException ie){ JOptionPane.showMessageDialog(playpen, "Unexpected Exception running Engine:\n"+ie); logger.error(ie); } } } catch (PLSecurityException ex) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+ex.getMessage()); logger.error("Got exception while exporting Trans", ex); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans", arex); } } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { plPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); plp.add(buttonPanel, BorderLayout.SOUTH); d.setContentPane(plp); d.pack(); d.setVisible(true); }
plexp.setPlDBCS(plPanel.getDbcs());
plexp.setPlDBCS(plPanel.getTargetDBCS());
public void actionPerformed(ActionEvent e) { final SQLDatabase souDB =playpen.getDatabase(); final PLExport plexp = new PLExport(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "PL Repository"); JPanel plp = new JPanel(new BorderLayout(12,12)); plp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final PLExportPanel plPanel = new PLExportPanel(); plp.add(plPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (plPanel.historyBox.getSelectedIndex() == 0) { JOptionPane.showMessageDialog(plPanel, "You have to select a target database from the list.", "Error", JOptionPane.ERROR_MESSAGE); return; } try { //plPanel.applyChanges(); plexp.setJobId(plPanel.getPlJobId()); plexp.setFolderName(plPanel.getPlFolderName()); plexp.setJobDescription(plPanel.getPlJobDescription()); plexp.setJobComment(plPanel.getPlJobComment()); plexp.setPlDBCS(plPanel.getDbcs()); plexp.setOutputTableOwner(plPanel.getPlOutputTableOwner()); plexp.setPlUsername(plPanel.getPlUserName()); plexp.setPlPassword(plPanel.getPlPassword()); } catch (Exception ex) { String message = "Can't export Transaction: "+ex.getMessage(); if (plPanel.isSelectedRunPLEngine()) { message += "\nThe engine will not run"; } JOptionPane.showMessageDialog(architectFrame, message); logger.error("Got exception while exporting Trans", ex); return; } d.setVisible(false); try { plexp.export(souDB); if (plPanel.isSelectedRunPLEngine()) { logger.debug("run PL LOADER Engine"); File plIni = new File(architectFrame.getUserSettings().getETLUserSettings().getPlDotIniPath()); File plDir = plIni.getParentFile(); File engineExe = new File(plDir, plPanel.getSelectedPlDatabase().getEngineExeutableName()); StringBuffer wcomm = new StringBuffer(1000); wcomm.append(engineExe.getPath()); wcomm.append(" USER_PROMPT=N"); wcomm.append(" JOB=").append(plPanel.getPlJobId()); wcomm.append(" USER=").append((plPanel.getDbcs()).getUser()).append("/").append((plPanel.getDbcs()).getPass()); wcomm.append("@").append(plPanel.getSelectedPlDatabase().getTNSName()); wcomm.append(" DEBUG=N SEND_EMAIL=N SKIP_PACKAGES=N CALC_DETAIL_STATS=N COMMIT_FREQ=100 APPEND_TO_JOB_LOG_IND=N"); wcomm.append(" APPEND_TO_JOB_ERR_IND=N"); wcomm.append(" SHOW_PROGRESS=100" ); System.out.println(wcomm.toString()); try { Process proc = Runtime.getRuntime().exec(wcomm.toString()); JDialog d = new JDialog(architectFrame, "Power*Loader Engine"); d.setContentPane(new EngineExecPanel(proc)); d.pack(); d.setVisible(true); } catch (IOException ie){ JOptionPane.showMessageDialog(playpen, "Unexpected Exception running Engine:\n"+ie); logger.error(ie); } } } catch (PLSecurityException ex) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+ex.getMessage()); logger.error("Got exception while exporting Trans", ex); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans", arex); } } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { plPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); plp.add(buttonPanel, BorderLayout.SOUTH); d.setContentPane(plp); d.pack(); d.setVisible(true); }
wcomm.append(" USER=").append((plPanel.getDbcs()).getUser()).append("/").append((plPanel.getDbcs()).getPass());
wcomm.append(" USER=").append((plPanel.getTargetDBCS()).getUser()).append("/").append((plPanel.getTargetDBCS()).getPass());
public void actionPerformed(ActionEvent e) { final SQLDatabase souDB =playpen.getDatabase(); final PLExport plexp = new PLExport(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "PL Repository"); JPanel plp = new JPanel(new BorderLayout(12,12)); plp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final PLExportPanel plPanel = new PLExportPanel(); plp.add(plPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (plPanel.historyBox.getSelectedIndex() == 0) { JOptionPane.showMessageDialog(plPanel, "You have to select a target database from the list.", "Error", JOptionPane.ERROR_MESSAGE); return; } try { //plPanel.applyChanges(); plexp.setJobId(plPanel.getPlJobId()); plexp.setFolderName(plPanel.getPlFolderName()); plexp.setJobDescription(plPanel.getPlJobDescription()); plexp.setJobComment(plPanel.getPlJobComment()); plexp.setPlDBCS(plPanel.getDbcs()); plexp.setOutputTableOwner(plPanel.getPlOutputTableOwner()); plexp.setPlUsername(plPanel.getPlUserName()); plexp.setPlPassword(plPanel.getPlPassword()); } catch (Exception ex) { String message = "Can't export Transaction: "+ex.getMessage(); if (plPanel.isSelectedRunPLEngine()) { message += "\nThe engine will not run"; } JOptionPane.showMessageDialog(architectFrame, message); logger.error("Got exception while exporting Trans", ex); return; } d.setVisible(false); try { plexp.export(souDB); if (plPanel.isSelectedRunPLEngine()) { logger.debug("run PL LOADER Engine"); File plIni = new File(architectFrame.getUserSettings().getETLUserSettings().getPlDotIniPath()); File plDir = plIni.getParentFile(); File engineExe = new File(plDir, plPanel.getSelectedPlDatabase().getEngineExeutableName()); StringBuffer wcomm = new StringBuffer(1000); wcomm.append(engineExe.getPath()); wcomm.append(" USER_PROMPT=N"); wcomm.append(" JOB=").append(plPanel.getPlJobId()); wcomm.append(" USER=").append((plPanel.getDbcs()).getUser()).append("/").append((plPanel.getDbcs()).getPass()); wcomm.append("@").append(plPanel.getSelectedPlDatabase().getTNSName()); wcomm.append(" DEBUG=N SEND_EMAIL=N SKIP_PACKAGES=N CALC_DETAIL_STATS=N COMMIT_FREQ=100 APPEND_TO_JOB_LOG_IND=N"); wcomm.append(" APPEND_TO_JOB_ERR_IND=N"); wcomm.append(" SHOW_PROGRESS=100" ); System.out.println(wcomm.toString()); try { Process proc = Runtime.getRuntime().exec(wcomm.toString()); JDialog d = new JDialog(architectFrame, "Power*Loader Engine"); d.setContentPane(new EngineExecPanel(proc)); d.pack(); d.setVisible(true); } catch (IOException ie){ JOptionPane.showMessageDialog(playpen, "Unexpected Exception running Engine:\n"+ie); logger.error(ie); } } } catch (PLSecurityException ex) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+ex.getMessage()); logger.error("Got exception while exporting Trans", ex); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans", arex); } } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { plPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); plp.add(buttonPanel, BorderLayout.SOUTH); d.setContentPane(plp); d.pack(); d.setVisible(true); }
if (plPanel.historyBox.getSelectedIndex() == 0) {
if (plPanel.getTargetDBCS() == null) {
public void actionPerformed(ActionEvent evt) { if (plPanel.historyBox.getSelectedIndex() == 0) { JOptionPane.showMessageDialog(plPanel, "You have to select a target database from the list.", "Error", JOptionPane.ERROR_MESSAGE); return; } try { //plPanel.applyChanges(); plexp.setJobId(plPanel.getPlJobId()); plexp.setFolderName(plPanel.getPlFolderName()); plexp.setJobDescription(plPanel.getPlJobDescription()); plexp.setJobComment(plPanel.getPlJobComment()); plexp.setPlDBCS(plPanel.getDbcs()); plexp.setOutputTableOwner(plPanel.getPlOutputTableOwner()); plexp.setPlUsername(plPanel.getPlUserName()); plexp.setPlPassword(plPanel.getPlPassword()); } catch (Exception ex) { String message = "Can't export Transaction: "+ex.getMessage(); if (plPanel.isSelectedRunPLEngine()) { message += "\nThe engine will not run"; } JOptionPane.showMessageDialog(architectFrame, message); logger.error("Got exception while exporting Trans", ex); return; } d.setVisible(false); try { plexp.export(souDB); if (plPanel.isSelectedRunPLEngine()) { logger.debug("run PL LOADER Engine"); File plIni = new File(architectFrame.getUserSettings().getETLUserSettings().getPlDotIniPath()); File plDir = plIni.getParentFile(); File engineExe = new File(plDir, plPanel.getSelectedPlDatabase().getEngineExeutableName()); StringBuffer wcomm = new StringBuffer(1000); wcomm.append(engineExe.getPath()); wcomm.append(" USER_PROMPT=N"); wcomm.append(" JOB=").append(plPanel.getPlJobId()); wcomm.append(" USER=").append((plPanel.getDbcs()).getUser()).append("/").append((plPanel.getDbcs()).getPass()); wcomm.append("@").append(plPanel.getSelectedPlDatabase().getTNSName()); wcomm.append(" DEBUG=N SEND_EMAIL=N SKIP_PACKAGES=N CALC_DETAIL_STATS=N COMMIT_FREQ=100 APPEND_TO_JOB_LOG_IND=N"); wcomm.append(" APPEND_TO_JOB_ERR_IND=N"); wcomm.append(" SHOW_PROGRESS=100" ); System.out.println(wcomm.toString()); try { Process proc = Runtime.getRuntime().exec(wcomm.toString()); JDialog d = new JDialog(architectFrame, "Power*Loader Engine"); d.setContentPane(new EngineExecPanel(proc)); d.pack(); d.setVisible(true); } catch (IOException ie){ JOptionPane.showMessageDialog(playpen, "Unexpected Exception running Engine:\n"+ie); logger.error(ie); } } } catch (PLSecurityException ex) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+ex.getMessage()); logger.error("Got exception while exporting Trans", ex); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans", arex); } }
plexp.setPlDBCS(plPanel.getDbcs());
plexp.setPlDBCS(plPanel.getTargetDBCS());
public void actionPerformed(ActionEvent evt) { if (plPanel.historyBox.getSelectedIndex() == 0) { JOptionPane.showMessageDialog(plPanel, "You have to select a target database from the list.", "Error", JOptionPane.ERROR_MESSAGE); return; } try { //plPanel.applyChanges(); plexp.setJobId(plPanel.getPlJobId()); plexp.setFolderName(plPanel.getPlFolderName()); plexp.setJobDescription(plPanel.getPlJobDescription()); plexp.setJobComment(plPanel.getPlJobComment()); plexp.setPlDBCS(plPanel.getDbcs()); plexp.setOutputTableOwner(plPanel.getPlOutputTableOwner()); plexp.setPlUsername(plPanel.getPlUserName()); plexp.setPlPassword(plPanel.getPlPassword()); } catch (Exception ex) { String message = "Can't export Transaction: "+ex.getMessage(); if (plPanel.isSelectedRunPLEngine()) { message += "\nThe engine will not run"; } JOptionPane.showMessageDialog(architectFrame, message); logger.error("Got exception while exporting Trans", ex); return; } d.setVisible(false); try { plexp.export(souDB); if (plPanel.isSelectedRunPLEngine()) { logger.debug("run PL LOADER Engine"); File plIni = new File(architectFrame.getUserSettings().getETLUserSettings().getPlDotIniPath()); File plDir = plIni.getParentFile(); File engineExe = new File(plDir, plPanel.getSelectedPlDatabase().getEngineExeutableName()); StringBuffer wcomm = new StringBuffer(1000); wcomm.append(engineExe.getPath()); wcomm.append(" USER_PROMPT=N"); wcomm.append(" JOB=").append(plPanel.getPlJobId()); wcomm.append(" USER=").append((plPanel.getDbcs()).getUser()).append("/").append((plPanel.getDbcs()).getPass()); wcomm.append("@").append(plPanel.getSelectedPlDatabase().getTNSName()); wcomm.append(" DEBUG=N SEND_EMAIL=N SKIP_PACKAGES=N CALC_DETAIL_STATS=N COMMIT_FREQ=100 APPEND_TO_JOB_LOG_IND=N"); wcomm.append(" APPEND_TO_JOB_ERR_IND=N"); wcomm.append(" SHOW_PROGRESS=100" ); System.out.println(wcomm.toString()); try { Process proc = Runtime.getRuntime().exec(wcomm.toString()); JDialog d = new JDialog(architectFrame, "Power*Loader Engine"); d.setContentPane(new EngineExecPanel(proc)); d.pack(); d.setVisible(true); } catch (IOException ie){ JOptionPane.showMessageDialog(playpen, "Unexpected Exception running Engine:\n"+ie); logger.error(ie); } } } catch (PLSecurityException ex) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+ex.getMessage()); logger.error("Got exception while exporting Trans", ex); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans", arex); } }
wcomm.append(" USER=").append((plPanel.getDbcs()).getUser()).append("/").append((plPanel.getDbcs()).getPass());
wcomm.append(" USER=").append((plPanel.getTargetDBCS()).getUser()).append("/").append((plPanel.getTargetDBCS()).getPass());
public void actionPerformed(ActionEvent evt) { if (plPanel.historyBox.getSelectedIndex() == 0) { JOptionPane.showMessageDialog(plPanel, "You have to select a target database from the list.", "Error", JOptionPane.ERROR_MESSAGE); return; } try { //plPanel.applyChanges(); plexp.setJobId(plPanel.getPlJobId()); plexp.setFolderName(plPanel.getPlFolderName()); plexp.setJobDescription(plPanel.getPlJobDescription()); plexp.setJobComment(plPanel.getPlJobComment()); plexp.setPlDBCS(plPanel.getDbcs()); plexp.setOutputTableOwner(plPanel.getPlOutputTableOwner()); plexp.setPlUsername(plPanel.getPlUserName()); plexp.setPlPassword(plPanel.getPlPassword()); } catch (Exception ex) { String message = "Can't export Transaction: "+ex.getMessage(); if (plPanel.isSelectedRunPLEngine()) { message += "\nThe engine will not run"; } JOptionPane.showMessageDialog(architectFrame, message); logger.error("Got exception while exporting Trans", ex); return; } d.setVisible(false); try { plexp.export(souDB); if (plPanel.isSelectedRunPLEngine()) { logger.debug("run PL LOADER Engine"); File plIni = new File(architectFrame.getUserSettings().getETLUserSettings().getPlDotIniPath()); File plDir = plIni.getParentFile(); File engineExe = new File(plDir, plPanel.getSelectedPlDatabase().getEngineExeutableName()); StringBuffer wcomm = new StringBuffer(1000); wcomm.append(engineExe.getPath()); wcomm.append(" USER_PROMPT=N"); wcomm.append(" JOB=").append(plPanel.getPlJobId()); wcomm.append(" USER=").append((plPanel.getDbcs()).getUser()).append("/").append((plPanel.getDbcs()).getPass()); wcomm.append("@").append(plPanel.getSelectedPlDatabase().getTNSName()); wcomm.append(" DEBUG=N SEND_EMAIL=N SKIP_PACKAGES=N CALC_DETAIL_STATS=N COMMIT_FREQ=100 APPEND_TO_JOB_LOG_IND=N"); wcomm.append(" APPEND_TO_JOB_ERR_IND=N"); wcomm.append(" SHOW_PROGRESS=100" ); System.out.println(wcomm.toString()); try { Process proc = Runtime.getRuntime().exec(wcomm.toString()); JDialog d = new JDialog(architectFrame, "Power*Loader Engine"); d.setContentPane(new EngineExecPanel(proc)); d.pack(); d.setVisible(true); } catch (IOException ie){ JOptionPane.showMessageDialog(playpen, "Unexpected Exception running Engine:\n"+ie); logger.error(ie); } } } catch (PLSecurityException ex) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+ex.getMessage()); logger.error("Got exception while exporting Trans", ex); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans", arex); } }
db.addSQLObjectListener(this);
try { ArchitectUtils.listenToHierarchy(this, db); } catch (ArchitectException ex) { logger.error("Couldn't listen to database", ex); }
public PlayPen(SQLDatabase db) { super(); if (db == null) throw new NullPointerException("db must be non-null"); this.db = db; relationships = new LinkedList(); db.addSQLObjectListener(this); setLayout(new PlayPenLayout(this)); setName("Play Pen"); setMinimumSize(new Dimension(200,200)); setBackground(java.awt.Color.white); setOpaque(false); // XXX: it really is opaque, but we can't have super.paintComponent() painting over top of our relationship lines dt = new DropTarget(this, new PlayPenDropListener()); tableNames = new HashMap(); addContainerListener(this); setupTablePanePopup(); }
if (c[i] instanceof SQLTable) { c[i].addSQLObjectListener(this);
try { ArchitectUtils.listenToHierarchy(this, c[i]); } catch (ArchitectException ex) { logger.error("Couldn't listen to added object", ex); } if (c[i] instanceof SQLTable || c[i] instanceof SQLRelationship) { fireEvent = true;
public void dbChildrenInserted(SQLObjectEvent e) { logger.debug("SQLObject children got inserted: "+e); SQLObject o = e.getSQLSource(); SQLObject[] c = e.getChildren(); for (int i = 0; i < c.length; i++) { if (c[i] instanceof SQLTable) { c[i].addSQLObjectListener(this); } } firePropertyChange("model.children", null, null); revalidate(); }
firePropertyChange("model.children", null, null); revalidate();
if (fireEvent) { firePropertyChange("model.children", null, null); revalidate(); }
public void dbChildrenInserted(SQLObjectEvent e) { logger.debug("SQLObject children got inserted: "+e); SQLObject o = e.getSQLSource(); SQLObject[] c = e.getChildren(); for (int i = 0; i < c.length; i++) { if (c[i] instanceof SQLTable) { c[i].addSQLObjectListener(this); } } firePropertyChange("model.children", null, null); revalidate(); }
c[i].removeSQLObjectListener(this);
public void dbChildrenRemoved(SQLObjectEvent e) { logger.debug("SQLObject children got removed: "+e); SQLObject o = e.getSQLSource(); SQLObject[] c = e.getChildren(); for (int i = 0; i < c.length; i++) { if (c[i] instanceof SQLTable) { c[i].removeSQLObjectListener(this); for (int j = 0; j < getComponentCount(); j++) { TablePane tp = (TablePane) getComponent(j); if (tp.getModel() == c[i]) { remove(j); } } } } firePropertyChange("model.children", null, null); repaint(); }
firePropertyChange("model.children", null, null); repaint();
if (fireEvent) { firePropertyChange("model.children", null, null); repaint(); }
public void dbChildrenRemoved(SQLObjectEvent e) { logger.debug("SQLObject children got removed: "+e); SQLObject o = e.getSQLSource(); SQLObject[] c = e.getChildren(); for (int i = 0; i < c.length; i++) { if (c[i] instanceof SQLTable) { c[i].removeSQLObjectListener(this); for (int j = 0; j < getComponentCount(); j++) { TablePane tp = (TablePane) getComponent(j); if (tp.getModel() == c[i]) { remove(j); } } } } firePropertyChange("model.children", null, null); repaint(); }
if ( context.getTagLibrary(libraryURI) == null ) {
if ( ! context.isTagLibraryRegistered(libraryURI) ) {
protected void configure() { // load the properties file of libraries available InputStream in = null; URL url = getClassLoader().getResource("org/apache/commons/jelly/jelly.properties"); if (url != null) { log.debug("Loading Jelly default tag libraries from: " + url); Properties properties = new Properties(); try { in = url.openStream(); properties.load(in); for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String uri = (String) entry.getKey(); String className = (String) entry.getValue(); String libraryURI = "jelly:" + uri; // don't overload any Mock Tags already if ( context.getTagLibrary(libraryURI) == null ) { context.registerTagLibrary(libraryURI, className); } } } catch (IOException e) { log.error("Could not load jelly properties from: " + url + ". Reason: " + e, e); } finally { try { in.close(); } catch (Exception e) { // ignore } } } }
public ExpressionScript(Expression expression) { this.expression = expression;
public ExpressionScript() {
public ExpressionScript(Expression expression) { this.expression = expression; }
public ConstantExpression(Object value) { this.value = value;
public ConstantExpression() {
public ConstantExpression(Object value) { this.value = value; }
public StaticTagScript(TagFactory tagFactory) { super(tagFactory);
public StaticTagScript() {
public StaticTagScript(TagFactory tagFactory) { super(tagFactory); }
if (this.counts[0][0] >= this.counts[0][1]){
if (this.counts[0][0] > this.counts[0][1]){
public String getOverTransmittedAllele(int type) { String[] alleleCodes = new String[5]; alleleCodes[0] = "X"; alleleCodes[1] = "A"; alleleCodes[2] = "C"; alleleCodes[3] = "G"; alleleCodes[4] = "T"; String retStr; if (this.counts[0][0] >= this.counts[0][1]){ retStr = alleleCodes[allele1]; }else{ retStr = alleleCodes[allele2]; } if (type != 1){ if (this.counts[1][0] >= this.counts[1][1]){ retStr += (", " + alleleCodes[allele1]); }else{ retStr += (", " + alleleCodes[allele2]); } } return retStr; }
if (this.counts[1][0] >= this.counts[1][1]){
if (this.counts[1][0] > this.counts[1][1]){
public String getOverTransmittedAllele(int type) { String[] alleleCodes = new String[5]; alleleCodes[0] = "X"; alleleCodes[1] = "A"; alleleCodes[2] = "C"; alleleCodes[3] = "G"; alleleCodes[4] = "T"; String retStr; if (this.counts[0][0] >= this.counts[0][1]){ retStr = alleleCodes[allele1]; }else{ retStr = alleleCodes[allele2]; } if (type != 1){ if (this.counts[1][0] >= this.counts[1][1]){ retStr += (", " + alleleCodes[allele1]); }else{ retStr += (", " + alleleCodes[allele2]); } } return retStr; }
}else if (this.counts[1][0] == this.counts[1][1]){ retStr += ", -";
public String getOverTransmittedAllele(int type) { String[] alleleCodes = new String[5]; alleleCodes[0] = "X"; alleleCodes[1] = "A"; alleleCodes[2] = "C"; alleleCodes[3] = "G"; alleleCodes[4] = "T"; String retStr; if (this.counts[0][0] >= this.counts[0][1]){ retStr = alleleCodes[allele1]; }else{ retStr = alleleCodes[allele2]; } if (type != 1){ if (this.counts[1][0] >= this.counts[1][1]){ retStr += (", " + alleleCodes[allele1]); }else{ retStr += (", " + alleleCodes[allele2]); } } return retStr; }
"-o <GAB,GAM,SPI,ALL> output type. Gabriel, 4 gamete, spine output or all 3. default is SFS.\n" +
"-o <GAB,GAM,SPI,ALL> output type. Gabriel, 4 gamete, spine output or all 3. default is Gabriel.\n" +
private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; String hapmapFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; boolean outputCheck=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println("HaploView command line options\n" + "-h, -help print this message\n" + "-n command line output only\n" + "-q quiet mode- doesnt print any warnings or information to screen\n" + "-p <pedfile> specify an input file in pedigree file format\n" + " pedfile specific options (nogui mode only): \n" + " --showcheck displays the results of the various pedigree integrity checks\n" + " --skipcheck skips the various pedfile checks\n" + //TODO: fix ignoremarkers //" --ignoremarkers <markers> ignores the specified markers.<markers> is a comma\n" + //" seperated list of markers. eg. 1,5,7,19,25\n" + "-a <hapmapfile> specify an input file in HapMap format\n" + "-l <hapsfile> specify an input file in .haps format\n" + "-i <infofile> specify a marker info file\n" + "-b <batchfile> batch mode. batchfile should contain a list of files either all genotype or alternating genotype/info\n" + "-d outputs dprime to <inputfile>.DPRIME\n" + "-c outputs marker checks to <inputfile>.CHECK\n" + " note: -d and -c default to no blocks output. use -o to also output blocks\n" + "-o <GAB,GAM,SPI,ALL> output type. Gabriel, 4 gamete, spine output or all 3. default is SFS.\n" + "-m <distance> maximum comparison distance in kilobases (integer). default is 500"); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha") || args[i].equals("-l")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equals("-a")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-a requires a filename"); System.exit(1); } else{ if(!hapmapFileName.equals("")){ System.out.println("multiple -a arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one -o argument is allowed"); System.exit(1); } if(args[i].equals("SFS") || args[i].equals("GAB")){ outputType = BLOX_GABRIEL; } else if(args[i].equals("GAM")){ outputType = BLOX_4GAM; } else if(args[i].equals("MJD") || args[i].equals("SPI")){ outputType = BLOX_SPINE; } else if(args[i].equals("ALL")) { outputType = BLOX_ALL; } } else { //defaults to SFS output outputType = BLOX_GABRIEL; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = true; } else if (args[i].equals("-c")){ outputCheck = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("")) && !outputDprime && !outputCheck) { outputType = BLOX_GABRIEL; if(nogui && !quietMode) { System.out.println("No output type specified. Default of SFS will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_hapmapfile = hapmapFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; arg_check = outputCheck; }
if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("")) && !outputDprime && !outputCheck) {
if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("") || !hapmapFileName.equals("")) && !outputDprime && !outputCheck) {
private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; String hapmapFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; boolean outputCheck=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println("HaploView command line options\n" + "-h, -help print this message\n" + "-n command line output only\n" + "-q quiet mode- doesnt print any warnings or information to screen\n" + "-p <pedfile> specify an input file in pedigree file format\n" + " pedfile specific options (nogui mode only): \n" + " --showcheck displays the results of the various pedigree integrity checks\n" + " --skipcheck skips the various pedfile checks\n" + //TODO: fix ignoremarkers //" --ignoremarkers <markers> ignores the specified markers.<markers> is a comma\n" + //" seperated list of markers. eg. 1,5,7,19,25\n" + "-a <hapmapfile> specify an input file in HapMap format\n" + "-l <hapsfile> specify an input file in .haps format\n" + "-i <infofile> specify a marker info file\n" + "-b <batchfile> batch mode. batchfile should contain a list of files either all genotype or alternating genotype/info\n" + "-d outputs dprime to <inputfile>.DPRIME\n" + "-c outputs marker checks to <inputfile>.CHECK\n" + " note: -d and -c default to no blocks output. use -o to also output blocks\n" + "-o <GAB,GAM,SPI,ALL> output type. Gabriel, 4 gamete, spine output or all 3. default is SFS.\n" + "-m <distance> maximum comparison distance in kilobases (integer). default is 500"); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha") || args[i].equals("-l")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equals("-a")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-a requires a filename"); System.exit(1); } else{ if(!hapmapFileName.equals("")){ System.out.println("multiple -a arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one -o argument is allowed"); System.exit(1); } if(args[i].equals("SFS") || args[i].equals("GAB")){ outputType = BLOX_GABRIEL; } else if(args[i].equals("GAM")){ outputType = BLOX_4GAM; } else if(args[i].equals("MJD") || args[i].equals("SPI")){ outputType = BLOX_SPINE; } else if(args[i].equals("ALL")) { outputType = BLOX_ALL; } } else { //defaults to SFS output outputType = BLOX_GABRIEL; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = true; } else if (args[i].equals("-c")){ outputCheck = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("")) && !outputDprime && !outputCheck) { outputType = BLOX_GABRIEL; if(nogui && !quietMode) { System.out.println("No output type specified. Default of SFS will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_hapmapfile = hapmapFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; arg_check = outputCheck; }
System.out.println(dPrimeTable.length);
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); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); 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.size()-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.size(); i++) { double pos = (Chromosome.getMarker(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.getMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { //TODO: fix bug with loading datasets with data and then without int thiswide = metrics.stringWidth(Chromosome.getMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } //System.out.println(widest); g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(Chromosome.getMarker(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(); System.out.println(dPrimeTable.length); 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; } //TODO:if you load data then info it doesn't handle selective drawing correctly 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); } } } } if (pref.getWidth() > visRect.width){ if (noImage){ //first time through draw a worldmap if dataset is big: final int WM_MAX_WIDTH = 300; int scalefactor; if (2*dPrimeTable.length < WM_MAX_WIDTH){ scalefactor = chartSize.width/(2*(dPrimeTable.length-1)); } else { scalefactor = chartSize.width/WM_MAX_WIDTH; } CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); worldmap = new BufferedImage(chartSize.width/scalefactor+wmBorder.getBorderInsets(this).left*2, chartSize.height/scalefactor+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); gw.setColor(this.getBackground()); gw.fillRect(1,1,worldmap.getWidth()-2,worldmap.getHeight()-2); //make a pretty border gw.setColor(Color.BLACK); wmBorder.paintBorder(this,gw,0,0,worldmap.getWidth()-1,worldmap.getHeight()-1); ir = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth()-1, worldmap.getHeight()-1); int prefBoxSize = ((worldmap.getWidth())/dPrimeTable.length-1); if (prefBoxSize < 1){ prefBoxSize=1; } for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } int xx = (x + y)+wmBorder.getBorderInsets(this).left;// * boxSize / 2; int yy = (y - x)+wmBorder.getBorderInsets(this).top;// * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - 1; diamondX[1] = xx + 1; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + 1; diamondX[3] = xx - 1; diamondY[3] = yy; gw.setColor(dPrimeTable[x][y].getColor()); gw.fillPolygon(new Polygon(diamondX, diamondY,4)); /*gw.fillRect(xx+wmBorder.getBorderInsets(this).left, yy+wmBorder.getBorderInsets(this).top,3,3);//prefBoxSize,prefBoxSize);*/ } } noImage = false; } paintWorldMap(g); } }
public void setModel( Object model ) { setModel( model, false );
public void setModel( Object model, boolean preserveState ) { Object[] modelArr = new Object[1]; modelArr[0] = model; setModel( modelArr, preserveState );
public void setModel( Object model ) { setModel( model, false ); }
if(dataType.isAssignableFrom(attrInfoType)){
if(attrInfoType != null && dataType.isAssignableFrom(attrInfoType)){
private boolean checkAttributeDataType(ObjectAttributeInfo[] objAttrInfo, String[] dataTypes, ApplicationConfig appConfig, List attributesList){ boolean result = false; outerloop: for(int i=0; i<objAttrInfo.length;i++){ ObjectAttributeInfo attrInfo = objAttrInfo[i]; for(int j=0; j<dataTypes.length; j++){ Class attrInfoType = getClass(attrInfo.getType(), appConfig.getModuleClassLoader()); Class dataType = getClass(dataTypes[j], this.getClass().getClassLoader()); if(dataType.isAssignableFrom(attrInfoType)){ result = true; if(attributesList != null){ attributesList.add(attrInfo); }else{ break outerloop; } } } } return result; }
throw new RuntimeException(e);
logger.fine("Error finding class of type=" + type + ", error=" + e.getMessage());
private Class getClass(String type, ClassLoader classLoader){ if(type.equals("boolean")) return Boolean.class; if(type.equals("byte")) return Byte.TYPE; if(type.equals("char")) return Character.class; if(type.equals("double")) return Double.class; if(type.equals("float")) return Float.class; if(type.equals("int")) return Integer.class; if(type.equals("long")) return Long.class; if(type.equals("short")) return Short.class; if(type.equals("void")) return Void.class; Class clazz = null; try{ clazz = Class.forName(type, true, classLoader); }catch(ClassNotFoundException e){ throw new RuntimeException(e); } return clazz; }
ObjectInfo objInfo = serverConnection.getObjectInfo(objName); ObjectAttributeInfo[] objAttrInfo = objInfo.getAttributes(); if(objAttrInfo!=null && objAttrInfo.length > 0){ if(dataTypes!=null && dataTypes.length > 0){ if(checkAttributeDataType(objAttrInfo, dataTypes, context.getApplicationConfig(), null)){
try { ObjectInfo objInfo = serverConnection.getObjectInfo(objName); ObjectAttributeInfo[] objAttrInfo = objInfo.getAttributes(); if(objAttrInfo!=null && objAttrInfo.length > 0){ if(dataTypes!=null && dataTypes.length > 0){ if(checkAttributeDataType(objAttrInfo, dataTypes, context.getApplicationConfig(), null)){ mbeanToAttributesList.add(mbeanData); } }else{
private List queryMBeansWithAttributes(ServiceContext context, String filter, String[] dataTypes) throws ServiceException{ ServerConnection serverConnection = context.getServerConnection(); List mbeans = queryMBeans(context, filter); List mbeanToAttributesList = new ArrayList(); for(Iterator itr=mbeans.iterator(); itr.hasNext();){ MBeanData mbeanData = (MBeanData)itr.next(); ObjectName objName = new ObjectName(mbeanData.getName()); ObjectInfo objInfo = serverConnection.getObjectInfo(objName); ObjectAttributeInfo[] objAttrInfo = objInfo.getAttributes(); if(objAttrInfo!=null && objAttrInfo.length > 0){ if(dataTypes!=null && dataTypes.length > 0){ if(checkAttributeDataType(objAttrInfo, dataTypes, context.getApplicationConfig(), null)){ mbeanToAttributesList.add(mbeanData); } }else{ mbeanToAttributesList.add(mbeanData); } } } return mbeanToAttributesList; }
}else{ mbeanToAttributesList.add(mbeanData);
private List queryMBeansWithAttributes(ServiceContext context, String filter, String[] dataTypes) throws ServiceException{ ServerConnection serverConnection = context.getServerConnection(); List mbeans = queryMBeans(context, filter); List mbeanToAttributesList = new ArrayList(); for(Iterator itr=mbeans.iterator(); itr.hasNext();){ MBeanData mbeanData = (MBeanData)itr.next(); ObjectName objName = new ObjectName(mbeanData.getName()); ObjectInfo objInfo = serverConnection.getObjectInfo(objName); ObjectAttributeInfo[] objAttrInfo = objInfo.getAttributes(); if(objAttrInfo!=null && objAttrInfo.length > 0){ if(dataTypes!=null && dataTypes.length > 0){ if(checkAttributeDataType(objAttrInfo, dataTypes, context.getApplicationConfig(), null)){ mbeanToAttributesList.add(mbeanData); } }else{ mbeanToAttributesList.add(mbeanData); } } } return mbeanToAttributesList; }
} catch (Exception e) { String errorMessage = "Error getting ObjectInfo for: " + objName + ", error=" + e.getMessage(); logger.log(Level.WARNING, errorMessage); logger.log(Level.FINE, errorMessage, e);
private List queryMBeansWithAttributes(ServiceContext context, String filter, String[] dataTypes) throws ServiceException{ ServerConnection serverConnection = context.getServerConnection(); List mbeans = queryMBeans(context, filter); List mbeanToAttributesList = new ArrayList(); for(Iterator itr=mbeans.iterator(); itr.hasNext();){ MBeanData mbeanData = (MBeanData)itr.next(); ObjectName objName = new ObjectName(mbeanData.getName()); ObjectInfo objInfo = serverConnection.getObjectInfo(objName); ObjectAttributeInfo[] objAttrInfo = objInfo.getAttributes(); if(objAttrInfo!=null && objAttrInfo.length > 0){ if(dataTypes!=null && dataTypes.length > 0){ if(checkAttributeDataType(objAttrInfo, dataTypes, context.getApplicationConfig(), null)){ mbeanToAttributesList.add(mbeanData); } }else{ mbeanToAttributesList.add(mbeanData); } } } return mbeanToAttributesList; }
ObjectInfo objInfo = serverConnection.getObjectInfo(objName); ObjectNotificationInfo[] notifications = objInfo.getNotifications(); if(notifications != null && notifications.length > 0){ mbeanToNoficationsMap.put(objName.getCanonicalName(), notifications);
try { ObjectInfo objInfo = serverConnection.getObjectInfo(objName); ObjectNotificationInfo[] notifications = objInfo.getNotifications(); if(notifications != null && notifications.length > 0){ mbeanToNoficationsMap.put(objName.getCanonicalName(), notifications); } } catch (Exception e) { String errorMessage = "Error getting ObjectInfo for: " + objName + ", error=" + e.getMessage(); logger.log(Level.WARNING, errorMessage); logger.log(Level.FINE, errorMessage, e);
public Map queryMBeansWithNotifications(ServiceContext context) throws ServiceException { ServerConnection serverConnection = context.getServerConnection(); Set mbeans = serverConnection.queryNames(DEFAULT_FILTER_OBJECT_NAME); Map mbeanToNoficationsMap = new TreeMap(); for(Iterator it=mbeans.iterator(); it.hasNext(); ){ ObjectName objName = (ObjectName)it.next(); ObjectInfo objInfo = serverConnection.getObjectInfo(objName); ObjectNotificationInfo[] notifications = objInfo.getNotifications(); if(notifications != null && notifications.length > 0){ mbeanToNoficationsMap.put(objName.getCanonicalName(), notifications); } } return mbeanToNoficationsMap; }
logger.warn("NOT Adding duplicate listener "+l+" to SQLObject "+this);
if (logger.isDebugEnabled()) { logger.debug("NOT Adding duplicate listener "+l+" to SQLObject "+this); }
public void addSQLObjectListener(SQLObjectListener l) { if (getSQLObjectListeners().contains(l)) { logger.warn("NOT Adding duplicate listener "+l+" to SQLObject "+this); return; } getSQLObjectListeners().add(l); }
public Object createNestedObject(String name) throws Exception {
public Object createNestedObject(Object object, String name) throws Exception {
public Object createNestedObject(String name) throws Exception { Object dataType = null; Object object = getObject(); 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; }
Object object = getObject();
public Object createNestedObject(String name) throws Exception { Object dataType = null; Object object = getObject(); 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; }
Object nested = null; Object parentObject = null;
public void doTag(XMLOutput output) throws Exception { Project project = getAntProject(); String tagName = getTagName(); if ( project.getTaskDefinitions().containsKey( tagName ) ) { // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { String text = getBodyText(); Object[] args = { text }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { // System.err.println( "Setting datatype/nested object of name: " + tagName ); // must be a datatype. AntTag ancestor = (AntTag) findAncestorWithClass( AntTag.class ); Object nested = null; if ( ancestor != null ) { nested = ancestor.createNestedObject( tagName ); } else { // System.err.println( "No ancestor" ); AntTagSupport ancestorToo = (AntTagSupport) findAncestorWithClass( AntTagSupport.class ); if ( ancestorToo != null ) { nested = ancestorToo.createNestedObject( tagName ); } } if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( ancestor != null ) { Object parentObj = ancestor.getObject(); if ( parentObj != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObj.getClass() ); try { ih.storeElement( project, parentObj, nested, tagName ); } catch (Exception e) { //log.warn( "Caught exception setting nested: " + tagName, e ); } } } } }
AntTag ancestor = (AntTag) findAncestorWithClass( AntTag.class ); Object nested = null;
TaskSource ancestor = (TaskSource) findAncestorWithClass( TaskSource.class );
public void doTag(XMLOutput output) throws Exception { Project project = getAntProject(); String tagName = getTagName(); if ( project.getTaskDefinitions().containsKey( tagName ) ) { // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { String text = getBodyText(); Object[] args = { text }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { // System.err.println( "Setting datatype/nested object of name: " + tagName ); // must be a datatype. AntTag ancestor = (AntTag) findAncestorWithClass( AntTag.class ); Object nested = null; if ( ancestor != null ) { nested = ancestor.createNestedObject( tagName ); } else { // System.err.println( "No ancestor" ); AntTagSupport ancestorToo = (AntTagSupport) findAncestorWithClass( AntTagSupport.class ); if ( ancestorToo != null ) { nested = ancestorToo.createNestedObject( tagName ); } } if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( ancestor != null ) { Object parentObj = ancestor.getObject(); if ( parentObj != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObj.getClass() ); try { ih.storeElement( project, parentObj, nested, tagName ); } catch (Exception e) { //log.warn( "Caught exception setting nested: " + tagName, e ); } } } } }
nested = ancestor.createNestedObject( tagName ); } else { AntTagSupport ancestorToo = (AntTagSupport) findAncestorWithClass( AntTagSupport.class ); if ( ancestorToo != null ) { nested = ancestorToo.createNestedObject( tagName ); }
parentObject = ancestor.getTaskObject(); nested = createNestedObject( parentObject, tagName );
public void doTag(XMLOutput output) throws Exception { Project project = getAntProject(); String tagName = getTagName(); if ( project.getTaskDefinitions().containsKey( tagName ) ) { // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { String text = getBodyText(); Object[] args = { text }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { // System.err.println( "Setting datatype/nested object of name: " + tagName ); // must be a datatype. AntTag ancestor = (AntTag) findAncestorWithClass( AntTag.class ); Object nested = null; if ( ancestor != null ) { nested = ancestor.createNestedObject( tagName ); } else { // System.err.println( "No ancestor" ); AntTagSupport ancestorToo = (AntTagSupport) findAncestorWithClass( AntTagSupport.class ); if ( ancestorToo != null ) { nested = ancestorToo.createNestedObject( tagName ); } } if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( ancestor != null ) { Object parentObj = ancestor.getObject(); if ( parentObj != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObj.getClass() ); try { ih.storeElement( project, parentObj, nested, tagName ); } catch (Exception e) { //log.warn( "Caught exception setting nested: " + tagName, e ); } } } } }
if ( ancestor != null ) { Object parentObj = ancestor.getObject(); if ( parentObj != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObj.getClass() ); try { ih.storeElement( project, parentObj, nested, tagName ); } catch (Exception e) { }
if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) {
public void doTag(XMLOutput output) throws Exception { Project project = getAntProject(); String tagName = getTagName(); if ( project.getTaskDefinitions().containsKey( tagName ) ) { // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { String text = getBodyText(); Object[] args = { text }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { // System.err.println( "Setting datatype/nested object of name: " + tagName ); // must be a datatype. AntTag ancestor = (AntTag) findAncestorWithClass( AntTag.class ); Object nested = null; if ( ancestor != null ) { nested = ancestor.createNestedObject( tagName ); } else { // System.err.println( "No ancestor" ); AntTagSupport ancestorToo = (AntTagSupport) findAncestorWithClass( AntTagSupport.class ); if ( ancestorToo != null ) { nested = ancestorToo.createNestedObject( tagName ); } } if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( ancestor != null ) { Object parentObj = ancestor.getObject(); if ( parentObj != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObj.getClass() ); try { ih.storeElement( project, parentObj, nested, tagName ); } catch (Exception e) { //log.warn( "Caught exception setting nested: " + tagName, e ); } } } } }
Object object = getObject();
Object object = getTaskObject();
public void setBeanProperties() throws Exception { Object object = getObject(); if ( object != null ) { Map map = getAttributes(); for ( Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); setBeanProperty( object, name, value ); } } }
if ( log.isDebugEnabled() ) { log.debug( "Setting bean property on: "+ object + " name: " + name + " value: " + value ); }
public void setBeanProperty(Object object, String name, Object value) throws Exception { // System.err.println( "Setting bean property on: "+ object + " name: " + name + " value: " + value ); IntrospectionHelper ih = IntrospectionHelper.getHelper( object.getClass() ); if ( value instanceof String ) { try { ih.setAttribute( getAntProject(), object, name.toLowerCase(), (String) value ); return; } catch (Exception e) { log.error( "Caught: " + e, e ); } } try { ih.storeElement( getAntProject(), object, value, name ); } catch (Exception e) { // let any exceptions bubble up from here BeanUtils.setProperty( object, name, value ); } }
repaint();
public void setRotation( double newRot ) { imgRot = newRot; xformImage = null; revalidate(); }
repaint();
public void setScale( float newValue ) { imgScale = newValue; xformImage = null; fitSize = false; revalidate(); }
if (attributeName.equals( "value" ) || attributeName.equals( "items" ) || attributeName.equals( "test" ) ) { return factory.createExpression( attributeValue );
ExpressionFactory myFactory = getExpressionFactory(); if ( myFactory == null ) { myFactory = factory; } if ( myFactory != null ) { if (attributeName.equals( "value" ) || attributeName.equals( "items" ) || attributeName.equals( "test" ) ) { return myFactory.createExpression( attributeValue ); }
public Expression createExpression(ExpressionFactory factory, String tagName, String attributeName, String attributeValue) throws Exception { if (attributeName.equals( "value" ) || attributeName.equals( "items" ) || attributeName.equals( "test" ) ) { return factory.createExpression( attributeValue ); } // will use the default expression instead return null; }
assert parameterTypes.length > 0 && (ServiceContext.class.isAssignableFrom(parameterTypes[0])) : "Invalid service method. First argument must be ServiceContext";
private static Vector getClassNames(Method method){ Class[] parameterTypes = method.getParameterTypes(); Vector vector = new Vector(parameterTypes.length); for(int i=0; i<parameterTypes.length; i++){ vector.add(parameterTypes[i].getName()); } return vector; }
public static Object unmarshal(Class clazz, String str){
public static Object unmarshal(String className, String str){
public static Object unmarshal(Class clazz, String str){ try { return org.exolab.castor.xml.Unmarshaller.unmarshal(clazz, new StringReader(str)); } catch (Exception e) { throw new RuntimeException("Error while unmarshalling obj of type:" + clazz.getName(), e); } }
return org.exolab.castor.xml.Unmarshaller.unmarshal(clazz, new StringReader(str)); } catch (Exception e) { throw new RuntimeException("Error while unmarshalling obj of type:" + clazz.getName(), e);
return unmarshal(Class.forName(className), str); } catch (ClassNotFoundException e) { throw new RuntimeException(e);
public static Object unmarshal(Class clazz, String str){ try { return org.exolab.castor.xml.Unmarshaller.unmarshal(clazz, new StringReader(str)); } catch (Exception e) { throw new RuntimeException("Error while unmarshalling obj of type:" + clazz.getName(), e); } }
StringWriter writer = new StringWriter(); try { org.exolab.castor.xml.Marshaller marshaller = new org.exolab.castor.xml.Marshaller(writer); marshaller.setRootElement("marshalledObject"); marshaller.setMarshalAsDocument(false); marshaller.setSuppressXSIType(true); marshaller.marshal(obj); } catch (Exception e) { throw new RuntimeException("Error while marshalling obj of type:" + obj.getClass().getName(), e);
String output; if(obj == null){ output = ""; }else if(obj.getClass().getName().startsWith("java.lang")){ output = obj.toString(); }else{ output = marshalToXml(obj);
public static String marshal(Object obj){ StringWriter writer = new StringWriter(); try { org.exolab.castor.xml.Marshaller marshaller = new org.exolab.castor.xml.Marshaller(writer); marshaller.setRootElement("marshalledObject"); marshaller.setMarshalAsDocument(false); marshaller.setSuppressXSIType(true); marshaller.marshal(obj); } catch (Exception e) { throw new RuntimeException("Error while marshalling obj of type:" + obj.getClass().getName(), e); } return writer.toString(); }
return writer.toString();
logger.fine("Marshalled value: " + output); return output;
public static String marshal(Object obj){ StringWriter writer = new StringWriter(); try { org.exolab.castor.xml.Marshaller marshaller = new org.exolab.castor.xml.Marshaller(writer); marshaller.setRootElement("marshalledObject"); marshaller.setMarshalAsDocument(false); marshaller.setSuppressXSIType(true); marshaller.marshal(obj); } catch (Exception e) { throw new RuntimeException("Error while marshalling obj of type:" + obj.getClass().getName(), e); } return writer.toString(); }
logger.debug("MetaData class is: " + dbmd.getClass().getName());
public synchronized void populate() throws ArchitectException { if (populated) return; int oldSize = children.size(); Connection con = null; ResultSet rs = null; try { con = getConnection(); DatabaseMetaData dbmd = con.getMetaData(); logger.debug("MetaData class is: " + dbmd.getClass().getName()); rs = dbmd.getCatalogs(); while (rs.next()) { String catName = rs.getString(1); SQLCatalog cat = null; if (catName != null) { cat = new SQLCatalog(this, catName); cat.setNativeTerm(dbmd.getCatalogTerm()); logger.debug("Set catalog term to "+cat.getNativeTerm()); children.add(cat); } } // if we tried to get Catalogs, and there were none, then I guess // we should look for Schemas instead (i.e. this database has no // catalogs, and schemas attached directly to the database) if ( children.size() == oldSize ) { rs = dbmd.getSchemas(); while (rs.next()) { children.add(new SQLSchema(this, rs.getString(1),false)); } } } catch (SQLException e) { throw new ArchitectException("database.populate.fail", e); } finally { populated = true; int newSize = children.size(); if (newSize > oldSize) { int[] changedIndices = new int[newSize - oldSize]; for (int i = 0, n = newSize - oldSize; i < n; i++) { changedIndices[i] = oldSize + i; } fireDbChildrenInserted(changedIndices, children.subList(oldSize, newSize)); } try { if ( rs != null ) rs.close(); } catch (SQLException e2) { throw new ArchitectException("database.rs.close.fail", e2); } } }
rs.close(); rs = null;
public synchronized void populate() throws ArchitectException { if (populated) return; int oldSize = children.size(); Connection con = null; ResultSet rs = null; try { con = getConnection(); DatabaseMetaData dbmd = con.getMetaData(); logger.debug("MetaData class is: " + dbmd.getClass().getName()); rs = dbmd.getCatalogs(); while (rs.next()) { String catName = rs.getString(1); SQLCatalog cat = null; if (catName != null) { cat = new SQLCatalog(this, catName); cat.setNativeTerm(dbmd.getCatalogTerm()); logger.debug("Set catalog term to "+cat.getNativeTerm()); children.add(cat); } } // if we tried to get Catalogs, and there were none, then I guess // we should look for Schemas instead (i.e. this database has no // catalogs, and schemas attached directly to the database) if ( children.size() == oldSize ) { rs = dbmd.getSchemas(); while (rs.next()) { children.add(new SQLSchema(this, rs.getString(1),false)); } } } catch (SQLException e) { throw new ArchitectException("database.populate.fail", e); } finally { populated = true; int newSize = children.size(); if (newSize > oldSize) { int[] changedIndices = new int[newSize - oldSize]; for (int i = 0, n = newSize - oldSize; i < n; i++) { changedIndices[i] = oldSize + i; } fireDbChildrenInserted(changedIndices, children.subList(oldSize, newSize)); } try { if ( rs != null ) rs.close(); } catch (SQLException e2) { throw new ArchitectException("database.rs.close.fail", e2); } } }
System.out.println(totalComps);
void generateDPrimeTable(long maxdist){ //calculating D prime requires the number of each possible 2 marker //haplotype in the dataset dPrimeTable = new PairwiseLinkage[Chromosome.getSize()][Chromosome.getSize()]; int doublehet; long negMaxdist = -1*maxdist; int[][] twoMarkerHaplos = new int[3][3]; totalComps = (Chromosome.getSize()*(Chromosome.getSize()-1))/2; System.out.println(totalComps); compsDone =0; //loop through all marker pairs for (int pos2 = 1; pos2 < dPrimeTable.length; pos2++){ //clear the array for (int pos1 = 0; pos1 < pos2; pos1++){ compsDone++; long sep = Chromosome.getMarker(pos1).getPosition() - Chromosome.getMarker(pos2).getPosition(); if (maxdist > 0){ if ((sep > maxdist || sep < negMaxdist)){ dPrimeTable[pos1][pos2] = null; continue; } } for (int i = 0; i < twoMarkerHaplos.length; i++){ for (int j = 0; j < twoMarkerHaplos[i].length; j++){ twoMarkerHaplos[i][j] = 0; } } doublehet = 0; //get the alleles for the markers int m1a1 = 0; int m1a2 = 0; int m2a1 = 0; int m2a2 = 0; int m1H = 0; int m2H = 0; for (int i = 0; i < chromosomes.size(); i++){ byte a1 = ((Chromosome) chromosomes.elementAt(i)).getGenotype(pos1); byte a2 = ((Chromosome) chromosomes.elementAt(i)).getGenotype(pos2); if (m1a1 > 0){ if (m1a2 == 0 && !(a1 == 5) && !(a1 == 0) && a1 != m1a1) m1a2 = a1; } else if (!(a1 == 5) && !(a1 == 0)) m1a1=a1; if (m2a1 > 0){ if (m2a2 == 0 && !(a2 == 5) && !(a2 == 0) && a2 != m2a1) m2a2 = a2; } else if (!(a2 == 5) && !(a2 == 0)) m2a1=a2; if (a1 == 5) m1H++; if (a2 == 5) m2H++; } //check for non-polymorphic markers if (m1a2==0){ if (m1H==0){ dPrimeTable[pos1][pos2] = null;//new PairwiseLinkage(0,0,0,0,0,nullArray); continue; } else { if (m1a1 == 1){ m1a2=2; } else { m1a2 = 1; } } } if (m2a2==0){ if (m2H==0){ dPrimeTable[pos1][pos2] = null;//new PairwiseLinkage(0,0,0,0,0,nullArray); continue; } else { if (m2a1 == 1){ m2a2=2; } else { m2a2 = 1; } } } int[] marker1num = new int[5]; int[] marker2num = new int[5]; marker1num[0]=0; marker1num[m1a1]=1; marker1num[m1a2]=2; marker2num[0]=0; marker2num[m2a1]=1; marker2num[m2a2]=2; //iterate through all chromosomes in dataset for (int i = 0; i < chromosomes.size(); i++){ //System.out.println(i + " " + pos1 + " " + pos2); //assign alleles for each of a pair of chromosomes at a marker to four variables byte a1 = ((Chromosome) chromosomes.elementAt(i)).getGenotype(pos1); byte a2 = ((Chromosome) chromosomes.elementAt(i)).getGenotype(pos2); byte b1 = ((Chromosome) chromosomes.elementAt(++i)).getGenotype(pos1); byte b2 = ((Chromosome) chromosomes.elementAt(i)).getGenotype(pos2); if (a1 == 0 || a2 == 0 || b1 == 0 || b2 == 0){ //skip missing data } else if ((a1 == 5 && a2 == 5) || (a1 == 5 && !(a2 == b2)) || (a2 == 5 && !(a1 == b1))) doublehet++; //find doublehets and resolved haplotypes else if (a1 == 5){ twoMarkerHaplos[1][marker2num[a2]]++; twoMarkerHaplos[2][marker2num[a2]]++; } else if (a2 == 5){ twoMarkerHaplos[marker1num[a1]][1]++; twoMarkerHaplos[marker1num[a1]][2]++; } else { twoMarkerHaplos[marker1num[a1]][marker2num[a2]]++; twoMarkerHaplos[marker1num[b1]][marker2num[b2]]++; } } //another monomorphic marker check int r1, r2, c1, c2; r1 = twoMarkerHaplos[1][1] + twoMarkerHaplos[1][2]; r2 = twoMarkerHaplos[2][1] + twoMarkerHaplos[2][2]; c1 = twoMarkerHaplos[1][1] + twoMarkerHaplos[2][1]; c2 = twoMarkerHaplos[1][2] + twoMarkerHaplos[2][2]; if ( (r1==0 || r2==0 || c1==0 || c2==0) && doublehet == 0){ dPrimeTable[pos1][pos2] = null;//new PairwiseLinkage(0,0,0,0,0,nullArray); continue; } //compute D Prime for this pair of markers. //return is a tab delimited string of d', lod, r^2, CI(low), CI(high) dPrimeTable[pos1][pos2] = computeDPrime(twoMarkerHaplos[1][1], twoMarkerHaplos[1][2], twoMarkerHaplos[2][1], twoMarkerHaplos[2][2], doublehet, 0.1); this.realCompsDone++; } } }
dPrimeTable[pos1][pos2] = null;
dPrimeTable[pos1][pos2] = new PairwiseLinkage(1,0,0,0,0,new double[0]);
void generateDPrimeTable(long maxdist){ //calculating D prime requires the number of each possible 2 marker //haplotype in the dataset dPrimeTable = new PairwiseLinkage[Chromosome.getSize()][Chromosome.getSize()]; int doublehet; long negMaxdist = -1*maxdist; int[][] twoMarkerHaplos = new int[3][3]; totalComps = (Chromosome.getSize()*(Chromosome.getSize()-1))/2; System.out.println(totalComps); compsDone =0; //loop through all marker pairs for (int pos2 = 1; pos2 < dPrimeTable.length; pos2++){ //clear the array for (int pos1 = 0; pos1 < pos2; pos1++){ compsDone++; long sep = Chromosome.getMarker(pos1).getPosition() - Chromosome.getMarker(pos2).getPosition(); if (maxdist > 0){ if ((sep > maxdist || sep < negMaxdist)){ dPrimeTable[pos1][pos2] = null; continue; } } for (int i = 0; i < twoMarkerHaplos.length; i++){ for (int j = 0; j < twoMarkerHaplos[i].length; j++){ twoMarkerHaplos[i][j] = 0; } } doublehet = 0; //get the alleles for the markers int m1a1 = 0; int m1a2 = 0; int m2a1 = 0; int m2a2 = 0; int m1H = 0; int m2H = 0; for (int i = 0; i < chromosomes.size(); i++){ byte a1 = ((Chromosome) chromosomes.elementAt(i)).getGenotype(pos1); byte a2 = ((Chromosome) chromosomes.elementAt(i)).getGenotype(pos2); if (m1a1 > 0){ if (m1a2 == 0 && !(a1 == 5) && !(a1 == 0) && a1 != m1a1) m1a2 = a1; } else if (!(a1 == 5) && !(a1 == 0)) m1a1=a1; if (m2a1 > 0){ if (m2a2 == 0 && !(a2 == 5) && !(a2 == 0) && a2 != m2a1) m2a2 = a2; } else if (!(a2 == 5) && !(a2 == 0)) m2a1=a2; if (a1 == 5) m1H++; if (a2 == 5) m2H++; } //check for non-polymorphic markers if (m1a2==0){ if (m1H==0){ dPrimeTable[pos1][pos2] = null;//new PairwiseLinkage(0,0,0,0,0,nullArray); continue; } else { if (m1a1 == 1){ m1a2=2; } else { m1a2 = 1; } } } if (m2a2==0){ if (m2H==0){ dPrimeTable[pos1][pos2] = null;//new PairwiseLinkage(0,0,0,0,0,nullArray); continue; } else { if (m2a1 == 1){ m2a2=2; } else { m2a2 = 1; } } } int[] marker1num = new int[5]; int[] marker2num = new int[5]; marker1num[0]=0; marker1num[m1a1]=1; marker1num[m1a2]=2; marker2num[0]=0; marker2num[m2a1]=1; marker2num[m2a2]=2; //iterate through all chromosomes in dataset for (int i = 0; i < chromosomes.size(); i++){ //System.out.println(i + " " + pos1 + " " + pos2); //assign alleles for each of a pair of chromosomes at a marker to four variables byte a1 = ((Chromosome) chromosomes.elementAt(i)).getGenotype(pos1); byte a2 = ((Chromosome) chromosomes.elementAt(i)).getGenotype(pos2); byte b1 = ((Chromosome) chromosomes.elementAt(++i)).getGenotype(pos1); byte b2 = ((Chromosome) chromosomes.elementAt(i)).getGenotype(pos2); if (a1 == 0 || a2 == 0 || b1 == 0 || b2 == 0){ //skip missing data } else if ((a1 == 5 && a2 == 5) || (a1 == 5 && !(a2 == b2)) || (a2 == 5 && !(a1 == b1))) doublehet++; //find doublehets and resolved haplotypes else if (a1 == 5){ twoMarkerHaplos[1][marker2num[a2]]++; twoMarkerHaplos[2][marker2num[a2]]++; } else if (a2 == 5){ twoMarkerHaplos[marker1num[a1]][1]++; twoMarkerHaplos[marker1num[a1]][2]++; } else { twoMarkerHaplos[marker1num[a1]][marker2num[a2]]++; twoMarkerHaplos[marker1num[b1]][marker2num[b2]]++; } } //another monomorphic marker check int r1, r2, c1, c2; r1 = twoMarkerHaplos[1][1] + twoMarkerHaplos[1][2]; r2 = twoMarkerHaplos[2][1] + twoMarkerHaplos[2][2]; c1 = twoMarkerHaplos[1][1] + twoMarkerHaplos[2][1]; c2 = twoMarkerHaplos[1][2] + twoMarkerHaplos[2][2]; if ( (r1==0 || r2==0 || c1==0 || c2==0) && doublehet == 0){ dPrimeTable[pos1][pos2] = null;//new PairwiseLinkage(0,0,0,0,0,nullArray); continue; } //compute D Prime for this pair of markers. //return is a tab delimited string of d', lod, r^2, CI(low), CI(high) dPrimeTable[pos1][pos2] = computeDPrime(twoMarkerHaplos[1][1], twoMarkerHaplos[1][2], twoMarkerHaplos[2][1], twoMarkerHaplos[2][2], doublehet, 0.1); this.realCompsDone++; } } }
System.out.println("well, i made it this far");
Haplotype[][] generateHaplotypes(Vector blocks, int hapthresh) throws HaploViewException{ //TODO: output indiv hap estimates Haplotype[][] results = new Haplotype[blocks.size()][]; //String raw = new String(); //String currentLine; this.totalBlocks = blocks.size(); this.blocksDone = 0; System.out.println("well, i made it this far"); for (int k = 0; k < blocks.size(); k++){ this.blocksDone++; int[] theBlock = (int[])blocks.elementAt(k); int[] hetcount = new int[theBlock.length]; int[][] loc = new int[theBlock.length][5]; int[][] convert = new int[theBlock.length][5]; int[][] unconvert = new int[theBlock.length][5]; //int totalHaps = 0; //parse genotypes for unresolved heterozygotes for (int i = 0; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); for (int j = 0; j < theBlock.length; j++){ byte theGeno = thisChrom.getFilteredGenotype(theBlock[j]); if (theGeno == 5){ hetcount[j]++; } else { loc[j][theGeno]++; } } //totalHaps ++; } for (int j = 0; j < theBlock.length; j++){ int a = 1; for (int m = 1; m <= 4; m++){ if (loc[j][m] > 0){ convert[j][m]=a; unconvert[j][a]=m; loc[j][m]+=(hetcount[j]/2); a++; } else { convert[j][m] = 0; unconvert[j][a] = 8; } } if (unconvert[j][2] == 0) unconvert[j][2] = 8; } String hapstr = ""; Vector inputHaploVector = new Vector(); for (int i = 0; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); Chromosome nextChrom = (Chromosome)chromosomes.elementAt(++i); int missing=0; //int dhet=0; for (int j = 0; j < theBlock.length; j++){ byte theGeno = thisChrom.getFilteredGenotype(theBlock[j]); byte nextGeno = nextChrom.getFilteredGenotype(theBlock[j]); if(theGeno == 0 || nextGeno == 0) missing++; } if (! (missing > theBlock.length/2 || missing > missingLimit)){ for (int j = 0; j < theBlock.length; j++){ byte theGeno = thisChrom.getFilteredGenotype(theBlock[j]); if (theGeno == 5){ hapstr = hapstr + "h"; } else { hapstr = hapstr + convert[j][theGeno]; } } inputHaploVector.add(hapstr); hapstr = ""; for (int j = 0; j < theBlock.length; j++){ byte nextGeno = nextChrom.getFilteredGenotype(theBlock[j]); if (nextGeno == 5){ hapstr = hapstr + "h"; }else{ hapstr = hapstr + convert[j][nextGeno]; } } inputHaploVector.add(hapstr); hapstr = ""; } } String[] input_haplos = (String[])inputHaploVector.toArray(new String[0]); //break up large blocks if needed int[] block_size; if (theBlock.length < 9){ block_size = new int[1]; block_size[0] = theBlock.length; } else { //some base-8 arithmetic int ones = theBlock.length%8; int eights = (theBlock.length - ones)/8; if (ones == 0){ block_size = new int[eights]; for (int i = 0; i < eights; i++){ block_size[i]=8; } } else { block_size = new int[eights+1]; for (int i = 0; i < eights-1; i++){ block_size[i]=8; } block_size[eights-1] = (8+ones)/2; block_size[eights] = 8+ones-block_size[eights-1]; } } String EMreturn = new String(""); int[] num_haplos_present = new int[1]; Vector haplos_present = new Vector(); Vector haplo_freq = new Vector(); char[][] input_haplos2 = new char[input_haplos.length][]; for (int j = 0; j < input_haplos.length; j++){ input_haplos2[j] = input_haplos[j].toCharArray(); } //kirby patch EM theEM = new EM(); theEM.full_em_breakup(input_haplos2, 4, num_haplos_present, haplos_present, haplo_freq, block_size, 0); for (int j = 0; j < haplos_present.size(); j++){ EMreturn += (String)haplos_present.elementAt(j)+"\t"+(String)haplo_freq.elementAt(j)+"\t"; } StringTokenizer st = new StringTokenizer(EMreturn); int p = 0; Haplotype[] tempArray = new Haplotype[st.countTokens()/2]; while(st.hasMoreTokens()){ String aString = st.nextToken(); int[] genos = new int[aString.length()]; for (int j = 0; j < aString.length(); j++){ //System.out.println(j + " " + aString.length() + " " + k); genos[j] = unconvert[j][Integer.parseInt(aString.substring(j, j+1))]; } double tempPerc = Double.parseDouble(st.nextToken()); if (tempPerc*100 > hapthresh){ tempArray[p] = new Haplotype(genos, tempPerc, theBlock); p++; } } //make the results array only large enough to hold haps //which pass threshold above results[k] = new Haplotype[p]; for (int z = 0; z < p; z++){ results[k][z] = tempArray[z]; } } return results; }
request.setAttribute(RequestAttributes.NAV_CURRENT_PAGE, "Execute Operation");
public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception{ final ObjectName objectName = context.getObjectName(); /* get the information about the operation to be executed */ final String operationName = request.getParameter("operationName"); final int paramCount = Integer.parseInt(request.getParameter("paramCount")); String[] params = new String[paramCount]; String[] signature = new String[paramCount]; for(int paramIndex=0; paramIndex < paramCount; paramIndex ++){ params[paramIndex] = request.getParameter(operationName + paramIndex + "_value"); signature[paramIndex] = request.getParameter(operationName + paramIndex + "_type"); } MBeanService service = ServiceFactory.getMBeanService(); OperationResultData[] resultData = service.invoke(Utils.getServiceContext(context), operationName, params, signature); request.setAttribute("operationResultData", resultData); return mapping.findForward(Forwards.SUCCESS); }
return new ObjectName(objectNameString);
if(objectNameString != null){ return new ObjectName(objectNameString); }else{ return null; }
public ObjectName getObjectName() { try { final String objectNameString = request.getParameter(RequestParams.OBJECT_NAME); return new ObjectName(objectNameString); } catch (MalformedObjectNameException e) { throw new RuntimeException(e); } }
public Config(List<ApplicationConfig> applications, List<DashboardConfig> dashboards){
public Config(List<ApplicationConfig> applications){
public Config(List<ApplicationConfig> applications, List<DashboardConfig> dashboards){ this.applications = applications; this.dashboards = dashboards; }
this.dashboards = dashboards;
public Config(List<ApplicationConfig> applications, List<DashboardConfig> dashboards){ this.applications = applications; this.dashboards = dashboards; }
Utils.csvToStringArray(clusterForm.getSelectedChildApplications());
StringUtils.csvToStringArray(clusterForm.getSelectedChildApplications());
public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { ApplicationClusterForm clusterForm = (ApplicationClusterForm)actionForm; String[] childAppIds = Utils.csvToStringArray(clusterForm.getSelectedChildApplications()); /* build list of new child applications */ List newChildApplications = getNewChildApplications(childAppIds); String applicationId = clusterForm.getApplicationId(); if(applicationId != null){ /* update existing application */ ApplicationClusterConfig clusterConfig = (ApplicationClusterConfig) ApplicationConfigManager.getApplicationConfig(applicationId); assert clusterConfig != null; clusterConfig.setName(clusterForm.getName()); final List oldChildApplications = clusterConfig.getApplications(); /* add applications outside the cluster (applications that are no longer in the cluster) */ for(Iterator it=oldChildApplications.iterator();it.hasNext();){ ApplicationConfig appConfig = (ApplicationConfig)it.next(); if(!newChildApplications.contains(appConfig)){ ApplicationConfigManager.addApplication(appConfig); appConfig.setClusterConfig(null); } } /* remove applications outside the cluster (applications that are now part of cluster) */ for(Iterator it=newChildApplications.iterator();it.hasNext();){ ApplicationConfig appConfig = (ApplicationConfig)it.next(); if(!oldChildApplications.contains(appConfig)){ ApplicationConfigManager.deleteApplication(appConfig); appConfig.setClusterConfig(clusterConfig); } } clusterConfig.setApplications(newChildApplications); ApplicationConfigManager.updateApplication(clusterConfig); UserActivityLogger.getInstance().logActivity( context.getUser().getUsername(), "Updated application cluster "+ "\""+clusterConfig.getName()+"\""); }else{ /* add new application cluster */ ApplicationClusterConfig clusterConfig = new ApplicationClusterConfig( ApplicationConfig.getNextApplicationId(), clusterForm.getName()); for(Iterator it=newChildApplications.iterator();it.hasNext();){ ApplicationConfig appConfig = (ApplicationConfig)it.next(); appConfig.setClusterConfig(clusterConfig); ApplicationConfigManager.deleteApplication(appConfig); } clusterConfig.setApplications(newChildApplications); /* remove from stand-alone list */ ApplicationConfigManager.addApplication(clusterConfig); UserActivityLogger.getInstance().logActivity( context.getUser().getUsername(), "Added application cluster "+ "\""+clusterConfig.getName()+"\""); } return mapping.findForward(Forwards.SUCCESS); }
finally { if ( ! context.isCacheTags() ) { clearTag(); } }
public void run(JellyContext context, XMLOutput output) throws Exception { try { Tag tag = getTag(); if ( tag == null ) { return; } tag.setContext(context); if ( tag instanceof DynaTag ) { DynaTag dynaTag = (DynaTag) tag; // ### probably compiling this to 2 arrays might be quicker and smaller for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Expression expression = (Expression) entry.getValue(); Object value = expression.evaluate(context); dynaTag.setAttribute(name, value); } } else { // treat the tag as a bean DynaBean dynaBean = new ConvertingWrapDynaBean( tag ); for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Expression expression = (Expression) entry.getValue(); Object value = expression.evaluate(context); dynaBean.set(name, value); } } tag.doTag(output); } catch (JellyException e) { handleException(e); } catch (Exception e) { handleException(e); } }
public DBListClass(PropertyMetaClass wclass) { super("dblist", "DB List", wclass);
public DBListClass(String name, String prettyname, PropertyMetaClass wclass) { super(name, prettyname, wclass);
public DBListClass(PropertyMetaClass wclass) { super("dblist", "DB List", wclass); }
fc = new JFileChooser(System.getProperty("user.dir"));
public HaploView(){ //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); fileMenu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem(QUIT); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); displayMenu.setMnemonic(KeyEvent.VK_D); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); viewMenuItems[i].setEnabled(false); group.add(viewMenuItems[i]); } displayMenu.addSeparator(); //a submenu ButtonGroup zg = new ButtonGroup(); JMenu zoomMenu = new JMenu("D prime zoom"); zoomMenu.setMnemonic(KeyEvent.VK_Z); zoomMenuItems = new JRadioButtonMenuItem[zoomItems.length]; for (int i = 0; i < zoomItems.length; i++){ zoomMenuItems[i] = new JRadioButtonMenuItem(zoomItems[i], i==0); zoomMenuItems[i].addActionListener(this); zoomMenuItems[i].setActionCommand("zoom" + i); zoomMenu.add(zoomMenuItems[i]); zg.add(zoomMenuItems[i]); } displayMenu.add(zoomMenu); //another submenu ButtonGroup cg = new ButtonGroup(); JMenu colorMenu = new JMenu("D prime color scheme"); colorMenu.setMnemonic(KeyEvent.VK_C); colorMenuItems = new JRadioButtonMenuItem[colorItems.length]; for (int i = 0; i< colorItems.length; i++){ colorMenuItems[i] = new JRadioButtonMenuItem(colorItems[i],i==0); colorMenuItems[i].addActionListener(this); colorMenuItems[i].setActionCommand("color" + i); colorMenu.add(colorMenuItems[i]); cg.add(colorMenuItems[i]); if (i != 0){ colorMenuItems[i].setEnabled(false); } } displayMenu.add(colorMenu); //analysis menu JMenu analysisMenu = new JMenu("Analysis"); analysisMenu.setMnemonic(KeyEvent.VK_A); menuBar.add(analysisMenu); //a submenu ButtonGroup bg = new ButtonGroup(); JMenu blockMenu = new JMenu("Define Blocks"); blockMenu.setMnemonic(KeyEvent.VK_B); blockMenuItems = new JRadioButtonMenuItem[blockItems.length]; for (int i = 0; i < blockItems.length; i++){ blockMenuItems[i] = new JRadioButtonMenuItem(blockItems[i], i==0); blockMenuItems[i].addActionListener(this); blockMenuItems[i].setActionCommand("block" + i); blockMenu.add(blockMenuItems[i]); bg.add(blockMenuItems[i]); if (i != 0){ blockMenuItems[i].setEnabled(false); } } analysisMenu.add(blockMenu); clearBlocksItem = new JMenuItem(CLEAR_BLOCKS); setAccelerator(clearBlocksItem, 'C', false); clearBlocksItem.addActionListener(this); clearBlocksItem.setEnabled(false); analysisMenu.add(clearBlocksItem); JMenuItem customizeBlocksItem = new JMenuItem(CUST_BLOCKS); customizeBlocksItem.addActionListener(this); analysisMenu.add(customizeBlocksItem); //color key keyMenu = new JMenu("Key"); changeKey(1); menuBar.add(Box.createHorizontalGlue()); menuBar.add(keyMenu); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); addComponentListener(new ResizeListener()); }
JFileChooser fc = new JFileChooser(System.getProperty("user.dir"));
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command == READ_GENOTYPES){ ReadDataDialog readDialog = new ReadDataDialog("Open new data", this); readDialog.pack(); readDialog.setVisible(true); } else if (command == READ_MARKERS){ JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); fc.setSelectedFile(null); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { readMarkers(fc.getSelectedFile()); } }else if (command == CUST_BLOCKS){ TweakBlockDefsDialog tweakDialog = new TweakBlockDefsDialog("Customize Blocks", this); tweakDialog.pack(); tweakDialog.setVisible(true); }else if (command == CLEAR_BLOCKS){ colorMenuItems[0].setSelected(true); for (int i = 1; i< colorMenuItems.length; i++){ colorMenuItems[i].setEnabled(false); } changeBlocks(3,1); //blockdef clauses }else if (command.startsWith("block")){ int method = Integer.valueOf(command.substring(5)).intValue(); changeBlocks(method,1); for (int i = 1; i < colorMenuItems.length; i++){ if (method+1 == i){ colorMenuItems[i].setEnabled(true); }else{ colorMenuItems[i].setEnabled(false); } } colorMenuItems[0].setSelected(true); //zooming clauses }else if (command.startsWith("zoom")){ dPrimeDisplay.zoom(Integer.valueOf(command.substring(4)).intValue()); //coloring clauses }else if (command.startsWith("color")){ dPrimeDisplay.refresh(Integer.valueOf(command.substring(5)).intValue()+1); changeKey(Integer.valueOf(command.substring(5)).intValue()+1); //exporting clauses }else if (command == EXPORT_PNG){ JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){ export(tabs.getSelectedIndex(), PNG_MODE, fc.getSelectedFile()); } }else if (command == EXPORT_TEXT){ JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){ export(tabs.getSelectedIndex(), TXT_MODE, fc.getSelectedFile()); } }else if (command == "Select All"){ checkPanel.selectAll(); }else if (command == "Rescore Markers"){ String cut = hwcut.getText(); if (cut.equals("")){ cut = "0"; } CheckData.hwCut = Double.parseDouble(cut); cut = genocut.getText(); if (cut.equals("")){ cut="0"; } CheckData.failedGenoCut = Integer.parseInt(cut); cut = mendcut.getText(); if (cut.equals("")){ cut="0"; } CheckData.numMendErrCut = Integer.parseInt(cut); checkPanel.redoRatings(); }else if (command == "Tutorial"){ showHelp(); } else if (command == QUIT){ quit(); } else { for (int i = 0; i < viewItems.length; i++) { if (command == viewItems[i]) tabs.setSelectedIndex(i); } } }
public Object evaluate(Context context) {
public Object evaluate(JellyContext context) {
public Object evaluate(Context context) { try { interpreter.setContext(context); if ( log.isDebugEnabled() ) { log.debug( "Evaluating EL: " + text ); } return interpreter.eval( text ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + text + ". Reason: " + e, e ); return null; } }
interpreter.setContext(context);
interpreter.setJellyContext(context);
public Object evaluate(Context context) { try { interpreter.setContext(context); if ( log.isDebugEnabled() ) { log.debug( "Evaluating EL: " + text ); } return interpreter.eval( text ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + text + ". Reason: " + e, e ); return null; } }
logger.info("DBTree: exporting single node");
public void dragGestureRecognized(DragGestureEvent dge) { logger.info("Drag gesture event: "+dge); // we only start drags on left-click drags InputEvent ie = dge.getTriggerEvent(); if ( (ie.getModifiers() & InputEvent.BUTTON1_MASK) == 0) { return; } DBTree t = (DBTree) dge.getComponent(); TreePath[] p = t.getSelectionPaths(); if (p == null || p.length == 0) { // nothing to export return; } else if (p.length == 1) { // export single node logger.info("DBTree: exporting single node"); SQLObject data = (SQLObject) p[0].getLastPathComponent(); dge.getDragSource().startDrag (dge, DragSource.DefaultCopyNoDrop, new SQLObjectTransferable(data), t); } else { // export list of nodes logger.info("DBTree: exporting list of nodes"); SQLObject[] nodes = new SQLObject[p.length]; for (int i = 0; i < p.length; i++) { nodes[i] = (SQLObject) p[i].getLastPathComponent(); } dge.getDragSource().startDrag (dge, DragSource.DefaultCopyNoDrop, new SQLObjectListTransferable(nodes), t); } }
logger.info("DBTree: exporting single node "+data.getName()+"@"+data.hashCode());
public void dragGestureRecognized(DragGestureEvent dge) { logger.info("Drag gesture event: "+dge); // we only start drags on left-click drags InputEvent ie = dge.getTriggerEvent(); if ( (ie.getModifiers() & InputEvent.BUTTON1_MASK) == 0) { return; } DBTree t = (DBTree) dge.getComponent(); TreePath[] p = t.getSelectionPaths(); if (p == null || p.length == 0) { // nothing to export return; } else if (p.length == 1) { // export single node logger.info("DBTree: exporting single node"); SQLObject data = (SQLObject) p[0].getLastPathComponent(); dge.getDragSource().startDrag (dge, DragSource.DefaultCopyNoDrop, new SQLObjectTransferable(data), t); } else { // export list of nodes logger.info("DBTree: exporting list of nodes"); SQLObject[] nodes = new SQLObject[p.length]; for (int i = 0; i < p.length; i++) { nodes[i] = (SQLObject) p[i].getLastPathComponent(); } dge.getDragSource().startDrag (dge, DragSource.DefaultCopyNoDrop, new SQLObjectListTransferable(nodes), t); } }
public DBTree(List initialDatabases) throws ArchitectException { super(new DBTreeModel(initialDatabases));
public DBTree() {
public DBTree(List initialDatabases) throws ArchitectException { super(new DBTreeModel(initialDatabases)); setRootVisible(false); setShowsRootHandles(true); ds = new DragSource(); DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer (this, DnDConstants.ACTION_COPY, new DBTreeDragGestureListener()); setupPropDialog(); popup = setupPopupMenu(); addMouseListener(new PopupListener()); }
Options.setgBrowseLeft(0); Options.setgBrowseRight(0); Chromosome.setDataChrom(null);
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals(RAW_DATA)){ load(PED); }else if (command.equals(PHASED_DATA)){ load(HAPS); }else if (command.equals(HAPMAP_DATA)){ load(HMP); }else if (command.equals(BROWSE_GENO)){ browse(GENO); }else if (command.equals(BROWSE_INFO)){ browse(INFO); }else if (command.equals("OK")){ HaploView caller = (HaploView)this.getParent(); if (doTDT.isSelected()){ if (trioButton.isSelected()){ Options.setAssocTest(ASSOC_TRIO); } else { Options.setAssocTest(ASSOC_CC); } }else{ Options.setAssocTest(ASSOC_NONE); } if (doGB.isSelected()){ Options.setShowGBrowse(true); }else{ Options.setShowGBrowse(false); } if (maxComparisonDistField.getText().equals("")){ Options.setMaxDistance(0); }else{ Options.setMaxDistance(Integer.parseInt(maxComparisonDistField.getText())); } String[] returnStrings = {genoFileField.getText(), infoFileField.getText()}; if (returnStrings[1].equals("")) returnStrings[1] = null; //if a dataset was previously loaded during this session, discard the display panes for it. caller.clearDisplays(); caller.readGenotypes(returnStrings, fileType); this.dispose(); }else if (command.equals("Cancel")){ this.dispose(); }else if (command.equals("tdt")){ if(this.doTDT.isSelected()){ trioButton.setEnabled(true); ccButton.setEnabled(true); }else{ trioButton.setEnabled(false); ccButton.setEnabled(false); } } }
gBrowsePanel.add(new JLabel("Download and show HapMap gene track? (requires internet connection)"));
gBrowsePanel.add(new JLabel("Download and show HapMap info track? (requires internet connection)"));
void load(int ft){ fileType = ft; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JPanel filePanel = new JPanel(); filePanel.setLayout(new BoxLayout(filePanel, BoxLayout.Y_AXIS)); JPanel topFilePanel = new JPanel(); JPanel botFilePanel = new JPanel(); genoFileField = new JTextField("",20); //workaround for dumb Swing can't requestFocus until shown bug //this one seems to throw a harmless exception in certain versions of the linux JRE try{ SwingUtilities.invokeLater( new Runnable(){ public void run() { genoFileField.requestFocus(); }}); }catch (RuntimeException re){ } //this one seems to really fuck over the 1.3 version of the windows JRE //in short: Java sucks. /*genoFileField.dispatchEvent( new FocusEvent( genoFileField, FocusEvent.FOCUS_GAINED, false ) );*/ infoFileField = new JTextField("",20); JButton browseGenoButton = new JButton("Browse"); browseGenoButton.setActionCommand(BROWSE_GENO); browseGenoButton.addActionListener(this); JButton browseInfoButton = new JButton("Browse"); browseInfoButton.setActionCommand(BROWSE_INFO); browseInfoButton.addActionListener(this); topFilePanel.add(new JLabel("Genotype file: ")); topFilePanel.add(genoFileField); topFilePanel.add(browseGenoButton); botFilePanel.add(new JLabel("Locus information file: ")); botFilePanel.add(infoFileField); botFilePanel.add(browseInfoButton); filePanel.add(topFilePanel); if (ft != HMP){ filePanel.add(botFilePanel); } filePanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); contents.add(filePanel); JPanel compDistPanel = new JPanel(); maxComparisonDistField = new NumberTextField("500",4, false); compDistPanel.add(new JLabel("Ignore pairwise comparisons of markers >")); compDistPanel.add(maxComparisonDistField); compDistPanel.add(new JLabel("kb apart.")); contents.add(compDistPanel); doGB = new JCheckBox();//show gbrowse pic from hapmap website? doGB.setSelected(false); if (ft == HMP){ JPanel gBrowsePanel = new JPanel(); gBrowsePanel.add(doGB); gBrowsePanel.add(new JLabel("Download and show HapMap gene track? (requires internet connection)")); contents.add(gBrowsePanel); } doTDT = new JCheckBox();//"Do association test?"); doTDT.setSelected(false); doTDT.setActionCommand("tdt"); doTDT.addActionListener(this); trioButton = new JRadioButton("Family trio data", true); trioButton.setEnabled(false); ccButton = new JRadioButton("Case/Control data"); ccButton.setEnabled(false); ButtonGroup group = new ButtonGroup(); group.add(trioButton); group.add(ccButton); if (ft == PED){ JPanel tdtOptsPanel = new JPanel(); JPanel tdtCheckBoxPanel = new JPanel(); tdtCheckBoxPanel.add(doTDT); tdtCheckBoxPanel.add(new JLabel("Do association test?")); tdtOptsPanel.add(trioButton); tdtOptsPanel.add(ccButton); contents.add(tdtCheckBoxPanel); contents.add(tdtOptsPanel); } JPanel choicePanel = new JPanel(); JButton okButton = new JButton("OK"); this.getRootPane().setDefaultButton(okButton); okButton.addActionListener(this); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); choicePanel.add(okButton); choicePanel.add(cancelButton); contents.add(choicePanel); this.setContentPane(contents); this.pack(); }
bw.write("#using " + getTagSNPs().size() + " SNPs in " + tags.size() + " tests.");
bw.write("#using " + getTagSNPs().size() + " Tag SNPs in " + tags.size() + " tests.");
public void saveResultToFile(File outFile) throws IOException { BufferedWriter bw = new BufferedWriter(new FileWriter(outFile)); bw.write("#tagging with r^2 cutoff: " + minRSquared); bw.newLine(); bw.write("#captured " + taggedSoFar + " of " + snps.size() +" alleles with mean r^2 of " + Util.roundDouble(meanRSq, 3)); bw.newLine(); bw.write("#captured " + percentOver8 + " percent of alleles with r^2 > 0.8"); bw.newLine(); bw.write("#using " + getTagSNPs().size() + " SNPs in " + tags.size() + " tests."); bw.newLine(); bw.write("Marker\tBest Test\tr^2 w/test"); bw.newLine(); for (int i = 0; i < snps.size(); i++) { StringBuffer line = new StringBuffer(); SNP snp = (SNP) snps.elementAt(i); line.append(snp.getName()).append("\t"); TagSequence theTag = snp.getBestTag(); if(theTag != null) { line.append(theTag.getName()).append("\t"); line.append(getPairwiseCompRsq(snp,theTag.getSequence())).append("\t"); } bw.write(line.toString()); bw.newLine(); } bw.newLine(); bw.write("Test\tAlleles Captured"); bw.newLine(); for(int i=0;i<tags.size();i++) { StringBuffer line = new StringBuffer(); TagSequence theTag = (TagSequence) tags.get(i); line.append(theTag.getName()).append("\t"); Vector tagged = theTag.getBestTagged(); for (int j = 0; j < tagged.size(); j++) { VariantSequence varSeq = (VariantSequence) tagged.elementAt(j); if(j !=0){ line.append(","); } line.append(varSeq.getName()); } bw.write(line.toString()); bw.newLine(); } bw.close(); }
bw.write("Marker\tBest Test\tr^2 w/test");
bw.write("Allele\tBest Test\tr^2 w/test");
public void saveResultToFile(File outFile) throws IOException { BufferedWriter bw = new BufferedWriter(new FileWriter(outFile)); bw.write("#tagging with r^2 cutoff: " + minRSquared); bw.newLine(); bw.write("#captured " + taggedSoFar + " of " + snps.size() +" alleles with mean r^2 of " + Util.roundDouble(meanRSq, 3)); bw.newLine(); bw.write("#captured " + percentOver8 + " percent of alleles with r^2 > 0.8"); bw.newLine(); bw.write("#using " + getTagSNPs().size() + " SNPs in " + tags.size() + " tests."); bw.newLine(); bw.write("Marker\tBest Test\tr^2 w/test"); bw.newLine(); for (int i = 0; i < snps.size(); i++) { StringBuffer line = new StringBuffer(); SNP snp = (SNP) snps.elementAt(i); line.append(snp.getName()).append("\t"); TagSequence theTag = snp.getBestTag(); if(theTag != null) { line.append(theTag.getName()).append("\t"); line.append(getPairwiseCompRsq(snp,theTag.getSequence())).append("\t"); } bw.write(line.toString()); bw.newLine(); } bw.newLine(); bw.write("Test\tAlleles Captured"); bw.newLine(); for(int i=0;i<tags.size();i++) { StringBuffer line = new StringBuffer(); TagSequence theTag = (TagSequence) tags.get(i); line.append(theTag.getName()).append("\t"); Vector tagged = theTag.getBestTagged(); for (int j = 0; j < tagged.size(); j++) { VariantSequence varSeq = (VariantSequence) tagged.elementAt(j); if(j !=0){ line.append(","); } line.append(varSeq.getName()); } bw.write(line.toString()); bw.newLine(); } bw.close(); }
FontMetrics boldfm = g.getFontMetrics(boldFont);
FontMetrics boldfm = g.getFontMetrics(boldFont); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2);
public void dPrimeDraw(String[][] table, boolean info, Vector snps, Graphics g){ int scale = table.length*30; int activeOffset = 0; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); if (info) activeOffset = labeloffset; //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale+activeOffset,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", activeOffset + shifts[0], shifts[1]); //if we know the marker names, print them down the side if (info){ g.setFont(regFont); for (int y = 0; y < table.length; y++){ String name = ((SNP)snps.elementAt(y)).getName(); g.drawString(name, labeloffset-3-regfm.stringWidth(name), y*30 + shifts[1]); } //now draw a diagonal bar showing marker spacings if (table.length > 3){ g.drawLine(labeloffset+90,5,labeloffset+scale-5,scale-90); double lineLength = Math.sqrt((scale-95)*(scale-95)*2); double start = ((SNP)snps.elementAt(0)).getPosition(); double totalLength = ((SNP)snps.elementAt(table.length-1)).getPosition() - start; int numKB = (int)(totalLength/1000); g.drawString(numKB+" Kb", labeloffset+150, 30); for (int y = 0; y < table.length; y++){ double fracLength = (((SNP)snps.elementAt(y)).getPosition() - start)/totalLength; double xOrYDist = Math.sqrt((fracLength*lineLength*fracLength*lineLength)/2); g.drawLine(labeloffset+25+y*30, 5+y*30,(int)(labeloffset+90+xOrYDist),(int)(5+xOrYDist)); } } } //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(st.nextToken()); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1+activeOffset, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30+activeOffset, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30)+activeOffset,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30+activeOffset, shifts[1]+(x+1)*30); } }
d = Float.parseFloat(st.nextToken());
d = Float.parseFloat(nf.format(Float.parseFloat(st.nextToken())));
public void dPrimeDraw(String[][] table, boolean info, Vector snps, Graphics g){ int scale = table.length*30; int activeOffset = 0; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); if (info) activeOffset = labeloffset; //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale+activeOffset,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", activeOffset + shifts[0], shifts[1]); //if we know the marker names, print them down the side if (info){ g.setFont(regFont); for (int y = 0; y < table.length; y++){ String name = ((SNP)snps.elementAt(y)).getName(); g.drawString(name, labeloffset-3-regfm.stringWidth(name), y*30 + shifts[1]); } //now draw a diagonal bar showing marker spacings if (table.length > 3){ g.drawLine(labeloffset+90,5,labeloffset+scale-5,scale-90); double lineLength = Math.sqrt((scale-95)*(scale-95)*2); double start = ((SNP)snps.elementAt(0)).getPosition(); double totalLength = ((SNP)snps.elementAt(table.length-1)).getPosition() - start; int numKB = (int)(totalLength/1000); g.drawString(numKB+" Kb", labeloffset+150, 30); for (int y = 0; y < table.length; y++){ double fracLength = (((SNP)snps.elementAt(y)).getPosition() - start)/totalLength; double xOrYDist = Math.sqrt((fracLength*lineLength*fracLength*lineLength)/2); g.drawLine(labeloffset+25+y*30, 5+y*30,(int)(labeloffset+90+xOrYDist),(int)(5+xOrYDist)); } } } //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(st.nextToken()); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1+activeOffset, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30+activeOffset, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30)+activeOffset,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30+activeOffset, shifts[1]+(x+1)*30); } }
NumberFormat nf = NumberFormat.getInstance(); NumberFormat nfMulti = NumberFormat.getInstance(); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); nfMulti.setMinimumFractionDigits(2); nfMulti.setMaximumFractionDigits(2);
public void haploDraw(Graphics gr, boolean myuseThickness, int mycolorThresh, int mycrossThinThresh, int mycrossThickThresh, double[] gapDPrime, Haplotype[][] hapsInBlocks){ NumberFormat nf = NumberFormat.getInstance(); NumberFormat nfMulti = NumberFormat.getInstance(); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); nfMulti.setMinimumFractionDigits(2); nfMulti.setMaximumFractionDigits(2); Graphics2D g = (Graphics2D) gr; final BasicStroke stroke = new BasicStroke(1.0f); final BasicStroke wideStroke = new BasicStroke(2.0f); final int verticalOffset = 43; final Font nonMonoFont = new Font("Lucida Bright", Font.PLAIN, 12); final Font regFont = new Font("Lucida Sans Typewriter", Font.PLAIN, 12); final Font smallFont = new Font("Lucida Sans Typewriter", Font.PLAIN, 7); final Font boldFont = new Font("Lucida Bright", Font.BOLD, 12); FontMetrics regfm = g.getFontMetrics(regFont); FontMetrics nonMonofm = g.getFontMetrics(nonMonoFont); FontMetrics boldfm = g.getFontMetrics(boldFont); String theHap = new String(); int x = 10; int y = verticalOffset; int totalWidth = 0; int[][]lookupPos = new int[hapsInBlocks.length][]; for (int p = 0; p < lookupPos.length; p++){ lookupPos[p] = new int[hapsInBlocks[p].length]; for (int q = 0; q < lookupPos[p].length; q++){ lookupPos[p][hapsInBlocks[p][q].getListOrder()] = q; //System.out.println(p + " " + q + " " + hapsInBlocks[p][q].getListOrder()); } } Dimension theDimension = haploGetPreferredSize(hapsInBlocks, gr); int windowX = (int)theDimension.getWidth(); int windowY = (int)theDimension.getHeight(); g.setColor(Color.white); g.fillRect(0,0,windowX,windowY); g.setColor(Color.black); for (int i = 0; i < hapsInBlocks.length; i++){ int[] markerNums = hapsInBlocks[i][0].getMarkers(); boolean[] tags = hapsInBlocks[i][0].getTags(); int headerX = x; for (int z = 0; z < markerNums.length; z++){ //put tag snps in red if (tags[z]) { g.setColor(Color.red); } //write labels with more than one digit vertically if (markerNums[z]+1 < 10){ g.setFont(regFont); g.drawString(String.valueOf(markerNums[z]+1), headerX, 18); headerX += (regfm.stringWidth(String.valueOf(markerNums[z]+1))); }else { int ones = (markerNums[z]+1)%10; int tens = (((markerNums[z]+1)-ones)%100)/10; g.setFont(regFont); g.drawString(String.valueOf(ones), headerX, 18); g.setFont(smallFont); g.drawString(String.valueOf(tens), headerX-2, 20-regfm.getAscent()); headerX += (regfm.stringWidth(String.valueOf(ones))); } g.setColor(Color.black); } for (int j = 0; j < hapsInBlocks[i].length; j++){ int curHapNum = lookupPos[i][j]; theHap = new String(); String thePercentage = new String(); int[] theGeno = hapsInBlocks[i][curHapNum].getGeno(); for (int k = 0; k < theGeno.length; k++){ //if we don't know what one of the alleles for a marker is, use "x" if (theGeno[k] == 8){ theHap += "x"; }else{ theHap += theGeno[k]; } } //draw the haplotype in mono font g.setFont(regFont); g.drawString(theHap, x, y); //draw the percentage value in non mono font thePercentage = " (" + nf.format(hapsInBlocks[i][curHapNum].getPercentage()) + ")"; g.setFont(nonMonoFont); g.drawString(thePercentage, x+regfm.stringWidth(theHap), y); totalWidth = regfm.stringWidth(theHap) + nonMonofm.stringWidth(thePercentage); if (i < hapsInBlocks.length - 1){ //draw crossovers for (int crossCount = 0; crossCount < hapsInBlocks[i+1].length; crossCount++){ double crossVal = hapsInBlocks[i][curHapNum].getCrossover(crossCount); if (myuseThickness){ //draw thin and thick lines if (crossVal*100 > mycrossThinThresh){ if (crossVal*100 > mycrossThickThresh){ g.setStroke(wideStroke); }else{ g.setStroke(stroke); } //this arcane formula draws lines neatly from one hap to another g.draw(new Line2D.Double((x+totalWidth+3), (y-regfm.getAscent()/2), (x+totalWidth+37), (verticalOffset-regfm.getAscent()/2+((regfm.getHeight()+5)*hapsInBlocks[i+1][crossCount].getListOrder())))); } }else{ //draw colored lines if(crossVal*100 > mycolorThresh){ g.setStroke(stroke); double overThresh = crossVal*100 - mycolorThresh; float lineRed, lineGreen, lineBlue; if(overThresh < (50-mycolorThresh)/2){ //cold colors lineRed=0.0f; lineBlue=new Double(0.9-((overThresh/((50-mycolorThresh)/2))*0.9)).floatValue(); lineGreen=0.9f-lineBlue; }else{ //hot colors lineBlue=0.0f; lineRed=new Double(((overThresh-(50-mycolorThresh)/2)/((50-mycolorThresh)/2))*0.9).floatValue(); lineGreen=0.9f-lineRed; } Color lineColor = new Color(lineRed, lineGreen, lineBlue); g.setColor(lineColor); g.setStroke(new BasicStroke(1.5f)); g.draw(new Line2D.Double((x+totalWidth+3), (y-regfm.getAscent()/2), (x+totalWidth+37), (verticalOffset-regfm.getAscent()/2+((regfm.getHeight()+5)*hapsInBlocks[i+1][crossCount].getListOrder())))); g.setColor(Color.black); g.setStroke(stroke); } } } } y += (regfm.getHeight()+5); } //add the multilocus d prime if appropriate if (i < hapsInBlocks.length - 1){ int multiX = x +totalWidth+3; g.setStroke(wideStroke); g.setFont(boldFont); g.drawRect(multiX, windowY-boldfm.getAscent()-4, boldfm.stringWidth("8.88")+3, boldfm.getAscent()+3); g.drawString(String.valueOf(nfMulti.format(gapDPrime[i])), multiX+2, windowY - 3); g.setStroke(stroke); } x += (totalWidth + 40); y = verticalOffset; } }
NumberFormat nf = NumberFormat.getInstance(); NumberFormat nfMulti = NumberFormat.getInstance(); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); nfMulti.setMinimumFractionDigits(2); nfMulti.setMaximumFractionDigits(2);
public void haploDraw(Graphics gr, boolean myuseThickness, int mycolorThresh, int mycrossThinThresh, int mycrossThickThresh, double[] gapDPrime, Haplotype[][] hapsInBlocks){ NumberFormat nf = NumberFormat.getInstance(); NumberFormat nfMulti = NumberFormat.getInstance(); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); nfMulti.setMinimumFractionDigits(2); nfMulti.setMaximumFractionDigits(2); Graphics2D g = (Graphics2D) gr; final BasicStroke stroke = new BasicStroke(1.0f); final BasicStroke wideStroke = new BasicStroke(2.0f); final int verticalOffset = 43; final Font nonMonoFont = new Font("Lucida Bright", Font.PLAIN, 12); final Font regFont = new Font("Lucida Sans Typewriter", Font.PLAIN, 12); final Font smallFont = new Font("Lucida Sans Typewriter", Font.PLAIN, 7); final Font boldFont = new Font("Lucida Bright", Font.BOLD, 12); FontMetrics regfm = g.getFontMetrics(regFont); FontMetrics nonMonofm = g.getFontMetrics(nonMonoFont); FontMetrics boldfm = g.getFontMetrics(boldFont); String theHap = new String(); int x = 10; int y = verticalOffset; int totalWidth = 0; int[][]lookupPos = new int[hapsInBlocks.length][]; for (int p = 0; p < lookupPos.length; p++){ lookupPos[p] = new int[hapsInBlocks[p].length]; for (int q = 0; q < lookupPos[p].length; q++){ lookupPos[p][hapsInBlocks[p][q].getListOrder()] = q; //System.out.println(p + " " + q + " " + hapsInBlocks[p][q].getListOrder()); } } Dimension theDimension = haploGetPreferredSize(hapsInBlocks, gr); int windowX = (int)theDimension.getWidth(); int windowY = (int)theDimension.getHeight(); g.setColor(Color.white); g.fillRect(0,0,windowX,windowY); g.setColor(Color.black); for (int i = 0; i < hapsInBlocks.length; i++){ int[] markerNums = hapsInBlocks[i][0].getMarkers(); boolean[] tags = hapsInBlocks[i][0].getTags(); int headerX = x; for (int z = 0; z < markerNums.length; z++){ //put tag snps in red if (tags[z]) { g.setColor(Color.red); } //write labels with more than one digit vertically if (markerNums[z]+1 < 10){ g.setFont(regFont); g.drawString(String.valueOf(markerNums[z]+1), headerX, 18); headerX += (regfm.stringWidth(String.valueOf(markerNums[z]+1))); }else { int ones = (markerNums[z]+1)%10; int tens = (((markerNums[z]+1)-ones)%100)/10; g.setFont(regFont); g.drawString(String.valueOf(ones), headerX, 18); g.setFont(smallFont); g.drawString(String.valueOf(tens), headerX-2, 20-regfm.getAscent()); headerX += (regfm.stringWidth(String.valueOf(ones))); } g.setColor(Color.black); } for (int j = 0; j < hapsInBlocks[i].length; j++){ int curHapNum = lookupPos[i][j]; theHap = new String(); String thePercentage = new String(); int[] theGeno = hapsInBlocks[i][curHapNum].getGeno(); for (int k = 0; k < theGeno.length; k++){ //if we don't know what one of the alleles for a marker is, use "x" if (theGeno[k] == 8){ theHap += "x"; }else{ theHap += theGeno[k]; } } //draw the haplotype in mono font g.setFont(regFont); g.drawString(theHap, x, y); //draw the percentage value in non mono font thePercentage = " (" + nf.format(hapsInBlocks[i][curHapNum].getPercentage()) + ")"; g.setFont(nonMonoFont); g.drawString(thePercentage, x+regfm.stringWidth(theHap), y); totalWidth = regfm.stringWidth(theHap) + nonMonofm.stringWidth(thePercentage); if (i < hapsInBlocks.length - 1){ //draw crossovers for (int crossCount = 0; crossCount < hapsInBlocks[i+1].length; crossCount++){ double crossVal = hapsInBlocks[i][curHapNum].getCrossover(crossCount); if (myuseThickness){ //draw thin and thick lines if (crossVal*100 > mycrossThinThresh){ if (crossVal*100 > mycrossThickThresh){ g.setStroke(wideStroke); }else{ g.setStroke(stroke); } //this arcane formula draws lines neatly from one hap to another g.draw(new Line2D.Double((x+totalWidth+3), (y-regfm.getAscent()/2), (x+totalWidth+37), (verticalOffset-regfm.getAscent()/2+((regfm.getHeight()+5)*hapsInBlocks[i+1][crossCount].getListOrder())))); } }else{ //draw colored lines if(crossVal*100 > mycolorThresh){ g.setStroke(stroke); double overThresh = crossVal*100 - mycolorThresh; float lineRed, lineGreen, lineBlue; if(overThresh < (50-mycolorThresh)/2){ //cold colors lineRed=0.0f; lineBlue=new Double(0.9-((overThresh/((50-mycolorThresh)/2))*0.9)).floatValue(); lineGreen=0.9f-lineBlue; }else{ //hot colors lineBlue=0.0f; lineRed=new Double(((overThresh-(50-mycolorThresh)/2)/((50-mycolorThresh)/2))*0.9).floatValue(); lineGreen=0.9f-lineRed; } Color lineColor = new Color(lineRed, lineGreen, lineBlue); g.setColor(lineColor); g.setStroke(new BasicStroke(1.5f)); g.draw(new Line2D.Double((x+totalWidth+3), (y-regfm.getAscent()/2), (x+totalWidth+37), (verticalOffset-regfm.getAscent()/2+((regfm.getHeight()+5)*hapsInBlocks[i+1][crossCount].getListOrder())))); g.setColor(Color.black); g.setStroke(stroke); } } } } y += (regfm.getHeight()+5); } //add the multilocus d prime if appropriate if (i < hapsInBlocks.length - 1){ int multiX = x +totalWidth+3; g.setStroke(wideStroke); g.setFont(boldFont); g.drawRect(multiX, windowY-boldfm.getAscent()-4, boldfm.stringWidth("8.88")+3, boldfm.getAscent()+3); g.drawString(String.valueOf(nfMulti.format(gapDPrime[i])), multiX+2, windowY - 3); g.setStroke(stroke); } x += (totalWidth + 40); y = verticalOffset; } }
public static LocalizationContext getLocalizationContext(JellyContext jc, String basename) { LocalizationContext locCtxt = null; ResourceBundle bundle = null; if ((basename == null) || basename.equals("")) { return new LocalizationContext(); } Locale pref = null; { Object tmp = jc.getVariable(Config.FMT_LOCALE); if (tmp != null && tmp instanceof Locale) { pref = (Locale) tmp; } } if (pref != null) { bundle = findMatch(basename, pref, jc.getClassLoader()); if (bundle != null) { locCtxt = new LocalizationContext(bundle, pref); } } if (locCtxt == null) { { Object tmp = jc.getVariable(Config.FMT_FALLBACK_LOCALE); if (tmp != null && tmp instanceof Locale) { pref = (Locale) tmp; } } if (pref != null) { bundle = findMatch(basename, pref, jc.getClassLoader()); if (bundle != null) { locCtxt = new LocalizationContext(bundle, pref); } } } if (locCtxt == null) { try { bundle = ResourceBundle.getBundle(basename, EMPTY_LOCALE, jc.getClassLoader()); if (bundle != null) { locCtxt = new LocalizationContext(bundle, null); } } catch (MissingResourceException mre) { } } if (locCtxt != null) { if (locCtxt.getLocale() != null) { } } else { locCtxt = new LocalizationContext(); }
public LocalizationContext getLocalizationContext() {
public static LocalizationContext getLocalizationContext(JellyContext jc, String basename) { LocalizationContext locCtxt = null; ResourceBundle bundle = null; if ((basename == null) || basename.equals("")) { return new LocalizationContext(); } // Try preferred locales Locale pref = null; { Object tmp = jc.getVariable(Config.FMT_LOCALE); if (tmp != null && tmp instanceof Locale) { pref = (Locale) tmp; } } if (pref != null) { // Preferred locale is application-based bundle = findMatch(basename, pref, jc.getClassLoader()); if (bundle != null) { locCtxt = new LocalizationContext(bundle, pref); } } if (locCtxt == null) { // No match found with preferred locales, try using fallback locale { Object tmp = jc.getVariable(Config.FMT_FALLBACK_LOCALE); if (tmp != null && tmp instanceof Locale) { pref = (Locale) tmp; } } if (pref != null) { bundle = findMatch(basename, pref, jc.getClassLoader()); if (bundle != null) { locCtxt = new LocalizationContext(bundle, pref); } } } if (locCtxt == null) { // try using the root resource bundle with the given basename try { bundle = ResourceBundle.getBundle(basename, EMPTY_LOCALE, jc.getClassLoader()); if (bundle != null) { locCtxt = new LocalizationContext(bundle, null); } } catch (MissingResourceException mre) { // do nothing } } if (locCtxt != null) { // set response locale if (locCtxt.getLocale() != null) { // TODO // SetLocaleSupport.setResponseLocale(jc, locCtxt.getLocale()); } } else { // create empty localization context locCtxt = new LocalizationContext(); } return locCtxt; }
private String generateUniqueColumnName(SQLColumn column, SQLTable table) {
private static String generateUniqueColumnName(SQLColumn column, SQLTable table) {
private String generateUniqueColumnName(SQLColumn column, SQLTable table) { return column.getName() + "_1"; // XXX: fix this to be better }
logger.debug("00000000000 object hash code: " + super.hashCode());
public void itemSelected(SelectionEvent e) { // what address am I? logger.debug("00000000000 object hash code: " + super.hashCode()); // ignore events unless active logger.debug("11111111ITEM SELECTED: " + e); if (!active) { logger.debug("222222222 not active."); return; } else { logger.debug("222222222 ACTIVE!!!."); } Selectable s = e.getSelectableSource(); // don't care when tables (or anything else) are deselected if (!s.isSelected()) { logger.debug("333333333 not selected."); return; } if (s instanceof TablePane) { logger.debug("4444444444444 instance of TablePane."); if (pkTable == null) { pkTable = (TablePane) s; logger.debug("555555555555 Creating relationship: PK Table is "+pkTable); } else { fkTable = (TablePane) s; logger.debug("66666666666666 Creating relationship: FK Table is "+fkTable); doCreateRelationship(); // this might fail, but still set things back to "normal" pp.setCursor(null); logger.debug("66666666666666 setting active to FALSE!"); active = false; } } else { logger.debug("777777777777 not instance of TablePane."); if (logger.isDebugEnabled()) logger.debug("The user clicked on a non-table component: "+s); } }
logger.debug("11111111ITEM SELECTED: " + e); if (!active) { logger.debug("222222222 not active."); return; } else { logger.debug("222222222 ACTIVE!!!."); }
if (!active) return;
public void itemSelected(SelectionEvent e) { // what address am I? logger.debug("00000000000 object hash code: " + super.hashCode()); // ignore events unless active logger.debug("11111111ITEM SELECTED: " + e); if (!active) { logger.debug("222222222 not active."); return; } else { logger.debug("222222222 ACTIVE!!!."); } Selectable s = e.getSelectableSource(); // don't care when tables (or anything else) are deselected if (!s.isSelected()) { logger.debug("333333333 not selected."); return; } if (s instanceof TablePane) { logger.debug("4444444444444 instance of TablePane."); if (pkTable == null) { pkTable = (TablePane) s; logger.debug("555555555555 Creating relationship: PK Table is "+pkTable); } else { fkTable = (TablePane) s; logger.debug("66666666666666 Creating relationship: FK Table is "+fkTable); doCreateRelationship(); // this might fail, but still set things back to "normal" pp.setCursor(null); logger.debug("66666666666666 setting active to FALSE!"); active = false; } } else { logger.debug("777777777777 not instance of TablePane."); if (logger.isDebugEnabled()) logger.debug("The user clicked on a non-table component: "+s); } }
if (!s.isSelected()) { logger.debug("333333333 not selected."); return; }
if (!s.isSelected()) return;
public void itemSelected(SelectionEvent e) { // what address am I? logger.debug("00000000000 object hash code: " + super.hashCode()); // ignore events unless active logger.debug("11111111ITEM SELECTED: " + e); if (!active) { logger.debug("222222222 not active."); return; } else { logger.debug("222222222 ACTIVE!!!."); } Selectable s = e.getSelectableSource(); // don't care when tables (or anything else) are deselected if (!s.isSelected()) { logger.debug("333333333 not selected."); return; } if (s instanceof TablePane) { logger.debug("4444444444444 instance of TablePane."); if (pkTable == null) { pkTable = (TablePane) s; logger.debug("555555555555 Creating relationship: PK Table is "+pkTable); } else { fkTable = (TablePane) s; logger.debug("66666666666666 Creating relationship: FK Table is "+fkTable); doCreateRelationship(); // this might fail, but still set things back to "normal" pp.setCursor(null); logger.debug("66666666666666 setting active to FALSE!"); active = false; } } else { logger.debug("777777777777 not instance of TablePane."); if (logger.isDebugEnabled()) logger.debug("The user clicked on a non-table component: "+s); } }
logger.debug("4444444444444 instance of TablePane.");
public void itemSelected(SelectionEvent e) { // what address am I? logger.debug("00000000000 object hash code: " + super.hashCode()); // ignore events unless active logger.debug("11111111ITEM SELECTED: " + e); if (!active) { logger.debug("222222222 not active."); return; } else { logger.debug("222222222 ACTIVE!!!."); } Selectable s = e.getSelectableSource(); // don't care when tables (or anything else) are deselected if (!s.isSelected()) { logger.debug("333333333 not selected."); return; } if (s instanceof TablePane) { logger.debug("4444444444444 instance of TablePane."); if (pkTable == null) { pkTable = (TablePane) s; logger.debug("555555555555 Creating relationship: PK Table is "+pkTable); } else { fkTable = (TablePane) s; logger.debug("66666666666666 Creating relationship: FK Table is "+fkTable); doCreateRelationship(); // this might fail, but still set things back to "normal" pp.setCursor(null); logger.debug("66666666666666 setting active to FALSE!"); active = false; } } else { logger.debug("777777777777 not instance of TablePane."); if (logger.isDebugEnabled()) logger.debug("The user clicked on a non-table component: "+s); } }
logger.debug("555555555555 Creating relationship: PK Table is "+pkTable);
logger.debug("Creating relationship: PK Table is "+pkTable);
public void itemSelected(SelectionEvent e) { // what address am I? logger.debug("00000000000 object hash code: " + super.hashCode()); // ignore events unless active logger.debug("11111111ITEM SELECTED: " + e); if (!active) { logger.debug("222222222 not active."); return; } else { logger.debug("222222222 ACTIVE!!!."); } Selectable s = e.getSelectableSource(); // don't care when tables (or anything else) are deselected if (!s.isSelected()) { logger.debug("333333333 not selected."); return; } if (s instanceof TablePane) { logger.debug("4444444444444 instance of TablePane."); if (pkTable == null) { pkTable = (TablePane) s; logger.debug("555555555555 Creating relationship: PK Table is "+pkTable); } else { fkTable = (TablePane) s; logger.debug("66666666666666 Creating relationship: FK Table is "+fkTable); doCreateRelationship(); // this might fail, but still set things back to "normal" pp.setCursor(null); logger.debug("66666666666666 setting active to FALSE!"); active = false; } } else { logger.debug("777777777777 not instance of TablePane."); if (logger.isDebugEnabled()) logger.debug("The user clicked on a non-table component: "+s); } }
logger.debug("66666666666666 Creating relationship: FK Table is "+fkTable); doCreateRelationship();
logger.debug("Creating relationship: FK Table is "+fkTable); doCreateRelationship(pkTable.getModel(),fkTable.getModel(),pp,identifying);
public void itemSelected(SelectionEvent e) { // what address am I? logger.debug("00000000000 object hash code: " + super.hashCode()); // ignore events unless active logger.debug("11111111ITEM SELECTED: " + e); if (!active) { logger.debug("222222222 not active."); return; } else { logger.debug("222222222 ACTIVE!!!."); } Selectable s = e.getSelectableSource(); // don't care when tables (or anything else) are deselected if (!s.isSelected()) { logger.debug("333333333 not selected."); return; } if (s instanceof TablePane) { logger.debug("4444444444444 instance of TablePane."); if (pkTable == null) { pkTable = (TablePane) s; logger.debug("555555555555 Creating relationship: PK Table is "+pkTable); } else { fkTable = (TablePane) s; logger.debug("66666666666666 Creating relationship: FK Table is "+fkTable); doCreateRelationship(); // this might fail, but still set things back to "normal" pp.setCursor(null); logger.debug("66666666666666 setting active to FALSE!"); active = false; } } else { logger.debug("777777777777 not instance of TablePane."); if (logger.isDebugEnabled()) logger.debug("The user clicked on a non-table component: "+s); } }
logger.debug("66666666666666 setting active to FALSE!");
public void itemSelected(SelectionEvent e) { // what address am I? logger.debug("00000000000 object hash code: " + super.hashCode()); // ignore events unless active logger.debug("11111111ITEM SELECTED: " + e); if (!active) { logger.debug("222222222 not active."); return; } else { logger.debug("222222222 ACTIVE!!!."); } Selectable s = e.getSelectableSource(); // don't care when tables (or anything else) are deselected if (!s.isSelected()) { logger.debug("333333333 not selected."); return; } if (s instanceof TablePane) { logger.debug("4444444444444 instance of TablePane."); if (pkTable == null) { pkTable = (TablePane) s; logger.debug("555555555555 Creating relationship: PK Table is "+pkTable); } else { fkTable = (TablePane) s; logger.debug("66666666666666 Creating relationship: FK Table is "+fkTable); doCreateRelationship(); // this might fail, but still set things back to "normal" pp.setCursor(null); logger.debug("66666666666666 setting active to FALSE!"); active = false; } } else { logger.debug("777777777777 not instance of TablePane."); if (logger.isDebugEnabled()) logger.debug("The user clicked on a non-table component: "+s); } }
logger.debug("777777777777 not instance of TablePane.");
public void itemSelected(SelectionEvent e) { // what address am I? logger.debug("00000000000 object hash code: " + super.hashCode()); // ignore events unless active logger.debug("11111111ITEM SELECTED: " + e); if (!active) { logger.debug("222222222 not active."); return; } else { logger.debug("222222222 ACTIVE!!!."); } Selectable s = e.getSelectableSource(); // don't care when tables (or anything else) are deselected if (!s.isSelected()) { logger.debug("333333333 not selected."); return; } if (s instanceof TablePane) { logger.debug("4444444444444 instance of TablePane."); if (pkTable == null) { pkTable = (TablePane) s; logger.debug("555555555555 Creating relationship: PK Table is "+pkTable); } else { fkTable = (TablePane) s; logger.debug("66666666666666 Creating relationship: FK Table is "+fkTable); doCreateRelationship(); // this might fail, but still set things back to "normal" pp.setCursor(null); logger.debug("66666666666666 setting active to FALSE!"); active = false; } } else { logger.debug("777777777777 not instance of TablePane."); if (logger.isDebugEnabled()) logger.debug("The user clicked on a non-table component: "+s); } }
if (theGeno == a1){
if (theGeno == 0){ thisHap[j] = '0'; }else if (theGeno == a1){
public void doEM(int[] theBlock) throws HaploViewException{ //break up large blocks if needed int[] block_size; if (theBlock.length < 9){ block_size = new int[1]; block_size[0] = theBlock.length; } else { //some base-8 arithmetic int ones = theBlock.length%8; int eights = (theBlock.length - ones)/8; if (ones == 0){ block_size = new int[eights]; for (int i = 0; i < eights; i++){ block_size[i]=8; } } else { block_size = new int[eights+1]; for (int i = 0; i < eights-1; i++){ block_size[i]=8; } block_size[eights-1] = (8+ones)/2; block_size[eights] = 8+ones-block_size[eights-1]; } } byte[] thisHap; Vector inputHaploSingletons = new Vector(); Vector inputHaploTrios = new Vector(); Vector affSingletons = new Vector(); Vector affTrios = new Vector(); //whichVector[i] stores a value which indicates which vector chromosome i's genotype should go in //1 indicates inputHaploSingletons (singletons), 2 indicates inputHaploTrios, //3 indicates a person from a broken trio who is treated as a singleton //0 indicates none (too much missing data) int[] whichVector = new int[chromosomes.size()]; for(int i=0;i<numTrios*4; i+=4) { Chromosome parentAFirst = (Chromosome) chromosomes.elementAt(i); Chromosome parentASecond = (Chromosome) chromosomes.elementAt(i+1); Chromosome parentBFirst = (Chromosome) chromosomes.elementAt(i+2); Chromosome parentBSecond = (Chromosome) chromosomes.elementAt(i+3); boolean tooManyMissingInASegmentA = false; boolean tooManyMissingInASegmentB = false; int totalMissingA = 0; int totalMissingB = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missingA = 0; int missingB = 0; for (int j = 0; j < block_size[n]; j++){ byte AFirstGeno = parentAFirst.getGenotype(theBlock[segmentShift+j]); byte ASecondGeno = parentASecond.getGenotype(theBlock[segmentShift+j]); byte BFirstGeno = parentBFirst.getGenotype(theBlock[segmentShift+j]); byte BSecondGeno = parentBSecond.getGenotype(theBlock[segmentShift+j]); if(AFirstGeno == 0 || ASecondGeno == 0) missingA++; if(BFirstGeno == 0 || BSecondGeno == 0) missingB++; } segmentShift += block_size[n]; if (missingA >= MISSINGLIMIT){ tooManyMissingInASegmentA = true; } if (missingB >= MISSINGLIMIT){ tooManyMissingInASegmentB = true; } totalMissingA += missingA; totalMissingB += missingB; } if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3 && !tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { //both parents are good so all 4 chroms are added as a trio whichVector[i] = 2; whichVector[i+1] = 2; whichVector[i+2] = 2; whichVector[i+3] = 2; } else if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3) { //first person good, so he's added as a singleton, other parent is dropped whichVector[i] = 3; whichVector[i+1] =3; whichVector[i+2] =0; whichVector[i+3]=0; } else if(!tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { //second person good, so he's added as a singleton, other parent is dropped whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =3; whichVector[i+3]=3; } else { //both people have too much missing data so neither is used whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =0; whichVector[i+3]=0; } } for (int i = numTrios*4; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); Chromosome nextChrom = (Chromosome)chromosomes.elementAt(++i); boolean tooManyMissingInASegment = false; int totalMissing = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missing = 0; for (int j = 0; j < block_size[n]; j++){ byte theGeno = thisChrom.getGenotype(theBlock[segmentShift+j]); byte nextGeno = nextChrom.getGenotype(theBlock[segmentShift+j]); if(theGeno == 0 || nextGeno == 0) missing++; } segmentShift += block_size[n]; if (missing >= MISSINGLIMIT){ tooManyMissingInASegment = true; } totalMissing += missing; } //we want to use chromosomes without too many missing genotypes in a given //subsegment (first term) or without too many missing genotypes in the //whole block (second term) if (!tooManyMissingInASegment && totalMissing <= 1+theBlock.length/3){ whichVector[i-1] = 1; whichVector[i] = 1; } } //we only want to add an affected status every other chromosome, so we flip this boolean each time boolean addAff = true; for (int i = 0; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); if(whichVector[i] > 0) { thisHap = new byte[theBlock.length]; for (int j = 0; j < theBlock.length; j++){ byte a1 = Chromosome.getMarker(theBlock[j]).getMajor(); byte a2 = Chromosome.getMarker(theBlock[j]).getMinor(); byte theGeno = thisChrom.getGenotype(theBlock[j]); if (theGeno >= 5){ thisHap[j] = 'h'; } else { if (theGeno == a1){ thisHap[j] = '1'; }else if (theGeno == a2){ thisHap[j] = '2'; }else{ thisHap[j] = '0'; } } } if(whichVector[i] == 1) { inputHaploSingletons.add(thisHap); if(addAff) { affSingletons.add(new Integer(thisChrom.getAffected())); } } else if(whichVector[i] ==2) { inputHaploTrios.add(thisHap); if(addAff) { affTrios.add(new Integer(thisChrom.getAffected())); } }else if (whichVector[i] == 3){ inputHaploSingletons.add(thisHap); if(addAff) { affSingletons.add(new Integer(0)); } } if(addAff) { addAff = false; } else { addAff =true; } } } int trioCount = inputHaploTrios.size() / 4; inputHaploTrios.addAll(inputHaploSingletons); affTrios.addAll(affSingletons); byte[][] input_haplos = (byte[][])inputHaploTrios.toArray(new byte[0][0]); full_em_breakup(input_haplos, block_size, trioCount, affTrios); }
thisHap[j] = '0';
throw new HaploViewException("Marker with > 2 alleles: " + Chromosome.getMarker(theBlock[j]).getName());
public void doEM(int[] theBlock) throws HaploViewException{ //break up large blocks if needed int[] block_size; if (theBlock.length < 9){ block_size = new int[1]; block_size[0] = theBlock.length; } else { //some base-8 arithmetic int ones = theBlock.length%8; int eights = (theBlock.length - ones)/8; if (ones == 0){ block_size = new int[eights]; for (int i = 0; i < eights; i++){ block_size[i]=8; } } else { block_size = new int[eights+1]; for (int i = 0; i < eights-1; i++){ block_size[i]=8; } block_size[eights-1] = (8+ones)/2; block_size[eights] = 8+ones-block_size[eights-1]; } } byte[] thisHap; Vector inputHaploSingletons = new Vector(); Vector inputHaploTrios = new Vector(); Vector affSingletons = new Vector(); Vector affTrios = new Vector(); //whichVector[i] stores a value which indicates which vector chromosome i's genotype should go in //1 indicates inputHaploSingletons (singletons), 2 indicates inputHaploTrios, //3 indicates a person from a broken trio who is treated as a singleton //0 indicates none (too much missing data) int[] whichVector = new int[chromosomes.size()]; for(int i=0;i<numTrios*4; i+=4) { Chromosome parentAFirst = (Chromosome) chromosomes.elementAt(i); Chromosome parentASecond = (Chromosome) chromosomes.elementAt(i+1); Chromosome parentBFirst = (Chromosome) chromosomes.elementAt(i+2); Chromosome parentBSecond = (Chromosome) chromosomes.elementAt(i+3); boolean tooManyMissingInASegmentA = false; boolean tooManyMissingInASegmentB = false; int totalMissingA = 0; int totalMissingB = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missingA = 0; int missingB = 0; for (int j = 0; j < block_size[n]; j++){ byte AFirstGeno = parentAFirst.getGenotype(theBlock[segmentShift+j]); byte ASecondGeno = parentASecond.getGenotype(theBlock[segmentShift+j]); byte BFirstGeno = parentBFirst.getGenotype(theBlock[segmentShift+j]); byte BSecondGeno = parentBSecond.getGenotype(theBlock[segmentShift+j]); if(AFirstGeno == 0 || ASecondGeno == 0) missingA++; if(BFirstGeno == 0 || BSecondGeno == 0) missingB++; } segmentShift += block_size[n]; if (missingA >= MISSINGLIMIT){ tooManyMissingInASegmentA = true; } if (missingB >= MISSINGLIMIT){ tooManyMissingInASegmentB = true; } totalMissingA += missingA; totalMissingB += missingB; } if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3 && !tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { //both parents are good so all 4 chroms are added as a trio whichVector[i] = 2; whichVector[i+1] = 2; whichVector[i+2] = 2; whichVector[i+3] = 2; } else if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3) { //first person good, so he's added as a singleton, other parent is dropped whichVector[i] = 3; whichVector[i+1] =3; whichVector[i+2] =0; whichVector[i+3]=0; } else if(!tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { //second person good, so he's added as a singleton, other parent is dropped whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =3; whichVector[i+3]=3; } else { //both people have too much missing data so neither is used whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =0; whichVector[i+3]=0; } } for (int i = numTrios*4; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); Chromosome nextChrom = (Chromosome)chromosomes.elementAt(++i); boolean tooManyMissingInASegment = false; int totalMissing = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missing = 0; for (int j = 0; j < block_size[n]; j++){ byte theGeno = thisChrom.getGenotype(theBlock[segmentShift+j]); byte nextGeno = nextChrom.getGenotype(theBlock[segmentShift+j]); if(theGeno == 0 || nextGeno == 0) missing++; } segmentShift += block_size[n]; if (missing >= MISSINGLIMIT){ tooManyMissingInASegment = true; } totalMissing += missing; } //we want to use chromosomes without too many missing genotypes in a given //subsegment (first term) or without too many missing genotypes in the //whole block (second term) if (!tooManyMissingInASegment && totalMissing <= 1+theBlock.length/3){ whichVector[i-1] = 1; whichVector[i] = 1; } } //we only want to add an affected status every other chromosome, so we flip this boolean each time boolean addAff = true; for (int i = 0; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); if(whichVector[i] > 0) { thisHap = new byte[theBlock.length]; for (int j = 0; j < theBlock.length; j++){ byte a1 = Chromosome.getMarker(theBlock[j]).getMajor(); byte a2 = Chromosome.getMarker(theBlock[j]).getMinor(); byte theGeno = thisChrom.getGenotype(theBlock[j]); if (theGeno >= 5){ thisHap[j] = 'h'; } else { if (theGeno == a1){ thisHap[j] = '1'; }else if (theGeno == a2){ thisHap[j] = '2'; }else{ thisHap[j] = '0'; } } } if(whichVector[i] == 1) { inputHaploSingletons.add(thisHap); if(addAff) { affSingletons.add(new Integer(thisChrom.getAffected())); } } else if(whichVector[i] ==2) { inputHaploTrios.add(thisHap); if(addAff) { affTrios.add(new Integer(thisChrom.getAffected())); } }else if (whichVector[i] == 3){ inputHaploSingletons.add(thisHap); if(addAff) { affSingletons.add(new Integer(0)); } } if(addAff) { addAff = false; } else { addAff =true; } } } int trioCount = inputHaploTrios.size() / 4; inputHaploTrios.addAll(inputHaploSingletons); affTrios.addAll(affSingletons); byte[][] input_haplos = (byte[][])inputHaploTrios.toArray(new byte[0][0]); full_em_breakup(input_haplos, block_size, trioCount, affTrios); }
if (cur.getRating() > 0){
int curRating = cur.getRating(); if (curRating > 0){
public void redoRatings(){ try{ Vector result = pedfile.check(); for (int i = 0; i < table.getRowCount(); i++){ MarkerResult cur = (MarkerResult)result.get(i); if (cur.getRating() > 0){ table.setValueAt(new Boolean(true),i,STATUS_COL); }else{ table.setValueAt(new Boolean(false),i,STATUS_COL); } } changed = true; }catch (Exception e){ e.printStackTrace(); } }
for(int i=0;i<extraInds.size();i++){ this.chromosomes.add(extraInds.elementAt(i)); if(((Chromosome)this.chromosomes.lastElement()).isHaploid()){
if(extraInds != null){ for(int i=0;i<extraInds.size();i++){
EM(Vector chromosomes, int numTrios, Vector extraInds){ //we need to add extra copies of haploid chromosomes so we add a second copy this.chromosomes = new Vector(); for(int i=0;i<extraInds.size();i++){ this.chromosomes.add(extraInds.elementAt(i)); if(((Chromosome)this.chromosomes.lastElement()).isHaploid()){ this.chromosomes.add(extraInds.elementAt(i)); } } extraTrioCount = this.chromosomes.size()/4; for(int i=0;i<chromosomes.size();i++) { this.chromosomes.add(chromosomes.elementAt(i)); if(((Chromosome)this.chromosomes.lastElement()).isHaploid()){ this.chromosomes.add(chromosomes.elementAt(i)); } } this.numTrios = numTrios + extraTrioCount; }
if(((Chromosome)this.chromosomes.lastElement()).isHaploid()){ this.chromosomes.add(extraInds.elementAt(i)); }
EM(Vector chromosomes, int numTrios, Vector extraInds){ //we need to add extra copies of haploid chromosomes so we add a second copy this.chromosomes = new Vector(); for(int i=0;i<extraInds.size();i++){ this.chromosomes.add(extraInds.elementAt(i)); if(((Chromosome)this.chromosomes.lastElement()).isHaploid()){ this.chromosomes.add(extraInds.elementAt(i)); } } extraTrioCount = this.chromosomes.size()/4; for(int i=0;i<chromosomes.size();i++) { this.chromosomes.add(chromosomes.elementAt(i)); if(((Chromosome)this.chromosomes.lastElement()).isHaploid()){ this.chromosomes.add(chromosomes.elementAt(i)); } } this.numTrios = numTrios + extraTrioCount; }
Process proc = Runtime.getRuntime().exec(commandLine.toString()); JDialog d = new JDialog(architectFrame, "Power*Loader Engine"); d.setContentPane(new EngineExecPanel(commandLine.toString(), proc));
final Process proc = Runtime.getRuntime().exec(commandLine.toString()); final JDialog d = new JDialog(architectFrame, "Power*Loader Engine"); EngineExecPanel eep = new EngineExecPanel(commandLine.toString(), proc); d.setContentPane(eep); JButton abortButton = new JButton(eep.getAbortAction()); JButton closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { d.setVisible(false); } }); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); buttonPanel.add(abortButton); buttonPanel.add(closeButton); eep.add(buttonPanel, BorderLayout.SOUTH);
public synchronized void setupDialog() { if (d != null) return; d = new JDialog(ArchitectFrame.getMainInstance(), "Export ETL Transactions to PL Repository"); // set export defaults if necessary if (plexp.getFolderName() == null || plexp.getFolderName().trim().length() == 0) { plexp.setFolderName(PLUtils.toPLIdentifier(architectFrame.getProject().getName()+"_FOLDER")); } if (plexp.getJobId() == null || plexp.getJobId().trim().length() == 0) { plexp.setJobId(PLUtils.toPLIdentifier(architectFrame.getProject().getName()+"_JOB")); } JPanel plp = new JPanel(new BorderLayout(12,12)); plp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final PLExportPanel plPanel = new PLExportPanel(); plPanel.setPLExport(plexp); plp.add(plPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { plPanel.applyChanges(); if (plexp.getPlDBCS() == null) { JOptionPane.showMessageDialog(plPanel, "You have to select a target database from the list.", "Error", JOptionPane.ERROR_MESSAGE); return; } if (plexp.getPlUsername().trim().length() == 0) { JOptionPane.showMessageDialog(plPanel, "You have to specify the PowerLoader User Name.", "Error", JOptionPane.ERROR_MESSAGE); return; } if (plexp.getJobId().trim().length() == 0) { JOptionPane.showMessageDialog(plPanel, "You have to specify the PowerLoader Job ID.", "Error", JOptionPane.ERROR_MESSAGE); return; } try { List targetDBWarnings = listMissingTargetTables(); if (!targetDBWarnings.isEmpty()) { JList warnings = new JList(targetDBWarnings.toArray()); JPanel cp = new JPanel(new BorderLayout()); cp.add(new JLabel("<html>The target database schema is not identical to your Architect schema.<br><br>Here are the differences:</html>"), BorderLayout.NORTH); cp.add(new JScrollPane(warnings), BorderLayout.CENTER); cp.add(new JLabel("Do you want to continue anyway?"), BorderLayout.SOUTH); int choice = JOptionPane.showConfirmDialog(playpen, cp, "Target Database Structure Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (choice == JOptionPane.NO_OPTION) return; } plexp.export(playpen.getDatabase()); if (plPanel.isSelectedRunPLEngine()) { logger.debug("Running PL Engine"); File plIni = new File(architectFrame.getUserSettings().getETLUserSettings().getPlDotIniPath()); File plDir = plIni.getParentFile(); File engineExe = new File(plDir, plPanel.getPLConnectionSpec().getEngineExeutableName()); StringBuffer commandLine = new StringBuffer(1000); commandLine.append(engineExe.getPath()); commandLine.append(" USER_PROMPT=N"); commandLine.append(" JOB=").append(plexp.getJobId()); commandLine.append(" USER=").append(plPanel.getPLConnectionSpec().getEngineConnectString()); commandLine.append(" DEBUG=N SEND_EMAIL=N SKIP_PACKAGES=N CALC_DETAIL_STATS=N COMMIT_FREQ=100 APPEND_TO_JOB_LOG_IND=N"); commandLine.append(" APPEND_TO_JOB_ERR_IND=N"); commandLine.append(" SHOW_PROGRESS=100" ); logger.debug(commandLine.toString()); try { Process proc = Runtime.getRuntime().exec(commandLine.toString()); JDialog d = new JDialog(architectFrame, "Power*Loader Engine"); d.setContentPane(new EngineExecPanel(commandLine.toString(), proc)); d.pack(); d.setLocationRelativeTo(plPanel); d.setVisible(true); } catch (IOException ie){ JOptionPane.showMessageDialog(playpen, "Unexpected Exception running Engine:\n"+ie); logger.error(ie); } } } catch (PLSecurityException ex) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+ex.getMessage()); logger.error("Got exception while exporting Trans", ex); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans", arex); } finally { d.setVisible(false); } } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { plPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); plp.add(buttonPanel, BorderLayout.SOUTH); d.setContentPane(plp); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); }
Process proc = Runtime.getRuntime().exec(commandLine.toString()); JDialog d = new JDialog(architectFrame, "Power*Loader Engine"); d.setContentPane(new EngineExecPanel(commandLine.toString(), proc));
final Process proc = Runtime.getRuntime().exec(commandLine.toString()); final JDialog d = new JDialog(architectFrame, "Power*Loader Engine"); EngineExecPanel eep = new EngineExecPanel(commandLine.toString(), proc); d.setContentPane(eep); JButton abortButton = new JButton(eep.getAbortAction()); JButton closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { d.setVisible(false); } }); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); buttonPanel.add(abortButton); buttonPanel.add(closeButton); eep.add(buttonPanel, BorderLayout.SOUTH);
public void actionPerformed(ActionEvent evt) { plPanel.applyChanges(); if (plexp.getPlDBCS() == null) { JOptionPane.showMessageDialog(plPanel, "You have to select a target database from the list.", "Error", JOptionPane.ERROR_MESSAGE); return; } if (plexp.getPlUsername().trim().length() == 0) { JOptionPane.showMessageDialog(plPanel, "You have to specify the PowerLoader User Name.", "Error", JOptionPane.ERROR_MESSAGE); return; } if (plexp.getJobId().trim().length() == 0) { JOptionPane.showMessageDialog(plPanel, "You have to specify the PowerLoader Job ID.", "Error", JOptionPane.ERROR_MESSAGE); return; } try { List targetDBWarnings = listMissingTargetTables(); if (!targetDBWarnings.isEmpty()) { JList warnings = new JList(targetDBWarnings.toArray()); JPanel cp = new JPanel(new BorderLayout()); cp.add(new JLabel("<html>The target database schema is not identical to your Architect schema.<br><br>Here are the differences:</html>"), BorderLayout.NORTH); cp.add(new JScrollPane(warnings), BorderLayout.CENTER); cp.add(new JLabel("Do you want to continue anyway?"), BorderLayout.SOUTH); int choice = JOptionPane.showConfirmDialog(playpen, cp, "Target Database Structure Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (choice == JOptionPane.NO_OPTION) return; } plexp.export(playpen.getDatabase()); if (plPanel.isSelectedRunPLEngine()) { logger.debug("Running PL Engine"); File plIni = new File(architectFrame.getUserSettings().getETLUserSettings().getPlDotIniPath()); File plDir = plIni.getParentFile(); File engineExe = new File(plDir, plPanel.getPLConnectionSpec().getEngineExeutableName()); StringBuffer commandLine = new StringBuffer(1000); commandLine.append(engineExe.getPath()); commandLine.append(" USER_PROMPT=N"); commandLine.append(" JOB=").append(plexp.getJobId()); commandLine.append(" USER=").append(plPanel.getPLConnectionSpec().getEngineConnectString()); commandLine.append(" DEBUG=N SEND_EMAIL=N SKIP_PACKAGES=N CALC_DETAIL_STATS=N COMMIT_FREQ=100 APPEND_TO_JOB_LOG_IND=N"); commandLine.append(" APPEND_TO_JOB_ERR_IND=N"); commandLine.append(" SHOW_PROGRESS=100" ); logger.debug(commandLine.toString()); try { Process proc = Runtime.getRuntime().exec(commandLine.toString()); JDialog d = new JDialog(architectFrame, "Power*Loader Engine"); d.setContentPane(new EngineExecPanel(commandLine.toString(), proc)); d.pack(); d.setLocationRelativeTo(plPanel); d.setVisible(true); } catch (IOException ie){ JOptionPane.showMessageDialog(playpen, "Unexpected Exception running Engine:\n"+ie); logger.error(ie); } } } catch (PLSecurityException ex) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+ex.getMessage()); logger.error("Got exception while exporting Trans", ex); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans", arex); } finally { d.setVisible(false); } }
plPanel.discardChanges(); d.setVisible(false); }
d.setVisible(false); }
public void actionPerformed(ActionEvent evt) { plPanel.discardChanges(); d.setVisible(false); }
a1 = ((Chromosome) chromosomes.elementAt(i)).genotypes[pos1]; a2 = ((Chromosome) chromosomes.elementAt(i)).genotypes[pos2]; b1 = ((Chromosome) chromosomes.elementAt(++i)).genotypes[pos1]; b2 = ((Chromosome) chromosomes.elementAt(i)).genotypes[pos2]; if (a1 == 0 || a2 == 0 || b1 == 0 || b2 == 0){ } else if (((a1 >= 5 || b1 >= 5) && (a2 >= 5 || b2 >= 5)) || (a1 >= 5 && !(a2 == b2)) || (a2 >= 5 && !(a1 == b1))){ doublehet++; } else if (a1 >= 5 || b1 >= 5){ twoMarkerHaplos[1][marker2num[a2]]++; twoMarkerHaplos[2][marker2num[a2]]++; } else if (a2 >= 5 || b2 >= 5){ twoMarkerHaplos[marker1num[a1]][1]++; twoMarkerHaplos[marker1num[a1]][2]++; } else { twoMarkerHaplos[marker1num[a1]][marker2num[a2]]++; twoMarkerHaplos[marker1num[b1]][marker2num[b2]]++; }
if(!((Chromosome)chromosomes.elementAt(i)).isHaploid()){ a1 = ((Chromosome) chromosomes.elementAt(i)).genotypes[pos1]; a2 = ((Chromosome) chromosomes.elementAt(i)).genotypes[pos2]; b1 = ((Chromosome) chromosomes.elementAt(++i)).genotypes[pos1]; b2 = ((Chromosome) chromosomes.elementAt(i)).genotypes[pos2]; if (a1 == 0 || a2 == 0 || b1 == 0 || b2 == 0){ } else if (((a1 >= 5 || b1 >= 5) && (a2 >= 5 || b2 >= 5)) || (a1 >= 5 && !(a2 == b2)) || (a2 >= 5 && !(a1 == b1))){ doublehet++; } else if (a1 >= 5 || b1 >= 5){ twoMarkerHaplos[1][marker2num[a2]]++; twoMarkerHaplos[2][marker2num[a2]]++; } else if (a2 >= 5 || b2 >= 5){ twoMarkerHaplos[marker1num[a1]][1]++; twoMarkerHaplos[marker1num[a1]][2]++; } else { twoMarkerHaplos[marker1num[a1]][marker2num[a2]]++; twoMarkerHaplos[marker1num[b1]][marker2num[b2]]++; } }else { a1 = ((Chromosome) chromosomes.elementAt(i)).genotypes[pos1]; a2 = ((Chromosome) chromosomes.elementAt(i)).genotypes[pos2]; if(a1 == 0 || a2 == 0) { }else{ twoMarkerHaplos[marker1num[a1]][marker2num[a2]]++; } }
public PairwiseLinkage computeDPrime(int pos1, int pos2){ int doublehet = 0; int[][] twoMarkerHaplos = new int[3][3]; for (int i = 0; i < twoMarkerHaplos.length; i++){ for (int j = 0; j < twoMarkerHaplos[i].length; j++){ twoMarkerHaplos[i][j] = 0; } } //check for non-polymorphic markers if (Chromosome.getUnfilteredMarker(pos1).getMAF() == 0 || Chromosome.getUnfilteredMarker(pos2).getMAF() == 0){ return null; } int[] marker1num = new int[5]; int[] marker2num = new int[5]; marker1num[0]=0; marker1num[Chromosome.getUnfilteredMarker(pos1).getMajor()]=1; marker1num[Chromosome.getUnfilteredMarker(pos1).getMinor()]=2; marker2num[0]=0; marker2num[Chromosome.getUnfilteredMarker(pos2).getMajor()]=1; marker2num[Chromosome.getUnfilteredMarker(pos2).getMinor()]=2; byte a1,a2,b1,b2; //iterate through all chromosomes in dataset for (int i = 0; i < chromosomes.size(); i++){ //System.out.println(i + " " + pos1 + " " + pos2); //assign alleles for each of a pair of chromosomes at a marker to four variables a1 = ((Chromosome) chromosomes.elementAt(i)).genotypes[pos1]; a2 = ((Chromosome) chromosomes.elementAt(i)).genotypes[pos2]; b1 = ((Chromosome) chromosomes.elementAt(++i)).genotypes[pos1]; b2 = ((Chromosome) chromosomes.elementAt(i)).genotypes[pos2]; if (a1 == 0 || a2 == 0 || b1 == 0 || b2 == 0){ //skip missing data } else if (((a1 >= 5 || b1 >= 5) && (a2 >= 5 || b2 >= 5)) || (a1 >= 5 && !(a2 == b2)) || (a2 >= 5 && !(a1 == b1))){ doublehet++; //find doublehets and resolved haplotypes } else if (a1 >= 5 || b1 >= 5){ twoMarkerHaplos[1][marker2num[a2]]++; twoMarkerHaplos[2][marker2num[a2]]++; } else if (a2 >= 5 || b2 >= 5){ twoMarkerHaplos[marker1num[a1]][1]++; twoMarkerHaplos[marker1num[a1]][2]++; } else { twoMarkerHaplos[marker1num[a1]][marker2num[a2]]++; twoMarkerHaplos[marker1num[b1]][marker2num[b2]]++; } } //another monomorphic marker check int r1, r2, c1, c2; r1 = twoMarkerHaplos[1][1] + twoMarkerHaplos[1][2]; r2 = twoMarkerHaplos[2][1] + twoMarkerHaplos[2][2]; c1 = twoMarkerHaplos[1][1] + twoMarkerHaplos[2][1]; c2 = twoMarkerHaplos[1][2] + twoMarkerHaplos[2][2]; if ( (r1==0 || r2==0 || c1==0 || c2==0) && doublehet == 0){ return new PairwiseLinkage(1,0,0,0,0,new double[0]); } //compute D Prime for this pair of markers. //return is a tab delimited string of d', lod, r^2, CI(low), CI(high) int i,count; //int j,k,itmp; int low_i = 0; int high_i = 0; double loglike, oldloglike;// meand, mean2d, sd; double tmp;//g,h,m,tmp,r; double num, denom1, denom2, denom, dprime;//, real_dprime; double pA1, pB1, pA2, pB2, loglike1, loglike0, rsq; double tmpAA, tmpAB, tmpBA, tmpBB, dpr;// tmp2AA, tmp2AB, tmp2BA, tmp2BB; double total_prob, sum_prob; double lsurface[] = new double[101]; /* store arguments in externals and compute allele frequencies */ known[AA]=twoMarkerHaplos[1][1]; known[AB]=twoMarkerHaplos[1][2]; known[BA]=twoMarkerHaplos[2][1]; known[BB]=twoMarkerHaplos[2][2]; unknownDH=doublehet; total_chroms= (int)(known[AA]+known[AB]+known[BA]+known[BB]+(2*unknownDH)); pA1 = (known[AA]+known[AB]+unknownDH) / (double) total_chroms; pB1 = 1.0-pA1; pA2 = (known[AA]+known[BA]+unknownDH) / (double) total_chroms; pB2 = 1.0-pA2; const_prob = 0.1; /* set initial conditions */ if (const_prob < 0.00) { probHaps[AA]=pA1*pA2; probHaps[AB]=pA1*pB2; probHaps[BA]=pB1*pA2; probHaps[BB]=pB1*pB2; } else { probHaps[AA]=const_prob; probHaps[AB]=const_prob; probHaps[BA]=const_prob; probHaps[BB]=const_prob;; /* so that the first count step will produce an initial estimate without inferences (this should be closer and therefore speedier than assuming they are all at equal frequency) */ count_haps(0); estimate_p(); } /* now we have an initial reasonable guess at p we can start the EM - let the fun begin */ const_prob=0.0; count=1; loglike=-999999999.0; do { oldloglike=loglike; count_haps(count); loglike = (known[AA]*Math.log(probHaps[AA]) + known[AB]*Math.log(probHaps[AB]) + known[BA]*Math.log(probHaps[BA]) + known[BB]*Math.log(probHaps[BB]))/LN10 + ((double)unknownDH*Math.log(probHaps[AA]*probHaps[BB] + probHaps[AB]*probHaps[BA]))/LN10; if (Math.abs(loglike-oldloglike) < TOLERANCE) break; estimate_p(); count++; } while(count < 1000); /* in reality I've never seen it need more than 10 or so iterations to converge so this is really here just to keep it from running off into eternity */ loglike1 = (known[AA]*Math.log(probHaps[AA]) + known[AB]*Math.log(probHaps[AB]) + known[BA]*Math.log(probHaps[BA]) + known[BB]*Math.log(probHaps[BB]) + (double)unknownDH*Math.log(probHaps[AA]*probHaps[BB] + probHaps[AB]*probHaps[BA]))/LN10; loglike0 = (known[AA]*Math.log(pA1*pA2) + known[AB]*Math.log(pA1*pB2) + known[BA]*Math.log(pB1*pA2) + known[BB]*Math.log(pB1*pB2) + (double)unknownDH*Math.log(2*pA1*pA2*pB1*pB2))/LN10; num = probHaps[AA]*probHaps[BB] - probHaps[AB]*probHaps[BA]; if (num < 0) { /* flip matrix so we get the positive D' */ /* flip AA with AB and BA with BB */ tmp=probHaps[AA]; probHaps[AA]=probHaps[AB]; probHaps[AB]=tmp; tmp=probHaps[BB]; probHaps[BB]=probHaps[BA]; probHaps[BA]=tmp; /* flip frequency of second allele */ //done in this slightly asinine way because of a compiler bugz0r in the dec-alpha version of java //which causes it to try to parallelize the swapping operations and mis-schedules them pA2 = pA2 + pB2; pB2 = pA2 - pB2; pA2 = pA2 - pB2; //pA2=pB2;pB2=temp; /* flip counts in the same fashion as p's */ tmp=numHaps[AA]; numHaps[AA]=numHaps[AB]; numHaps[AB]=tmp; tmp=numHaps[BB]; numHaps[BB]=numHaps[BA]; numHaps[BA]=tmp; /* num has now undergone a sign change */ num = probHaps[AA]*probHaps[BB] - probHaps[AB]*probHaps[BA]; /* flip known array for likelihood computation */ tmp=known[AA]; known[AA]=known[AB]; known[AB]=tmp; tmp=known[BB]; known[BB]=known[BA]; known[BA]=tmp; } denom1 = (probHaps[AA]+probHaps[BA])*(probHaps[BA]+probHaps[BB]); denom2 = (probHaps[AA]+probHaps[AB])*(probHaps[AB]+probHaps[BB]); if (denom1 < denom2) { denom = denom1; } else { denom = denom2; } dprime = num/denom; /* add computation of r^2 = (D^2)/p(1-p)q(1-q) */ rsq = num*num/(pA1*pB1*pA2*pB2); //real_dprime=dprime; for (i=0; i<=100; i++) { dpr = (double)i*0.01; tmpAA = dpr*denom + pA1*pA2; tmpAB = pA1-tmpAA; tmpBA = pA2-tmpAA; tmpBB = pB1-tmpBA; if (i==100) { /* one value will be 0 */ if (tmpAA < 1e-10) tmpAA=1e-10; if (tmpAB < 1e-10) tmpAB=1e-10; if (tmpBA < 1e-10) tmpBA=1e-10; if (tmpBB < 1e-10) tmpBB=1e-10; } lsurface[i] = (known[AA]*Math.log(tmpAA) + known[AB]*Math.log(tmpAB) + known[BA]*Math.log(tmpBA) + known[BB]*Math.log(tmpBB) + (double)unknownDH*Math.log(tmpAA*tmpBB + tmpAB*tmpBA))/LN10; } /* Confidence bounds #2 - used in Gabriel et al (2002) - translate into posterior dist of D' - assumes a flat prior dist. of D' - someday we may be able to make this even more clever by adjusting given the distribution of observed D' values for any given distance after some large scale studies are complete */ total_prob=sum_prob=0.0; for (i=0; i<=100; i++) { lsurface[i] -= loglike1; lsurface[i] = Math.pow(10.0,lsurface[i]); total_prob += lsurface[i]; } for (i=0; i<=100; i++) { sum_prob += lsurface[i]; if (sum_prob > 0.05*total_prob && sum_prob-lsurface[i] < 0.05*total_prob) { low_i = i-1; break; } } sum_prob=0.0; for (i=100; i>=0; i--) { sum_prob += lsurface[i]; if (sum_prob > 0.05*total_prob && sum_prob-lsurface[i] < 0.05*total_prob) { high_i = i+1; break; } } if (high_i > 100){ high_i = 100; } double[] freqarray = {probHaps[AA], probHaps[AB], probHaps[BB], probHaps[BA]}; return new PairwiseLinkage(Util.roundDouble(dprime,3), Util.roundDouble((loglike1-loglike0),2), Util.roundDouble(rsq,3), ((double)low_i/100.0), ((double)high_i/100.0), freqarray); }