rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
st = new StringTokenizer(cc, ";"); | Object ccInput = this.cc.evaluate(context); st = new StringTokenizer(ccInput.toString(), ";"); | public void doTag(XMLOutput xmlOutput) throws JellyTagException { Properties props = new Properties(); props.putAll(context.getVariables()); // if a server was set then configure the system property if (server != null) { props.put("mail.smtp.host", server); } else { if (props.get("mail.smtp.host") == null) { throw new JellyTagException("no smtp server configured"); } } // check if there was no to address if (to == null) { throw new JellyTagException("no to address specified"); } // check if there was no from if (from == null) { throw new JellyTagException("no from address specified"); } // get the messageBody from the message attribute or from the tag body // lets insure that our body is evaluated whichever as child tags may // communicate with us to set properties etc. String messageBody = message; if (message != null) { invokeBody(xmlOutput); } else { message = getBodyText(encodeXML); } // configure the mail session Session session = Session.getDefaultInstance(props, null); // construct the mime message MimeMessage msg = new MimeMessage(session); try { // set the from address msg.setFrom(new InternetAddress(from)); // parse out the to addresses StringTokenizer st = new StringTokenizer(to, ";"); InternetAddress[] addresses = new InternetAddress[st.countTokens()]; int addressCount = 0; while (st.hasMoreTokens()) { addresses[addressCount++] = new InternetAddress(st.nextToken().trim()); } // set the recipients msg.setRecipients(Message.RecipientType.TO, addresses); // parse out the cc addresses if (cc != null) { st = new StringTokenizer(cc, ";"); InternetAddress[] ccAddresses = new InternetAddress[st.countTokens()]; int ccAddressCount = 0; while (st.hasMoreTokens()) { ccAddresses[ccAddressCount++] = new InternetAddress(st.nextToken().trim()); } // set the cc recipients msg.setRecipients(Message.RecipientType.CC, ccAddresses); } } catch (AddressException e) { throw new JellyTagException(e); } catch (MessagingException e) { throw new JellyTagException(e); } try { // set the subject if (subject != null) { msg.setSubject(subject); } // set a timestamp msg.setSentDate(new Date()); // if there was no attachment just set the text/body of the message if (attachment == null) { msg.setText(messageBody); } else { // attach the multipart mime message // setup the body MimeBodyPart mbp1 = new MimeBodyPart(); mbp1.setText(messageBody); // setup the attachment MimeBodyPart mbp2 = new MimeBodyPart(); FileDataSource fds = new FileDataSource(attachment); mbp2.setDataHandler(new DataHandler(fds)); mbp2.setFileName(fds.getName()); // create the multipart and add its parts Multipart mp = new MimeMultipart(); mp.addBodyPart(mbp1); mp.addBodyPart(mbp2); msg.setContent(mp); } logger.info("sending email to " + to + " using " + server); // send the email Transport.send(msg); } catch (MessagingException e) { throw new JellyTagException(e); } } |
msg.setSubject(subject); | Object subjectInput = this.subject.evaluate(context); msg.setSubject(subjectInput.toString()); | public void doTag(XMLOutput xmlOutput) throws JellyTagException { Properties props = new Properties(); props.putAll(context.getVariables()); // if a server was set then configure the system property if (server != null) { props.put("mail.smtp.host", server); } else { if (props.get("mail.smtp.host") == null) { throw new JellyTagException("no smtp server configured"); } } // check if there was no to address if (to == null) { throw new JellyTagException("no to address specified"); } // check if there was no from if (from == null) { throw new JellyTagException("no from address specified"); } // get the messageBody from the message attribute or from the tag body // lets insure that our body is evaluated whichever as child tags may // communicate with us to set properties etc. String messageBody = message; if (message != null) { invokeBody(xmlOutput); } else { message = getBodyText(encodeXML); } // configure the mail session Session session = Session.getDefaultInstance(props, null); // construct the mime message MimeMessage msg = new MimeMessage(session); try { // set the from address msg.setFrom(new InternetAddress(from)); // parse out the to addresses StringTokenizer st = new StringTokenizer(to, ";"); InternetAddress[] addresses = new InternetAddress[st.countTokens()]; int addressCount = 0; while (st.hasMoreTokens()) { addresses[addressCount++] = new InternetAddress(st.nextToken().trim()); } // set the recipients msg.setRecipients(Message.RecipientType.TO, addresses); // parse out the cc addresses if (cc != null) { st = new StringTokenizer(cc, ";"); InternetAddress[] ccAddresses = new InternetAddress[st.countTokens()]; int ccAddressCount = 0; while (st.hasMoreTokens()) { ccAddresses[ccAddressCount++] = new InternetAddress(st.nextToken().trim()); } // set the cc recipients msg.setRecipients(Message.RecipientType.CC, ccAddresses); } } catch (AddressException e) { throw new JellyTagException(e); } catch (MessagingException e) { throw new JellyTagException(e); } try { // set the subject if (subject != null) { msg.setSubject(subject); } // set a timestamp msg.setSentDate(new Date()); // if there was no attachment just set the text/body of the message if (attachment == null) { msg.setText(messageBody); } else { // attach the multipart mime message // setup the body MimeBodyPart mbp1 = new MimeBodyPart(); mbp1.setText(messageBody); // setup the attachment MimeBodyPart mbp2 = new MimeBodyPart(); FileDataSource fds = new FileDataSource(attachment); mbp2.setDataHandler(new DataHandler(fds)); mbp2.setFileName(fds.getName()); // create the multipart and add its parts Multipart mp = new MimeMultipart(); mp.addBodyPart(mbp1); mp.addBodyPart(mbp2); msg.setContent(mp); } logger.info("sending email to " + to + " using " + server); // send the email Transport.send(msg); } catch (MessagingException e) { throw new JellyTagException(e); } } |
public void setCC(String cc) { | public void setCC(Expression cc) { | public void setCC(String cc) { this.cc = cc; } |
public void setFrom(String from) { | public void setFrom(Expression from) { | public void setFrom(String from) { this.from = from; } |
public void setMessage(String message) { | public void setMessage(Expression message) { | public void setMessage(String message) { this.message = message; } |
public void setServer(String server) { | public void setServer(Expression server) { | public void setServer(String server) { this.server = server; } |
public void setSubject(String subject) { | public void setSubject(Expression subject) { | public void setSubject(String subject) { this.subject = subject; } |
public void setTo(String to) { | public void setTo(Expression to) { | public void setTo(String to) { this.to = to; } |
amount--; | public int skipNext(int amount) throws FetchException { if (amount <= 0) { if (amount < 0) { throw new IllegalArgumentException("Cannot skip negative amount: " + amount); } return 0; } ResultSet rs = mResultSet; if (rs == null) { return 0; } mHasNext = true; int actual = 0; while (amount > 0) { try { if (rs.next()) { actual++; } else { mHasNext = false; close(); break; } } catch (SQLException e) { throw mStorage.getJDBCRepository().toFetchException(e); } } return actual; } |
|
getBody().run(context, output); | invokeBody(output); | public void doTag(XMLOutput output) throws Exception { // for use by inner classes this.output = output; Stylesheet stylesheet = getStylesheet(); stylesheet.clear(); // run the body to add the rules getBody().run(context, output); stylesheet.setModeName(getMode()); if (var != null) { context.setVariable(var, stylesheet); } else { Object source = getSource(); if (log.isDebugEnabled()) { log.debug("About to evaluate stylesheet on source: " + source); } stylesheet.run(source); } } |
private boolean login( LoginDlg ld ) { | private void login( LoginDlg ld ) throws PhotovaultException { | private boolean login( LoginDlg ld ) { boolean success = false; String user = ld.getUsername(); String passwd = ld.getPassword(); String dbName = ld.getDb(); log.debug( "Using configuration " + dbName ); settings.setConfiguration( dbName ); PVDatabase db = settings.getDatabase( dbName ); String sqldbName = db.getDbName(); log.debug( "Mysql DB name: " + sqldbName ); if ( sqldbName == null ) { JOptionPane.showMessageDialog( ld, "Could not find dbname for configuration " + db, "Configuration error", JOptionPane.ERROR_MESSAGE ); return false; } if ( ODMG.initODMG( user, passwd, db ) ) { log.debug( "Connection succesful!!!" ); // Login is succesfull // ld.setVisible( false ); success = true; int schemaVersion = db.getSchemaVersion(); if ( schemaVersion < db.CURRENT_SCHEMA_VERSION ) { String options[] = {"Proceed", "Exit Photovault"}; if ( JOptionPane.YES_OPTION == JOptionPane.showOptionDialog( ld, "The database was created with an older version of Photovault\n" + "Photovault will upgrade the database format before starting.", "Upgrade database", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, null ) ) { final SchemaUpdateAction updater = new SchemaUpdateAction( db ); SchemaUpdateStatusDlg statusDlg = new SchemaUpdateStatusDlg( null, true ); updater.addSchemaUpdateListener( statusDlg ); Thread upgradeThread = new Thread() { public void run() { updater.upgradeDatabase(); } }; upgradeThread.start(); statusDlg.setVisible( true ); success = true; } } } return success; } |
log.debug( "Mysql DB name: " + sqldbName ); if ( sqldbName == null ) { JOptionPane.showMessageDialog( ld, "Could not find dbname for configuration " + db, "Configuration error", JOptionPane.ERROR_MESSAGE ); return false; | log.debug( "Mysql DB name: " + sqldbName ); if ( sqldbName == null ) { JOptionPane.showMessageDialog( ld, "Could not find dbname for configuration " + db, "Configuration error", JOptionPane.ERROR_MESSAGE ); throw new PhotovaultException( "Could not find dbname for configuration " + db ); | private boolean login( LoginDlg ld ) { boolean success = false; String user = ld.getUsername(); String passwd = ld.getPassword(); String dbName = ld.getDb(); log.debug( "Using configuration " + dbName ); settings.setConfiguration( dbName ); PVDatabase db = settings.getDatabase( dbName ); String sqldbName = db.getDbName(); log.debug( "Mysql DB name: " + sqldbName ); if ( sqldbName == null ) { JOptionPane.showMessageDialog( ld, "Could not find dbname for configuration " + db, "Configuration error", JOptionPane.ERROR_MESSAGE ); return false; } if ( ODMG.initODMG( user, passwd, db ) ) { log.debug( "Connection succesful!!!" ); // Login is succesfull // ld.setVisible( false ); success = true; int schemaVersion = db.getSchemaVersion(); if ( schemaVersion < db.CURRENT_SCHEMA_VERSION ) { String options[] = {"Proceed", "Exit Photovault"}; if ( JOptionPane.YES_OPTION == JOptionPane.showOptionDialog( ld, "The database was created with an older version of Photovault\n" + "Photovault will upgrade the database format before starting.", "Upgrade database", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, null ) ) { final SchemaUpdateAction updater = new SchemaUpdateAction( db ); SchemaUpdateStatusDlg statusDlg = new SchemaUpdateStatusDlg( null, true ); updater.addSchemaUpdateListener( statusDlg ); Thread upgradeThread = new Thread() { public void run() { updater.upgradeDatabase(); } }; upgradeThread.start(); statusDlg.setVisible( true ); success = true; } } } return success; } |
if ( ODMG.initODMG( user, passwd, db ) ) { log.debug( "Connection succesful!!!" ); success = true; int schemaVersion = db.getSchemaVersion(); if ( schemaVersion < db.CURRENT_SCHEMA_VERSION ) { String options[] = {"Proceed", "Exit Photovault"}; if ( JOptionPane.YES_OPTION == JOptionPane.showOptionDialog( ld, "The database was created with an older version of Photovault\n" + "Photovault will upgrade the database format before starting.", "Upgrade database", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, null ) ) { final SchemaUpdateAction updater = new SchemaUpdateAction( db ); SchemaUpdateStatusDlg statusDlg = new SchemaUpdateStatusDlg( null, true ); updater.addSchemaUpdateListener( statusDlg ); Thread upgradeThread = new Thread() { public void run() { updater.upgradeDatabase(); } }; upgradeThread.start(); statusDlg.setVisible( true ); success = true; } | ODMG.initODMG( user, passwd, db ); log.debug( "Connection succesful!!!" ); success = true; int schemaVersion = db.getSchemaVersion(); if ( schemaVersion < db.CURRENT_SCHEMA_VERSION ) { String options[] = {"Proceed", "Exit Photovault"}; if ( JOptionPane.YES_OPTION == JOptionPane.showOptionDialog( ld, "The database was created with an older version of Photovault\n" + "Photovault will upgrade the database format before starting.", "Upgrade database", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, null ) ) { final SchemaUpdateAction updater = new SchemaUpdateAction( db ); SchemaUpdateStatusDlg statusDlg = new SchemaUpdateStatusDlg( null, true ); updater.addSchemaUpdateListener( statusDlg ); Thread upgradeThread = new Thread() { public void run() { updater.upgradeDatabase(); } }; upgradeThread.start(); statusDlg.setVisible( true ); success = true; } else { System.exit( 0 ); | private boolean login( LoginDlg ld ) { boolean success = false; String user = ld.getUsername(); String passwd = ld.getPassword(); String dbName = ld.getDb(); log.debug( "Using configuration " + dbName ); settings.setConfiguration( dbName ); PVDatabase db = settings.getDatabase( dbName ); String sqldbName = db.getDbName(); log.debug( "Mysql DB name: " + sqldbName ); if ( sqldbName == null ) { JOptionPane.showMessageDialog( ld, "Could not find dbname for configuration " + db, "Configuration error", JOptionPane.ERROR_MESSAGE ); return false; } if ( ODMG.initODMG( user, passwd, db ) ) { log.debug( "Connection succesful!!!" ); // Login is succesfull // ld.setVisible( false ); success = true; int schemaVersion = db.getSchemaVersion(); if ( schemaVersion < db.CURRENT_SCHEMA_VERSION ) { String options[] = {"Proceed", "Exit Photovault"}; if ( JOptionPane.YES_OPTION == JOptionPane.showOptionDialog( ld, "The database was created with an older version of Photovault\n" + "Photovault will upgrade the database format before starting.", "Upgrade database", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, null ) ) { final SchemaUpdateAction updater = new SchemaUpdateAction( db ); SchemaUpdateStatusDlg statusDlg = new SchemaUpdateStatusDlg( null, true ); updater.addSchemaUpdateListener( statusDlg ); Thread upgradeThread = new Thread() { public void run() { updater.upgradeDatabase(); } }; upgradeThread.start(); statusDlg.setVisible( true ); success = true; } } } return success; } |
return success; | private boolean login( LoginDlg ld ) { boolean success = false; String user = ld.getUsername(); String passwd = ld.getPassword(); String dbName = ld.getDb(); log.debug( "Using configuration " + dbName ); settings.setConfiguration( dbName ); PVDatabase db = settings.getDatabase( dbName ); String sqldbName = db.getDbName(); log.debug( "Mysql DB name: " + sqldbName ); if ( sqldbName == null ) { JOptionPane.showMessageDialog( ld, "Could not find dbname for configuration " + db, "Configuration error", JOptionPane.ERROR_MESSAGE ); return false; } if ( ODMG.initODMG( user, passwd, db ) ) { log.debug( "Connection succesful!!!" ); // Login is succesfull // ld.setVisible( false ); success = true; int schemaVersion = db.getSchemaVersion(); if ( schemaVersion < db.CURRENT_SCHEMA_VERSION ) { String options[] = {"Proceed", "Exit Photovault"}; if ( JOptionPane.YES_OPTION == JOptionPane.showOptionDialog( ld, "The database was created with an older version of Photovault\n" + "Photovault will upgrade the database format before starting.", "Upgrade database", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, null ) ) { final SchemaUpdateAction updater = new SchemaUpdateAction( db ); SchemaUpdateStatusDlg statusDlg = new SchemaUpdateStatusDlg( null, true ); updater.addSchemaUpdateListener( statusDlg ); Thread upgradeThread = new Thread() { public void run() { updater.upgradeDatabase(); } }; upgradeThread.start(); statusDlg.setVisible( true ); success = true; } } } return success; } |
|
if ( login( login ) ) { | try { login( login ); | void run() { checkSystem(); PhotovaultSettings settings = PhotovaultSettings.getSettings(); Collection databases = settings.getDatabases(); if ( databases.size() == 0 ) { DbSettingsDlg dlg = new DbSettingsDlg( null, true ); if ( dlg.showDialog() != dlg.APPROVE_OPTION ) { System.exit( 0 ); } } LoginDlg login = new LoginDlg( this ); boolean loginOK = false; while ( !loginOK ) { int retval = login.showDialog(); switch( retval ) { case LoginDlg.RETURN_REASON_CANCEL: System.exit( 0 ); break; case LoginDlg.RETURN_REASON_NEWDB: DbSettingsDlg dlg = new DbSettingsDlg( null, true ); if ( dlg.showDialog() == dlg.APPROVE_OPTION ) { login = new LoginDlg( this ); } break; case LoginDlg.RETURN_REASON_APPROVE: if ( login( login ) ) { loginOK = true; BrowserWindow wnd = new BrowserWindow(); } else { JOptionPane.showMessageDialog( null, "Error logging into Photovault", "Login error", JOptionPane.ERROR_MESSAGE ); } break; default: log.error( "Unknown return code form LoginDlg.showDialog(): " + retval ); break; } } } |
} else { JOptionPane.showMessageDialog( null, "Error logging into Photovault", | } catch( PhotovaultException e ) { JOptionPane.showMessageDialog( null, e.getMessage(), | void run() { checkSystem(); PhotovaultSettings settings = PhotovaultSettings.getSettings(); Collection databases = settings.getDatabases(); if ( databases.size() == 0 ) { DbSettingsDlg dlg = new DbSettingsDlg( null, true ); if ( dlg.showDialog() != dlg.APPROVE_OPTION ) { System.exit( 0 ); } } LoginDlg login = new LoginDlg( this ); boolean loginOK = false; while ( !loginOK ) { int retval = login.showDialog(); switch( retval ) { case LoginDlg.RETURN_REASON_CANCEL: System.exit( 0 ); break; case LoginDlg.RETURN_REASON_NEWDB: DbSettingsDlg dlg = new DbSettingsDlg( null, true ); if ( dlg.showDialog() == dlg.APPROVE_OPTION ) { login = new LoginDlg( this ); } break; case LoginDlg.RETURN_REASON_APPROVE: if ( login( login ) ) { loginOK = true; BrowserWindow wnd = new BrowserWindow(); } else { JOptionPane.showMessageDialog( null, "Error logging into Photovault", "Login error", JOptionPane.ERROR_MESSAGE ); } break; default: log.error( "Unknown return code form LoginDlg.showDialog(): " + retval ); break; } } } |
logger.debug("Creating new ExportTxProcess for tables: "+exportTables); | public ExportTxProcess (PLExport plExport,List<SQLTable> exportTables, JDialog parentDialog, JProgressBar progressBar, JLabel label) { this.plExport = plExport; this.exportTables = exportTables; d = parentDialog; label.setText("Exporting Meta Data..."); new ProgressWatcher(progressBar, plExport, label); } |
|
tables = exportingTables; | logger.debug("setExportingTables(): got new list of tables to export: "+exportingTables); tables = new ArrayList<SQLTable>(exportingTables); | public void setExportingTables(List<SQLTable> exportingTables) { tables = exportingTables; } |
List targetTables = tables; List targetDBWarnings = listMissingTargetTables(targetTables); | List targetDBWarnings = listMissingTargetTables(tables); | public synchronized void setupDialog() { logger.debug("running setupDialog()"); if (plexp == null) { throw new NullPointerException("setupDialog: plexp was null"); } // always refresh Target Database (it might have changed) plexp.setTargetDataSource(ArchitectFrame.getMainInstance().getProject().getTargetDatabase().getDataSource()); // Cannot use ArchitectPanelBuilder here yet because // of the progressbar. 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); // make an intermediate JPanel JPanel bottomPanel = new JPanel(new GridLayout(1,2,25,0)); // 25 pixel hgap JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton(ArchitectPanelBuilder.OK_BUTTON_LABEL); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (!plPanel.applyChanges()) { return; } try { List targetTables = tables; List targetDBWarnings = listMissingTargetTables(targetTables); if (!targetDBWarnings.isEmpty()) { // modal dialog (hold things up until the user says YES or NO) 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(architectFrame, cp, "Target Database Structure Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (choice == JOptionPane.NO_OPTION) { return; } } // got this far, so it's ok to run the PL Export thread ExportTxProcess etp = new ExportTxProcess(plexp,targetTables,d, plCreateTxProgressBar,plCreateTxLabel); new Thread(etp).start(); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); return; } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans",arex); return; } } }); buttonPanel.add(okButton); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { plPanel.discardChanges(); d.setVisible(false); } }; cancelAction.putValue(Action.NAME, ArchitectPanelBuilder.CANCEL_BUTTON_LABEL); ArchitectPanelBuilder.makeJDialogCancellable(d, cancelAction); d.getRootPane().setDefaultButton(okButton); JButton cancelButton = new JButton(cancelAction); buttonPanel.add(cancelButton); // stick in the progress bar here... JPanel progressPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); plCreateTxProgressBar = new JProgressBar(); plCreateTxProgressBar.setStringPainted(true); progressPanel.add(plCreateTxProgressBar); plCreateTxLabel = new JLabel ("Exporting PL Transactions..."); progressPanel.add(plCreateTxLabel); // figure out how much space this needs before setting // child components to be invisible progressPanel.setPreferredSize(progressPanel.getPreferredSize()); plCreateTxProgressBar.setVisible(false); plCreateTxLabel.setVisible(false); bottomPanel.add(progressPanel); // left side, left justified bottomPanel.add(buttonPanel); // right side, right justified plp.add(bottomPanel, BorderLayout.SOUTH); d.setContentPane(plp); // experiment with preferred size crap: d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); } |
if (choice == JOptionPane.NO_OPTION) { | if (choice != JOptionPane.YES_OPTION) { | public synchronized void setupDialog() { logger.debug("running setupDialog()"); if (plexp == null) { throw new NullPointerException("setupDialog: plexp was null"); } // always refresh Target Database (it might have changed) plexp.setTargetDataSource(ArchitectFrame.getMainInstance().getProject().getTargetDatabase().getDataSource()); // Cannot use ArchitectPanelBuilder here yet because // of the progressbar. 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); // make an intermediate JPanel JPanel bottomPanel = new JPanel(new GridLayout(1,2,25,0)); // 25 pixel hgap JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton(ArchitectPanelBuilder.OK_BUTTON_LABEL); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (!plPanel.applyChanges()) { return; } try { List targetTables = tables; List targetDBWarnings = listMissingTargetTables(targetTables); if (!targetDBWarnings.isEmpty()) { // modal dialog (hold things up until the user says YES or NO) 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(architectFrame, cp, "Target Database Structure Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (choice == JOptionPane.NO_OPTION) { return; } } // got this far, so it's ok to run the PL Export thread ExportTxProcess etp = new ExportTxProcess(plexp,targetTables,d, plCreateTxProgressBar,plCreateTxLabel); new Thread(etp).start(); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); return; } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans",arex); return; } } }); buttonPanel.add(okButton); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { plPanel.discardChanges(); d.setVisible(false); } }; cancelAction.putValue(Action.NAME, ArchitectPanelBuilder.CANCEL_BUTTON_LABEL); ArchitectPanelBuilder.makeJDialogCancellable(d, cancelAction); d.getRootPane().setDefaultButton(okButton); JButton cancelButton = new JButton(cancelAction); buttonPanel.add(cancelButton); // stick in the progress bar here... JPanel progressPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); plCreateTxProgressBar = new JProgressBar(); plCreateTxProgressBar.setStringPainted(true); progressPanel.add(plCreateTxProgressBar); plCreateTxLabel = new JLabel ("Exporting PL Transactions..."); progressPanel.add(plCreateTxLabel); // figure out how much space this needs before setting // child components to be invisible progressPanel.setPreferredSize(progressPanel.getPreferredSize()); plCreateTxProgressBar.setVisible(false); plCreateTxLabel.setVisible(false); bottomPanel.add(progressPanel); // left side, left justified bottomPanel.add(buttonPanel); // right side, right justified plp.add(bottomPanel, BorderLayout.SOUTH); d.setContentPane(plp); // experiment with preferred size crap: d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); } |
ExportTxProcess etp = new ExportTxProcess(plexp,targetTables,d, | ExportTxProcess etp = new ExportTxProcess(plexp,tables,d, | public synchronized void setupDialog() { logger.debug("running setupDialog()"); if (plexp == null) { throw new NullPointerException("setupDialog: plexp was null"); } // always refresh Target Database (it might have changed) plexp.setTargetDataSource(ArchitectFrame.getMainInstance().getProject().getTargetDatabase().getDataSource()); // Cannot use ArchitectPanelBuilder here yet because // of the progressbar. 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); // make an intermediate JPanel JPanel bottomPanel = new JPanel(new GridLayout(1,2,25,0)); // 25 pixel hgap JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton(ArchitectPanelBuilder.OK_BUTTON_LABEL); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (!plPanel.applyChanges()) { return; } try { List targetTables = tables; List targetDBWarnings = listMissingTargetTables(targetTables); if (!targetDBWarnings.isEmpty()) { // modal dialog (hold things up until the user says YES or NO) 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(architectFrame, cp, "Target Database Structure Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (choice == JOptionPane.NO_OPTION) { return; } } // got this far, so it's ok to run the PL Export thread ExportTxProcess etp = new ExportTxProcess(plexp,targetTables,d, plCreateTxProgressBar,plCreateTxLabel); new Thread(etp).start(); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); return; } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans",arex); return; } } }); buttonPanel.add(okButton); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { plPanel.discardChanges(); d.setVisible(false); } }; cancelAction.putValue(Action.NAME, ArchitectPanelBuilder.CANCEL_BUTTON_LABEL); ArchitectPanelBuilder.makeJDialogCancellable(d, cancelAction); d.getRootPane().setDefaultButton(okButton); JButton cancelButton = new JButton(cancelAction); buttonPanel.add(cancelButton); // stick in the progress bar here... JPanel progressPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); plCreateTxProgressBar = new JProgressBar(); plCreateTxProgressBar.setStringPainted(true); progressPanel.add(plCreateTxProgressBar); plCreateTxLabel = new JLabel ("Exporting PL Transactions..."); progressPanel.add(plCreateTxLabel); // figure out how much space this needs before setting // child components to be invisible progressPanel.setPreferredSize(progressPanel.getPreferredSize()); plCreateTxProgressBar.setVisible(false); plCreateTxLabel.setVisible(false); bottomPanel.add(progressPanel); // left side, left justified bottomPanel.add(buttonPanel); // right side, right justified plp.add(bottomPanel, BorderLayout.SOUTH); d.setContentPane(plp); // experiment with preferred size crap: d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); } |
List targetTables = tables; List targetDBWarnings = listMissingTargetTables(targetTables); | List targetDBWarnings = listMissingTargetTables(tables); | public void actionPerformed(ActionEvent evt) { if (!plPanel.applyChanges()) { return; } try { List targetTables = tables; List targetDBWarnings = listMissingTargetTables(targetTables); if (!targetDBWarnings.isEmpty()) { // modal dialog (hold things up until the user says YES or NO) 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(architectFrame, cp, "Target Database Structure Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (choice == JOptionPane.NO_OPTION) { return; } } // got this far, so it's ok to run the PL Export thread ExportTxProcess etp = new ExportTxProcess(plexp,targetTables,d, plCreateTxProgressBar,plCreateTxLabel); new Thread(etp).start(); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); return; } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans",arex); return; } } |
if (choice == JOptionPane.NO_OPTION) { | if (choice != JOptionPane.YES_OPTION) { | public void actionPerformed(ActionEvent evt) { if (!plPanel.applyChanges()) { return; } try { List targetTables = tables; List targetDBWarnings = listMissingTargetTables(targetTables); if (!targetDBWarnings.isEmpty()) { // modal dialog (hold things up until the user says YES or NO) 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(architectFrame, cp, "Target Database Structure Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (choice == JOptionPane.NO_OPTION) { return; } } // got this far, so it's ok to run the PL Export thread ExportTxProcess etp = new ExportTxProcess(plexp,targetTables,d, plCreateTxProgressBar,plCreateTxLabel); new Thread(etp).start(); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); return; } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans",arex); return; } } |
ExportTxProcess etp = new ExportTxProcess(plexp,targetTables,d, | ExportTxProcess etp = new ExportTxProcess(plexp,tables,d, | public void actionPerformed(ActionEvent evt) { if (!plPanel.applyChanges()) { return; } try { List targetTables = tables; List targetDBWarnings = listMissingTargetTables(targetTables); if (!targetDBWarnings.isEmpty()) { // modal dialog (hold things up until the user says YES or NO) 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(architectFrame, cp, "Target Database Structure Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (choice == JOptionPane.NO_OPTION) { return; } } // got this far, so it's ok to run the PL Export thread ExportTxProcess etp = new ExportTxProcess(plexp,targetTables,d, plCreateTxProgressBar,plCreateTxLabel); new Thread(etp).start(); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); return; } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans",arex); return; } } |
HaploData(){ assocTest = 0; | HaploData(int b){ assocTest = b; | HaploData(){ assocTest = 0; } |
protected void setParameters() { | protected void setParameters(HttpUrlMethod method) { | protected void setParameters() { NameValuePair nvp = null; for (int index = 0; index < getParameters().size(); index++) { NameValuePair parameter = (NameValuePair) getParameters(). get(index); _postMethod.addParameter(parameter); } } |
_postMethod.addParameter(parameter); | ((UrlPostMethod) method).addParameter(parameter); | protected void setParameters() { NameValuePair nvp = null; for (int index = 0; index < getParameters().size(); index++) { NameValuePair parameter = (NameValuePair) getParameters(). get(index); _postMethod.addParameter(parameter); } } |
final MBeanConfig configuredMBean = config.findMBeanByObjectName(objectName.getCanonicalName()); | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { makeResponseNotCacheable(response); final ObjectName objectName = context.getObjectName(); final ApplicationConfig config = context.getApplicationConfig(); final MBeanConfig configuredMBean = config.findMBeanByObjectName(objectName.getCanonicalName()); AccessController.checkAccess(context.getServiceContext(), ACL_VIEW_APPLICATIONS); if(configuredMBean != null) AccessController.checkAccess(context.getServiceContext(), ACL_VIEW_MBEANS); List<ApplicationConfig> applications = null; if(config.isCluster()){ applications = config.getApplications(); }else{ applications = new ArrayList<ApplicationConfig>(1); applications.add(config); } /* the ObjectInfo for the mbean that is being viewed */ ObjectInfo objInfo = null; /* array that will be initialized with all attribute names for this mbean */ String[] attributeNames = null; /* a Map which constains list of attribute values for each application in the cluster. ApplicationConfig is the key and attribute List is the value*/ final Map<ApplicationConfig, List> appConfigToAttrListMap = new HashMap<ApplicationConfig, List>(applications.size()); for(Iterator it=applications.iterator(); it.hasNext(); ){ ApplicationConfig childAppConfig = (ApplicationConfig)it.next(); ServerConnection serverConnection = null; try { serverConnection = ServerConnector.getServerConnection(childAppConfig); /* assuming that all servers in this cluster have exact same object info, we will get the ObjectInfo from the first server in the list (could be further down in the list, if the first server(s) is down */ if(objInfo == null){ objInfo = serverConnection.getObjectInfo(objectName); assert objInfo != null; ObjectAttributeInfo[] attributes = objInfo.getAttributes(); attributeNames = new String[attributes.length]; for (int i = 0; i < attributes.length; i++) { // TODO: we should only add the readable attributes here attributeNames[i] = attributes[i].getName(); } } /* add attribute values of this application to the map*/ appConfigToAttrListMap.put(childAppConfig, serverConnection.getAttributes(objectName, attributeNames)); } catch (ConnectionFailedException e){ logger.log(Level.FINE, "Error retrieving attributes for:" + childAppConfig.getName(), e); /* add null, indicating that the server is down */ appConfigToAttrListMap.put(childAppConfig, null); } finally{ ServiceUtils.close(serverConnection); } } /* if objInfo is null, that means that we couldn't get connection to any server */ if(objInfo == null){ throw new ConnectionFailedException(null); } request.setAttribute("objInfo", objInfo); request.setAttribute("appConfigToAttrListMap", appConfigToAttrListMap); /* setup the form to be used in the html form */ MBeanConfigForm mbeanConfigForm = (MBeanConfigForm)actionForm; mbeanConfigForm.setObjectName(objectName.getCanonicalName()); ApplicationConfig appConfig = context.getApplicationConfig(); MBeanConfig mbeanConfig = appConfig.findMBeanByObjectName(objectName.getCanonicalName()); if(mbeanConfig != null){ if(appConfig.isCluster()){ request.setAttribute("mbeanIncludedIn", "cluster"); }else{ request.setAttribute("mbeanIncludedIn", "application"); } request.setAttribute("mbeanConfig", mbeanConfig); }else{ ApplicationConfig clusterConfig = appConfig.getClusterConfig(); if(clusterConfig != null){ mbeanConfig = clusterConfig.findMBeanByObjectName(objectName.getCanonicalName()); } if(mbeanConfig != null){ request.setAttribute("mbeanIncludedIn", "cluster"); request.setAttribute("mbeanConfig", mbeanConfig); } } return mapping.findForward(Forwards.SUCCESS); } |
|
if(configuredMBean != null) AccessController.checkAccess(context.getServiceContext(), ACL_VIEW_MBEANS); | AccessController.checkAccess(context.getServiceContext(), ACL_VIEW_MBEANS); | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { makeResponseNotCacheable(response); final ObjectName objectName = context.getObjectName(); final ApplicationConfig config = context.getApplicationConfig(); final MBeanConfig configuredMBean = config.findMBeanByObjectName(objectName.getCanonicalName()); AccessController.checkAccess(context.getServiceContext(), ACL_VIEW_APPLICATIONS); if(configuredMBean != null) AccessController.checkAccess(context.getServiceContext(), ACL_VIEW_MBEANS); List<ApplicationConfig> applications = null; if(config.isCluster()){ applications = config.getApplications(); }else{ applications = new ArrayList<ApplicationConfig>(1); applications.add(config); } /* the ObjectInfo for the mbean that is being viewed */ ObjectInfo objInfo = null; /* array that will be initialized with all attribute names for this mbean */ String[] attributeNames = null; /* a Map which constains list of attribute values for each application in the cluster. ApplicationConfig is the key and attribute List is the value*/ final Map<ApplicationConfig, List> appConfigToAttrListMap = new HashMap<ApplicationConfig, List>(applications.size()); for(Iterator it=applications.iterator(); it.hasNext(); ){ ApplicationConfig childAppConfig = (ApplicationConfig)it.next(); ServerConnection serverConnection = null; try { serverConnection = ServerConnector.getServerConnection(childAppConfig); /* assuming that all servers in this cluster have exact same object info, we will get the ObjectInfo from the first server in the list (could be further down in the list, if the first server(s) is down */ if(objInfo == null){ objInfo = serverConnection.getObjectInfo(objectName); assert objInfo != null; ObjectAttributeInfo[] attributes = objInfo.getAttributes(); attributeNames = new String[attributes.length]; for (int i = 0; i < attributes.length; i++) { // TODO: we should only add the readable attributes here attributeNames[i] = attributes[i].getName(); } } /* add attribute values of this application to the map*/ appConfigToAttrListMap.put(childAppConfig, serverConnection.getAttributes(objectName, attributeNames)); } catch (ConnectionFailedException e){ logger.log(Level.FINE, "Error retrieving attributes for:" + childAppConfig.getName(), e); /* add null, indicating that the server is down */ appConfigToAttrListMap.put(childAppConfig, null); } finally{ ServiceUtils.close(serverConnection); } } /* if objInfo is null, that means that we couldn't get connection to any server */ if(objInfo == null){ throw new ConnectionFailedException(null); } request.setAttribute("objInfo", objInfo); request.setAttribute("appConfigToAttrListMap", appConfigToAttrListMap); /* setup the form to be used in the html form */ MBeanConfigForm mbeanConfigForm = (MBeanConfigForm)actionForm; mbeanConfigForm.setObjectName(objectName.getCanonicalName()); ApplicationConfig appConfig = context.getApplicationConfig(); MBeanConfig mbeanConfig = appConfig.findMBeanByObjectName(objectName.getCanonicalName()); if(mbeanConfig != null){ if(appConfig.isCluster()){ request.setAttribute("mbeanIncludedIn", "cluster"); }else{ request.setAttribute("mbeanIncludedIn", "application"); } request.setAttribute("mbeanConfig", mbeanConfig); }else{ ApplicationConfig clusterConfig = appConfig.getClusterConfig(); if(clusterConfig != null){ mbeanConfig = clusterConfig.findMBeanByObjectName(objectName.getCanonicalName()); } if(mbeanConfig != null){ request.setAttribute("mbeanIncludedIn", "cluster"); request.setAttribute("mbeanConfig", mbeanConfig); } } return mapping.findForward(Forwards.SUCCESS); } |
registerTag("responseCode", ResponseCodeTag.class); | public JettyTagLibrary() { registerTag("jettyHttpServer", JettyHttpServerTag.class); registerTag("socketListener", SocketListenerTag.class); registerTag("realm", RealmTag.class); registerTag("httpContext", HttpContextTag.class); registerTag("resourceHandler", ResourceHandlerTag.class); registerTag("notFoundHandler", NotFoundHandlerTag.class); registerTag("securityHandler", SecurityHandlerTag.class); registerTag("jellyResourceHandler", JellyResourceHandlerTag.class); registerTag("getRequest", GetRequestTag.class); registerTag("postRequest", PostRequestTag.class); registerTag("putRequest", PutRequestTag.class); registerTag("deleteRequest", DeleteRequestTag.class); registerTag("responseHeader", ResponseHeaderTag.class); registerTag("responseBody", ResponseBodyTag.class); } |
|
ServiceContext srvcContext = Utils.getServiceContext(context, expression); ObjectAttribute objAttribute = mbeanService.getObjectAttribute(srvcContext, expression.getTargetName()); | ServiceContext srvcContext = null; ObjectAttribute objAttribute = null; try { srvcContext = Utils.getServiceContext(context, expression); objAttribute = mbeanService.getObjectAttribute(srvcContext, expression.getTargetName()); } finally { if(srvcContext != null) srvcContext.getServerConnection().close(); } | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception{ String attributes = request.getParameter("attributes"); assert attributes != null; List exprList = parse(attributes); List objectAttrList = new LinkedList(); MBeanService mbeanService = ServiceFactory.getMBeanService(); for(Iterator it=exprList.iterator(); it.hasNext();){ Expression expression = (Expression)it.next(); ServiceContext srvcContext = Utils.getServiceContext(context, expression); ObjectAttribute objAttribute = mbeanService.getObjectAttribute(srvcContext, expression.getTargetName()); assert objAttribute != null; assert objAttribute.getStatus() == ObjectAttribute.STATUS_OK; objectAttrList.add(objAttribute); } request.setAttribute("objectAttrList", objectAttrList); return mapping.findForward(Forwards.SUCCESS); } |
logger.debug("compoundGroupEnd: edit stack ="+compoundEditStackCount); | logger.debug("compoundGroupEnd: edit stack ="+compoundEditStackCount +" ce=" +ce); | private void compoundGroupEnd() { if (UndoManager.this.isUndoOrRedoing()) return; if (compoundEditStackCount <= 0){ throw new IllegalStateException("No compound edit in progress"); } compoundEditStackCount--; if (compoundEditStackCount == 0) returnToEditState(); if (logger.isDebugEnabled()) { logger.debug("compoundGroupEnd: edit stack ="+compoundEditStackCount); } } |
if (compoundEditStackCount == 1) | if (compoundEditStackCount == 1){ | private void compoundGroupStart(String toolTip) { if (UndoManager.this.isUndoOrRedoing()) return; compoundEditStackCount++; if (compoundEditStackCount == 1) ce = new CompEdit(toolTip); if (logger.isDebugEnabled()) { logger.debug("compoundGroupStart: edit stack ="+compoundEditStackCount); } } |
fireStateChanged(); } | private void compoundGroupStart(String toolTip) { if (UndoManager.this.isUndoOrRedoing()) return; compoundEditStackCount++; if (compoundEditStackCount == 1) ce = new CompEdit(toolTip); if (logger.isDebugEnabled()) { logger.debug("compoundGroupStart: edit stack ="+compoundEditStackCount); } } |
|
fireStateChanged(); | private void returnToEditState() { if (compoundEditStackCount != 0) { throw new IllegalStateException("The compound edit stack ("+compoundEditStackCount+") should be 0"); } // add any movements List<PlayPenComponentEvent> condensedMoveEvents = new ArrayList<PlayPenComponentEvent>(); for (Map.Entry<PlayPenComponent, Point> ent : newPositions.entrySet()) { PlayPenComponent ppc = ent.getKey(); Point oldPos = originalPositions.get(ppc); Point newPos = ent.getValue(); condensedMoveEvents.add(new PlayPenComponentEvent(ppc, oldPos, newPos)); } if (ce != null) { if (condensedMoveEvents.size()>0 ){ TablePaneLocationEdit tableEdit = new TablePaneLocationEdit(condensedMoveEvents); ce.addEdit(tableEdit); } // make sure the edit is no longer in progress ce.end(); newPositions.clear(); if (ce.canUndo()) { logger.debug("Adding compound edit " + ce + " to undo manager"); UndoManager.this.addEdit(ce); } else { logger.debug("Compound edit " + ce + " is not undoable so we are not adding it"); } ce = null; } else { if (condensedMoveEvents.size()>0 ){ UndoManager.this.addEdit(new TablePaneLocationEdit(condensedMoveEvents)); } newPositions.clear(); } logger.debug("Returning to regular state"); } |
|
settings.addDatabase( pvd ); | try { settings.addDatabase( pvd ); } catch (PhotovaultException ex) { ex.printStackTrace(); } | private void createDatabase() { File dbDir = null; try { dbDir = File.createTempFile("pv_junit_derby_instance", ""); dbDir.delete(); } catch (IOException ex) { ex.printStackTrace(); } PVDatabase pvd = new PVDatabase(); pvd.setInstanceType( PVDatabase.TYPE_EMBEDDED ); pvd.setEmbeddedDirectory( dbDir ); pvd.createDatabase( "", "", "junit_seed_data.xml" ); PhotovaultSettings settings = PhotovaultSettings.getSettings(); pvd.setName( "pv_junit" ); settings.addDatabase( pvd ); } |
public DDLStatement(SQLObject object, StatementType type, String sqlText) { | public DDLStatement(SQLObject object, StatementType type, String sqlText, String targetCatalog, String targetSchema) { | public DDLStatement(SQLObject object, StatementType type, String sqlText) { this.object = object; this.type = type; this.sqlText = sqlText; } |
this.targetCatalog = targetCatalog; this.targetSchema = targetSchema; | public DDLStatement(SQLObject object, StatementType type, String sqlText) { this.object = object; this.type = type; this.sqlText = sqlText; } |
|
project = (Project) context.getVariable( "org.apache.commons.jelly.werkz.Project" ); | project = (Project) context.findVariable( "org.apache.commons.jelly.werkz.Project" ); | public Project getProject() { if ( project == null ) { // we may be invoked inside a child script, so lets try find the parent project project = (Project) context.getVariable( "org.apache.commons.jelly.werkz.Project" ); if ( project == null ) { project = new Project(); context.setVariable( "org.apache.commons.jelly.werkz.Project", project ); } } return project; } |
log.debug( "Looking up variable: " + name + " answer: " + answer ); | String answerString = null; try { answerString = answer.toString(); } catch(Exception ex) {} if(answerString==null && answer!=null) answerString = " of class " + answer.getClass(); log.debug( "Looking up variable: " + name + " answer: " + answerString ); | public Object getVariable(String name) { // look in parent first Object answer = super.getVariable(name); if (answer == null) { answer = project.getProperty(name); } if ( log.isDebugEnabled() ) { log.debug( "Looking up variable: " + name + " answer: " + answer ); } return answer; } |
FindBlocks(String[][] data){ | FindBlocks(PairwiseLinkage[][] data){ | FindBlocks(String[][] data){ dPrime = data; } |
null); | data.getParamValues()); | public ApplicationConfigData addApplication(ServiceContext context, ApplicationConfigData data){ AccessController.checkAccess(context, ACLConstants.ACL_ADD_APPLICATIONS); /* do the operation */ String appId = ApplicationConfig.getNextApplicationId(); Integer port = data.getPort(); ApplicationConfig config = ApplicationConfigFactory.create(appId, data.getName(), data.getType(), data.getHost(), port, data.getURL(), data.getUsername(), data.getPassword(), null); try { ApplicationConfigManager.addApplication(config); } catch (ApplicationConfigManager.DuplicateApplicationNameException e) { throw new ServiceException(ErrorCodes.APPLICATION_NAME_ALREADY_EXISTS, e.getAppName()); } data.setApplicationId(appId); /* log the operation */ UserActivityLogger.getInstance().logActivity( context.getUser().getUsername(), "Added application "+ "\""+config.getName()+"\""); return data; } |
logger.debug("Starting to create relationship!"); | logger.debug("Starting to create relationship, setting active to TRUE!"); | public void actionPerformed(ActionEvent evt) { logger.debug("the hashcode is: " + super.hashCode()); pkTable = null; fkTable = null; logger.debug("Starting to create relationship!"); active = true; pp.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); // gets over the "can't select a selected item" pp.selectNone(); } |
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; } 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); active = false; } } else { logger.debug("777777777777 not instance of TablePane."); if (logger.isDebugEnabled()) logger.debug("The user clicked on a non-table component: "+s); } } |
|
int numStrong = 0; int numRec = 0; | int numStrong = 0; int numRec = 0; int numInGroup = 0; | Vector doSFS(){ float cutHighCI = 0.98f; float cutLowCI = 0.70f; float recHighCI = 0.90f; int numStrong = 0; int numRec = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first make a list of marker pairs in "strong LD", sorted by distance apart for (int x = 0; x < dPrime.length-1; x++){ for (int y = x+1; y < dPrime.length; y++){ StringTokenizer st = new StringTokenizer(dPrime[x][y]); //get the right bits from the string st.nextToken(); float lod = Float.parseFloat(st.nextToken()); st.nextToken(); float lowCI = Float.parseFloat(st.nextToken()); float highCI = Float.parseFloat(st.nextToken()); if (lod < -90) continue; //missing data if (highCI < cutHighCI || lowCI < cutLowCI) continue; //must pass "strong LD" test Vector addMe = new Vector(); //a vector of x, y, separation int sep = y - x - 1; //compute separation of two markers addMe.add(String.valueOf(x)); addMe.add(String.valueOf(y)); addMe.add(String.valueOf(sep)); if (strongPairs.size() == 0){ //put first pair first strongPairs.add(addMe); }else{ //sort by descending separation of markers in each pair for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); break; } } } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; for (int v = 0; v < strongPairs.size(); v++){ int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ //loop over columns in row y for (int x = first; x < y; x++){ StringTokenizer st = new StringTokenizer(dPrime[x][y]); //get the right bits st.nextToken(); float lod = Float.parseFloat(st.nextToken()); st.nextToken(); float lowCI = Float.parseFloat(st.nextToken()); float highCI = Float.parseFloat(st.nextToken()); if (lod < -90) continue; //monomorphic marker error if (lod == 0 && lowCI == 0 && highCI == 0) continue; //skip bad markers if (lowCI > cutLowCI && highCI > cutHighCI) numStrong++; //strong LD if (highCI < recHighCI) numRec++; //recombination } } if (numStrong + numRec == 0) continue; if (numStrong/(numStrong + numRec) > 0.95){ //this qualifies as a block //add to the block list, but in order by first marker number: if (blocks.size() == 0){ //put first block first blocks.add(first + " " + last); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ StringTokenizer st = new StringTokenizer((String)blocks.elementAt(b)); if (first < Integer.parseInt(st.nextToken())){ blocks.insertElementAt(first + " " + last, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(first + " " + last); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } numStrong = 0; numRec = 0; } return stringVec2intVec(blocks); } |
if (lowCI > cutLowCI && highCI > cutHighCI) numStrong++; | if (lowCI > cutLowCI && highCI > cutHighCI) { numStrong++; } | Vector doSFS(){ float cutHighCI = 0.98f; float cutLowCI = 0.70f; float recHighCI = 0.90f; int numStrong = 0; int numRec = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first make a list of marker pairs in "strong LD", sorted by distance apart for (int x = 0; x < dPrime.length-1; x++){ for (int y = x+1; y < dPrime.length; y++){ StringTokenizer st = new StringTokenizer(dPrime[x][y]); //get the right bits from the string st.nextToken(); float lod = Float.parseFloat(st.nextToken()); st.nextToken(); float lowCI = Float.parseFloat(st.nextToken()); float highCI = Float.parseFloat(st.nextToken()); if (lod < -90) continue; //missing data if (highCI < cutHighCI || lowCI < cutLowCI) continue; //must pass "strong LD" test Vector addMe = new Vector(); //a vector of x, y, separation int sep = y - x - 1; //compute separation of two markers addMe.add(String.valueOf(x)); addMe.add(String.valueOf(y)); addMe.add(String.valueOf(sep)); if (strongPairs.size() == 0){ //put first pair first strongPairs.add(addMe); }else{ //sort by descending separation of markers in each pair for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); break; } } } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; for (int v = 0; v < strongPairs.size(); v++){ int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ //loop over columns in row y for (int x = first; x < y; x++){ StringTokenizer st = new StringTokenizer(dPrime[x][y]); //get the right bits st.nextToken(); float lod = Float.parseFloat(st.nextToken()); st.nextToken(); float lowCI = Float.parseFloat(st.nextToken()); float highCI = Float.parseFloat(st.nextToken()); if (lod < -90) continue; //monomorphic marker error if (lod == 0 && lowCI == 0 && highCI == 0) continue; //skip bad markers if (lowCI > cutLowCI && highCI > cutHighCI) numStrong++; //strong LD if (highCI < recHighCI) numRec++; //recombination } } if (numStrong + numRec == 0) continue; if (numStrong/(numStrong + numRec) > 0.95){ //this qualifies as a block //add to the block list, but in order by first marker number: if (blocks.size() == 0){ //put first block first blocks.add(first + " " + last); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ StringTokenizer st = new StringTokenizer((String)blocks.elementAt(b)); if (first < Integer.parseInt(st.nextToken())){ blocks.insertElementAt(first + " " + last, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(first + " " + last); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } numStrong = 0; numRec = 0; } return stringVec2intVec(blocks); } |
if (numStrong + numRec == 0) continue; | if (numInGroup > 3){ if (numStrong + numRec < 6) continue; }else if (numInGroup > 2){ if (numStrong + numRec < 3) continue; }else{ if (numStrong + numRec < 1) continue; } | Vector doSFS(){ float cutHighCI = 0.98f; float cutLowCI = 0.70f; float recHighCI = 0.90f; int numStrong = 0; int numRec = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first make a list of marker pairs in "strong LD", sorted by distance apart for (int x = 0; x < dPrime.length-1; x++){ for (int y = x+1; y < dPrime.length; y++){ StringTokenizer st = new StringTokenizer(dPrime[x][y]); //get the right bits from the string st.nextToken(); float lod = Float.parseFloat(st.nextToken()); st.nextToken(); float lowCI = Float.parseFloat(st.nextToken()); float highCI = Float.parseFloat(st.nextToken()); if (lod < -90) continue; //missing data if (highCI < cutHighCI || lowCI < cutLowCI) continue; //must pass "strong LD" test Vector addMe = new Vector(); //a vector of x, y, separation int sep = y - x - 1; //compute separation of two markers addMe.add(String.valueOf(x)); addMe.add(String.valueOf(y)); addMe.add(String.valueOf(sep)); if (strongPairs.size() == 0){ //put first pair first strongPairs.add(addMe); }else{ //sort by descending separation of markers in each pair for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); break; } } } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; for (int v = 0; v < strongPairs.size(); v++){ int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ //loop over columns in row y for (int x = first; x < y; x++){ StringTokenizer st = new StringTokenizer(dPrime[x][y]); //get the right bits st.nextToken(); float lod = Float.parseFloat(st.nextToken()); st.nextToken(); float lowCI = Float.parseFloat(st.nextToken()); float highCI = Float.parseFloat(st.nextToken()); if (lod < -90) continue; //monomorphic marker error if (lod == 0 && lowCI == 0 && highCI == 0) continue; //skip bad markers if (lowCI > cutLowCI && highCI > cutHighCI) numStrong++; //strong LD if (highCI < recHighCI) numRec++; //recombination } } if (numStrong + numRec == 0) continue; if (numStrong/(numStrong + numRec) > 0.95){ //this qualifies as a block //add to the block list, but in order by first marker number: if (blocks.size() == 0){ //put first block first blocks.add(first + " " + last); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ StringTokenizer st = new StringTokenizer((String)blocks.elementAt(b)); if (first < Integer.parseInt(st.nextToken())){ blocks.insertElementAt(first + " " + last, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(first + " " + last); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } numStrong = 0; numRec = 0; } return stringVec2intVec(blocks); } |
numStrong = 0; numRec = 0; | numStrong = 0; numRec = 0; numInGroup = 0; | Vector doSFS(){ float cutHighCI = 0.98f; float cutLowCI = 0.70f; float recHighCI = 0.90f; int numStrong = 0; int numRec = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first make a list of marker pairs in "strong LD", sorted by distance apart for (int x = 0; x < dPrime.length-1; x++){ for (int y = x+1; y < dPrime.length; y++){ StringTokenizer st = new StringTokenizer(dPrime[x][y]); //get the right bits from the string st.nextToken(); float lod = Float.parseFloat(st.nextToken()); st.nextToken(); float lowCI = Float.parseFloat(st.nextToken()); float highCI = Float.parseFloat(st.nextToken()); if (lod < -90) continue; //missing data if (highCI < cutHighCI || lowCI < cutLowCI) continue; //must pass "strong LD" test Vector addMe = new Vector(); //a vector of x, y, separation int sep = y - x - 1; //compute separation of two markers addMe.add(String.valueOf(x)); addMe.add(String.valueOf(y)); addMe.add(String.valueOf(sep)); if (strongPairs.size() == 0){ //put first pair first strongPairs.add(addMe); }else{ //sort by descending separation of markers in each pair for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); break; } } } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; for (int v = 0; v < strongPairs.size(); v++){ int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ //loop over columns in row y for (int x = first; x < y; x++){ StringTokenizer st = new StringTokenizer(dPrime[x][y]); //get the right bits st.nextToken(); float lod = Float.parseFloat(st.nextToken()); st.nextToken(); float lowCI = Float.parseFloat(st.nextToken()); float highCI = Float.parseFloat(st.nextToken()); if (lod < -90) continue; //monomorphic marker error if (lod == 0 && lowCI == 0 && highCI == 0) continue; //skip bad markers if (lowCI > cutLowCI && highCI > cutHighCI) numStrong++; //strong LD if (highCI < recHighCI) numRec++; //recombination } } if (numStrong + numRec == 0) continue; if (numStrong/(numStrong + numRec) > 0.95){ //this qualifies as a block //add to the block list, but in order by first marker number: if (blocks.size() == 0){ //put first block first blocks.add(first + " " + last); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ StringTokenizer st = new StringTokenizer((String)blocks.elementAt(b)); if (first < Integer.parseInt(st.nextToken())){ blocks.insertElementAt(first + " " + last, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(first + " " + last); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } numStrong = 0; numRec = 0; } return stringVec2intVec(blocks); } |
registerTagLibrary( "jelly:core", new CoreTagLibrary() ); registerTagLibrary( "jelly:xml", new XMLTagLibrary() ); | 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(); registerTagLibrary( "jelly:" + uri, className ); } } catch (IOException e) { log.error( "Could not load jelly properties from: " + url + ". Reason: " + e, e ); } finally { try { in.close(); } catch (Exception e) { } } } | protected void configure() { registerTagLibrary( "jelly:core", new CoreTagLibrary() ); registerTagLibrary( "jelly:xml", new XMLTagLibrary() ); } |
registerTag("invokeStatic", InvokeStaticTag.class); | public CoreTagLibrary() { registerTag("jelly", JellyTag.class); // core tags registerTag("out", ExprTag.class); registerTag("catch", CatchTag.class); registerTag("forEach", ForEachTag.class); registerTag("set", SetTag.class); registerTag("remove", RemoveTag.class); registerTag("while", WhileTag.class); // conditional tags registerTag("if", IfTag.class); registerTag("choose", ChooseTag.class); registerTag("when", WhenTag.class); registerTag("otherwise", OtherwiseTag.class); registerTag("switch", SwitchTag.class); registerTag("case", CaseTag.class); registerTag("default", DefaultTag.class); // other tags registerTag("include", IncludeTag.class); registerTag("import", ImportTag.class); // extensions to JSTL registerTag("arg", ArgTag.class); registerTag("break", BreakTag.class); registerTag("expr", ExprTag.class); registerTag("file", FileTag.class); registerTag("invoke", InvokeTag.class); registerTag("new", NewTag.class); registerTag("scope", ScopeTag.class); registerTag("setProperties", SetPropertiesTag.class); registerTag("thread", ThreadTag.class); registerTag("useBean", UseBeanTag.class); registerTag("useList", UseListTag.class); registerTag("whitespace", WhitespaceTag.class); } |
|
ClassLoaders loaders = new ClassLoaders(); loaders.put( getClassLoader() ); | ClassLoaders loaders = ClassLoaders.getAppLoaders(TagLibrary.class, getClass(), false); | public DiscoverClasses getDiscoverClasses() { if ( discovery == null ) { ClassLoaders loaders = new ClassLoaders(); loaders.put( getClassLoader() ); discovery = new DiscoverClasses(loaders); discovery.addClassLoader( getClassLoader() ); } return discovery; } |
discovery.addClassLoader( getClassLoader() ); | public DiscoverClasses getDiscoverClasses() { if ( discovery == null ) { ClassLoaders loaders = new ClassLoaders(); loaders.put( getClassLoader() ); discovery = new DiscoverClasses(loaders); discovery.addClassLoader( getClassLoader() ); } return discovery; } |
|
DiscoverClass discover = new DiscoverClass(loaders); Class implClass = discover.find(TestInterface2.class); TagLibrary answer = null; try { answer = (TagLibrary) DiscoverSingleton.find(TagLibrary.class, name); } catch (Exception e) { log.error( "Could not load service: " + name ); } return answer; */ | public TagLibrary resolveTagLibrary(String uri) { DiscoverClasses discovery = getDiscoverClasses(); String name = uri; if ( uri.startsWith( "jelly:" ) ) { name = "jelly." + uri.substring(6); } log.info( "Looking up service name: " + name ); ResourceClassIterator iter = discovery.findResourceClasses(name); while (iter.hasNext()) { ResourceClass resource = iter.nextResourceClass(); try { Class typeClass = resource.loadClass(); if ( typeClass != null ) { return newInstance(uri, typeClass); } } catch (Exception e) { log.error( "Could not load service: " + resource ); } } log.info( "Could not find any services for name: " + name ); return null; } |
|
if (noDivByZero){ | if (noDivByZero && multidprime <= 1.00){ | public double[] computeMultiDprime(Haplotype[][] haplos){ double[] multidprimeArray = new double[haplos.length]; for (int gap = 0; gap < haplos.length - 1; gap++){ double[][] multilocusTable = new double[haplos[gap].length][]; double[] rowSum = new double[haplos[gap].length]; double[] colSum = new double[haplos[gap+1].length]; double multilocusTotal = 0; for (int i = 0; i < haplos[gap].length; i++){ multilocusTable[i] = haplos[gap][i].getCrossovers(); } //compute multilocus D' for (int i = 0; i < rowSum.length; i++){ for (int j = 0; j < colSum.length; j++){ rowSum[i] += multilocusTable[i][j]; colSum[j] += multilocusTable[i][j]; multilocusTotal += multilocusTable[i][j]; if (rowSum[i] == 0) rowSum[i] = 0.0001; if (colSum[j] == 0) colSum[j] = 0.0001; } } double multidprime = 0; boolean noDivByZero = false; for (int i = 0; i < rowSum.length; i++){ for (int j = 0; j < colSum.length; j++){ double num = (multilocusTable[i][j]/multilocusTotal) - (rowSum[i]/multilocusTotal)*(colSum[j]/multilocusTotal); double denom; if (num < 0){ double denom1 = (rowSum[i]/multilocusTotal)*(colSum[j]/multilocusTotal); double denom2 = (1.0 - (rowSum[i]/multilocusTotal))*(1.0 - (colSum[j]/multilocusTotal)); if (denom1 < denom2) { denom = denom1; }else{ denom = denom2; } }else{ double denom1 = (rowSum[i]/multilocusTotal)*(1.0 -(colSum[j]/multilocusTotal)); double denom2 = (1.0 - (rowSum[i]/multilocusTotal))*(colSum[j]/multilocusTotal); if (denom1 < denom2){ denom = denom1; }else{ denom = denom2; } } if (denom != 0){ noDivByZero = true; multidprime += (rowSum[i]/multilocusTotal)*(colSum[j]/multilocusTotal)*Math.abs(num/denom); } } } if (noDivByZero){ multidprimeArray[gap] = multidprime; }else{ multidprimeArray[gap] = 1.00; } } return multidprimeArray; } |
haplos[i][k].clearTags(); | public void pickTags(Haplotype[][] haplos){ for (int i = 0; i < haplos.length; i++){ //first clear the tags for this block haplos[i][0].clearTags(); //next pick the tagSNPs Vector theBestSubset = getBestSubset(haplos[i]); for (int j = 0; j < theBestSubset.size(); j++){ haplos[i][0].addTag(((Integer)theBestSubset.elementAt(j)).intValue()); } for (int k = 1; k < haplos[i].length; k++){ //so the tags should be a property of the block, but there's no object to represent it right now //so we just make sure we copy the tags into all the haps in this block...sorry, I suck. haplos[i][k].clearTags(); haplos[i][k].setTags(haplos[i][0].getTags()); } } } |
|
Stylesheet answer = new Stylesheet(); answer.setValueOfAction( new Action() { public void run(Node node) throws Exception { String text = node.getStringValue(); if ( text != null && text.length() > 0 ) { output.write( text ); } } } ); return answer; | JellyStylesheet answer = new JellyStylesheet(); answer.setOutput(output); return answer; | protected Stylesheet createStylesheet(final XMLOutput output) { // add default actions Stylesheet answer = new Stylesheet(); answer.setValueOfAction( new Action() { public void run(Node node) throws Exception { String text = node.getStringValue(); if ( text != null && text.length() > 0 ) { // #### should use an 'output' property // when this variable gets reused output.write( text ); } } } ); return answer; } |
System.out.println("Haplotype association results must be generated one block\n" + "definition at a time and so cannot be used with output type ALL."); | System.out.println("Haplotype association results cannot be used with block output \"ALL\""); | private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; if(!quietMode && fileName != null){ System.out.println("Using data file " + fileName); } inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } textData = new HaploData(); Vector result = null; if(fileType == HAPS){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED) { //read in ped file result = textData.linkageToChrom(inputFile, PED); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile result = textData.linkageToChrom(inputFile,HMP); } //once check has been run, but before anything else, we can filter the markers boolean[] markerResults = new boolean[result.size()]; for (int i = 0; i < result.size(); i++){ if (((MarkerResult)result.get(i)).getRating() > 0 || skipCheck){ markerResults[i] = true; }else{ markerResults[i] = false; } } for (int i = 0; i < excludedMarkers.size(); i++){ int cur = ((Integer)excludedMarkers.elementAt(i)).intValue(); if (cur < 1 || cur > markerResults.length){ System.out.println("Excluded marker out of bounds has been ignored: " + cur + "\nMarkers must be between 1 and N, where N is the total number of markers."); System.exit(1); }else{ markerResults[cur-1] = false; } } Chromosome.doFilter(markerResults); File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (result != null){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } if(!quietMode && infoFile != null){ System.out.println("Using marker file " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); if(blockOutputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; Haplotype[][] filtHaplos; switch(blockOutputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); cust = textData.readBlocks(blocksFile); break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL if(blockOutputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, false); filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, false); filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);; OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, false); filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else{ //guesses blocks based on output type determined above. textData.guessBlocks(blockOutputType, cust); haplos = textData.generateHaplotypes(textData.blocks, false); filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { if (blockOutputType == BLOX_ALL){ System.out.println("Haplotype association results must be generated one block\n" + "definition at a time and so cannot be used with output type ALL."); }else{ HaploData.saveHapAssocToText(haplos, fileName + ".HAPASSOC"); } } } if(outputDprime) { OutputFile = validateOutputFile(fileName + ".LD"); if (textData.dpTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getSize()); } } if (outputPNG || outputCompressedPNG){ OutputFile = validateOutputFile(fileName + ".LD.PNG"); if (textData.dpTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (trackFileName != null){ textData.readAnalysisTrack(new File(trackFileName)); } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getName()); }catch(JimiException je){ System.out.println(je.getMessage()); } } if(Options.getAssocTest() == ASSOC_TRIO){ Vector tdtResults = TDT.calcTrioTDT(textData.getPedFile()); HaploData.saveMarkerAssocToText(tdtResults, fileName + ".ASSOC"); } else if(Options.getAssocTest() == ASSOC_CC) { Vector ccResults = TDT.calcCCTDT(textData.getPedFile()); HaploData.saveMarkerAssocToText(ccResults, fileName + ".ASSOC"); } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
public void linkageToChrom(boolean[] markerResults, PedFile pedFile) throws IllegalArgumentException{ | public void linkageToChrom(boolean[] markerResults, PedFile pedFile) throws IllegalArgumentException, HaploViewException, PedFileException{ | public void linkageToChrom(boolean[] markerResults, PedFile pedFile) throws IllegalArgumentException{ if(markerResults == null){ throw new IllegalArgumentException(); } Vector indList = pedFile.getOrder(); int numMarkers = 0; Vector usedParents = new Vector(); Individual currentInd; Family currentFamily; Vector chrom = new Vector(); for(int x=0; x < indList.size(); x++){ String[] indAndFamID = (String[])indList.elementAt(x); currentFamily = pedFile.getFamily(indAndFamID[0]); currentInd = currentFamily.getMember(indAndFamID[1]); if(currentInd.getIsTyped()){ //singleton if(currentFamily.getNumMembers() == 1){ numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == thisMarker[1]){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = 5; chrom2[i] = 5; } } //chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1)); //chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2)); }else{ //skip if indiv is parent in trio or unaffected //TODO: chokes when no affected status is specified. if (!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0") || currentInd.getAffectedStatus() != 2)){ //trio if (!(usedParents.contains( currentInd.getFamilyID() + " " + currentInd.getMomID()) || usedParents.contains(currentInd.getFamilyID() + " " + currentInd.getDadID()))){ //add 4 phased haps provided that we haven't used this trio already numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; boolean[] kidMissing = new boolean[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { kidMissing[i] = true; //kid missing if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else { dadTb[i] = 5; dadUb[i] = 5; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else { momTb[i] = 5; momUb[i] = 5; } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 5; momUb[i] = 5; } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { //everybody het dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 5; momUb[i] = 5; } } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadUb,false,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momUb,false,kidMissing)); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getDadID()); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getMomID()); } } } } } //set up the indexing to take into account skipped markers. Need //to loop through twice because first time we just count number of //unskipped markers int count = 0; for (int i = 0; i < numMarkers; i++){ if (markerResults[i]){ count++; } } Chromosome.realIndex = new int[count]; int k = 0; for (int i =0; i < numMarkers; i++){ if (markerResults[i]){ Chromosome.realIndex[k] = i; k++; } } chromosomes = chrom; try{ prepareMarkerInput(null,0); }catch(HaploViewException e){ }catch(IOException e){ } } |
if(currentFamily.getNumMembers() == 1){ | if((currentFamily.getNumMembers() == 1 && assocTest == 0) || assocTest == 2){ | public void linkageToChrom(boolean[] markerResults, PedFile pedFile) throws IllegalArgumentException{ if(markerResults == null){ throw new IllegalArgumentException(); } Vector indList = pedFile.getOrder(); int numMarkers = 0; Vector usedParents = new Vector(); Individual currentInd; Family currentFamily; Vector chrom = new Vector(); for(int x=0; x < indList.size(); x++){ String[] indAndFamID = (String[])indList.elementAt(x); currentFamily = pedFile.getFamily(indAndFamID[0]); currentInd = currentFamily.getMember(indAndFamID[1]); if(currentInd.getIsTyped()){ //singleton if(currentFamily.getNumMembers() == 1){ numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == thisMarker[1]){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = 5; chrom2[i] = 5; } } //chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1)); //chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2)); }else{ //skip if indiv is parent in trio or unaffected //TODO: chokes when no affected status is specified. if (!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0") || currentInd.getAffectedStatus() != 2)){ //trio if (!(usedParents.contains( currentInd.getFamilyID() + " " + currentInd.getMomID()) || usedParents.contains(currentInd.getFamilyID() + " " + currentInd.getDadID()))){ //add 4 phased haps provided that we haven't used this trio already numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; boolean[] kidMissing = new boolean[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { kidMissing[i] = true; //kid missing if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else { dadTb[i] = 5; dadUb[i] = 5; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else { momTb[i] = 5; momUb[i] = 5; } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 5; momUb[i] = 5; } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { //everybody het dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 5; momUb[i] = 5; } } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadUb,false,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momUb,false,kidMissing)); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getDadID()); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getMomID()); } } } } } //set up the indexing to take into account skipped markers. Need //to loop through twice because first time we just count number of //unskipped markers int count = 0; for (int i = 0; i < numMarkers; i++){ if (markerResults[i]){ count++; } } Chromosome.realIndex = new int[count]; int k = 0; for (int i =0; i < numMarkers; i++){ if (markerResults[i]){ Chromosome.realIndex[k] = i; k++; } } chromosomes = chrom; try{ prepareMarkerInput(null,0); }catch(HaploViewException e){ }catch(IOException e){ } } |
chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1,currentInd.getAffectedStatus()==2)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2,currentInd.getAffectedStatus()==2)); | public void linkageToChrom(boolean[] markerResults, PedFile pedFile) throws IllegalArgumentException{ if(markerResults == null){ throw new IllegalArgumentException(); } Vector indList = pedFile.getOrder(); int numMarkers = 0; Vector usedParents = new Vector(); Individual currentInd; Family currentFamily; Vector chrom = new Vector(); for(int x=0; x < indList.size(); x++){ String[] indAndFamID = (String[])indList.elementAt(x); currentFamily = pedFile.getFamily(indAndFamID[0]); currentInd = currentFamily.getMember(indAndFamID[1]); if(currentInd.getIsTyped()){ //singleton if(currentFamily.getNumMembers() == 1){ numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == thisMarker[1]){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = 5; chrom2[i] = 5; } } //chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1)); //chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2)); }else{ //skip if indiv is parent in trio or unaffected //TODO: chokes when no affected status is specified. if (!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0") || currentInd.getAffectedStatus() != 2)){ //trio if (!(usedParents.contains( currentInd.getFamilyID() + " " + currentInd.getMomID()) || usedParents.contains(currentInd.getFamilyID() + " " + currentInd.getDadID()))){ //add 4 phased haps provided that we haven't used this trio already numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; boolean[] kidMissing = new boolean[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { kidMissing[i] = true; //kid missing if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else { dadTb[i] = 5; dadUb[i] = 5; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else { momTb[i] = 5; momUb[i] = 5; } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 5; momUb[i] = 5; } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { //everybody het dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 5; momUb[i] = 5; } } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadUb,false,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momUb,false,kidMissing)); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getDadID()); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getMomID()); } } } } } //set up the indexing to take into account skipped markers. Need //to loop through twice because first time we just count number of //unskipped markers int count = 0; for (int i = 0; i < numMarkers; i++){ if (markerResults[i]){ count++; } } Chromosome.realIndex = new int[count]; int k = 0; for (int i =0; i < numMarkers; i++){ if (markerResults[i]){ Chromosome.realIndex[k] = i; k++; } } chromosomes = chrom; try{ prepareMarkerInput(null,0); }catch(HaploViewException e){ }catch(IOException e){ } } |
|
if (!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0") || currentInd.getAffectedStatus() != 2)){ if (!(usedParents.contains( currentInd.getFamilyID() + " " + currentInd.getMomID()) || usedParents.contains(currentInd.getFamilyID() + " " + currentInd.getDadID()))){ numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; boolean[] kidMissing = new boolean[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { kidMissing[i] = true; if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else { dadTb[i] = 5; dadUb[i] = 5; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else { momTb[i] = 5; momUb[i] = 5; } } else if (kid1 == kid2) { if (dad1 == 0) { | if (!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0")) && (currentInd.getAffectedStatus() == 2 || assocTest == 0)){ numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; boolean[] kidMissing = new boolean[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { kidMissing[i] = true; if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else { dadTb[i] = 5; dadUb[i] = 5; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else { momTb[i] = 5; momUb[i] = 5; } } else if (kid1 == kid2) { if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { if (dad1 == 0 && mom1 == 0) { dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 5; momUb[i] = 5; } else if (mom1 == 0 && dad1 != dad2) { dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { | public void linkageToChrom(boolean[] markerResults, PedFile pedFile) throws IllegalArgumentException{ if(markerResults == null){ throw new IllegalArgumentException(); } Vector indList = pedFile.getOrder(); int numMarkers = 0; Vector usedParents = new Vector(); Individual currentInd; Family currentFamily; Vector chrom = new Vector(); for(int x=0; x < indList.size(); x++){ String[] indAndFamID = (String[])indList.elementAt(x); currentFamily = pedFile.getFamily(indAndFamID[0]); currentInd = currentFamily.getMember(indAndFamID[1]); if(currentInd.getIsTyped()){ //singleton if(currentFamily.getNumMembers() == 1){ numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == thisMarker[1]){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = 5; chrom2[i] = 5; } } //chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1)); //chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2)); }else{ //skip if indiv is parent in trio or unaffected //TODO: chokes when no affected status is specified. if (!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0") || currentInd.getAffectedStatus() != 2)){ //trio if (!(usedParents.contains( currentInd.getFamilyID() + " " + currentInd.getMomID()) || usedParents.contains(currentInd.getFamilyID() + " " + currentInd.getDadID()))){ //add 4 phased haps provided that we haven't used this trio already numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; boolean[] kidMissing = new boolean[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { kidMissing[i] = true; //kid missing if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else { dadTb[i] = 5; dadUb[i] = 5; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else { momTb[i] = 5; momUb[i] = 5; } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 5; momUb[i] = 5; } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { //everybody het dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 5; momUb[i] = 5; } } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadUb,false,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momUb,false,kidMissing)); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getDadID()); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getMomID()); } } } } } //set up the indexing to take into account skipped markers. Need //to loop through twice because first time we just count number of //unskipped markers int count = 0; for (int i = 0; i < numMarkers; i++){ if (markerResults[i]){ count++; } } Chromosome.realIndex = new int[count]; int k = 0; for (int i =0; i < numMarkers; i++){ if (markerResults[i]){ Chromosome.realIndex[k] = i; k++; } } chromosomes = chrom; try{ prepareMarkerInput(null,0); }catch(HaploViewException e){ }catch(IOException e){ } } |
dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { | } } else if (mom1 == 0 && dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { | public void linkageToChrom(boolean[] markerResults, PedFile pedFile) throws IllegalArgumentException{ if(markerResults == null){ throw new IllegalArgumentException(); } Vector indList = pedFile.getOrder(); int numMarkers = 0; Vector usedParents = new Vector(); Individual currentInd; Family currentFamily; Vector chrom = new Vector(); for(int x=0; x < indList.size(); x++){ String[] indAndFamID = (String[])indList.elementAt(x); currentFamily = pedFile.getFamily(indAndFamID[0]); currentInd = currentFamily.getMember(indAndFamID[1]); if(currentInd.getIsTyped()){ //singleton if(currentFamily.getNumMembers() == 1){ numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == thisMarker[1]){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = 5; chrom2[i] = 5; } } //chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1)); //chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2)); }else{ //skip if indiv is parent in trio or unaffected //TODO: chokes when no affected status is specified. if (!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0") || currentInd.getAffectedStatus() != 2)){ //trio if (!(usedParents.contains( currentInd.getFamilyID() + " " + currentInd.getMomID()) || usedParents.contains(currentInd.getFamilyID() + " " + currentInd.getDadID()))){ //add 4 phased haps provided that we haven't used this trio already numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; boolean[] kidMissing = new boolean[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { kidMissing[i] = true; //kid missing if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else { dadTb[i] = 5; dadUb[i] = 5; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else { momTb[i] = 5; momUb[i] = 5; } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 5; momUb[i] = 5; } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { //everybody het dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 5; momUb[i] = 5; } } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadUb,false,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momUb,false,kidMissing)); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getDadID()); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getMomID()); } } } } } //set up the indexing to take into account skipped markers. Need //to loop through twice because first time we just count number of //unskipped markers int count = 0; for (int i = 0; i < numMarkers; i++){ if (markerResults[i]){ count++; } } Chromosome.realIndex = new int[count]; int k = 0; for (int i =0; i < numMarkers; i++){ if (markerResults[i]){ Chromosome.realIndex[k] = i; k++; } } chromosomes = chrom; try{ prepareMarkerInput(null,0); }catch(HaploViewException e){ }catch(IOException e){ } } |
momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { if (dad1 == 0 && mom1 == 0) { dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 5; momUb[i] = 5; } else if (mom1 == 0 && dad1 != dad2) { dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 5; momUb[i] = 5; } | } } else if (dad1 == dad2 && mom1 != mom2) { dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 5; momUb[i] = 5; | public void linkageToChrom(boolean[] markerResults, PedFile pedFile) throws IllegalArgumentException{ if(markerResults == null){ throw new IllegalArgumentException(); } Vector indList = pedFile.getOrder(); int numMarkers = 0; Vector usedParents = new Vector(); Individual currentInd; Family currentFamily; Vector chrom = new Vector(); for(int x=0; x < indList.size(); x++){ String[] indAndFamID = (String[])indList.elementAt(x); currentFamily = pedFile.getFamily(indAndFamID[0]); currentInd = currentFamily.getMember(indAndFamID[1]); if(currentInd.getIsTyped()){ //singleton if(currentFamily.getNumMembers() == 1){ numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == thisMarker[1]){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = 5; chrom2[i] = 5; } } //chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1)); //chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2)); }else{ //skip if indiv is parent in trio or unaffected //TODO: chokes when no affected status is specified. if (!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0") || currentInd.getAffectedStatus() != 2)){ //trio if (!(usedParents.contains( currentInd.getFamilyID() + " " + currentInd.getMomID()) || usedParents.contains(currentInd.getFamilyID() + " " + currentInd.getDadID()))){ //add 4 phased haps provided that we haven't used this trio already numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; boolean[] kidMissing = new boolean[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { kidMissing[i] = true; //kid missing if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else { dadTb[i] = 5; dadUb[i] = 5; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else { momTb[i] = 5; momUb[i] = 5; } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 5; momUb[i] = 5; } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { //everybody het dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 5; momUb[i] = 5; } } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadUb,false,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momUb,false,kidMissing)); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getDadID()); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getMomID()); } } } } } //set up the indexing to take into account skipped markers. Need //to loop through twice because first time we just count number of //unskipped markers int count = 0; for (int i = 0; i < numMarkers; i++){ if (markerResults[i]){ count++; } } Chromosome.realIndex = new int[count]; int k = 0; for (int i =0; i < numMarkers; i++){ if (markerResults[i]){ Chromosome.realIndex[k] = i; k++; } } chromosomes = chrom; try{ prepareMarkerInput(null,0); }catch(HaploViewException e){ }catch(IOException e){ } } |
chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadUb,false,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momUb,false,kidMissing)); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getDadID()); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getMomID()); | public void linkageToChrom(boolean[] markerResults, PedFile pedFile) throws IllegalArgumentException{ if(markerResults == null){ throw new IllegalArgumentException(); } Vector indList = pedFile.getOrder(); int numMarkers = 0; Vector usedParents = new Vector(); Individual currentInd; Family currentFamily; Vector chrom = new Vector(); for(int x=0; x < indList.size(); x++){ String[] indAndFamID = (String[])indList.elementAt(x); currentFamily = pedFile.getFamily(indAndFamID[0]); currentInd = currentFamily.getMember(indAndFamID[1]); if(currentInd.getIsTyped()){ //singleton if(currentFamily.getNumMembers() == 1){ numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == thisMarker[1]){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = 5; chrom2[i] = 5; } } //chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1)); //chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2)); }else{ //skip if indiv is parent in trio or unaffected //TODO: chokes when no affected status is specified. if (!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0") || currentInd.getAffectedStatus() != 2)){ //trio if (!(usedParents.contains( currentInd.getFamilyID() + " " + currentInd.getMomID()) || usedParents.contains(currentInd.getFamilyID() + " " + currentInd.getDadID()))){ //add 4 phased haps provided that we haven't used this trio already numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; boolean[] kidMissing = new boolean[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { kidMissing[i] = true; //kid missing if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else { dadTb[i] = 5; dadUb[i] = 5; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else { momTb[i] = 5; momUb[i] = 5; } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 5; momUb[i] = 5; } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { //everybody het dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 5; momUb[i] = 5; } } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadUb,false,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momTb,true,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momUb,false,kidMissing)); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getDadID()); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getMomID()); } } } } } //set up the indexing to take into account skipped markers. Need //to loop through twice because first time we just count number of //unskipped markers int count = 0; for (int i = 0; i < numMarkers; i++){ if (markerResults[i]){ count++; } } Chromosome.realIndex = new int[count]; int k = 0; for (int i =0; i < numMarkers; i++){ if (markerResults[i]){ Chromosome.realIndex[k] = i; k++; } } chromosomes = chrom; try{ prepareMarkerInput(null,0); }catch(HaploViewException e){ }catch(IOException e){ } } |
|
public void linkageToHapsFormat(boolean[] markerResults, PedFile pedFile, String hapFileName)throws IOException{ | public void linkageToHapsFormat(boolean[] markerResults, PedFile pedFile, String hapFileName)throws IOException, PedFileException{ | public void linkageToHapsFormat(boolean[] markerResults, PedFile pedFile, String hapFileName)throws IOException{ FileWriter linkageToHapsWriter = new FileWriter(new File(hapFileName)); Vector indList = pedFile.getOrder(); int numMarkers = 0; Vector usedParents = new Vector(); Individual currentInd; Family currentFamily; for(int x=0; x < indList.size(); x++){ String[] indAndFamID = (String[])indList.elementAt(x); currentFamily = pedFile.getFamily(indAndFamID[0]); currentInd = currentFamily.getMember(indAndFamID[1]); boolean begin = false; if(currentInd.getIsTyped()){ //singleton if(currentFamily.getNumMembers() == 1){ StringBuffer hap1 = new StringBuffer(numMarkers); StringBuffer hap2 = new StringBuffer(numMarkers); hap1.append(currentInd.getFamilyID()).append("\t").append(currentInd.getIndividualID()).append("\t"); hap2.append(currentInd.getFamilyID()).append("\t").append(currentInd.getIndividualID()).append("\t"); numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ if (markerResults[i]){ if (begin){ hap1.append(" "); hap2.append(" "); } byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == thisMarker[1]){ hap1.append(thisMarker[0]); hap2.append(thisMarker[1]); }else{ hap1.append("h"); hap2.append("h"); } begin=true; } } hap1.append("\n"); hap2.append("\n"); hap1.append(hap2); linkageToHapsWriter.write(hap1.toString()); } else{ //skip if indiv is parent in trio or unaffected if (!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0") || currentInd.getAffectedStatus() != 2)){ //trio String dadT = new String(""); String dadU = new String(""); String momT = new String(""); String momU = new String(""); if (!(usedParents.contains( currentInd.getFamilyID() + " " + currentInd.getMomID()) || usedParents.contains(currentInd.getFamilyID() + " " + currentInd.getDadID()))){ //add 4 phased haps provided that we haven't used this trio already numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ if (markerResults[i]){ if (begin){ dadT+=" ";dadU+=" ";momT+=" ";momU+=" "; } byte[] thisMarker = currentInd.getMarker(i); int kid1 = thisMarker[0]; int kid2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); int mom1 = thisMarker[0]; int mom2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); int dad1 = thisMarker[0]; int dad2 = thisMarker[1]; if (kid1==0 || kid2==0){ //kid missing if (dad1==dad2){dadT += dad1; dadU +=dad1;} else{dadT+="h"; dadU+="h";} if (mom1==mom2){momT+=mom1; momU+=mom1;} else{momT+="h"; momU+="h";} }else if (kid1==kid2){ //kid homozygous if(dad1==0){dadT+=kid1;dadU+="0";} else if (dad1==kid1){dadT+=dad1;dadU+=dad2;} else {dadT+=dad2;dadU+=dad1;} if(mom1==0){momT+=kid1;momU+="0";} else if (mom1==kid1){momT+=mom1;momU+=mom2;} else {momT+=mom2;momU+=mom1;} }else{ //kid heterozygous and this if tree's a bitch if(dad1==0 && mom1==0){ //both missing dadT+="0";dadU+="0";momT+="0";momU+="0"; }else if (dad1==0 && mom1 != mom2){ //dad missing mom het dadT+="0";dadU+="0";momT+="h";momU+="h"; }else if (mom1==0 && dad1 != dad2){ //dad het mom missing dadT+="h"; dadU+="h"; momT+="0"; momU+="0"; }else if (dad1==0 && mom1 == mom2){ //dad missing mom hom momT += mom1; momU += mom1; dadU+="0"; if(kid1==mom1){dadT+=kid2;}else{dadT+=kid1;} }else if (mom1==0 && dad1==dad2){ //mom missing dad hom dadT+=dad1;dadU+=dad1;momU+="0"; if(kid1==dad1){momT+=kid2;}else{momT+=kid1;} }else if (dad1==dad2 && mom1 != mom2){ //dad hom mom het dadT+=dad1; dadU+=dad2; if(kid1==dad1){momT+=kid2;momU+=kid1; }else{momT+=kid1;momU+=kid2;} }else if (mom1==mom2 && dad1!=dad2){ //dad het mom hom momT+=mom1; momU+=mom2; if(kid1==mom1){dadT+=kid2;dadU+=kid1; }else{dadT+=kid1;dadU+=kid2;} }else if (dad1==dad2 && mom1==mom2){ //mom & dad hom dadT+=dad1; dadU+=dad1; momT+=mom1; momU+=mom1; }else{ //everybody het dadT+="h";dadU+="h";momT+="h";momU+="h"; } } begin=true; } } momT+="\n";momU+="\n";dadT+="\n";dadU+="\n"; linkageToHapsWriter.write(currentInd.getFamilyID()+"-"+currentInd.getDadID()+"\tT\t" + dadT); linkageToHapsWriter.write(currentInd.getFamilyID()+"-"+currentInd.getDadID()+"\tU\t" + dadU); linkageToHapsWriter.write(currentInd.getFamilyID()+"-"+currentInd.getMomID()+"\tT\t" + momT); linkageToHapsWriter.write(currentInd.getFamilyID()+"-"+currentInd.getMomID()+"\tU\t" + momU); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getDadID()); usedParents.add(currentInd.getFamilyID()+" "+currentInd.getMomID()); } } } } } linkageToHapsWriter.close(); } |
chroms.add(new Chromosome(ped, indiv, genos, infile.getName())); | chroms.add(new Chromosome(ped, indiv, genos, false, infile.getName())); | void prepareHapsInput(File infile) throws IOException, HaploViewException{ //this method is called to suck in data from a file (its only argument) //of genotypes and sets up the Chromosome objects. String currentLine; Vector chroms = new Vector(); byte[] genos = new byte[0]; String ped, indiv; if(infile.length() < 1){ throw new HaploViewException("Genotype file is empty or does not exist: " + infile.getName()); } //read the file: BufferedReader in = new BufferedReader(new FileReader(infile)); int lineCount = 0; int numTokens = 0; boolean even = true; while ((currentLine = in.readLine()) != null){ lineCount++; //each line is expected to be of the format: //ped indiv geno geno geno geno... if (currentLine.length() == 0){ //skip blank lines continue; } even = !even; StringTokenizer st = new StringTokenizer(currentLine); //first two tokens are expected to be ped, indiv ped = st.nextToken(); indiv = st.nextToken(); //all other tokens are loaded into a vector (they should all be genotypes) genos = new byte[st.countTokens()]; int q = 0; if (numTokens == 0){ numTokens = st.countTokens(); } if (numTokens != st.countTokens()){ throw new HaploViewException("Genotype file error:\nLine " + lineCount + " appears to have an incorrect number of entries"); } while (st.hasMoreTokens()){ String thisGenotype = (String)st.nextElement(); if (thisGenotype.equals("h")) { genos[q] = 5; }else{ try{ genos[q] = Byte.parseByte(thisGenotype); }catch (NumberFormatException nfe){ throw new HaploViewException("Genotype file input error:\ngenotype value \"" + thisGenotype + "\" on line " + lineCount + " not allowed."); } } if (genos[q] < 0 || genos[q] > 5){ throw new HaploViewException("Genotype file input error:\ngenotype value \"" + genos[q] + "\" on line " + lineCount + " not allowed."); } q++; } //a Chromosome is created and added to a vector of chromosomes. //this is what is evetually returned. chroms.add(new Chromosome(ped, indiv, genos, infile.getName())); } if (!even){ //we're missing a line here throw new HaploViewException("Genotype file appears to have an odd number of lines.\n"+ "Each individual is required to have two chromosomes"); } chromosomes = chroms; //initialize realIndex Chromosome.realIndex = new int[genos.length]; for (int i = 0; i < genos.length; i++){ Chromosome.realIndex[i] = i; } try{ prepareMarkerInput(null,0); }catch(HaploViewException e){ } } |
String n1 = t1.getName().toLowerCase(); String n2 = t2.getName().toLowerCase(); | String n1 = t1.getName(); String n2 = t2.getName(); if (n1 != null) n1 = n1.toLowerCase(); if (n2 != null) n2 = n2.toLowerCase(); | public int compare(SQLObject t1, SQLObject t2) { // if t1 and t2 refer to the same object, or are both null, then they're equal if (t1 == t2) return 0; else if (t1 == null) return -1; else if (t2 == null) return 1; else { //TODO In version 2.0 we want this to be an option String n1 = t1.getName().toLowerCase(); String n2 = t2.getName().toLowerCase(); if (n1 == n2) return 0; else if (n1 == null) return -1; else if (n2 == null) return 1; else return n1.compareTo(n2); } } |
assertEquals("There are multiple copies of this relationship in the parent's export keys folder",2,parentTable.getExportedKeys().size()); assertEquals("There are multiple copies of this relationship in the child's import keys folder",1,childTable1.getImportedKeys().size()); | assertEquals("There are multiple copies of this relationship in the parent's exported keys folder",2,parentTable.getExportedKeys().size()); assertEquals("There are multiple copies of this relationship in the child's imported keys folder",1,childTable1.getImportedKeys().size()); | public void testReconnectOldRelationshipWithCustomMapping() throws ArchitectException { List<SQLColumn> origParentCols = new ArrayList<SQLColumn>(parentTable.getColumns()); List<SQLColumn> origChild1Cols = new ArrayList<SQLColumn>(childTable1.getColumns()); parentTable.removeExportedKey(rel1); rel1.attachRelationship(parentTable, childTable1, false); assertEquals("Exported key columns disappeared", origParentCols, parentTable.getColumns()); assertEquals("Imported key columns didn't get put back", origChild1Cols, childTable1.getColumns()); assertEquals("There are multiple copies of this relationship in the parent's export keys folder",2,parentTable.getExportedKeys().size()); assertEquals("There are multiple copies of this relationship in the child's import keys folder",1,childTable1.getImportedKeys().size()); } |
public FileIterator(Project project, Iterator fileSetIterator) { this.project = project; this.fileSetIterator = fileSetIterator; | public FileIterator(Project project, Iterator fileSetIterator) { this( project, fileSetIterator, false); | public FileIterator(Project project, Iterator fileSetIterator) { this.project = project; this.fileSetIterator = fileSetIterator; } |
files = ds.getIncludedFiles(); | if (iterateDirectories) { files = ds.getIncludedDirectories(); } else { files = ds.getIncludedFiles(); } | private boolean setNextObject() { while (true) { while (ds == null) { if ( ! fileSetIterator.hasNext() ) { return false; } FileSet fs = (FileSet) fileSetIterator.next(); ds = fs.getDirectoryScanner(project); ds.scan(); files = ds.getIncludedFiles(); if ( files.length > 0 ) { fileIndex = -1; break; } else { ds = null; } } if ( ds != null && files != null ) { if ( ++fileIndex < files.length ) { nextFile = new File( ds.getBasedir(), files[fileIndex] ); nextObjectSet = true; return true; } else { ds = null; } } } } |
public void run(Context context, XMLOutput output) throws Exception { | public void run(JellyContext context, XMLOutput output) throws Exception { | public void run(Context context, XMLOutput output) throws Exception { if ( test != null ) { if ( test.evaluateAsBoolean( context ) ) { getBody().run( context, output ); } } } |
logger.debug("project: " + ArchitectFrame.getMainInstance().getProject()); if (ArchitectFrame.getMainInstance().getProject() == null || ArchitectFrame.getMainInstance().getProject().getTargetDatabase() == value) { | SQLDatabase db = (SQLDatabase) value; if (db.isPlayPenDatabase()) { | public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { setText(value.toString()); if (value instanceof SQLDatabase) { logger.debug("project: " + ArchitectFrame.getMainInstance().getProject()); if (ArchitectFrame.getMainInstance().getProject() == null || // getProject() is null when program is starting ArchitectFrame.getMainInstance().getProject().getTargetDatabase() == value) { setIcon(targetIcon); StringBuffer name = new StringBuffer(); name.append("Project"); /*if (ArchitectFrame.getMainInstance().getProject() != null ){ String temp = ArchitectFrame.getMainInstance().getProject(). getTargetDatabase().getName(); if (temp == null) { temp = ""; // beacuse empty string is omitted from the label } else { temp = temp.trim(); } if (temp.length() > 0){ name.append(" ("); name.append(ArchitectFrame.getMainInstance().getProject().getTargetDatabase().getName()); name.append(")"); } } setText(name.toString()); */ } else { setIcon(dbIcon); } } else if (value instanceof SQLCatalog) { if (((SQLCatalog) value).getNativeTerm().equals("owner")) { setIcon(ownerIcon); } else if (((SQLCatalog) value).getNativeTerm().equals("database")) { setIcon(dbIcon); } else if (((SQLCatalog) value).getNativeTerm().equals("schema")) { setIcon(schemaIcon); } else { setIcon(cataIcon); } } else if (value instanceof SQLSchema) { if (((SQLSchema) value).getNativeTerm().equals("owner")) { setIcon(ownerIcon); } else { setIcon(schemaIcon); } } else if (value instanceof SQLTable) { setIcon(tableIcon); if (((SQLTable) value).getObjectType() != null) { setText(((SQLTable) value).getName()+" ("+((SQLTable) value).getObjectType()+")"); } else { setText(((SQLTable) value).getName()); } } else if (value instanceof SQLRelationship) { setIcon(keyIcon); } else { setIcon(null); } this.selected = sel; this.hasFocus = hasFocus; if (value instanceof SQLObject) { if (((SQLObject) value).isPopulated()) { setForeground(Color.black); } else { setForeground(Color.lightGray); } } return this; } |
StringBuffer name = new StringBuffer(); name.append("Project"); | if (db.getName() == null || db.getName().length() == 0) { setText("Project"); } else { setText("Project ("+db.getName()+")"); } | public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { setText(value.toString()); if (value instanceof SQLDatabase) { logger.debug("project: " + ArchitectFrame.getMainInstance().getProject()); if (ArchitectFrame.getMainInstance().getProject() == null || // getProject() is null when program is starting ArchitectFrame.getMainInstance().getProject().getTargetDatabase() == value) { setIcon(targetIcon); StringBuffer name = new StringBuffer(); name.append("Project"); /*if (ArchitectFrame.getMainInstance().getProject() != null ){ String temp = ArchitectFrame.getMainInstance().getProject(). getTargetDatabase().getName(); if (temp == null) { temp = ""; // beacuse empty string is omitted from the label } else { temp = temp.trim(); } if (temp.length() > 0){ name.append(" ("); name.append(ArchitectFrame.getMainInstance().getProject().getTargetDatabase().getName()); name.append(")"); } } setText(name.toString()); */ } else { setIcon(dbIcon); } } else if (value instanceof SQLCatalog) { if (((SQLCatalog) value).getNativeTerm().equals("owner")) { setIcon(ownerIcon); } else if (((SQLCatalog) value).getNativeTerm().equals("database")) { setIcon(dbIcon); } else if (((SQLCatalog) value).getNativeTerm().equals("schema")) { setIcon(schemaIcon); } else { setIcon(cataIcon); } } else if (value instanceof SQLSchema) { if (((SQLSchema) value).getNativeTerm().equals("owner")) { setIcon(ownerIcon); } else { setIcon(schemaIcon); } } else if (value instanceof SQLTable) { setIcon(tableIcon); if (((SQLTable) value).getObjectType() != null) { setText(((SQLTable) value).getName()+" ("+((SQLTable) value).getObjectType()+")"); } else { setText(((SQLTable) value).getName()); } } else if (value instanceof SQLRelationship) { setIcon(keyIcon); } else { setIcon(null); } this.selected = sel; this.hasFocus = hasFocus; if (value instanceof SQLObject) { if (((SQLObject) value).isPopulated()) { setForeground(Color.black); } else { setForeground(Color.lightGray); } } return this; } |
public DBTree() { | private DBTree() { | public DBTree() { setUI(new MultiDragTreeUI()); setRootVisible(false); setShowsRootHandles(true); ds = new DragSource(); ds.createDefaultDragGestureRecognizer (this, DnDConstants.ACTION_COPY, new DBTreeDragGestureListener()); newDBCSAction = new NewDBCSAction(); dbcsPropertiesAction = new DBCSPropertiesAction(); removeDBCSAction = new RemoveDBCSAction(); showInPlayPenAction = new ShowInPlayPenAction(); setupPropDialog(); addMouseListener(new PopupListener()); setCellRenderer(new SQLObjectRenderer()); } |
return connectionSpec.getDisplayName(); | if (connectionSpec != null) { return connectionSpec.getDisplayName(); } else { return "PlayPen Database"; } | public String getName() { return connectionSpec.getDisplayName(); } |
return connectionSpec.getDisplayName(); | return getName(); | public String getShortDisplayName() { return connectionSpec.getDisplayName(); } |
if (connectionSpec != null) { return connectionSpec.getDisplayName(); } else { return "PlayPen Database"; } | return getName(); | public String toString() { if (connectionSpec != null) { return connectionSpec.getDisplayName(); } else { return "PlayPen Database"; } } |
int size = tagStack.size(); if ( size <= 0 ) { parentTag = null; } else { parentTag = (Tag) tagStack.remove( size - 1 ); } | public void endElement(String namespaceURI, String localName, String qName) throws SAXException { tagScript = (TagScript) tagScriptStack.remove(tagScriptStack.size() - 1); if (tagScript != null) { if (textBuffer.length() > 0) { script.addScript(new TextScript(textBuffer.toString())); textBuffer.setLength(0); } script = (ScriptBlock) scriptStack.pop(); } else { textBuffer.append("</"); textBuffer.append(qName); textBuffer.append(">"); } } |
|
parentTag = tag; | if ( parentTag != null ) { tagStack.add( parentTag ); } parentTag = tag; | public void startElement( String namespaceURI, String localName, String qName, Attributes list) throws SAXException { try { // if this is a tag then create a script to run it // otherwise pass the text to the current body tagScript = createTag(namespaceURI, localName, list); if (tagScript == null) { tagScript = createStaticTag(namespaceURI, localName, qName, list); } tagScriptStack.add(tagScript); if (tagScript != null) { // set parent relationship... Tag tag = tagScript.getTag(); tag.setParent(parentTag); parentTag = tag; if (textBuffer.length() > 0) { script.addScript(new TextScript(textBuffer.toString())); textBuffer.setLength(0); } script.addScript(tagScript); // start a new body scriptStack.push(script); script = new ScriptBlock(); tag.setBody(script); } else { // XXXX: might wanna handle empty elements later... textBuffer.append("<"); textBuffer.append(qName); int size = list.getLength(); for (int i = 0; i < size; i++) { textBuffer.append(" "); textBuffer.append(list.getQName(i)); textBuffer.append("="); textBuffer.append("\""); textBuffer.append(list.getValue(i)); textBuffer.append("\""); } textBuffer.append(">"); } } catch (SAXException e) { throw e; } catch (Exception e) { log.error( "Caught exception: " + e, e ); throw new SAXException( "Runtime Exception: " + e, e ); } } |
Object size = attributes.remove("size"); if (size != null) { Point point = null; if (size instanceof Point) { point = (Point) size; } else { point = PointConverter.getInstance().parse(size.toString()); } Control control = (Control) bean; control.setSize(point); } | Control control = (Control) bean; Object size = attributes.remove("size"); setSize(control, size); Object colorValue = attributes.remove("background"); Color background = getColor(control, colorValue); control.setBackground(background); colorValue = attributes.remove("foreground"); Color foreground = getColor(control, colorValue); control.setForeground(foreground); | protected void setBeanProperties(Object bean, Map attributes) throws JellyTagException { // special handling of size property as the Control object breaks the // JavaBean naming conventions by overloading the setSize() method if (bean instanceof Control) { Object size = attributes.remove("size"); if (size != null) { Point point = null; if (size instanceof Point) { point = (Point) size; } else { point = PointConverter.getInstance().parse(size.toString()); } Control control = (Control) bean; control.setSize(point); } } // TODO Auto-generated method stub super.setBeanProperties(bean, attributes); } |
if(Array.getLength(data) > 0){ return formatArray(data); } | return formatArray(data); | public static String format(Object data){ /* if data is null, return the configured null value */ if(data == null) return nullValue; /* check for a DataFormat for given type (normal object or array)*/ DataFormat formatter = findDataFormat(data); if(formatter != defaultFormatter){ return formatter.format(data); }else if(data.getClass().isArray()){ /* see if there is a formatter configured for the elements of the array. This assumes that the array has the same elements. */ if(Array.getLength(data) > 0){ return formatArray(data); } } /* format with the default formatter */ return defaultFormatter.format(data); } |
for (index = begin; index < end; index += step ) { | for (index = begin; index <= end; index += step ) { | public void doTag(XMLOutput output) throws Exception { if (log.isDebugEnabled()) { log.debug("running with items: " + items); } if (items != null) { Iterator iter = items.evaluateAsIterator(context); if (log.isDebugEnabled()) { log.debug("Iterating through: " + iter); } // ignore the first items of the iterator for (index = 0; index < begin && iter.hasNext(); index++ ) { iter.next(); } while (iter.hasNext() && index < end) { Object value = iter.next(); if (var != null) { context.setVariable(var, value); } if (indexVar != null) { context.setVariable(indexVar, new Integer(index)); } invokeBody(output); // now we need to move to next index index++; for ( int i = 1; i < step; i++, index++ ) { if ( ! iter.hasNext() ) { return; } iter.next(); } } } else { if ( end == Integer.MAX_VALUE && begin == 0 ) { throw new MissingAttributeException( "items" ); } else { String varName = var; if ( varName == null ) { varName = indexVar; } for (index = begin; index < end; index += step ) { if (varName != null) { Object value = new Integer(index); context.setVariable(varName, value); } invokeBody(output); } } } } |
public Object evaluate(Context context) { | public Object evaluate(JellyContext context) { | public Object evaluate(Context context) { // XXXX: unfortunately we must sychronize evaluations // so that we can swizzle in the context. // maybe we could create an expression from a context // (and so create a BSFManager for a context) synchronized (registry) { registry.setContext(context); try { // XXXX: hack - there must be a better way!!! for ( Iterator iter = context.getVariableNames(); iter.hasNext(); ) { String name = (String) iter.next(); Object value = context.getVariable( name ); manager.declareBean( name, value, value.getClass() ); } return engine.eval( text, -1, -1, text ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + text + ". Reason: " + e, e ); return null; } } } |
registry.setContext(context); | registry.setJellyContext(context); | public Object evaluate(Context context) { // XXXX: unfortunately we must sychronize evaluations // so that we can swizzle in the context. // maybe we could create an expression from a context // (and so create a BSFManager for a context) synchronized (registry) { registry.setContext(context); try { // XXXX: hack - there must be a better way!!! for ( Iterator iter = context.getVariableNames(); iter.hasNext(); ) { String name = (String) iter.next(); Object value = context.getVariable( name ); manager.declareBean( name, value, value.getClass() ); } return engine.eval( text, -1, -1, text ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + text + ". Reason: " + e, e ); return null; } } } |
public void setContext(Context context) { | public void setContext(JellyContext context) { | public void setContext(Context context) { this.context = context; } |
if (which.equals(c[i])){ | if (which.equalsIgnoreCase(c[i])){ | public GBrowseDialog(HaploView h, String title){ super (h,title); hv = h; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JPanel chromPanel = new JPanel(); chromPanel.add(new JLabel("Chromosome")); String[] c = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "X", "Y"}; cbox = new JComboBox(c); if (Chromosome.getDataChrom() != null){ String which = Chromosome.getDataChrom().substring(3); for (int i = 0; i < c.length; i++){ if (which.equals(c[i])){ cbox.setSelectedIndex(i); } } } chromPanel.add(cbox); contents.add(chromPanel); JPanel boundsPanel = new JPanel(); boundsPanel.add(new JLabel("from")); minField = new JTextField(Long.toString(Chromosome.getMarker(0).getPosition()), 9); boundsPanel.add(minField); boundsPanel.add(new JLabel(" to")); maxField = new JTextField(Long.toString(Chromosome.getMarker(Chromosome.getSize()-1).getPosition()), 9); boundsPanel.add(maxField); contents.add(boundsPanel); JPanel buildPanel = new JPanel(); buildPanel.add(new JLabel("Genome build: ")); String[]b ={"34","35"}; buildBox = new JComboBox(b); buildBox.setSelectedIndex(1); buildPanel.add(buildBox); contents.add(buildPanel); JPanel buttonPanel = new JPanel(); JButton cancelBut = new JButton("Cancel"); cancelBut.addActionListener(this); JButton okBut = new JButton("OK"); okBut.addActionListener(this); buttonPanel.add(okBut); buttonPanel.add(cancelBut); contents.add(buttonPanel); this.getRootPane().setDefaultButton(okBut); contents.add(new JLabel("(Note: this option requires an internet connection)")); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); } |
} if (Chromosome.getDataChrom().equalsIgnoreCase("chrp")){ cbox.setSelectedIndex(22); | public GBrowseDialog(HaploView h, String title){ super (h,title); hv = h; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JPanel chromPanel = new JPanel(); chromPanel.add(new JLabel("Chromosome")); String[] c = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "X", "Y"}; cbox = new JComboBox(c); if (Chromosome.getDataChrom() != null){ String which = Chromosome.getDataChrom().substring(3); for (int i = 0; i < c.length; i++){ if (which.equals(c[i])){ cbox.setSelectedIndex(i); } } } chromPanel.add(cbox); contents.add(chromPanel); JPanel boundsPanel = new JPanel(); boundsPanel.add(new JLabel("from")); minField = new JTextField(Long.toString(Chromosome.getMarker(0).getPosition()), 9); boundsPanel.add(minField); boundsPanel.add(new JLabel(" to")); maxField = new JTextField(Long.toString(Chromosome.getMarker(Chromosome.getSize()-1).getPosition()), 9); boundsPanel.add(maxField); contents.add(boundsPanel); JPanel buildPanel = new JPanel(); buildPanel.add(new JLabel("Genome build: ")); String[]b ={"34","35"}; buildBox = new JComboBox(b); buildBox.setSelectedIndex(1); buildPanel.add(buildBox); contents.add(buildPanel); JPanel buttonPanel = new JPanel(); JButton cancelBut = new JButton("Cancel"); cancelBut.addActionListener(this); JButton okBut = new JButton("OK"); okBut.addActionListener(this); buttonPanel.add(okBut); buttonPanel.add(cancelBut); contents.add(buttonPanel); this.getRootPane().setDefaultButton(okBut); contents.add(new JLabel("(Note: this option requires an internet connection)")); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); } |
|
columnSelector.setModel(new SQLTableListModel(t)); new ProgressWatcher(progressBar,pm); new Thread(new Runnable() { public void run() { try { progressBar.setVisible(true); if (pm.getResult(t) == null) { pm.setCancelled(false); pm.createProfiles(Collections.nCopies(1, t)); } progressBar.setVisible(false); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(ProfilePanel.this, "Error during profile run", e); } catch (ArchitectException e) { e.printStackTrace(); | List<SQLColumn> columns = new ArrayList<SQLColumn>(); for (ProfileResult pr : tableModel.getResultList() ) { if (pr instanceof ColumnProfileResult) { SQLColumn column = (SQLColumn)pr.getProfiledObject(); SQLTable t2 = column.getParentTable(); if ( t == t2 && (!columns.contains(column)) ) { columns.add(column); | private void setup() { progressBar.setVisible(false); FormLayout controlsLayout = new FormLayout( "4dlu,fill:min(150dlu;default):grow, 4dlu", // columns "default, 4dlu, fill:min(200dlu;default):grow,4dlu,default"); // rows CellConstraints cc = new CellConstraints(); setLayout(new BorderLayout()); controlsArea = logger.isDebugEnabled() ? new FormDebugPanel(controlsLayout) : new JPanel(controlsLayout); controlsArea.setLayout(new BoxLayout(controlsArea, BoxLayout.Y_AXIS)); tableSelector = new JComboBox(); tableSelector.addActionListener(new ActionListener() { /* * Called when the user selects a table; create its profile (slow) */ public void actionPerformed(ActionEvent e) { final SQLTable t = (SQLTable) tableSelector.getSelectedItem(); if (t == null) { return; } try { columnSelector.setModel(new SQLTableListModel(t)); new ProgressWatcher(progressBar,pm); // Do the work - build the profiles for this table new Thread(new Runnable() { public void run() { try { progressBar.setVisible(true); if (pm.getResult(t) == null) { pm.setCancelled(false); pm.createProfiles(Collections.nCopies(1, t)); } progressBar.setVisible(false); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(ProfilePanel.this, "Error during profile run", e); } catch (ArchitectException e) { e.printStackTrace(); } } }).start(); } catch (Exception evt) { JOptionPane.showMessageDialog(null, "Error in profile", "Error", JOptionPane.ERROR_MESSAGE); evt.printStackTrace(); } } }); columnSelector = new JList(); // TODO maybe someday we can allow the user to compare profiles by removing this... columnSelector.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); columnSelector.addListSelectionListener(new ListSelectionListener() { /* * Called when the user selects a column; gets its profile (fast) */ public void valueChanged(ListSelectionEvent e) { SQLColumn col = (SQLColumn) columnSelector.getSelectedValue(); if (col == null) { logger.debug("Null selection in columnSelector.ListSelectionListener"); return; } displayPanel.displayProfile((SQLTable) tableSelector.getSelectedItem(), col); } }); PanelBuilder pb = new PanelBuilder(controlsLayout,controlsArea); pb.setDefaultDialogBorder(); pb.add(tableSelector, cc.xy(2, 1)); pb.add(new JScrollPane(columnSelector), cc.xy(2, 3)); pb.add(progressBar,cc.xy(2,5)); this.add(controlsArea, BorderLayout.WEST); displayPanel.setChartType(chartType); this.add(displayPanel.getDisplayArea(), BorderLayout.CENTER); } |
}).start(); | columnSelector.setModel(new DefaultComboBoxModel(columns.toArray())); if ( columns.size() > 0 ) { if ( selectedColumn != null && columns.contains(selectedColumn)) { columnSelector.setSelectedValue(selectedColumn,true); } else { columnSelector.setSelectedIndex(0); } } | private void setup() { progressBar.setVisible(false); FormLayout controlsLayout = new FormLayout( "4dlu,fill:min(150dlu;default):grow, 4dlu", // columns "default, 4dlu, fill:min(200dlu;default):grow,4dlu,default"); // rows CellConstraints cc = new CellConstraints(); setLayout(new BorderLayout()); controlsArea = logger.isDebugEnabled() ? new FormDebugPanel(controlsLayout) : new JPanel(controlsLayout); controlsArea.setLayout(new BoxLayout(controlsArea, BoxLayout.Y_AXIS)); tableSelector = new JComboBox(); tableSelector.addActionListener(new ActionListener() { /* * Called when the user selects a table; create its profile (slow) */ public void actionPerformed(ActionEvent e) { final SQLTable t = (SQLTable) tableSelector.getSelectedItem(); if (t == null) { return; } try { columnSelector.setModel(new SQLTableListModel(t)); new ProgressWatcher(progressBar,pm); // Do the work - build the profiles for this table new Thread(new Runnable() { public void run() { try { progressBar.setVisible(true); if (pm.getResult(t) == null) { pm.setCancelled(false); pm.createProfiles(Collections.nCopies(1, t)); } progressBar.setVisible(false); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(ProfilePanel.this, "Error during profile run", e); } catch (ArchitectException e) { e.printStackTrace(); } } }).start(); } catch (Exception evt) { JOptionPane.showMessageDialog(null, "Error in profile", "Error", JOptionPane.ERROR_MESSAGE); evt.printStackTrace(); } } }); columnSelector = new JList(); // TODO maybe someday we can allow the user to compare profiles by removing this... columnSelector.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); columnSelector.addListSelectionListener(new ListSelectionListener() { /* * Called when the user selects a column; gets its profile (fast) */ public void valueChanged(ListSelectionEvent e) { SQLColumn col = (SQLColumn) columnSelector.getSelectedValue(); if (col == null) { logger.debug("Null selection in columnSelector.ListSelectionListener"); return; } displayPanel.displayProfile((SQLTable) tableSelector.getSelectedItem(), col); } }); PanelBuilder pb = new PanelBuilder(controlsLayout,controlsArea); pb.setDefaultDialogBorder(); pb.add(tableSelector, cc.xy(2, 1)); pb.add(new JScrollPane(columnSelector), cc.xy(2, 3)); pb.add(progressBar,cc.xy(2,5)); this.add(controlsArea, BorderLayout.WEST); displayPanel.setChartType(chartType); this.add(displayPanel.getDisplayArea(), BorderLayout.CENTER); } |
columnSelector.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { SQLColumn col = (SQLColumn)columnSelector.getSelectedValue(); for ( int i=0; i<viewTable.getRowCount(); i++ ) { if ( col == viewTable.getValueAt(i, viewTable.convertColumnIndexToView( ProfileColumn.valueOf("COLUMN").ordinal()))) { viewTable.setRowSelectionInterval(i,i); break; } } tabPane.setSelectedIndex(0); } } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } }); | private void setup() { progressBar.setVisible(false); FormLayout controlsLayout = new FormLayout( "4dlu,fill:min(150dlu;default):grow, 4dlu", // columns "default, 4dlu, fill:min(200dlu;default):grow,4dlu,default"); // rows CellConstraints cc = new CellConstraints(); setLayout(new BorderLayout()); controlsArea = logger.isDebugEnabled() ? new FormDebugPanel(controlsLayout) : new JPanel(controlsLayout); controlsArea.setLayout(new BoxLayout(controlsArea, BoxLayout.Y_AXIS)); tableSelector = new JComboBox(); tableSelector.addActionListener(new ActionListener() { /* * Called when the user selects a table; create its profile (slow) */ public void actionPerformed(ActionEvent e) { final SQLTable t = (SQLTable) tableSelector.getSelectedItem(); if (t == null) { return; } try { columnSelector.setModel(new SQLTableListModel(t)); new ProgressWatcher(progressBar,pm); // Do the work - build the profiles for this table new Thread(new Runnable() { public void run() { try { progressBar.setVisible(true); if (pm.getResult(t) == null) { pm.setCancelled(false); pm.createProfiles(Collections.nCopies(1, t)); } progressBar.setVisible(false); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(ProfilePanel.this, "Error during profile run", e); } catch (ArchitectException e) { e.printStackTrace(); } } }).start(); } catch (Exception evt) { JOptionPane.showMessageDialog(null, "Error in profile", "Error", JOptionPane.ERROR_MESSAGE); evt.printStackTrace(); } } }); columnSelector = new JList(); // TODO maybe someday we can allow the user to compare profiles by removing this... columnSelector.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); columnSelector.addListSelectionListener(new ListSelectionListener() { /* * Called when the user selects a column; gets its profile (fast) */ public void valueChanged(ListSelectionEvent e) { SQLColumn col = (SQLColumn) columnSelector.getSelectedValue(); if (col == null) { logger.debug("Null selection in columnSelector.ListSelectionListener"); return; } displayPanel.displayProfile((SQLTable) tableSelector.getSelectedItem(), col); } }); PanelBuilder pb = new PanelBuilder(controlsLayout,controlsArea); pb.setDefaultDialogBorder(); pb.add(tableSelector, cc.xy(2, 1)); pb.add(new JScrollPane(columnSelector), cc.xy(2, 3)); pb.add(progressBar,cc.xy(2,5)); this.add(controlsArea, BorderLayout.WEST); displayPanel.setChartType(chartType); this.add(displayPanel.getDisplayArea(), BorderLayout.CENTER); } |
|
} | public void displayProfile(SQLTable t, SQLColumn c) { ColumnProfileResult cr = (ColumnProfileResult) pm.getResult(c); TableProfileResult tr = (TableProfileResult) pm.getResult(t); if (tr instanceof TableProfileResult) { rowCount = tr.getRowCount(); } else { rowCount = 0; } rowCountDisplay.setText(Integer.toString(rowCount)); StringBuffer sb = new StringBuffer(); sb.append(c); if (c.isPrimaryKey()) { sb.append(' ').append("[PK]"); } setTitle(sb.toString()); nullableLabel.setText(Boolean.toString(c.isDefinitelyNullable())); if (cr == null) { ProfilePanel.logger.error("displayProfile called but unable to get ColumnProfileResult for column: "+c); // XXX the following code should instead replace chartPanel with a JLabel that contains the error message // (and also not create a dummy profile result) cr = new ColumnProfileResult(c); cr.setCreateStartTime(0); chartPanel.setChart(ChartFactory.createPieChart("", new DefaultPieDataset(), false, false, false)); } else { chartPanel.setChart(createTopNChart(c)); } nullCountLabel.setText(Integer.toString(cr.getNullCount())); int nullsInRecords = cr.getNullCount(); double ratio = rowCount > 0 ? nullsInRecords * 100D / rowCount : 0; nullPercentLabel.setText(format(ratio)); uniqueCountLabel.setText(Integer.toString(cr.getDistinctValueCount())); double uniqueRatio = rowCount > 0 ? cr.getDistinctValueCount() * 100D / rowCount : 0; uniquePercentLabel.setText(format(uniqueRatio)); minLengthLabel.setText(Integer.toString(cr.getMinLength())); maxLengthLabel.setText(Integer.toString(cr.getMaxLength())); minValue.setText(cr.getMinValue() == null ? "" : cr.getMinValue().toString()); maxValue.setText(cr.getMaxValue() == null ? "" : cr.getMaxValue().toString()); Object o = cr.getAvgValue(); if (o == null) { avgValue.setText(""); } else if (o instanceof BigDecimal) { double d = ((BigDecimal)o).doubleValue(); avgValue.setText(format(d)); } else { ProfilePanel.logger.debug("Got avgValue of type: " + o.getClass().getName()); avgValue.setText(cr.getAvgValue().toString()); } FreqValueCountTableModel freqValueCountTableModel = new FreqValueCountTableModel(cr); TableModelSortDecorator sortModel = new TableModelSortDecorator(freqValueCountTableModel); freqValueTable.setModel(sortModel); sortModel.setTableHeader(freqValueTable.getTableHeader()); freqValueTable.initColumnSizes(); } |
|
} | public void displayProfile(SQLTable t, SQLColumn c) { ColumnProfileResult cr = (ColumnProfileResult) pm.getResult(c); TableProfileResult tr = (TableProfileResult) pm.getResult(t); if (tr instanceof TableProfileResult) { rowCount = tr.getRowCount(); } else { rowCount = 0; } rowCountDisplay.setText(Integer.toString(rowCount)); StringBuffer sb = new StringBuffer(); sb.append(c); if (c.isPrimaryKey()) { sb.append(' ').append("[PK]"); } setTitle(sb.toString()); nullableLabel.setText(Boolean.toString(c.isDefinitelyNullable())); if (cr == null) { ProfilePanel.logger.error("displayProfile called but unable to get ColumnProfileResult for column: "+c); // XXX the following code should instead replace chartPanel with a JLabel that contains the error message // (and also not create a dummy profile result) cr = new ColumnProfileResult(c); cr.setCreateStartTime(0); chartPanel.setChart(ChartFactory.createPieChart("", new DefaultPieDataset(), false, false, false)); } else { chartPanel.setChart(createTopNChart(c)); } nullCountLabel.setText(Integer.toString(cr.getNullCount())); int nullsInRecords = cr.getNullCount(); double ratio = rowCount > 0 ? nullsInRecords * 100D / rowCount : 0; nullPercentLabel.setText(format(ratio)); uniqueCountLabel.setText(Integer.toString(cr.getDistinctValueCount())); double uniqueRatio = rowCount > 0 ? cr.getDistinctValueCount() * 100D / rowCount : 0; uniquePercentLabel.setText(format(uniqueRatio)); minLengthLabel.setText(Integer.toString(cr.getMinLength())); maxLengthLabel.setText(Integer.toString(cr.getMaxLength())); minValue.setText(cr.getMinValue() == null ? "" : cr.getMinValue().toString()); maxValue.setText(cr.getMaxValue() == null ? "" : cr.getMaxValue().toString()); Object o = cr.getAvgValue(); if (o == null) { avgValue.setText(""); } else if (o instanceof BigDecimal) { double d = ((BigDecimal)o).doubleValue(); avgValue.setText(format(d)); } else { ProfilePanel.logger.debug("Got avgValue of type: " + o.getClass().getName()); avgValue.setText(cr.getAvgValue().toString()); } FreqValueCountTableModel freqValueCountTableModel = new FreqValueCountTableModel(cr); TableModelSortDecorator sortModel = new TableModelSortDecorator(freqValueCountTableModel); freqValueTable.setModel(sortModel); sortModel.setTableHeader(freqValueTable.getTableHeader()); freqValueTable.initColumnSizes(); } |
|
refreshTable(); | public TDTPanel(Vector chromosomes) { result = TDT.calcTDT(chromosomes); tableColumnNames.add("Name"); tableColumnNames.add("Chi Squared"); tableColumnNames.add("T/U Ratio"); tableColumnNames.add("p value"); } |
|
logger.debug("Ignoring Reset request"); return; | logger.debug("Ignoring Reset request for: " + getConnectionSpec()); populated = true; } else { logger.debug("Resetting: " + getConnectionSpec()); List old = children; if (old != null && old.size() > 0) { int[] oldIndices = new int[old.size()]; for (int i = 0, n = old.size(); i < n; i++) { oldIndices[i] = i; } fireDbChildrenRemoved(oldIndices, old); } children = new ArrayList(); populated = false; | protected void reset() { if (ignoreReset) { logger.debug("Ignoring Reset request"); return; } logger.debug("Resetting...."); // tear down old connection stuff List old = children; if (old != null && old.size() > 0) { int[] oldIndices = new int[old.size()]; for (int i = 0, n = old.size(); i < n; i++) { oldIndices[i] = i; } fireDbChildrenRemoved(oldIndices, old); } children = new ArrayList(); if (connection != null) { try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } } connection = null; populated = false; } |
logger.debug("Resetting...."); List old = children; if (old != null && old.size() > 0) { int[] oldIndices = new int[old.size()]; for (int i = 0, n = old.size(); i < n; i++) { oldIndices[i] = i; } fireDbChildrenRemoved(oldIndices, old); } children = new ArrayList(); | protected void reset() { if (ignoreReset) { logger.debug("Ignoring Reset request"); return; } logger.debug("Resetting...."); // tear down old connection stuff List old = children; if (old != null && old.size() > 0) { int[] oldIndices = new int[old.size()]; for (int i = 0, n = old.size(); i < n; i++) { oldIndices[i] = i; } fireDbChildrenRemoved(oldIndices, old); } children = new ArrayList(); if (connection != null) { try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } } connection = null; populated = false; } |
|
populated = false; | protected void reset() { if (ignoreReset) { logger.debug("Ignoring Reset request"); return; } logger.debug("Resetting...."); // tear down old connection stuff List old = children; if (old != null && old.size() > 0) { int[] oldIndices = new int[old.size()]; for (int i = 0, n = old.size(); i < n; i++) { oldIndices[i] = i; } fireDbChildrenRemoved(oldIndices, old); } children = new ArrayList(); if (connection != null) { try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } } connection = null; populated = false; } |
|
request.setAttribute(RequestAttributes.NAV_CURRENT_PAGE, currentDashboardConfig.getName()); | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { DashboardRepository instance = DashboardRepository.getInstance(); ApplicationConfig appConfig = context.getApplicationConfig(); String currentDashboardId = request.getParameter("dashBID"); DashboardConfig currentDashboardConfig = null; for(String dashboardId : appConfig.getDashboards()){ if(currentDashboardId.equals(dashboardId)){ currentDashboardConfig = instance.get(dashboardId); break; } } if(currentDashboardConfig == null) currentDashboardConfig = instance.get(currentDashboardId); request.setAttribute("dashboardPage", currentDashboardConfig.getTemplate()); return mapping.findForward(Forwards.SUCCESS); } |
|
table.getColumnModel().getColumn(2).setPreferredWidth(300); | table.getColumnModel().getColumn(0).setPreferredWidth(120); table.getColumnModel().getColumn(1).setPreferredWidth(120); table.getColumnModel().getColumn(2).setPreferredWidth(240); | public FilteredIndividualsDialog(HaploView h, String title) { super(h,title); JTable table; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents,BoxLayout.Y_AXIS)); Vector axedPeople = h.theData.getPedFile().getAxedPeople(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("IndividualID"); colNames.add("Reason"); Vector data = new Vector(); for(int i=0;i<axedPeople.size();i++) { Vector tmpVec = new Vector(); Individual currentInd = (Individual) axedPeople.get(i); tmpVec.add(currentInd.getFamilyID()); tmpVec.add(currentInd.getIndividualID()); tmpVec.add(currentInd.getReasonImAxed()); data.add(tmpVec); } tableModel = new BasicTableModel(colNames,data); TableSorter sorter = new TableSorter(tableModel); table = new JTable(sorter); sorter.setTableHeader(table.getTableHeader()); table.getColumnModel().getColumn(2).setPreferredWidth(300); JScrollPane tableScroller = new JScrollPane(table); int tableHeight = (table.getRowHeight()+table.getRowMargin())*(table.getRowCount()+2); if (tableHeight > 300){ tableScroller.setPreferredSize(new Dimension(400, 300)); }else{ tableScroller.setPreferredSize(new Dimension(400, tableHeight)); } tableScroller.setBorder(BorderFactory.createEmptyBorder(2,5,2,5)); contents.add(tableScroller); JPanel buttonPanel = new JPanel(); JButton exportButton = new JButton("Export to File"); exportButton.addActionListener(this); JButton okButton = new JButton("Close"); okButton.addActionListener(this); buttonPanel.add(exportButton); buttonPanel.add(okButton); contents.add(buttonPanel); setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); } |
} catch(MessagingException e) { log.error("error processing incoming mail: " + e.getMessage()); throw e; | public void sendMail(MailAddress sender, Collection recipients, MimeMessage msg) throws MessagingException { MailProcessingRecord mailProcessingRecord = new MailProcessingRecord(); mailProcessingRecord.setReceivingQueue("smtpOutbound"); mailProcessingRecord.setTimeFetchStart(System.currentTimeMillis()); mailProcessingRecord.setByteReceivedTotal(msg.getSize()); try { String[] id = msg.getHeader(HeaderConstants.MAIL_ID_HEADER); if (id == null || id.length == 0 ) { log.info("skipping non-postage mail. message is lost. subject was: " + msg.getSubject()); return; } mailProcessingRecord.setMailId(id[0]); String[] subjectHeader = msg.getHeader("Subject"); if (subjectHeader != null && subjectHeader.length > 0) { mailProcessingRecord.setSubject(subjectHeader[0]); } // TODO mailProcessingRecord.setByteReceivedText(); // TODO mailProcessingRecord.setByteReceivedBinary(); mailProcessingRecord.setTimeFetchEnd(System.currentTimeMillis()); } finally{ boolean matched = m_results.matchMailRecord(mailProcessingRecord); if (!matched) { if (mailProcessingRecord.getMailId() == null) mailProcessingRecord.setMailId(MailProcessingRecord.getNextId()); m_results.addNewMailRecord(mailProcessingRecord); } } } |
|
tmp=pA2; pA2=pB2; pB2=tmp; | pA2 = pA2 + pB2; pB2 = pA2 - pB2; pA2 = pA2 - pB2; | public PairwiseLinkage computeDPrime(int pos1, int pos2){ long sep = Chromosome.getMarker(pos2).getPosition() - Chromosome.getMarker(pos1).getPosition(); if (maxdist > 0){ if ((sep > maxdist || sep < negMaxdist)){ return null; } } compsDone++; 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.getMarker(pos1).getMAF() == 0 || Chromosome.getMarker(pos2).getMAF() == 0){ return null; //System.out.println("Marker " + (pos1+1) + " is monomorphic.");//TODO Make this happier } int[] marker1num = new int[5]; int[] marker2num = new int[5]; marker1num[0]=0; marker1num[Chromosome.getMarker(pos1).getMajor()]=1; marker1num[Chromosome.getMarker(pos1).getMinor()]=2; marker2num[0]=0; marker2num[Chromosome.getMarker(pos2).getMajor()]=1; marker2num[Chromosome.getMarker(pos2).getMinor()]=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){ 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) this.realCompsDone++; 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[105]; /* 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]*log10(probHaps[AA]) + known[AB]*log10(probHaps[AB]) + known[BA]*log10(probHaps[BA]) + known[BB]*log10(probHaps[BB]) + (double)unknownDH*log10(probHaps[AA]*probHaps[BB] + probHaps[AB]*probHaps[BA]); 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]*log10(probHaps[AA]) + known[AB]*log10(probHaps[AB]) + known[BA]*log10(probHaps[BA]) + known[BB]*log10(probHaps[BB]) + (double)unknownDH*log10(probHaps[AA]*probHaps[BB] + probHaps[AB]*probHaps[BA]); loglike0 = known[AA]*log10(pA1*pA2) + known[AB]*log10(pA1*pB2) + known[BA]*log10(pB1*pA2) + known[BB]*log10(pB1*pB2) + (double)unknownDH*log10(2*pA1*pA2*pB1*pB2); 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 */ tmp=pA2; pA2=pB2; pB2=tmp; /* 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]*log10(tmpAA) + known[AB]*log10(tmpAB) + known[BA]*log10(tmpBA) + known[BB]*log10(tmpBB) + (double)unknownDH*log10(tmpAA*tmpBB + tmpAB*tmpBA); } /* 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(roundDouble(dprime), roundDouble((loglike1-loglike0)), roundDouble(rsq), ((double)low_i/100.0), ((double)high_i/100.0), freqarray); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.