rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
Storable newReplicaEntry = mReplicaStorage.prepare(); | S newReplicaEntry = mReplicaStorage.prepare(); | void resyncEntries(S replicaEntry, S masterEntry) throws FetchException, PersistException { if (replicaEntry == null && masterEntry == null) { return; } Log log = LogFactory.getLog(ReplicatedRepository.class); setReplicationDisabled(true); try { Transaction txn = mRepository.enterTransaction(); try { if (replicaEntry != null) { if (masterEntry == null) { log.info("Deleting bogus entry: " + replicaEntry); } replicaEntry.tryDelete(); } if (masterEntry != null) { Storable newReplicaEntry = mReplicaStorage.prepare(); if (replicaEntry == null) { masterEntry.copyAllProperties(newReplicaEntry); log.info("Adding missing entry: " + newReplicaEntry); } else { if (replicaEntry.equalProperties(masterEntry)) { return; } // First copy from old replica to preserve values of // any independent properties. Be sure not to copy // nulls from old replica to new replica, in case new // non-nullable properties have been added. This is why // copyUnequalProperties is called instead of // copyAllProperties. replicaEntry.copyUnequalProperties(newReplicaEntry); // Calling copyAllProperties will skip unsupported // independent properties in master, thus preserving // old independent property values. masterEntry.copyAllProperties(newReplicaEntry); log.info("Replacing stale entry with: " + newReplicaEntry); } if (!newReplicaEntry.tryInsert()) { // Try to correct bizarre corruption. newReplicaEntry.tryDelete(); newReplicaEntry.tryInsert(); } } txn.commit(); } finally { txn.exit(); } } finally { setReplicationDisabled(false); } } |
log.info("Adding missing entry: " + newReplicaEntry); | log.info("Adding missing replica entry: " + newReplicaEntry); | void resyncEntries(S replicaEntry, S masterEntry) throws FetchException, PersistException { if (replicaEntry == null && masterEntry == null) { return; } Log log = LogFactory.getLog(ReplicatedRepository.class); setReplicationDisabled(true); try { Transaction txn = mRepository.enterTransaction(); try { if (replicaEntry != null) { if (masterEntry == null) { log.info("Deleting bogus entry: " + replicaEntry); } replicaEntry.tryDelete(); } if (masterEntry != null) { Storable newReplicaEntry = mReplicaStorage.prepare(); if (replicaEntry == null) { masterEntry.copyAllProperties(newReplicaEntry); log.info("Adding missing entry: " + newReplicaEntry); } else { if (replicaEntry.equalProperties(masterEntry)) { return; } // First copy from old replica to preserve values of // any independent properties. Be sure not to copy // nulls from old replica to new replica, in case new // non-nullable properties have been added. This is why // copyUnequalProperties is called instead of // copyAllProperties. replicaEntry.copyUnequalProperties(newReplicaEntry); // Calling copyAllProperties will skip unsupported // independent properties in master, thus preserving // old independent property values. masterEntry.copyAllProperties(newReplicaEntry); log.info("Replacing stale entry with: " + newReplicaEntry); } if (!newReplicaEntry.tryInsert()) { // Try to correct bizarre corruption. newReplicaEntry.tryDelete(); newReplicaEntry.tryInsert(); } } txn.commit(); } finally { txn.exit(); } } finally { setReplicationDisabled(false); } } |
replicaEntry.copyUnequalProperties(newReplicaEntry); masterEntry.copyAllProperties(newReplicaEntry); log.info("Replacing stale entry with: " + newReplicaEntry); | transferToReplicaEntry(replicaEntry, masterEntry, newReplicaEntry); log.info("Replacing stale replica entry with: " + newReplicaEntry); | void resyncEntries(S replicaEntry, S masterEntry) throws FetchException, PersistException { if (replicaEntry == null && masterEntry == null) { return; } Log log = LogFactory.getLog(ReplicatedRepository.class); setReplicationDisabled(true); try { Transaction txn = mRepository.enterTransaction(); try { if (replicaEntry != null) { if (masterEntry == null) { log.info("Deleting bogus entry: " + replicaEntry); } replicaEntry.tryDelete(); } if (masterEntry != null) { Storable newReplicaEntry = mReplicaStorage.prepare(); if (replicaEntry == null) { masterEntry.copyAllProperties(newReplicaEntry); log.info("Adding missing entry: " + newReplicaEntry); } else { if (replicaEntry.equalProperties(masterEntry)) { return; } // First copy from old replica to preserve values of // any independent properties. Be sure not to copy // nulls from old replica to new replica, in case new // non-nullable properties have been added. This is why // copyUnequalProperties is called instead of // copyAllProperties. replicaEntry.copyUnequalProperties(newReplicaEntry); // Calling copyAllProperties will skip unsupported // independent properties in master, thus preserving // old independent property values. masterEntry.copyAllProperties(newReplicaEntry); log.info("Replacing stale entry with: " + newReplicaEntry); } if (!newReplicaEntry.tryInsert()) { // Try to correct bizarre corruption. newReplicaEntry.tryDelete(); newReplicaEntry.tryInsert(); } } txn.commit(); } finally { txn.exit(); } } finally { setReplicationDisabled(false); } } |
synchronized (lock) { while (true) { storage = mStorageMap.get(type); if (storage != null) { return storage; } if (doCreate) { break; } try { lock.wait(); } catch (InterruptedException e) { throw new RepositoryException("Interrupted"); } } StorableIntrospector.examine(type); storage = createStorage(type); mStorageMap.put(type, storage); lock.notifyAll(); | if (Thread.holdsLock(lock)) { throw new IllegalStateException ("Recursively trying to create storage for type: " + type); | public <S extends Storable> Storage<S> storageFor(Class<S> type) throws MalformedTypeException, SupportException, RepositoryException { Storage storage = mStorageMap.get(type); if (storage != null) { return storage; } Object lock; boolean doCreate; synchronized (mStorableTypeLockMap) { lock = mStorableTypeLockMap.get(type); if (lock != null) { doCreate = false; } else { doCreate = true; lock = new Object(); mStorableTypeLockMap.put(type, lock); } } synchronized (lock) { // Check storage map again before creating new storage. while (true) { storage = mStorageMap.get(type); if (storage != null) { return storage; } if (doCreate) { break; } try { lock.wait(); } catch (InterruptedException e) { throw new RepositoryException("Interrupted"); } } // Examine and throw exception early if there is a problem. StorableIntrospector.examine(type); storage = createStorage(type); mStorageMap.put(type, storage); lock.notifyAll(); } // Storable type lock no longer needed. synchronized (mStorableTypeLockMap) { mStorableTypeLockMap.remove(type); } return storage; } |
synchronized (mStorableTypeLockMap) { mStorableTypeLockMap.remove(type); | try { synchronized (lock) { while (true) { storage = mStorageMap.get(type); if (storage != null) { return storage; } if (doCreate) { break; } try { lock.wait(); } catch (InterruptedException e) { throw new RepositoryException("Interrupted"); } } StorableIntrospector.examine(type); storage = createStorage(type); mStorageMap.put(type, storage); lock.notifyAll(); } } finally { synchronized (mStorableTypeLockMap) { mStorableTypeLockMap.remove(type); } | public <S extends Storable> Storage<S> storageFor(Class<S> type) throws MalformedTypeException, SupportException, RepositoryException { Storage storage = mStorageMap.get(type); if (storage != null) { return storage; } Object lock; boolean doCreate; synchronized (mStorableTypeLockMap) { lock = mStorableTypeLockMap.get(type); if (lock != null) { doCreate = false; } else { doCreate = true; lock = new Object(); mStorableTypeLockMap.put(type, lock); } } synchronized (lock) { // Check storage map again before creating new storage. while (true) { storage = mStorageMap.get(type); if (storage != null) { return storage; } if (doCreate) { break; } try { lock.wait(); } catch (InterruptedException e) { throw new RepositoryException("Interrupted"); } } // Examine and throw exception early if there is a problem. StorableIntrospector.examine(type); storage = createStorage(type); mStorageMap.put(type, storage); lock.notifyAll(); } // Storable type lock no longer needed. synchronized (mStorableTypeLockMap) { mStorableTypeLockMap.remove(type); } return storage; } |
logger.debug("added rectangles, new bounds: " + scrollTo); | public void actionPerformed(ActionEvent e) { playpen.setZoom(playpen.getZoom() + zoomStep); Rectangle scrollTo = null; Iterator it = playpen.getSelectedItems().iterator(); while (it.hasNext()) { Rectangle bounds = ((Component) it.next()).getBounds(); if (scrollTo == null) { scrollTo = new Rectangle(bounds); } else { scrollTo.add(bounds); } } if (scrollTo != null && !scrollTo.isEmpty()) { playpen.zoomRect(scrollTo); playpen.scrollRectToVisible(scrollTo); } } |
|
* Do not use delimiters for the database object names in SQWL statements. | * Do not use delimiters for the database object names in SQL statements. | public void createDatabase( String user, String passwd ) { // Get the database schema XML file InputStream schemaIS = getClass().getClassLoader().getResourceAsStream( "photovault_schema.xml" ); Database dbModel = new DatabaseIO().read( new InputStreamReader( schemaIS ) ); // Create the datasource for accessing this database String driverName = "com.mysql.jdbc.Driver"; String dbUrl = "jdbc:mysql://" + getDbHost() + "/" + getDbName(); DataSource ds = null; if ( instanceType == TYPE_EMBEDDED ) { if ( !embeddedDirectory.exists() ) { embeddedDirectory.mkdirs(); } File derbyDir = new File( embeddedDirectory, "derby" ); File photoDir = new File( embeddedDirectory, "photos"); Volume vol = new Volume( "photos", photoDir.getAbsolutePath() ); addVolume( vol ); System.setProperty( "derby.system.home", derbyDir.getAbsolutePath() ); driverName = "org.apache.derby.jdbc.EmbeddedDriver"; dbUrl = "jdbc:derby:photovault;create=true"; EmbeddedDataSource derbyDs = new EmbeddedDataSource(); derbyDs.setDatabaseName( "photovault" ); derbyDs.setCreateDatabase( "create" ); ds = derbyDs; } else { MysqlDataSource mysqlDs = new MysqlDataSource(); mysqlDs.setURL( dbUrl ); mysqlDs.setUser( user ); mysqlDs.setPassword( passwd ); ds = mysqlDs; } Platform platform = PlatformFactory.createNewPlatformInstance( ds ); /* * Do not use delimiters for the database object names in SQWL statements. * This is to avoid case sensitivity problems with SQL92 compliant * databases like Derby - non-delimited identifiers are interpreted as case * insensitive. * * I am not sure if this is the correct way to solve the issue, however, * I am not willing to make a big change of schema definitions either. */ platform.getPlatformInfo().setDelimiterToken( "" ); platform.setUsername( user ); platform.setPassword( passwd ); platform.createTables( dbModel, true, true ); // Insert the seed data to database DataToDatabaseSink sink = new DataToDatabaseSink( platform, dbModel ); DataReader reader = new DataReader(); reader.setModel( dbModel ); reader.setSink( sink ); InputStream seedDataStream = this.getClass().getClassLoader().getResourceAsStream( "photovault_seed_data.xml" ); try { reader.parse( seedDataStream ); } catch (SAXException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } // Create the database // TODO: Since the seed has only 48 significant bits this id is not really an // 128-bit random number!!! Random rnd = new Random(); String idStr = ""; StringBuffer idBuf = new StringBuffer(); for ( int n=0; n < 4; n++ ) { int r = rnd.nextInt(); idBuf.append( Integer.toHexString( r ) ); } idStr = idBuf.toString(); DynaBean dbInfo = dbModel.createDynaBeanFor( "database_info", false ); dbInfo.set( "database_id", idStr ); dbInfo.set( "schema_version", new Integer(3) ); dbInfo.set( "create_time", new Timestamp( System.currentTimeMillis() ) ); platform.insert( dbModel, dbInfo ); } |
String localName = null; | public void doTag(XMLOutput output) throws Exception { String localName = null; int idx = name.indexOf(':'); if (idx >= 0) { localName = name.substring(idx + 1); } else { localName = name; } /** * @todo we should buffer up any SAX events and replay then * inside the startElement/endElement block */ invokeBody(output); output.startElement(namespace, localName, name, attributes); /** @todo we should replay the cached SAX events (if any) here */ output.endElement(namespace, localName, name); attributes.clear(); } |
|
if (idx >= 0) { localName = name.substring(idx + 1); | final String localName = (idx >= 0) ? name.substring(idx + 1) : name; outputAttributes = false; XMLOutput newOutput = new XMLOutput(output) { public void startElement( String uri, String localName, String qName, Attributes atts) throws SAXException { initialize(); super.startElement(uri, localName, qName, atts); } public void endElement(String uri, String localName, String qName) throws SAXException { initialize(); super.endElement(uri, localName, qName); } public void characters(char ch[], int start, int length) throws SAXException { initialize(); super.characters(ch, start, length); } public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { initialize(); super.ignorableWhitespace(ch, start, length); } public void processingInstruction(String target, String data) throws SAXException { initialize(); super.processingInstruction(target, data); } protected void initialize() throws SAXException { if (!outputAttributes) { super.startElement(namespace, localName, name, attributes); outputAttributes = true; } } }; invokeBody(newOutput); if (!outputAttributes) { output.startElement(namespace, localName, name, attributes); outputAttributes = true; | public void doTag(XMLOutput output) throws Exception { String localName = null; int idx = name.indexOf(':'); if (idx >= 0) { localName = name.substring(idx + 1); } else { localName = name; } /** * @todo we should buffer up any SAX events and replay then * inside the startElement/endElement block */ invokeBody(output); output.startElement(namespace, localName, name, attributes); /** @todo we should replay the cached SAX events (if any) here */ output.endElement(namespace, localName, name); attributes.clear(); } |
else { localName = name; } invokeBody(output); output.startElement(namespace, localName, name, attributes); | public void doTag(XMLOutput output) throws Exception { String localName = null; int idx = name.indexOf(':'); if (idx >= 0) { localName = name.substring(idx + 1); } else { localName = name; } /** * @todo we should buffer up any SAX events and replay then * inside the startElement/endElement block */ invokeBody(output); output.startElement(namespace, localName, name, attributes); /** @todo we should replay the cached SAX events (if any) here */ output.endElement(namespace, localName, name); attributes.clear(); } |
|
public void setAttributeValue( String name, String value ) { | public void setAttributeValue( String name, String value ) throws JellyException { if (outputAttributes) { throw new JellyException( "Cannot set the value of attribute: " + name + " as we have already output the startElement() SAX event" ); } | public void setAttributeValue( String name, String value ) { // ### we'll assume that all attributes are in no namespace! // ### this is severely limiting! // ### we should be namespace aware int index = attributes.getIndex("", name); if (index >= 0) { attributes.removeAttribute(index); } // treat null values as no attribute if (value != null) { attributes.addAttribute("", name, name, "CDATA", value); } } |
tableModelSortDecorator.initColumnSizes(viewTable); | public void actionPerformed(ActionEvent e) { if (dbTree == null) { logger.debug("dbtree was null when actionPerformed called"); return; } if ( dbTree.getSelectionPaths() == null ) { logger.debug("dbtree path selection was null when actionPerformed called"); return; } try { Set<SQLObject> sqlObject = new HashSet<SQLObject>(); for ( TreePath tp : dbTree.getSelectionPaths() ) { if ( tp.getLastPathComponent() instanceof SQLDatabase ) { sqlObject.add((SQLDatabase)tp.getLastPathComponent()); } else if ( tp.getLastPathComponent() instanceof SQLCatalog ) { SQLCatalog cat = (SQLCatalog)tp.getLastPathComponent(); sqlObject.add(cat); SQLDatabase db = ArchitectUtils.getAncestor(cat,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLSchema ) { SQLSchema sch = (SQLSchema)tp.getLastPathComponent(); sqlObject.add(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLTable ) { SQLTable tab = (SQLTable)tp.getLastPathComponent(); sqlObject.add(tab); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLTable.Folder ) { SQLTable tab = ArchitectUtils.getAncestor((Folder)tp.getLastPathComponent(),SQLTable.class); sqlObject.add(tab); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLColumn ) { SQLTable tab = ((SQLColumn)tp.getLastPathComponent()).getParentTable(); sqlObject.add((SQLColumn)tp.getLastPathComponent()); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } } final ArrayList<SQLObject> filter = new ArrayList<SQLObject>(); final Set<SQLTable> tables = new HashSet<SQLTable>(); for ( SQLObject o : sqlObject ) { if ( o instanceof SQLColumn){ tables.add(((SQLColumn)o).getParentTable()); } else { tables.addAll(ArchitectUtils.tablesUnder(o)); } if (! (o instanceof Folder)){ filter.add(o); } } profileManager.setCancelled(false); d = new JDialog(ArchitectFrame.getMainInstance(), "Table Profiles"); Action closeAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { profileManager.setCancelled(true); d.setVisible(false); } }; closeAction.putValue(Action.NAME, "Close"); final JDefaultButton closeButton = new JDefaultButton(closeAction); final JPanel progressViewPanel = new JPanel(new BorderLayout()); final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.add(closeButton); progressViewPanel.add(buttonPanel, BorderLayout.SOUTH); final JProgressBar progressBar = new JProgressBar(); progressBar.setPreferredSize(new Dimension(450,20)); progressViewPanel.add(progressBar, BorderLayout.CENTER); final JLabel workingOn = new JLabel("Profiling:"); progressViewPanel.add(workingOn, BorderLayout.NORTH); ArchitectPanelBuilder.makeJDialogCancellable( d, new CommonCloseAction(d)); d.getRootPane().setDefaultButton(closeButton); d.setContentPane(progressViewPanel); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); new ProgressWatcher(progressBar,profileManager,workingOn); new Thread( new Runnable() { public void run() { try { List<SQLTable> toBeProfiled = new ArrayList<SQLTable>(); for (SQLTable t: tables) { if (profileManager.getResult(t)== null) { toBeProfiled.add(t); workingOn.setText("Adding "+t.getName()+ " ("+toBeProfiled.size()+")"); } } profileManager.createProfiles(toBeProfiled, workingOn); progressBar.setVisible(false); JLabel status = new JLabel("Generating reports, Please wait......"); progressViewPanel.add(status, BorderLayout.NORTH); status.setVisible(true); JTabbedPane tabPane = new JTabbedPane(); ProfileTableModel tm = new ProfileTableModel(); for (SQLObject sqo: filter){ tm.addFilter(sqo); } tm.setProfileManager(profileManager); TableModelSortDecorator tableModelSortDecorator = new TableModelSortDecorator(tm); final JTable viewTable = new JTable(tableModelSortDecorator); viewTable.setDefaultRenderer(Object.class,new ProfileTableCellRenderer()); JTableHeader tableHeader = viewTable.getTableHeader(); tableModelSortDecorator.setTableHeader(tableHeader); // reset column widths // tableModelSortDecorator.initColumnSizes(viewTable); viewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ProfilePanelMouseListener profilePanelMouseListener = new ProfilePanelMouseListener(); profilePanelMouseListener.setTabPane(tabPane); viewTable.addMouseListener( profilePanelMouseListener); JScrollPane editorScrollPane = new JScrollPane(viewTable); editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(800, 600)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); JPanel tableViewPane = new JPanel(new BorderLayout()); tableViewPane.add(editorScrollPane,BorderLayout.CENTER); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(); JButton save = new JButton(new AbstractAction("Save") { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.addChoosableFileFilter(ASUtils.PDF_FILE_FILTER); chooser.addChoosableFileFilter(ASUtils.HTML_FILE_FILTER); chooser.removeChoosableFileFilter(chooser.getAcceptAllFileFilter()); int response = chooser.showSaveDialog(d); if (response != JFileChooser.APPROVE_OPTION) { return; } else { File file = chooser.getSelectedFile(); final FileFilter fileFilter = chooser.getFileFilter(); if (fileFilter == ASUtils.HTML_FILE_FILTER) { if (!file.getPath().endsWith(".html")) { file = new File(file.getPath()+".html"); } } else { if (!file.getPath().endsWith(".pdf")) { file = new File(file.getPath()+".pdf"); } } if (file.exists()) { response = JOptionPane.showConfirmDialog( d, "The file\n\n"+file.getPath()+"\n\nalready exists. Do you want to overwrite it?", "File Exists", JOptionPane.YES_NO_OPTION); if (response == JOptionPane.NO_OPTION) { actionPerformed(e); return; } } final File file2 = new File(file.getPath()); Runnable saveTask = new Runnable() { public void run() { List tabList = new ArrayList(tables); OutputStream out = null; try { out = new BufferedOutputStream(new FileOutputStream(file2)); if (fileFilter == ASUtils.HTML_FILE_FILTER){ final String encoding = "utf-8"; ProfileHTMLFormat prf = new ProfileHTMLFormat(encoding); OutputStreamWriter osw = new OutputStreamWriter(out, encoding); osw.append(prf.format(tabList,profileManager)); osw.flush(); } else { new ProfilePDFFormat().createPdf(out, tabList, profileManager); } } catch (Exception ex) { ASUtils.showExceptionDialog(d,"Could not save PDF File", ex); } finally { if ( out != null ) { try { out.flush(); out.close(); } catch (IOException ex) { ASUtils.showExceptionDialog(d,"Could not close PDF File", ex); } } } } }; new Thread(saveTask).start(); } } }); JButton refresh = new JButton(new AbstractAction("Refresh"){ public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); System.out.println(o.getClass()); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } ((ProfileTableModel)viewTable.getModel()).refresh(); } }); JButton delete = new JButton(new AbstractAction("Delete"){ public void actionPerformed(ActionEvent e) { int[] killMe = viewTable.getSelectedRows(); Arrays.sort(killMe); // iterate backwards so the rows don't shift away on us! for (int i = killMe.length-1; i >= 0; i--) { logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete column:", e1); } } ((ProfileTableModel)viewTable.getModel()).refresh(); } }); JButton deleteAll = new JButton(new AbstractAction("Delete All"){ public void actionPerformed(ActionEvent e) { profileManager.clear(); ((ProfileTableModel)viewTable.getModel()).refresh(); } }); JButton[] buttonArray = {refresh,delete,deleteAll,save,closeButton}; buttonBuilder.addGriddedButtons(buttonArray); tableViewPane.add(buttonBuilder.getPanel(),BorderLayout.SOUTH); tabPane.addTab("Table View", tableViewPane ); ProfilePanel p = new ProfilePanel(profileManager); tabPane.addTab("Graph View",p); profilePanelMouseListener.setProfilePanel(p); List<SQLTable> list = new ArrayList(tables); p.setTables(list); p.setChartType(ChartTypes.PIE); d.remove(progressViewPanel); d.setContentPane(tabPane); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e); } catch (ArchitectException e) { logger.error("Error in Profile Action", e); ASUtils.showExceptionDialog(dbTree, "Error during profile run", e); } } }).start(); } catch (Exception ex) { logger.error("Error in Profile Action ", ex); ASUtils.showExceptionDialog(dbTree, "Error during profile run", ex); } } |
|
tableModelSortDecorator.initColumnSizes(viewTable); | public void run() { try { List<SQLTable> toBeProfiled = new ArrayList<SQLTable>(); for (SQLTable t: tables) { if (profileManager.getResult(t)== null) { toBeProfiled.add(t); workingOn.setText("Adding "+t.getName()+ " ("+toBeProfiled.size()+")"); } } profileManager.createProfiles(toBeProfiled, workingOn); progressBar.setVisible(false); JLabel status = new JLabel("Generating reports, Please wait......"); progressViewPanel.add(status, BorderLayout.NORTH); status.setVisible(true); JTabbedPane tabPane = new JTabbedPane(); ProfileTableModel tm = new ProfileTableModel(); for (SQLObject sqo: filter){ tm.addFilter(sqo); } tm.setProfileManager(profileManager); TableModelSortDecorator tableModelSortDecorator = new TableModelSortDecorator(tm); final JTable viewTable = new JTable(tableModelSortDecorator); viewTable.setDefaultRenderer(Object.class,new ProfileTableCellRenderer()); JTableHeader tableHeader = viewTable.getTableHeader(); tableModelSortDecorator.setTableHeader(tableHeader); // reset column widths // tableModelSortDecorator.initColumnSizes(viewTable); viewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ProfilePanelMouseListener profilePanelMouseListener = new ProfilePanelMouseListener(); profilePanelMouseListener.setTabPane(tabPane); viewTable.addMouseListener( profilePanelMouseListener); JScrollPane editorScrollPane = new JScrollPane(viewTable); editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(800, 600)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); JPanel tableViewPane = new JPanel(new BorderLayout()); tableViewPane.add(editorScrollPane,BorderLayout.CENTER); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(); JButton save = new JButton(new AbstractAction("Save") { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.addChoosableFileFilter(ASUtils.PDF_FILE_FILTER); chooser.addChoosableFileFilter(ASUtils.HTML_FILE_FILTER); chooser.removeChoosableFileFilter(chooser.getAcceptAllFileFilter()); int response = chooser.showSaveDialog(d); if (response != JFileChooser.APPROVE_OPTION) { return; } else { File file = chooser.getSelectedFile(); final FileFilter fileFilter = chooser.getFileFilter(); if (fileFilter == ASUtils.HTML_FILE_FILTER) { if (!file.getPath().endsWith(".html")) { file = new File(file.getPath()+".html"); } } else { if (!file.getPath().endsWith(".pdf")) { file = new File(file.getPath()+".pdf"); } } if (file.exists()) { response = JOptionPane.showConfirmDialog( d, "The file\n\n"+file.getPath()+"\n\nalready exists. Do you want to overwrite it?", "File Exists", JOptionPane.YES_NO_OPTION); if (response == JOptionPane.NO_OPTION) { actionPerformed(e); return; } } final File file2 = new File(file.getPath()); Runnable saveTask = new Runnable() { public void run() { List tabList = new ArrayList(tables); OutputStream out = null; try { out = new BufferedOutputStream(new FileOutputStream(file2)); if (fileFilter == ASUtils.HTML_FILE_FILTER){ final String encoding = "utf-8"; ProfileHTMLFormat prf = new ProfileHTMLFormat(encoding); OutputStreamWriter osw = new OutputStreamWriter(out, encoding); osw.append(prf.format(tabList,profileManager)); osw.flush(); } else { new ProfilePDFFormat().createPdf(out, tabList, profileManager); } } catch (Exception ex) { ASUtils.showExceptionDialog(d,"Could not save PDF File", ex); } finally { if ( out != null ) { try { out.flush(); out.close(); } catch (IOException ex) { ASUtils.showExceptionDialog(d,"Could not close PDF File", ex); } } } } }; new Thread(saveTask).start(); } } }); JButton refresh = new JButton(new AbstractAction("Refresh"){ public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); System.out.println(o.getClass()); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } ((ProfileTableModel)viewTable.getModel()).refresh(); } }); JButton delete = new JButton(new AbstractAction("Delete"){ public void actionPerformed(ActionEvent e) { int[] killMe = viewTable.getSelectedRows(); Arrays.sort(killMe); // iterate backwards so the rows don't shift away on us! for (int i = killMe.length-1; i >= 0; i--) { logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete column:", e1); } } ((ProfileTableModel)viewTable.getModel()).refresh(); } }); JButton deleteAll = new JButton(new AbstractAction("Delete All"){ public void actionPerformed(ActionEvent e) { profileManager.clear(); ((ProfileTableModel)viewTable.getModel()).refresh(); } }); JButton[] buttonArray = {refresh,delete,deleteAll,save,closeButton}; buttonBuilder.addGriddedButtons(buttonArray); tableViewPane.add(buttonBuilder.getPanel(),BorderLayout.SOUTH); tabPane.addTab("Table View", tableViewPane ); ProfilePanel p = new ProfilePanel(profileManager); tabPane.addTab("Graph View",p); profilePanelMouseListener.setProfilePanel(p); List<SQLTable> list = new ArrayList(tables); p.setTables(list); p.setChartType(ChartTypes.PIE); d.remove(progressViewPanel); d.setContentPane(tabPane); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e); } catch (ArchitectException e) { logger.error("Error in Profile Action", e); ASUtils.showExceptionDialog(dbTree, "Error during profile run", e); } } |
|
System.out.println(ufe); | log.warn(ufe); | public void drop(DropTargetDropEvent e) { hoverTimer.stop(); // Prevent hover timer from doing an unwanted expandPath or collapsePath if (!isDropAcceptable(e)) { e.rejectDrop(); return; } e.acceptDrop(e.getDropAction()); Transferable transferable = e.getTransferable(); DataFlavor[] flavors = transferable.getTransferDataFlavors(); for (int i = 0; i < flavors.length; i++ ) { DataFlavor flavor = flavors[i]; if (flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType)) { try { Point pt = e.getLocation(); TreePath pathTarget = tree.getClosestPathForLocation(pt.x, pt.y); PhotoFolder folder = (PhotoFolder) pathTarget.getLastPathComponent(); PhotoCollectionTransferHandler.setLastImportTarget( folder ); PhotoInfo[] photos = (PhotoInfo[])transferable.getTransferData(photoInfoFlavor); for ( int n = 0; n < photos.length; n++ ) { folder.addPhoto( photos[n] ); } break; // No need to check remaining flavors } catch (UnsupportedFlavorException ufe) { System.out.println(ufe); e.dropComplete(false); return; } catch (IOException ioe) { System.out.println(ioe); e.dropComplete(false); return; } } } e.dropComplete(true); } |
System.out.println(ioe); | log.warn(ioe); | public void drop(DropTargetDropEvent e) { hoverTimer.stop(); // Prevent hover timer from doing an unwanted expandPath or collapsePath if (!isDropAcceptable(e)) { e.rejectDrop(); return; } e.acceptDrop(e.getDropAction()); Transferable transferable = e.getTransferable(); DataFlavor[] flavors = transferable.getTransferDataFlavors(); for (int i = 0; i < flavors.length; i++ ) { DataFlavor flavor = flavors[i]; if (flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType)) { try { Point pt = e.getLocation(); TreePath pathTarget = tree.getClosestPathForLocation(pt.x, pt.y); PhotoFolder folder = (PhotoFolder) pathTarget.getLastPathComponent(); PhotoCollectionTransferHandler.setLastImportTarget( folder ); PhotoInfo[] photos = (PhotoInfo[])transferable.getTransferData(photoInfoFlavor); for ( int n = 0; n < photos.length; n++ ) { folder.addPhoto( photos[n] ); } break; // No need to check remaining flavors } catch (UnsupportedFlavorException ufe) { System.out.println(ufe); e.dropComplete(false); return; } catch (IOException ioe) { System.out.println(ioe); e.dropComplete(false); return; } } } e.dropComplete(true); } |
} else { niprint("populated=\"true\" "); | protected void saveSQLObject(SQLObject o) throws IOException, ArchitectException { String id = (String) objectIdMap.get(o); if (id != null) { println("<reference ref-id=\""+id+"\" />"); return; } String type; Map propNames = new TreeMap(); if (o instanceof SQLDatabase) { id = "DB"+objectIdMap.size(); type = "database"; propNames.put("dbcs-ref", dbcsIdMap.get(((SQLDatabase) o).getConnectionSpec())); } else if (o instanceof SQLCatalog) { id = "CAT"+objectIdMap.size(); type = "catalog"; propNames.put("catalogName", ((SQLCatalog) o).getCatalogName()); } else if (o instanceof SQLSchema) { id = "SCH"+objectIdMap.size(); type = "schema"; propNames.put("schemaName", ((SQLSchema) o).getSchemaName()); } else if (o instanceof SQLTable) { id = "TAB"+objectIdMap.size(); type = "table"; propNames.put("tableName", ((SQLTable) o).getTableName()); propNames.put("remarks", ((SQLTable) o).getRemarks()); propNames.put("objectType", ((SQLTable) o).getObjectType()); propNames.put("primaryKeyName", ((SQLTable) o).getPrimaryKeyName()); if (pm != null) { pm.setProgress(++progress); pm.setNote(o.getShortDisplayName()); } } else if (o instanceof SQLTable.Folder) { id = "FOL"+objectIdMap.size(); type = "folder"; propNames.put("name", ((SQLTable.Folder) o).getName()); propNames.put("type", new Integer(((SQLTable.Folder) o).getType())); } else if (o instanceof SQLColumn) { id = "COL"+objectIdMap.size(); type = "column"; SQLColumn sourceCol = ((SQLColumn) o).getSourceColumn(); if (sourceCol != null) { propNames.put("source-column-ref", objectIdMap.get(sourceCol)); } propNames.put("columnName", ((SQLColumn) o).getColumnName()); propNames.put("type", new Integer(((SQLColumn) o).getType())); propNames.put("sourceDBTypeName", ((SQLColumn) o).getSourceDBTypeName()); propNames.put("scale", new Integer(((SQLColumn) o).getScale())); propNames.put("precision", new Integer(((SQLColumn) o).getPrecision())); propNames.put("nullable", new Integer(((SQLColumn) o).getNullable())); propNames.put("remarks", ((SQLColumn) o).getRemarks()); propNames.put("defaultValue", ((SQLColumn) o).getDefaultValue()); propNames.put("primaryKeySeq", ((SQLColumn) o).getPrimaryKeySeq()); propNames.put("autoIncrement", new Boolean(((SQLColumn) o).isAutoIncrement())); } else if (o instanceof SQLRelationship) { id = "REL"+objectIdMap.size(); type = "relationship"; propNames.put("pk-table-ref", objectIdMap.get(((SQLRelationship) o).getPkTable())); propNames.put("fk-table-ref", objectIdMap.get(((SQLRelationship) o).getFkTable())); propNames.put("updateRule", new Integer(((SQLRelationship) o).getUpdateRule())); propNames.put("deleteRule", new Integer(((SQLRelationship) o).getDeleteRule())); propNames.put("deferrability", new Integer(((SQLRelationship) o).getDeferrability())); propNames.put("pkCardinality", new Integer(((SQLRelationship) o).getPkCardinality())); propNames.put("fkCardinality", new Integer(((SQLRelationship) o).getFkCardinality())); propNames.put("identifying", new Boolean(((SQLRelationship) o).isIdentifying())); propNames.put("name", ((SQLRelationship) o).getName()); } else if (o instanceof SQLRelationship.ColumnMapping) { id = "CMP"+objectIdMap.size(); type = "column-mapping"; propNames.put("pk-column-ref", objectIdMap.get(((SQLRelationship.ColumnMapping) o).getPkColumn())); propNames.put("fk-column-ref", objectIdMap.get(((SQLRelationship.ColumnMapping) o).getFkColumn())); } else if (o instanceof SQLExceptionNode) { id = "EXC"+objectIdMap.size(); type = "sql-exception"; propNames.put("message", ((SQLExceptionNode) o).getMessage()); } else { throw new UnsupportedOperationException("Woops, the SQLObject type " +o.getClass().getName()+" is not supported!"); } objectIdMap.put(o, id); boolean skipChildren = false; //print("<"+type+" hashCode=\""+o.hashCode()+"\" id=\""+id+"\" "); // use this for debugging duplicate object problems print("<"+type+" id=\""+id+"\" "); if (o.allowsChildren() && o.isPopulated() && o.getChildCount() == 1 && o.getChild(0) instanceof SQLExceptionNode) { // if the only child is an exception node, just save the parent as non-populated niprint("populated=\"false\" "); skipChildren = true; } else if ( (!savingEntireSource) && (!o.isPopulated()) ) { niprint("populated=\"false\" "); } Iterator props = propNames.keySet().iterator(); while (props.hasNext()) { Object key = props.next(); Object value = propNames.get(key); if (value != null) { niprint(key+"=\""+value+"\" "); } } if ( (!skipChildren) && o.allowsChildren() && (savingEntireSource || o.isPopulated()) ) { niprintln(">"); Iterator children = o.getChildren().iterator(); indent++; while (children.hasNext()) { SQLObject child = (SQLObject) children.next(); if ( ! (child instanceof SQLRelationship)) { saveSQLObject(child); } } if (o instanceof SQLDatabase) { saveRelationships((SQLDatabase) o); } indent--; println("</"+type+">"); } else { niprintln("/>"); } } |
|
Map paramValues = config.getParamValues(); if(appForm.getJndiFactory() != null){ paramValues.put(ApplicationConfig.JNDI_FACTORY, appForm.getJndiFactory()); }else{ paramValues.remove(ApplicationConfig.JNDI_FACTORY); } if(appForm.getJndiURL() != null){ paramValues.put(ApplicationConfig.JNDI_URL, appForm.getJndiURL()); }else{ paramValues.remove(ApplicationConfig.JNDI_URL); } | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { AccessController.checkAccess(context.getServiceContext(), ACL_EDIT_APPLICATIONS); ApplicationForm appForm = (ApplicationForm)actionForm; ApplicationConfig config = ApplicationConfigManager.getApplicationConfig( appForm.getApplicationId()); assert config != null; config.setName(appForm.getName()); config.setHost(appForm.getHost()); if(appForm.getPort() != null) config.setPort(new Integer(appForm.getPort())); config.setURL(appForm.getURL()); config.setUsername(appForm.getUsername()); final String password = appForm.getPassword(); if(!password.equals(ApplicationForm.FORM_PASSWORD)){ config.setPassword(password); } ApplicationConfigManager.updateApplication(config); UserActivityLogger.getInstance().logActivity( context.getUser().getUsername(), "Updated application "+"\""+config.getName()+"\""); return mapping.findForward(Forwards.SUCCESS); } |
|
getInherit() ) { | isInherit() ) { | public Object getVariable(String name) { Object value = variables.get(name); if ( value == null && getInherit() ) { value = getParent().findVariable( name ); } return value; } |
public void setExport(boolean shouldExport) { this.shouldExport = shouldExport; | public void setExport(boolean export) { this.export = export; | public void setExport(boolean shouldExport) { this.shouldExport = shouldExport; } |
public void setInherit(boolean shouldInherit) { this.shouldInherit = shouldInherit; | public void setInherit(boolean inherit) { this.inherit = inherit; | public void setInherit(boolean shouldInherit) { this.shouldInherit = shouldInherit; } |
if ( getExport() ) { | if ( isExport() ) { | public void setVariable(String name, Object value) { if ( getExport() ) { getParent().setVariable( name, value ); return; } if (value == null) { variables.remove(name); } else { variables.put(name, value); } } |
Haplotype h = (Haplotype) alleles.get(i); | Haplotype h = (Haplotype) filteredAlleles.get(i); | public String getFreqString(int i ){ if (Options.getAssocTest() == ASSOC_TRIO){ return ""; } nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); StringBuffer countSB = new StringBuffer(); Haplotype h = (Haplotype) alleles.get(i); double caseSum = 0, controlSum = 0; for (int j = 0; j < alleles.size(); j++){ caseSum += ((Haplotype)alleles.get(j)).getCaseCount(); controlSum += ((Haplotype)alleles.get(j)).getControlCount(); } countSB.append(nf.format(h.getCaseCount()/caseSum)).append(", "); countSB.append(nf.format(h.getControlCount()/controlSum)); return countSB.toString(); } |
public JSR160ServerConnection(JMXConnector jmxc ) | public JSR160ServerConnection(JMXConnector jmxc, MBeanServerConnection mbeanServer) | public JSR160ServerConnection(JMXConnector jmxc ) throws IOException { assert jmxc != null; this.jmxc = jmxc; this.mbeanServer = jmxc.getMBeanServerConnection(); } |
this.mbeanServer = jmxc.getMBeanServerConnection(); | this.mbeanServer = mbeanServer; | public JSR160ServerConnection(JMXConnector jmxc ) throws IOException { assert jmxc != null; this.jmxc = jmxc; this.mbeanServer = jmxc.getMBeanServerConnection(); } |
throw new RuntimeException("Notifications not supported"); | Class[] methodSignature = new Class[]{String.class, javax.management.ObjectName.class, new Object[0].getClass(), new String[0].getClass()}; Object[] methodArgs = new Object[]{className, toJMXObjectName(name), params, signature}; callMBeanServer("createMBean", methodSignature, methodArgs); | public void createMBean(String className, ObjectName name, Object[] params, String[] signature){ throw new RuntimeException("Notifications not supported"); } |
throw new RuntimeException("unregisterMBean not supported"); | Class[] methodSignature = new Class[]{javax.management.ObjectName.class}; Object[] methodArgs = new Object[]{toJMXObjectName(objectName)}; callMBeanServer("unregisterMBean", methodSignature, methodArgs); | public void unregisterMBean(ObjectName objectName){ throw new RuntimeException("unregisterMBean not supported"); } |
return ((Haplotype) alleles.get(i)).toString(); | return ((Haplotype) filteredAlleles.get(i)).toString(); | public String getAlleleName(int i) { return ((Haplotype) alleles.get(i)).toString(); } |
public String getFreq(int j) { double freq = ((Haplotype)alleles.get(j)).getPercentage(); | public String getFreq(int i) { double freq = ((Haplotype)alleles.get(i)).getPercentage(); | public String getFreq(int j) { double freq = ((Haplotype)alleles.get(j)).getPercentage(); if (freq < 0){ return (""); }else{ nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); return nf.format(freq); } } |
return ((Haplotype) alleles.get(i)).toNumericString(); | return ((Haplotype) filteredAlleles.get(i)).toNumericString(); | public String getNumericAlleleName(int i){ return ((Haplotype) alleles.get(i)).toNumericString(); } |
tempRec.p = (float)(probMap.get(new Long(tempRec.h1))); | if (tempRec.h1 == tempRec.h2){ tempRec.p = (float)(probMap.get(new Long(tempRec.h1))); }else{ tempRec.p = 0; } | private void full_em_breakup( byte[][] input_haplos, int[] block_size, Vector affStatus, Vector kidAffStatus, boolean[] haploid) throws HaploViewException{ int num_poss, iter; double total = 0; int block, start_locus, end_locus, biggest_block_size; int num_indivs = 0; int num_blocks = block_size.length; int num_haplos = input_haplos.length; int num_loci = input_haplos[0].length; Recovery tempRec; if (num_loci > MAXLOCI){ throw new HaploViewException("Too many loci in a single block (> "+MAXLOCI+" non-redundant)"); } //figure out the size of the biggest block biggest_block_size=block_size[0]; for (int i=1; i<num_blocks; i++) { if (block_size[i] > biggest_block_size) biggest_block_size=block_size[i]; } num_poss = two_n[biggest_block_size]; data = new OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) data[i]= new OBS(); superdata = new SUPER_OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) superdata[i]= new SUPER_OBS(num_blocks); double[][] hprob = new double[num_blocks][num_poss]; int[][] hlist = new int[num_blocks][num_poss]; int[] num_hlist = new int[num_blocks]; int[] hint = new int[num_poss]; MapWrap probMap = new MapWrap(PSEUDOCOUNT); /* for trio option */ if (Options.getAssocTest() == ASSOC_TRIO) { ambighet = new int[(num_haplos/4)][num_loci]; store_dhet_status(num_haplos,num_loci,input_haplos); } end_locus=-1; //now we loop through the blocks for (block=0; block<num_blocks; block++) { start_locus=end_locus+1; end_locus=start_locus+block_size[block]-1; num_poss=two_n[block_size[block]]; //read_observations initializes the values in data[] (array of OBS) num_indivs=read_observations(num_haplos,num_loci,input_haplos,start_locus,end_locus); total=(double)num_poss; total *= PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (int i=0; i<num_indivs; i++) { if (data[i].nposs==1) { tempRec = (Recovery)data[i].poss.elementAt(0); probMap.put(new Long(tempRec.h1), probMap.get(new Long(tempRec.h1)) + 1.0); if (!haploid[i]){ probMap.put(new Long(tempRec.h2), probMap.get(new Long(tempRec.h2)) + 1.0); total+=2.0; }else{ total+=1.0; } } } probMap.normalize(total); // EM LOOP: assign ambiguous data based on p, then re-estimate p iter=0; while (iter<20) { // compute probabilities of each possible observation for (int i=0; i<num_indivs; i++) { total=0.0; for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); if(haploid[i]){ tempRec.p = (float)(probMap.get(new Long(tempRec.h1))); }else { tempRec.p = (float)(probMap.get(new Long(tempRec.h1))*probMap.get(new Long(tempRec.h2))); } total+=tempRec.p; } // normalize for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); tempRec.p /= total; } } // re-estimate prob probMap = new MapWrap(1e-10); total=num_poss*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); probMap.put(new Long(tempRec.h1),probMap.get(new Long(tempRec.h1)) + tempRec.p); if (!haploid[i]){ probMap.put(new Long(tempRec.h2),probMap.get(new Long(tempRec.h2)) + tempRec.p); total+=(2.0*(tempRec.p)); }else{ total += tempRec.p; } } } probMap.normalize(total); iter++; } int m=0; for(long j=0;j<num_poss; j++){ hint[(int)j]=-1; if (probMap.get(new Long(j)) > .001) { // printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); hlist[block][m]=(int)j; hprob[block][m]=probMap.get(new Long(j)); hint[(int)j]=m; m++; } } num_hlist[block]=m; // store current block results in super obs structure store_block_haplos(hlist, hprob, hint, block, num_indivs); } /* for each block */ double poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } /* LIGATE and finish this mess :) */ fullProbMap = new MapWrap(PSEUDOCOUNT); create_super_haplos(num_indivs,num_blocks,num_hlist); /* run standard EM on supercombos */ /* start prob array with probabilities from full observations */ total = poss_full * PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (int i=0; i<num_indivs; i++) { if (superdata[i].nsuper==1) { Long h1 = new Long(superdata[i].superposs[0].h1); Long h2 = new Long(superdata[i].superposs[0].h2); fullProbMap.put(h1,fullProbMap.get(h1) +1.0); if (!haploid[i]){ fullProbMap.put(h2,fullProbMap.get(h2) +1.0); total+=2.0; }else{ total+=1.0; } } } fullProbMap.normalize(total); /* EM LOOP: assign ambiguous data based on p, then re-estimate p */ iter=0; while (iter<20) { /* compute probabilities of each possible observation */ for (int i=0; i<num_indivs; i++) { total=0.0; for (int k=0; k<superdata[i].nsuper; k++) { if(haploid[i]){ superdata[i].superposs[k].p = (float) (fullProbMap.get(new Long(superdata[i].superposs[k].h1))); }else{ superdata[i].superposs[k].p = (float) (fullProbMap.get(new Long(superdata[i].superposs[k].h1))* fullProbMap.get(new Long(superdata[i].superposs[k].h2))); } total+=superdata[i].superposs[k].p; } /* normalize */ for (int k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p /= total; } } /* re-estimate prob */ fullProbMap = new MapWrap(1e-10); total=poss_full*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<superdata[i].nsuper; k++) { fullProbMap.put(new Long(superdata[i].superposs[k].h1),fullProbMap.get(new Long(superdata[i].superposs[k].h1)) + superdata[i].superposs[k].p); if(!haploid[i]){ fullProbMap.put(new Long(superdata[i].superposs[k].h2),fullProbMap.get(new Long(superdata[i].superposs[k].h2)) + superdata[i].superposs[k].p); total+=(2.0*superdata[i].superposs[k].p); }else{ total += superdata[i].superposs[k].p; } } } fullProbMap.normalize(total); iter++; } /* we're done - the indices of superprob now have to be decoded to reveal the actual haplotypes they represent */ if(Options.getAssocTest() == ASSOC_TRIO) { kidConsistentCache = new boolean[numFilteredTrios][][]; for(int i=0;i<numFilteredTrios*2;i+=2) { if (((Integer)kidAffStatus.elementAt(i)).intValue() == 2){ kidConsistentCache[i/2] = new boolean[superdata[i].nsuper][]; for (int n=0; n<superdata[i].nsuper; n++) { kidConsistentCache[i/2][n] = new boolean[superdata[i+1].nsuper]; for (int m=0; m<superdata[i+1].nsuper; m++) { kidConsistentCache[i/2][n][m] = kid_consistent(superdata[i].superposs[n].h1, superdata[i+1].superposs[m].h1,num_blocks, block_size,hlist,num_hlist,i/2,num_loci); } } } } } realAffectedStatus = affStatus; doAssociationTests(affStatus, null, kidAffStatus); Vector haplos_present = new Vector(); Vector haplo_freq= new Vector(); ArrayList keys = new ArrayList(fullProbMap.theMap.keySet()); Collections.sort(keys); Iterator kitr = keys.iterator(); while(kitr.hasNext()) { Object key = kitr.next(); long keyLong = ((Long)key).longValue(); if(fullProbMap.get(key) > .001) { haplos_present.addElement(decode_haplo_str(keyLong,num_blocks,block_size,hlist,num_hlist)); haplo_freq.addElement(new Double(fullProbMap.get(key))); } } double[] freqs = new double[haplo_freq.size()]; for(int j=0;j<haplo_freq.size();j++) { freqs[j] = ((Double)haplo_freq.elementAt(j)).doubleValue(); } this.haplotypes = (int[][])haplos_present.toArray(new int[0][0]); this.frequencies = freqs; /* if (dump_phased_haplos) { if ((fpdump=fopen("emphased.haps","w"))!=NULL) { for (i=0; i<num_indivs; i++) { best=0; for (k=0; k<superdata[i].nsuper; k++) { if (superdata[i].superposs[k].p > superdata[i].superposs[best].p) { best=k; } } h1 = superdata[i].superposs[best].h1; h2 = superdata[i].superposs[best].h2; fprintf(fpdump,"%s\n",decode_haplo_str(h1,num_blocks,block_size,hlist,num_hlist)); fprintf(fpdump,"%s\n",decode_haplo_str(h2,num_blocks,block_size,hlist,num_hlist)); } fclose(fpdump); } } */ //return 0; } |
superdata[i].superposs[k].p = (float) (fullProbMap.get(new Long(superdata[i].superposs[k].h1))); | if (superdata[i].superposs[k].h1 == superdata[i].superposs[k].h2){ superdata[i].superposs[k].p = (float) (fullProbMap.get(new Long(superdata[i].superposs[k].h1))); }else{ superdata[i].superposs[k].p = 0; } | private void full_em_breakup( byte[][] input_haplos, int[] block_size, Vector affStatus, Vector kidAffStatus, boolean[] haploid) throws HaploViewException{ int num_poss, iter; double total = 0; int block, start_locus, end_locus, biggest_block_size; int num_indivs = 0; int num_blocks = block_size.length; int num_haplos = input_haplos.length; int num_loci = input_haplos[0].length; Recovery tempRec; if (num_loci > MAXLOCI){ throw new HaploViewException("Too many loci in a single block (> "+MAXLOCI+" non-redundant)"); } //figure out the size of the biggest block biggest_block_size=block_size[0]; for (int i=1; i<num_blocks; i++) { if (block_size[i] > biggest_block_size) biggest_block_size=block_size[i]; } num_poss = two_n[biggest_block_size]; data = new OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) data[i]= new OBS(); superdata = new SUPER_OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) superdata[i]= new SUPER_OBS(num_blocks); double[][] hprob = new double[num_blocks][num_poss]; int[][] hlist = new int[num_blocks][num_poss]; int[] num_hlist = new int[num_blocks]; int[] hint = new int[num_poss]; MapWrap probMap = new MapWrap(PSEUDOCOUNT); /* for trio option */ if (Options.getAssocTest() == ASSOC_TRIO) { ambighet = new int[(num_haplos/4)][num_loci]; store_dhet_status(num_haplos,num_loci,input_haplos); } end_locus=-1; //now we loop through the blocks for (block=0; block<num_blocks; block++) { start_locus=end_locus+1; end_locus=start_locus+block_size[block]-1; num_poss=two_n[block_size[block]]; //read_observations initializes the values in data[] (array of OBS) num_indivs=read_observations(num_haplos,num_loci,input_haplos,start_locus,end_locus); total=(double)num_poss; total *= PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (int i=0; i<num_indivs; i++) { if (data[i].nposs==1) { tempRec = (Recovery)data[i].poss.elementAt(0); probMap.put(new Long(tempRec.h1), probMap.get(new Long(tempRec.h1)) + 1.0); if (!haploid[i]){ probMap.put(new Long(tempRec.h2), probMap.get(new Long(tempRec.h2)) + 1.0); total+=2.0; }else{ total+=1.0; } } } probMap.normalize(total); // EM LOOP: assign ambiguous data based on p, then re-estimate p iter=0; while (iter<20) { // compute probabilities of each possible observation for (int i=0; i<num_indivs; i++) { total=0.0; for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); if(haploid[i]){ tempRec.p = (float)(probMap.get(new Long(tempRec.h1))); }else { tempRec.p = (float)(probMap.get(new Long(tempRec.h1))*probMap.get(new Long(tempRec.h2))); } total+=tempRec.p; } // normalize for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); tempRec.p /= total; } } // re-estimate prob probMap = new MapWrap(1e-10); total=num_poss*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); probMap.put(new Long(tempRec.h1),probMap.get(new Long(tempRec.h1)) + tempRec.p); if (!haploid[i]){ probMap.put(new Long(tempRec.h2),probMap.get(new Long(tempRec.h2)) + tempRec.p); total+=(2.0*(tempRec.p)); }else{ total += tempRec.p; } } } probMap.normalize(total); iter++; } int m=0; for(long j=0;j<num_poss; j++){ hint[(int)j]=-1; if (probMap.get(new Long(j)) > .001) { // printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); hlist[block][m]=(int)j; hprob[block][m]=probMap.get(new Long(j)); hint[(int)j]=m; m++; } } num_hlist[block]=m; // store current block results in super obs structure store_block_haplos(hlist, hprob, hint, block, num_indivs); } /* for each block */ double poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } /* LIGATE and finish this mess :) */ fullProbMap = new MapWrap(PSEUDOCOUNT); create_super_haplos(num_indivs,num_blocks,num_hlist); /* run standard EM on supercombos */ /* start prob array with probabilities from full observations */ total = poss_full * PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (int i=0; i<num_indivs; i++) { if (superdata[i].nsuper==1) { Long h1 = new Long(superdata[i].superposs[0].h1); Long h2 = new Long(superdata[i].superposs[0].h2); fullProbMap.put(h1,fullProbMap.get(h1) +1.0); if (!haploid[i]){ fullProbMap.put(h2,fullProbMap.get(h2) +1.0); total+=2.0; }else{ total+=1.0; } } } fullProbMap.normalize(total); /* EM LOOP: assign ambiguous data based on p, then re-estimate p */ iter=0; while (iter<20) { /* compute probabilities of each possible observation */ for (int i=0; i<num_indivs; i++) { total=0.0; for (int k=0; k<superdata[i].nsuper; k++) { if(haploid[i]){ superdata[i].superposs[k].p = (float) (fullProbMap.get(new Long(superdata[i].superposs[k].h1))); }else{ superdata[i].superposs[k].p = (float) (fullProbMap.get(new Long(superdata[i].superposs[k].h1))* fullProbMap.get(new Long(superdata[i].superposs[k].h2))); } total+=superdata[i].superposs[k].p; } /* normalize */ for (int k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p /= total; } } /* re-estimate prob */ fullProbMap = new MapWrap(1e-10); total=poss_full*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<superdata[i].nsuper; k++) { fullProbMap.put(new Long(superdata[i].superposs[k].h1),fullProbMap.get(new Long(superdata[i].superposs[k].h1)) + superdata[i].superposs[k].p); if(!haploid[i]){ fullProbMap.put(new Long(superdata[i].superposs[k].h2),fullProbMap.get(new Long(superdata[i].superposs[k].h2)) + superdata[i].superposs[k].p); total+=(2.0*superdata[i].superposs[k].p); }else{ total += superdata[i].superposs[k].p; } } } fullProbMap.normalize(total); iter++; } /* we're done - the indices of superprob now have to be decoded to reveal the actual haplotypes they represent */ if(Options.getAssocTest() == ASSOC_TRIO) { kidConsistentCache = new boolean[numFilteredTrios][][]; for(int i=0;i<numFilteredTrios*2;i+=2) { if (((Integer)kidAffStatus.elementAt(i)).intValue() == 2){ kidConsistentCache[i/2] = new boolean[superdata[i].nsuper][]; for (int n=0; n<superdata[i].nsuper; n++) { kidConsistentCache[i/2][n] = new boolean[superdata[i+1].nsuper]; for (int m=0; m<superdata[i+1].nsuper; m++) { kidConsistentCache[i/2][n][m] = kid_consistent(superdata[i].superposs[n].h1, superdata[i+1].superposs[m].h1,num_blocks, block_size,hlist,num_hlist,i/2,num_loci); } } } } } realAffectedStatus = affStatus; doAssociationTests(affStatus, null, kidAffStatus); Vector haplos_present = new Vector(); Vector haplo_freq= new Vector(); ArrayList keys = new ArrayList(fullProbMap.theMap.keySet()); Collections.sort(keys); Iterator kitr = keys.iterator(); while(kitr.hasNext()) { Object key = kitr.next(); long keyLong = ((Long)key).longValue(); if(fullProbMap.get(key) > .001) { haplos_present.addElement(decode_haplo_str(keyLong,num_blocks,block_size,hlist,num_hlist)); haplo_freq.addElement(new Double(fullProbMap.get(key))); } } double[] freqs = new double[haplo_freq.size()]; for(int j=0;j<haplo_freq.size();j++) { freqs[j] = ((Double)haplo_freq.elementAt(j)).doubleValue(); } this.haplotypes = (int[][])haplos_present.toArray(new int[0][0]); this.frequencies = freqs; /* if (dump_phased_haplos) { if ((fpdump=fopen("emphased.haps","w"))!=NULL) { for (i=0; i<num_indivs; i++) { best=0; for (k=0; k<superdata[i].nsuper; k++) { if (superdata[i].superposs[k].p > superdata[i].superposs[best].p) { best=k; } } h1 = superdata[i].superposs[best].h1; h2 = superdata[i].superposs[best].h2; fprintf(fpdump,"%s\n",decode_haplo_str(h1,num_blocks,block_size,hlist,num_hlist)); fprintf(fpdump,"%s\n",decode_haplo_str(h2,num_blocks,block_size,hlist,num_hlist)); } fclose(fpdump); } } */ //return 0; } |
this.zeroed = new Vector(); | public Individual(){ this.markers = new Vector(); } |
|
this.zeroed.add(new Boolean(false)); | public void addMarker(byte[] marker){ this.markers.add(marker); } |
|
byte zeroArray[] = {0,0}; this.markers.set(i, zeroArray); | this.zeroed.set(i, new Boolean(true)); | public void zeroOutMarker(int i){ byte zeroArray[] = {0,0}; this.markers.set(i, zeroArray); } |
public TagScript createTagScript(String name, Attributes attributes) throws Exception { | public TagScript createTagScript(final String name, Attributes attributes) throws Exception { | public TagScript createTagScript(String name, Attributes attributes) throws Exception { Project project = getProject(); // custom Ant tags if ( name.equals("fileScanner") ) { Tag tag = new FileScannerTag(new FileScanner(project)); return TagScript.newInstance(tag); } AntTag tag = new AntTag( getProject(), name ); if ( name.equals( "echo" ) ) { tag.setTrim(false); } return TagScript.newInstance(tag); } |
Project project = getProject(); if ( name.equals("fileScanner") ) { Tag tag = new FileScannerTag(new FileScanner(project)); return TagScript.newInstance(tag); | TagScript answer = createCustomTagScript(name, attributes); if ( answer == null ) { answer = new DynaTagScript( new TagFactory() { public Tag createTag() throws Exception { return AntTagLibrary.this.createTag(name); } } ); | public TagScript createTagScript(String name, Attributes attributes) throws Exception { Project project = getProject(); // custom Ant tags if ( name.equals("fileScanner") ) { Tag tag = new FileScannerTag(new FileScanner(project)); return TagScript.newInstance(tag); } AntTag tag = new AntTag( getProject(), name ); if ( name.equals( "echo" ) ) { tag.setTrim(false); } return TagScript.newInstance(tag); } |
AntTag tag = new AntTag( getProject(), name ); if ( name.equals( "echo" ) ) { tag.setTrim(false); } return TagScript.newInstance(tag); | return answer; | public TagScript createTagScript(String name, Attributes attributes) throws Exception { Project project = getProject(); // custom Ant tags if ( name.equals("fileScanner") ) { Tag tag = new FileScannerTag(new FileScanner(project)); return TagScript.newInstance(tag); } AntTag tag = new AntTag( getProject(), name ); if ( name.equals( "echo" ) ) { tag.setTrim(false); } return TagScript.newInstance(tag); } |
this( AntTagLibrary.createProject() ); | this.antTagLib = new AntTagLibrary(); | public JeezTagLibrary() { this( AntTagLibrary.createProject() ); } |
public TagScript createTagScript(String name, Attributes attrs) throws Exception { TagScript script = super.createTagScript( name, attrs ); | public TagScript createTagScript( final String name, Attributes attrs ) throws Exception { | public TagScript createTagScript(String name, Attributes attrs) throws Exception { TagScript script = super.createTagScript( name, attrs ); if ( script == null ) { // script = this.coreTagLib.createTagScript( name, attrs ); if ( script == null ) { script = this.werkzTagLib.createTagScript( name, attrs ); if ( script == null ) { if ( isRuntimeTask( name ) ) { if ( ! project.getTaskDefinitions().containsKey( name ) ) { script = this.antTagLib.createRuntimeTaskTagScript( name, attrs ); } else { this.runtimeTasks.remove( name ); } } if ( script == null ) { script = this.antTagLib.createTagScript( name, attrs ); } if ( name.equals( "taskdef" ) ) { addRuntimeTask( attrs.getValue( "name" ) ); } } } } return script; } |
script = antTagLib.createCustomTagScript( name, attrs ); | public TagScript createTagScript(String name, Attributes attrs) throws Exception { TagScript script = super.createTagScript( name, attrs ); if ( script == null ) { // script = this.coreTagLib.createTagScript( name, attrs ); if ( script == null ) { script = this.werkzTagLib.createTagScript( name, attrs ); if ( script == null ) { if ( isRuntimeTask( name ) ) { if ( ! project.getTaskDefinitions().containsKey( name ) ) { script = this.antTagLib.createRuntimeTaskTagScript( name, attrs ); } else { this.runtimeTasks.remove( name ); } } if ( script == null ) { script = this.antTagLib.createTagScript( name, attrs ); } if ( name.equals( "taskdef" ) ) { addRuntimeTask( attrs.getValue( "name" ) ); } } } } return script; } |
|
script = this.werkzTagLib.createTagScript( name, attrs ); if ( script == null ) { if ( isRuntimeTask( name ) ) { if ( ! project.getTaskDefinitions().containsKey( name ) ) { script = this.antTagLib.createRuntimeTaskTagScript( name, attrs ); } else { this.runtimeTasks.remove( name ); | return new DynaTagScript( new TagFactory() { public Tag createTag() throws Exception { Tag tag = JeezTagLibrary.this.createTag(name); if ( tag != null ) { return tag; } else { return antTagLib.createTag( name ); } | public TagScript createTagScript(String name, Attributes attrs) throws Exception { TagScript script = super.createTagScript( name, attrs ); if ( script == null ) { // script = this.coreTagLib.createTagScript( name, attrs ); if ( script == null ) { script = this.werkzTagLib.createTagScript( name, attrs ); if ( script == null ) { if ( isRuntimeTask( name ) ) { if ( ! project.getTaskDefinitions().containsKey( name ) ) { script = this.antTagLib.createRuntimeTaskTagScript( name, attrs ); } else { this.runtimeTasks.remove( name ); } } if ( script == null ) { script = this.antTagLib.createTagScript( name, attrs ); } if ( name.equals( "taskdef" ) ) { addRuntimeTask( attrs.getValue( "name" ) ); } } } } return script; } |
if ( script == null ) { script = this.antTagLib.createTagScript( name, attrs ); } if ( name.equals( "taskdef" ) ) { addRuntimeTask( attrs.getValue( "name" ) ); } } | ); | public TagScript createTagScript(String name, Attributes attrs) throws Exception { TagScript script = super.createTagScript( name, attrs ); if ( script == null ) { // script = this.coreTagLib.createTagScript( name, attrs ); if ( script == null ) { script = this.werkzTagLib.createTagScript( name, attrs ); if ( script == null ) { if ( isRuntimeTask( name ) ) { if ( ! project.getTaskDefinitions().containsKey( name ) ) { script = this.antTagLib.createRuntimeTaskTagScript( name, attrs ); } else { this.runtimeTasks.remove( name ); } } if ( script == null ) { script = this.antTagLib.createTagScript( name, attrs ); } if ( name.equals( "taskdef" ) ) { addRuntimeTask( attrs.getValue( "name" ) ); } } } } return script; } |
public TagScript createTagScript(String name, Attributes attributes) | public TagScript createTagScript(final String name, Attributes attributes) | public TagScript createTagScript(String name, Attributes attributes) throws Exception { Object value = templates.get(name); if ( value instanceof Script ) { Script template = (Script) value; DynamicTag tag = new DynamicTag(template); // XXXX: somehow we should find the template's // <invokeBody> tag and associate it with this instance return new DynaTagScript(tag); } else if ( value instanceof DynaTag ) { DynaTag tag = (DynaTag) value; return new DynaTagScript(tag); } return null; } |
Object value = templates.get(name); if ( value instanceof Script ) { Script template = (Script) value; DynamicTag tag = new DynamicTag(template); return new DynaTagScript(tag); } else if ( value instanceof DynaTag ) { DynaTag tag = (DynaTag) value; return new DynaTagScript(tag); } return null; | return new DynaTagScript( new TagFactory() { public Tag createTag() throws Exception { return DynamicTagLibrary.this.createTag(name); } } ); | public TagScript createTagScript(String name, Attributes attributes) throws Exception { Object value = templates.get(name); if ( value instanceof Script ) { Script template = (Script) value; DynamicTag tag = new DynamicTag(template); // XXXX: somehow we should find the template's // <invokeBody> tag and associate it with this instance return new DynaTagScript(tag); } else if ( value instanceof DynaTag ) { DynaTag tag = (DynaTag) value; return new DynaTagScript(tag); } return null; } |
public void setDisplayThresh(int amount) { parent.displayThresh = amount; parent.adjustDisplay(); | public void setDisplayThresh(int amount){ if (parent.displayThresh != amount){ parent.adjustDisplay(amount); } | public void setDisplayThresh(int amount) { parent.displayThresh = amount; parent.adjustDisplay(); } |
if (this.getParent() != null){ if (this.getPreferredSize().height > this.getParent().getHeight()){ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); }else{ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); } } | public void adjustDisplay(int dt){ //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh Haplotype[][] filts; filts = new Haplotype[orderedHaplos.length][]; int numhaps = 0; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > dt){ tempVector.add(orderedHaplos[i][j]); numhaps++; } } if (numhaps > 1){ printable++; numhaps=0; } filts[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filts[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filts.length)){ JOptionPane.showMessageDialog(this.getParent(), "Error: At least one block has too few haplotypes of frequency > " + dt, "Error", JOptionPane.ERROR_MESSAGE); return; } displayThresh = dt; filteredHaplos = filts; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); repaint(); } |
|
assertEquals("displayName", l.getLastPropertyChange()); | assertEquals("name", l.getLastPropertyChange()); | public void testSetDisplayName() { CountingPropertyChangeListener l = new CountingPropertyChangeListener(); ds.addPropertyChangeListener(l); ds.setDisplayName("test"); assertEquals(1, l.getPropertyChangeCount()); assertEquals("displayName", l.getLastPropertyChange()); assertEquals("test", ds.getDisplayName()); } |
ind.setZeroedArray(sortedZeroed); | void prepareMarkerInput(File infile, String[][] hapmapGoodies) throws IOException, HaploViewException{ //this method is called to gather data about the markers used. //It is assumed that the input file is two columns, the first being //the name and the second the absolute position. the maxdist is //used to determine beyond what distance comparisons will not be //made. if the infile param is null, loads up "dummy info" for //situation where no info file exists //An optional third column is supported which is designed to hold //association study data. If there is a third column there will be //a visual indicator in the D' display that there is additional data //and the detailed data can be viewed with a mouse press. Vector names = new Vector(); HashSet dupCheck = new HashSet(); Vector positions = new Vector(); Vector extras = new Vector(); dupsToBeFlagged = false; dupNames = false; try{ if (infile != null){ if (infile.length() < 1){ throw new HaploViewException("Info file is empty or does not exist: " + infile.getName()); } String currentLine; long prevloc = -1000000000; //read the input file: BufferedReader in = new BufferedReader(new FileReader(infile)); int lineCount = 0; while ((currentLine = in.readLine()) != null){ StringTokenizer st = new StringTokenizer(currentLine); if (st.countTokens() > 1){ lineCount++; }else if (st.countTokens() == 1){ //complain if only one field found throw new HaploViewException("Info file format error on line "+lineCount+ ":\n Info file must be of format: <markername> <markerposition>"); }else{ //skip blank lines continue; } String name = st.nextToken(); String l = st.nextToken(); String extra = null; if (st.hasMoreTokens()) extra = st.nextToken(); long loc; try{ loc = Long.parseLong(l); }catch (NumberFormatException nfe){ throw new HaploViewException("Info file format error on line "+lineCount+ ":\n\"" + l + "\" should be of type long." + "\n Info file must be of format: <markername> <markerposition>"); } //basically if anyone is crazy enough to load a dataset, then go back and load //an out-of-order info file we tell them to bugger off and start over. if (loc < prevloc && Chromosome.markers != null){ throw new HaploViewException("Info file out of order with preloaded dataset:\n"+ name + "\nPlease reload data file and info file together."); } prevloc = loc; if (names.contains(name)){ dupCheck.add(name); } names.add(name); positions.add(l); extras.add(extra); } if (lineCount > Chromosome.getUnfilteredSize()){ throw(new HaploViewException("Info file error:\nMarker number mismatch: too many\nmarkers in info file compared to data file.")); } if (lineCount < Chromosome.getUnfilteredSize()){ throw(new HaploViewException("Info file error:\nMarker number mismatch: too few\nmarkers in info file compared to data file.")); } infoKnown=true; } if (hapmapGoodies != null){ //we know some stuff from the hapmap so we'll add it here for (int x=0; x < hapmapGoodies.length; x++){ names.add(hapmapGoodies[x][0]); positions.add(hapmapGoodies[x][1]); extras.add(null); if (names.contains(hapmapGoodies[x][0])){ dupCheck.add(hapmapGoodies[x][0]); } } infoKnown = true; } //check for duplicate names Iterator ditr = dupCheck.iterator(); while (ditr.hasNext()){ String n = (String) ditr.next(); int numdups = 1; for (int i = 0; i < names.size(); i++){ if (names.get(i).equals(n)){ //leave the first instance of the duplicate name the same if (numdups > 1){ String newName = n + "." + numdups; while (names.contains(newName)){ numdups++; newName = n + "." + numdups; } names.setElementAt(newName,i); dupNames = true; } numdups++; } } } //sort the markers int numLines = names.size(); class SortingHelper implements Comparable{ long pos; int orderInFile; public SortingHelper(long pos, int order){ this.pos = pos; this.orderInFile = order; } public int compareTo(Object o) { SortingHelper sh = (SortingHelper)o; if (sh.pos > pos){ return -1; }else if (sh.pos < pos){ return 1; }else{ return 0; } } } boolean needSort = false; Vector sortHelpers = new Vector(); for (int k = 0; k < (numLines); k++){ sortHelpers.add(new SortingHelper(Long.parseLong((String)positions.get(k)),k)); } //loop through and check if any markers are out of order for (int k = 1; k < (numLines); k++){ if(((SortingHelper)sortHelpers.get(k)).compareTo(sortHelpers.get(k-1)) < 0) { needSort = true; break; } } //if any were out of order, then we need to put them in order if(needSort){ //sort the positions Collections.sort(sortHelpers); Vector newNames = new Vector(); Vector newExtras = new Vector(); Vector newPositions = new Vector(); int[] realPos = new int[numLines]; //reorder the vectors names and extras so that they have the same order as the sorted markers for (int i = 0; i < sortHelpers.size(); i++){ realPos[i] = ((SortingHelper)sortHelpers.get(i)).orderInFile; newNames.add(names.get(realPos[i])); newPositions.add(positions.get(realPos[i])); newExtras.add(extras.get(realPos[i])); } names = newNames; extras = newExtras; positions = newPositions; byte[] tempGenotype = new byte[sortHelpers.size()]; //now we reorder all the individuals genotypes according to the sorted marker order for(int j=0;j<chromosomes.size();j++){ Chromosome tempChrom = (Chromosome)chromosomes.elementAt(j); for(int i =0;i<sortHelpers.size();i++){ tempGenotype[i] = tempChrom.getUnfilteredGenotype(realPos[i]); } for(int i=0;i<sortHelpers.size();i++){ tempChrom.setGenotype(tempGenotype[i],i); } } //sort pedfile objects //todo: this should really be done before pedfile is subjected to any processing. //todo: that would require altering some order of operations in dealing with inputs Vector unsortedRes = pedFile.getResults(); Vector sortedRes = new Vector(); for (int i = 0; i < realPos.length; i++){ sortedRes.add(unsortedRes.elementAt(realPos[i])); } pedFile.setResults(sortedRes); Vector o = pedFile.getAllIndividuals(); for (int i = 0; i < o.size(); i++){ Individual ind = (Individual) o.get(i); Vector unsortedMarkers = ind.getMarkers(); Vector sortedMarkers = new Vector(); for (int j = 0; j < unsortedMarkers.size(); j++){ sortedMarkers.add(unsortedMarkers.elementAt(realPos[j])); } ind.setMarkers(sortedMarkers); } } }catch (HaploViewException e){ throw(e); }finally{ double numChroms = chromosomes.size(); Vector markerInfo = new Vector(); double[] numBadGenotypes = new double[Chromosome.getUnfilteredSize()]; percentBadGenotypes = new double[Chromosome.getUnfilteredSize()]; Vector results = null; if (pedFile != null){ results = pedFile.getResults(); } long prevPosition = Long.MIN_VALUE; SNP prevMarker = null; MarkerResult pmr = null; for (int i = 0; i < Chromosome.getUnfilteredSize(); i++){ MarkerResult mr = null; if (results != null){ mr = (MarkerResult)results.elementAt(i); } //to compute minor/major alleles, browse chrom list and count instances of each allele byte a1 = 0; byte a2 = 0; double numa1 = 0; double numa2 = 0; for (int j = 0; j < chromosomes.size(); j++){ //if there is a data point for this marker on this chromosome byte thisAllele = ((Chromosome)chromosomes.elementAt(j)).getUnfilteredGenotype(i); if (!(thisAllele == 0)){ if (thisAllele >= 5){ numa1+=0.5; numa2+=0.5; if (thisAllele < 9){ if (a1==0){ a1 = (byte)(thisAllele-4); }else if (a2 == 0){ if (!(thisAllele-4 == a1)){ a2 = (byte)(thisAllele-4); } } } }else if (a1 == 0){ a1 = thisAllele; numa1++; }else if (thisAllele == a1){ numa1++; }else{ numa2++; a2 = thisAllele; } } else { numBadGenotypes[i]++; } } if (numa2 > numa1){ byte temp = a1; double tempnum = numa1; numa1 = numa2; a1 = a2; numa2 = tempnum; a2 = temp; } double maf; if (mr != null){ maf = Util.roundDouble(mr.getMAF(),3); }else{ maf = Util.roundDouble((numa2/(numa1+numa2)),3); } if (infoKnown){ long pos = Long.parseLong((String)positions.elementAt(i)); SNP thisMarker = (new SNP((String)names.elementAt(i), pos, maf, a1, a2, (String)extras.elementAt(i))); markerInfo.add(thisMarker); if (mr != null){ double genoPC = mr.getGenoPercent(); //check to make sure adjacent SNPs do not have identical positions if (prevPosition != Long.MIN_VALUE){ //only do this for markers 2..N, since we're comparing to the previous location if (pos == prevPosition){ dupsToBeFlagged = true; if (genoPC >= pmr.getGenoPercent()){ //use this one because it has more genotypes thisMarker.setDup(1); prevMarker.setDup(2); }else{ //use the other one because it has more genotypes thisMarker.setDup(2); prevMarker.setDup(1); } } } prevPosition = pos; prevMarker = thisMarker; pmr = mr; } }else{ markerInfo.add(new SNP("Marker " + String.valueOf(i+1), (i*4000), maf,a1,a2)); } percentBadGenotypes[i] = numBadGenotypes[i]/numChroms; } Chromosome.markers = markerInfo; } } |
|
editColumnAction.setDBTree(dbTree); insertColumnAction.setDBTree(dbTree); editRelationshipAction.setDBTree(dbTree); deleteSelectedAction.setDBTree(dbTree); editTableAction.setDBTree(dbTree); | protected void setupActions() { aboutAction.setPlayPen(playpen); printAction.setPlayPen(playpen); deleteSelectedAction.setPlayPen(playpen); editColumnAction.setPlayPen(playpen); insertColumnAction.setPlayPen(playpen); editTableAction.setPlayPen(playpen); createTableAction.setPlayPen(playpen); createIdentifyingRelationshipAction.setPlayPen(playpen); createNonIdentifyingRelationshipAction.setPlayPen(playpen); editRelationshipAction.setPlayPen(playpen); exportPLTransAction.setPlayPen(playpen); zoomInAction.setPlayPen(playpen); zoomOutAction.setPlayPen(playpen); prefAction.setArchitectFrame(this); projectSettingsAction.setArchitectFrame(this); } |
|
public void dPrimeDraw(String[][] table, Graphics g){ | public void dPrimeDraw(String[][] table, boolean info, Vector snps, Graphics g){ | public void dPrimeDraw(String[][] table, Graphics g){ int scale = table.length*30; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", shifts[0], shifts[1]); //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(st.nextToken()); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30) ,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30, shifts[1]+(x+1)*30); } } |
g.fillRect(0,0,scale,scale); | g.fillRect(0,0,scale+activeOffset,scale); | public void dPrimeDraw(String[][] table, Graphics g){ int scale = table.length*30; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", shifts[0], shifts[1]); //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(st.nextToken()); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30) ,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30, shifts[1]+(x+1)*30); } } |
g.drawString("1", shifts[0], shifts[1]); | g.drawString("1", activeOffset + shifts[0], shifts[1]); | public void dPrimeDraw(String[][] table, Graphics g){ int scale = table.length*30; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", shifts[0], shifts[1]); //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(st.nextToken()); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30) ,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30, shifts[1]+(x+1)*30); } } |
if (info){ g.setFont(regFont); for (int y = 0; y < table.length; y++){ String name = ((SNP)snps.elementAt(y)).getName(); g.drawString(name, labeloffset-3-regfm.stringWidth(name), y*30 + shifts[1]); } if (table.length > 3){ g.drawLine(labeloffset+90,5,labeloffset+scale-5,scale-90); double lineLength = Math.sqrt((scale-95)*(scale-95)*2); double start = ((SNP)snps.elementAt(0)).getPosition(); double totalLength = ((SNP)snps.elementAt(table.length-1)).getPosition() - start; int numKB = (int)(totalLength/1000); g.drawString(numKB+" Kb", labeloffset+150, 30); for (int y = 0; y < table.length; y++){ double fracLength = (((SNP)snps.elementAt(y)).getPosition() - start)/totalLength; double xOrYDist = Math.sqrt((fracLength*lineLength*fracLength*lineLength)/2); g.drawLine(labeloffset+25+y*30, 5+y*30,(int)(labeloffset+90+xOrYDist),(int)(5+xOrYDist)); } } } | public void dPrimeDraw(String[][] table, Graphics g){ int scale = table.length*30; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", shifts[0], shifts[1]); //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(st.nextToken()); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30) ,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30, shifts[1]+(x+1)*30); } } |
|
g.fillRect(x*30+1, y*30+1, 28, 28); | g.fillRect(x*30+1+activeOffset, y*30+1, 28, 28); | public void dPrimeDraw(String[][] table, Graphics g){ int scale = table.length*30; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", shifts[0], shifts[1]); //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(st.nextToken()); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30) ,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30, shifts[1]+(x+1)*30); } } |
g.drawRect(x*30, y*30, 30, 30); | g.drawRect(x*30+activeOffset, y*30, 30, 30); | public void dPrimeDraw(String[][] table, Graphics g){ int scale = table.length*30; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", shifts[0], shifts[1]); //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(st.nextToken()); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30) ,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30, shifts[1]+(x+1)*30); } } |
g.drawString(Float.toString(d), shifts[0]+(x*30) ,(y*30)+shifts[1]); | g.drawString(Float.toString(d), shifts[0]+(x*30)+activeOffset,(y*30)+shifts[1]); | public void dPrimeDraw(String[][] table, Graphics g){ int scale = table.length*30; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", shifts[0], shifts[1]); //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(st.nextToken()); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30) ,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30, shifts[1]+(x+1)*30); } } |
g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30, shifts[1]+(x+1)*30); | g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30+activeOffset, shifts[1]+(x+1)*30); | public void dPrimeDraw(String[][] table, Graphics g){ int scale = table.length*30; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", shifts[0], shifts[1]); //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(st.nextToken()); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30) ,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30, shifts[1]+(x+1)*30); } } |
public Dimension dPrimeGetPreferredSize(int size){ return new Dimension(size*30, size*30); | public Dimension dPrimeGetPreferredSize(int size, boolean info){ if (info){ return new Dimension((labeloffset+size*30), size*30); }else{ return new Dimension(size*30, size*30); } | public Dimension dPrimeGetPreferredSize(int size){ return new Dimension(size*30, size*30); } |
h.put(name, value); | h.put(name, value.toString()); | public Hashtable getProperties() { Hashtable h = new Hashtable(); for (Iterator i = this.context.getVariableNames(); i.hasNext(); ) { String name = (String) i.next(); Object value = this.context.getVariable(name); if (value != null) { h.put(name, value); } } return h; } |
properties = new HashMap(); | properties = new HashMap<String,String>(); | public ArchitectDataSource() { properties = new HashMap(); } |
return (String) properties.get(key); | return properties.get(key); | public String get(String key) { return (String) properties.get(key); } |
return (String) properties.get(PL_DSN); | return properties.get(PL_DSN); | public String getOdbcDsn() { return (String) properties.get(PL_DSN); } |
protected PropertyChangeSupport getPcs() { | private PropertyChangeSupport getPcs() { | protected PropertyChangeSupport getPcs() { if (pcs == null) pcs = new PropertyChangeSupport(this); return pcs; } |
return (String) properties.get(PL_TYPE); | return properties.get(PL_TYPE); | public String getPlDbType() { return (String) properties.get(PL_TYPE); } |
return (String) properties.get(PL_SCHEMA_OWNER); | return properties.get(PL_SCHEMA_OWNER); | public String getPlSchema() { return (String) properties.get(PL_SCHEMA_OWNER); } |
public Map getPropertiesMap() { return properties; | public Map<String,String> getPropertiesMap() { return Collections.unmodifiableMap(properties); | public Map getPropertiesMap() { return properties; } |
Window.setDefaultImage(image); | window.getShell().setImage(image); | private void setWindowImage(Window window, Image image) { Window.setDefaultImage(image); } |
throw new JellyTagException("This tag must be nested within a widget"); | throw new JellyTagException("This tag must be nested within a Widget or a Window"); | public void doTag(XMLOutput output) throws JellyTagException { // invoke by body just in case some nested tag configures me invokeBody(output); Widget parent = getParentWidget(); if (parent == null) { throw new JellyTagException("This tag must be nested within a widget"); } Image image = new Image(parent.getDisplay(), getSrc()); if (parent instanceof Label) { Label label = (Label) parent; label.setImage(image); } else if (parent instanceof Button) { Button button = (Button) parent; button.setImage(image); } else if (parent instanceof Item) { Item item = (Item) parent; item.setImage(image); } else if (parent instanceof Decorations) { Decorations item = (Decorations) parent; item.setImage(image); } else { throw new JellyTagException("This tag must be nested inside a <label>, <button> or <item> tag"); } } |
Image image = new Image(parent.getDisplay(), getSrc()); | public void doTag(XMLOutput output) throws JellyTagException { // invoke by body just in case some nested tag configures me invokeBody(output); Widget parent = getParentWidget(); if (parent == null) { throw new JellyTagException("This tag must be nested within a widget"); } Image image = new Image(parent.getDisplay(), getSrc()); if (parent instanceof Label) { Label label = (Label) parent; label.setImage(image); } else if (parent instanceof Button) { Button button = (Button) parent; button.setImage(image); } else if (parent instanceof Item) { Item item = (Item) parent; item.setImage(image); } else if (parent instanceof Decorations) { Decorations item = (Decorations) parent; item.setImage(image); } else { throw new JellyTagException("This tag must be nested inside a <label>, <button> or <item> tag"); } } |
|
if (parent instanceof Label) { Label label = (Label) parent; label.setImage(image); } else if (parent instanceof Button) { Button button = (Button) parent; button.setImage(image); } else if (parent instanceof Item) { Item item = (Item) parent; item.setImage(image); } else if (parent instanceof Decorations) { Decorations item = (Decorations) parent; item.setImage(image); } else { throw new JellyTagException("This tag must be nested inside a <label>, <button> or <item> tag"); } } | Image image = new Image(parent.getDisplay(), getSrc()); setWidgetImage(parent, image); } | public void doTag(XMLOutput output) throws JellyTagException { // invoke by body just in case some nested tag configures me invokeBody(output); Widget parent = getParentWidget(); if (parent == null) { throw new JellyTagException("This tag must be nested within a widget"); } Image image = new Image(parent.getDisplay(), getSrc()); if (parent instanceof Label) { Label label = (Label) parent; label.setImage(image); } else if (parent instanceof Button) { Button button = (Button) parent; button.setImage(image); } else if (parent instanceof Item) { Item item = (Item) parent; item.setImage(image); } else if (parent instanceof Decorations) { Decorations item = (Decorations) parent; item.setImage(image); } else { throw new JellyTagException("This tag must be nested inside a <label>, <button> or <item> tag"); } } |
colorMenuItems[0].setSelected(true); | colorMenuItems[Options.getLDColorScheme()].setSelected(true); | public HaploView(){ try{ fc = new JFileChooser(System.getProperty("user.dir")); }catch(NullPointerException n){ try{ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); fc = new JFileChooser(System.getProperty("user.dir")); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }catch(Exception e){ } } //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); analysisItem = new JMenuItem(READ_ANALYSIS_TRACK); setAccelerator(analysisItem, 'A', false); analysisItem.addActionListener(this); analysisItem.setEnabled(false); fileMenu.add(analysisItem); blocksItem = new JMenuItem(READ_BLOCKS_FILE); setAccelerator(blocksItem, 'B', false); blocksItem.addActionListener(this); blocksItem.setEnabled(false); fileMenu.add(blocksItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); fileMenu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem("Quit"); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu displayMenu = new JMenu("Display"); displayMenu.setMnemonic(KeyEvent.VK_D); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); viewMenuItems[i].setEnabled(false); group.add(viewMenuItems[i]); } displayMenu.addSeparator(); //a submenu ButtonGroup zg = new ButtonGroup(); JMenu zoomMenu = new JMenu("LD zoom"); zoomMenu.setMnemonic(KeyEvent.VK_Z); zoomMenuItems = new JRadioButtonMenuItem[zoomItems.length]; for (int i = 0; i < zoomItems.length; i++){ zoomMenuItems[i] = new JRadioButtonMenuItem(zoomItems[i], i==0); zoomMenuItems[i].addActionListener(this); zoomMenuItems[i].setActionCommand("zoom" + i); zoomMenu.add(zoomMenuItems[i]); zg.add(zoomMenuItems[i]); } displayMenu.add(zoomMenu); //another submenu ButtonGroup cg = new ButtonGroup(); JMenu colorMenu = new JMenu("LD color scheme"); colorMenu.setMnemonic(KeyEvent.VK_C); colorMenuItems = new JRadioButtonMenuItem[colorItems.length]; for (int i = 0; i< colorItems.length; i++){ colorMenuItems[i] = new JRadioButtonMenuItem(colorItems[i],i==0); colorMenuItems[i].addActionListener(this); colorMenuItems[i].setActionCommand("color" + i); colorMenu.add(colorMenuItems[i]); cg.add(colorMenuItems[i]); } colorMenuItems[0].setSelected(true); displayMenu.add(colorMenu); JMenuItem spacingItem = new JMenuItem("LD Display Spacing"); spacingItem.setMnemonic(KeyEvent.VK_S); spacingItem.addActionListener(this); displayMenu.add(spacingItem); displayMenu.setEnabled(false); //analysis menu analysisMenu = new JMenu("Analysis"); analysisMenu.setMnemonic(KeyEvent.VK_A); menuBar.add(analysisMenu); //a submenu ButtonGroup bg = new ButtonGroup(); JMenu blockMenu = new JMenu("Define Blocks"); blockMenu.setMnemonic(KeyEvent.VK_B); blockMenuItems = new JRadioButtonMenuItem[blockItems.length]; for (int i = 0; i < blockItems.length; i++){ blockMenuItems[i] = new JRadioButtonMenuItem(blockItems[i], i==0); blockMenuItems[i].addActionListener(this); blockMenuItems[i].setActionCommand("block" + i); blockMenuItems[i].setEnabled(false); blockMenu.add(blockMenuItems[i]); bg.add(blockMenuItems[i]); } analysisMenu.add(blockMenu); clearBlocksItem = new JMenuItem(CLEAR_BLOCKS); setAccelerator(clearBlocksItem, 'C', false); clearBlocksItem.addActionListener(this); clearBlocksItem.setEnabled(false); analysisMenu.add(clearBlocksItem); JMenuItem customizeBlocksItem = new JMenuItem(CUST_BLOCKS); customizeBlocksItem.addActionListener(this); analysisMenu.add(customizeBlocksItem); analysisMenu.setEnabled(false); //color key keyMenu = new JMenu("Key"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(keyMenu); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* Configuration.readConfigFile(); if(Configuration.isCheckForUpdate()) { Object[] options = {"Yes", "Not now", "Never ask again"}; int n = JOptionPane.showOptionDialog(this, "Would you like to check if a new version " + "of haploview is available?", "Check for update", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if(n == JOptionPane.YES_OPTION) { UpdateChecker uc = new UpdateChecker(); if(uc.checkForUpdate()) { JOptionPane.showMessageDialog(this, "A new version of Haploview is available!\n Visit http://www.broad.mit.edu/mpg/haploview/ to download the new version\n (current version: " + Constants.VERSION + " newest version: " + uc.getNewVersion() + ")" , "Update Available", JOptionPane.INFORMATION_MESSAGE); } } else if(n == JOptionPane.CANCEL_OPTION) { Configuration.setCheckForUpdate(false); Configuration.writeConfigFile(); } } */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); } |
drp.addMenuElement(tpc.toString(), tpc.getName()); | drp.addMenuElement(tpc.getIdentifier().toString(), tpc.getName()); | public PresentationObject getLetterForm(IWContext iwc) { Table T = new Table(); TextInput fromAddress = new TextInput("from_address"); fromAddress.setLength(80); TextInput fromName = new TextInput("from_name"); fromName.setLength(80); TextInput subject = new TextInput("subject"); subject.setLength(80); TextArea body = new TextArea("body", 70, 20); int row = 1; if (topics != null && topics.size() > 0) { T.add(tf.format(iwrb.getLocalizedString("list.topic", "Topic"), tf.HEADER), 1, row); DropdownMenu drp = new DropdownMenu("topic_id"); drp.setToSubmit(); java.util.Iterator iter = topics.iterator(); EmailTopic tpc; if (topics.size() > 1) { while (iter.hasNext()) { tpc = (EmailTopic) iter.next(); if(defaultTopic == null) defaultTopic = tpc; drp.addMenuElement(tpc.toString(), tpc.getName()); } if(topic>0) drp.setSelectedElement(topic); T.add(drp, 2, row++); } else if (iter.hasNext()) { tpc = (EmailTopic) iter.next(); defaultTopic = tpc; T.add(new HiddenInput("topic_id", tpc.toString()), 2, row++); } } if(defaultTopic!=null){ fromName.setContent(defaultTopic.getSenderName()); fromAddress.setContent(defaultTopic.getSenderEmail()); if(inpSubject!=null) subject.setContent(inpSubject); body.setContent(inpBody); } T.add( tf.format(iwrb.getLocalizedString("letter.from_name", "Sender name"), tf.HEADER), 1, row); T.add(fromName, 2, row++); T.add(tf.format(iwrb.getLocalizedString("letter.from_address", "Sender address"), tf.HEADER),1,row); T.add(fromAddress, 2, row++); T.add(tf.format(iwrb.getLocalizedString("letter.subject", "Subject"), tf.HEADER), 1, row); T.add(subject, 2, row++); T.add(tf.format(iwrb.getLocalizedString("letter.body", "Body"), tf.HEADER), 1, row); T.add(body, 2, row++); SubmitButton send = new SubmitButton(iwrb.getLocalizedImageButton("send", "Send"), "send"); //SubmitButton save = new SubmitButton(iwrb.getLocalizedImageButton("save","Save"),"save"); //CheckBox save = new CheckBox("save", "true"); Table submitTable = new Table(5, 1); //submitTable.add(tf.format(iwrb.getLocalizedString("save_to_archive","Save to archive")),3,1); //submitTable.add(save,3,1); submitTable.add(send, 5, 1); T.add(submitTable, 2, row); T.setAlignment(2, row, "right"); return T; } |
T.add(new HiddenInput("topic_id", tpc.toString()), 2, row++); | T.add(new HiddenInput("topic_id",tpc.getIdentifier().toString()), 2, row++); | public PresentationObject getLetterForm(IWContext iwc) { Table T = new Table(); TextInput fromAddress = new TextInput("from_address"); fromAddress.setLength(80); TextInput fromName = new TextInput("from_name"); fromName.setLength(80); TextInput subject = new TextInput("subject"); subject.setLength(80); TextArea body = new TextArea("body", 70, 20); int row = 1; if (topics != null && topics.size() > 0) { T.add(tf.format(iwrb.getLocalizedString("list.topic", "Topic"), tf.HEADER), 1, row); DropdownMenu drp = new DropdownMenu("topic_id"); drp.setToSubmit(); java.util.Iterator iter = topics.iterator(); EmailTopic tpc; if (topics.size() > 1) { while (iter.hasNext()) { tpc = (EmailTopic) iter.next(); if(defaultTopic == null) defaultTopic = tpc; drp.addMenuElement(tpc.toString(), tpc.getName()); } if(topic>0) drp.setSelectedElement(topic); T.add(drp, 2, row++); } else if (iter.hasNext()) { tpc = (EmailTopic) iter.next(); defaultTopic = tpc; T.add(new HiddenInput("topic_id", tpc.toString()), 2, row++); } } if(defaultTopic!=null){ fromName.setContent(defaultTopic.getSenderName()); fromAddress.setContent(defaultTopic.getSenderEmail()); if(inpSubject!=null) subject.setContent(inpSubject); body.setContent(inpBody); } T.add( tf.format(iwrb.getLocalizedString("letter.from_name", "Sender name"), tf.HEADER), 1, row); T.add(fromName, 2, row++); T.add(tf.format(iwrb.getLocalizedString("letter.from_address", "Sender address"), tf.HEADER),1,row); T.add(fromAddress, 2, row++); T.add(tf.format(iwrb.getLocalizedString("letter.subject", "Subject"), tf.HEADER), 1, row); T.add(subject, 2, row++); T.add(tf.format(iwrb.getLocalizedString("letter.body", "Body"), tf.HEADER), 1, row); T.add(body, 2, row++); SubmitButton send = new SubmitButton(iwrb.getLocalizedImageButton("send", "Send"), "send"); //SubmitButton save = new SubmitButton(iwrb.getLocalizedImageButton("save","Save"),"save"); //CheckBox save = new CheckBox("save", "true"); Table submitTable = new Table(5, 1); //submitTable.add(tf.format(iwrb.getLocalizedString("save_to_archive","Save to archive")),3,1); //submitTable.add(save,3,1); submitTable.add(send, 5, 1); T.add(submitTable, 2, row); T.setAlignment(2, row, "right"); return T; } |
public void doTag(XMLOutput output) throws Exception { | public void doTag(XMLOutput output) throws MissingAttributeException, Exception { | public void doTag(XMLOutput output) throws Exception { if (test != null) { while (test.evaluateAsBoolean(getContext())) { if (log.isDebugEnabled()) { log.debug("evaluated to true! gonna keep on chuggin!"); } invokeBody(output); } } else { throw new MissingAttributeException("test"); } } |
final long maxCompDist = Long.parseLong(filenames[2])*1000; | maxCompDist = Long.parseLong(filenames[2])*1000; | void processData(){ final long maxCompDist = Long.parseLong(filenames[2])*1000; try{ this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; infoKnown = false; if (!(filenames[1].equals(""))){ readMarkers(new File(filenames[1])); } theData.generateDPrimeTable(maxCompDist); theData.guessBlocks(0); drawPicture(theData); theData.finished = true; return ""; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); defineBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); worker.start(); timer.start(); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } |
int good = theData.prepareMarkerInput(inputFile); | int good = theData.prepareMarkerInput(inputFile,maxCompDist); | void readMarkers(File inputFile){ try { int good = theData.prepareMarkerInput(inputFile); if (good == -1){ JOptionPane.showMessageDialog(this, "Number of markers in info file does not match number of markers in dataset.", "Error", JOptionPane.ERROR_MESSAGE); }else{ infoKnown=true; if (dPrimeDisplay != null){ dPrimeDisplay.loadMarkers(); } } }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } |
throw new LockedColumnException(this); | throw new LockedColumnException(this,col); | public void checkColumnLocked(SQLColumn col) throws LockedColumnException { for (SQLRelationship.ColumnMapping cm : getMappings()) { if (cm.getFkColumn() == col) { throw new LockedColumnException(this); } } } |
Iterator iter = modelFields.values().iterator(); while( iter.hasNext() ) { FieldController fieldCtrl = (FieldController) iter.next(); fieldCtrl.updateAllViews(); } | public void setView( PhotoInfoView view ) { views.clear(); views.add( view ); } |
|
Context context = new Context(); | JellyContext context = new JellyContext(); | public void testParse() throws Exception { InputStream in = getClass().getResourceAsStream( "example.jelly" ); XMLParser parser = new XMLParser(); Script script = parser.parse( in ); script = script.compile(); log.debug( "Found: " + script ); assertTrue( "Script is a TagScript", script instanceof TagScript ); Context context = new Context(); StringWriter buffer = new StringWriter(); script.run( context, XMLOutput.createXMLOutput( buffer ) ); String text = buffer.toString().trim(); if ( log.isDebugEnabled() ) { log.debug( "Evaluated script as..." ); log.debug( text ); } assertEquals( "Produces the correct output", "It works!", text ); } |
setDynaBean( new WrapDynaBean(dataType) ); | setDynaBean( new ConvertingWrapDynaBean(dataType) ); | public void setDataType(Object dataType) { this.dataType = dataType; setDynaBean( new WrapDynaBean(dataType) ); } |
} | }else{ g2.fillRect(0,0,size.width, size.height); } g2.setColor(Color.black); | public void paintComponent(Graphics g){ PairwiseLinkage[][] dPrimeTable = theData.filteredDPrimeTable; Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); if (size.height < pref.height){ setSize(pref); } //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setColor(BG_GREY); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.black); g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //TODO: finish implementing scaling gizmo /*//deal with adding some space to better display data with large gaps int cumulativeGap[] = new int[Chromosome.getFilteredSize()]; for (int i = 0; i < cumulativeGap.length; i++){ cumulativeGap[i] = 0; } if (theData.infoKnown){ double mean = (((SNP)Chromosome.markers[Chromosome.markers.length-1]).getPosition() - ((SNP)Chromosome.markers[0]).getPosition())/Chromosome.markers.length-1; for (int i = 1; i < cumulativeGap.length; i++){ double sep = Chromosome.getMarker(i).getPosition() - Chromosome.getMarker(i-1).getPosition(); if (sep > mean*10){ cumulativeGap[i] = cumulativeGap[i-1] + (int)(sep/mean)*4; }else{ cumulativeGap[i] = cumulativeGap[i-1]; } } } */ //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop; } int lineSpan = (dPrimeTable.length-1) * boxSize; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked g2.setColor(Color.white); g2.fillRect(left, top, lineSpan, TRACK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left, top, lineSpan, TRACK_HEIGHT); //get the data into an easier format double positions[] = new double[theData.analysisPositions.size()]; double values[] = new double[theData.analysisPositions.size()]; for (int x = 0; x < positions.length; x++){ positions[x] = ((Double)theData.analysisPositions.elementAt(x)).doubleValue(); values[x] = ((Double)theData.analysisValues.elementAt(x)).doubleValue(); } g2.setColor(Color.black); double min = Double.MAX_VALUE; double max = -min; for (int x = 0; x < positions.length; x++){ if(values[x] < min){ min = values[x]; } if (values[x] > max){ max = values[x]; } } double range = max-min; //todo: this is kinda hideous for (int x = 0; x < positions.length - 1; x++){ if (positions[x] >= minpos && positions[x+1] <= maxpos){ g2.draw(new Line2D.Double(lineSpan * Math.abs((positions[x] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x] - min)/range)), lineSpan * Math.abs((positions[x+1] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x+1] - min)/range)))); } } top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left+1, top+1, lineSpan-1, TICK_HEIGHT-1); g2.setColor(Color.black); g2.drawRect(left, top, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getFilteredSize(); i++){ double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineSpan*pos); g2.setStroke(thickerStroke); g2.drawLine(xx, top, xx, top + TICK_HEIGHT); g2.setStroke(thinnerStroke); g2.drawLine(xx, top + TICK_HEIGHT, left + i*boxSize, top+TICK_BOTTOM); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printDetails){ widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printDetails){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printDetails){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g2.setColor((val < 50) ? Color.gray : Color.black); if (boxColor == Color.darkGray){ g2.setColor(Color.white); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } boolean even = true; //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.drawLine(left + (2*first) * boxSize/2 - boxRadius, top, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g2.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last) * boxSize/2+boxRadius, top); for (int j = first; j <= last; j++){ if (theData.isInBlock[j]){ g2.setStroke(fatStroke); }else{ g2.setStroke(dashedFatStroke); } g2.drawLine(left+j*boxSize-boxSize/2, top-blockDispHeight, left+j*boxSize+boxSize/2, top-blockDispHeight); } //lines to connect to block display g2.setStroke(fatStroke); g2.drawLine(left + first*boxSize-boxSize/2, top-1, left+first*boxSize-boxSize/2, top-blockDispHeight); g2.drawLine(left+last*boxSize+boxSize/2, top-1, left+last*boxSize+boxSize/2, top-blockDispHeight); if (printDetails){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getFilteredMarker(last).getPosition() - Chromosome.getFilteredMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, left+first*boxSize-boxSize/2+TEXT_GAP, top-boxSize/3); } } g2.setStroke(thickerStroke); //see if the user has right-clicked to popup some marker info if(popupExists){ int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getWidth() < visRect.width){ //dumb bug where little datasets popup the box in the wrong place smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); for (int x = 0; x < displayStrings.length; x++){ g.drawString(displayStrings[x],popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } if (showWM && !forExport){ //dataset is big enough to require worldmap final int WM_BD_GAP = 1; final int WM_BD_HEIGHT = 2; final int WM_BD_TOTAL = WM_BD_HEIGHT + 2*WM_BD_GAP; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth-WM_BD_TOTAL))); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2+WM_BD_TOTAL, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top + WM_BD_TOTAL; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left+(int)(prefBoxSize*first), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)((last-first+1)*prefBoxSize), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if we're drawing a worldmap resize rect if (resizeRectExists){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRectExists){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } } |
g2.setColor(BG_GREY); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.black); | public void paintComponent(Graphics g){ PairwiseLinkage[][] dPrimeTable = theData.filteredDPrimeTable; Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); if (size.height < pref.height){ setSize(pref); } //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setColor(BG_GREY); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.black); g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //TODO: finish implementing scaling gizmo /*//deal with adding some space to better display data with large gaps int cumulativeGap[] = new int[Chromosome.getFilteredSize()]; for (int i = 0; i < cumulativeGap.length; i++){ cumulativeGap[i] = 0; } if (theData.infoKnown){ double mean = (((SNP)Chromosome.markers[Chromosome.markers.length-1]).getPosition() - ((SNP)Chromosome.markers[0]).getPosition())/Chromosome.markers.length-1; for (int i = 1; i < cumulativeGap.length; i++){ double sep = Chromosome.getMarker(i).getPosition() - Chromosome.getMarker(i-1).getPosition(); if (sep > mean*10){ cumulativeGap[i] = cumulativeGap[i-1] + (int)(sep/mean)*4; }else{ cumulativeGap[i] = cumulativeGap[i-1]; } } } */ //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop; } int lineSpan = (dPrimeTable.length-1) * boxSize; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked g2.setColor(Color.white); g2.fillRect(left, top, lineSpan, TRACK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left, top, lineSpan, TRACK_HEIGHT); //get the data into an easier format double positions[] = new double[theData.analysisPositions.size()]; double values[] = new double[theData.analysisPositions.size()]; for (int x = 0; x < positions.length; x++){ positions[x] = ((Double)theData.analysisPositions.elementAt(x)).doubleValue(); values[x] = ((Double)theData.analysisValues.elementAt(x)).doubleValue(); } g2.setColor(Color.black); double min = Double.MAX_VALUE; double max = -min; for (int x = 0; x < positions.length; x++){ if(values[x] < min){ min = values[x]; } if (values[x] > max){ max = values[x]; } } double range = max-min; //todo: this is kinda hideous for (int x = 0; x < positions.length - 1; x++){ if (positions[x] >= minpos && positions[x+1] <= maxpos){ g2.draw(new Line2D.Double(lineSpan * Math.abs((positions[x] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x] - min)/range)), lineSpan * Math.abs((positions[x+1] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x+1] - min)/range)))); } } top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left+1, top+1, lineSpan-1, TICK_HEIGHT-1); g2.setColor(Color.black); g2.drawRect(left, top, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getFilteredSize(); i++){ double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineSpan*pos); g2.setStroke(thickerStroke); g2.drawLine(xx, top, xx, top + TICK_HEIGHT); g2.setStroke(thinnerStroke); g2.drawLine(xx, top + TICK_HEIGHT, left + i*boxSize, top+TICK_BOTTOM); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printDetails){ widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printDetails){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printDetails){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g2.setColor((val < 50) ? Color.gray : Color.black); if (boxColor == Color.darkGray){ g2.setColor(Color.white); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } boolean even = true; //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.drawLine(left + (2*first) * boxSize/2 - boxRadius, top, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g2.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last) * boxSize/2+boxRadius, top); for (int j = first; j <= last; j++){ if (theData.isInBlock[j]){ g2.setStroke(fatStroke); }else{ g2.setStroke(dashedFatStroke); } g2.drawLine(left+j*boxSize-boxSize/2, top-blockDispHeight, left+j*boxSize+boxSize/2, top-blockDispHeight); } //lines to connect to block display g2.setStroke(fatStroke); g2.drawLine(left + first*boxSize-boxSize/2, top-1, left+first*boxSize-boxSize/2, top-blockDispHeight); g2.drawLine(left+last*boxSize+boxSize/2, top-1, left+last*boxSize+boxSize/2, top-blockDispHeight); if (printDetails){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getFilteredMarker(last).getPosition() - Chromosome.getFilteredMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, left+first*boxSize-boxSize/2+TEXT_GAP, top-boxSize/3); } } g2.setStroke(thickerStroke); //see if the user has right-clicked to popup some marker info if(popupExists){ int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getWidth() < visRect.width){ //dumb bug where little datasets popup the box in the wrong place smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); for (int x = 0; x < displayStrings.length; x++){ g.drawString(displayStrings[x],popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } if (showWM && !forExport){ //dataset is big enough to require worldmap final int WM_BD_GAP = 1; final int WM_BD_HEIGHT = 2; final int WM_BD_TOTAL = WM_BD_HEIGHT + 2*WM_BD_GAP; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth-WM_BD_TOTAL))); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2+WM_BD_TOTAL, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top + WM_BD_TOTAL; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left+(int)(prefBoxSize*first), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)((last-first+1)*prefBoxSize), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if we're drawing a worldmap resize rect if (resizeRectExists){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRectExists){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } } |
|
if (a1 == 5 && a2 == 5){ | if (a1 >= 5 && a2 >= 5){ | public void tallyCCInd(byte a1, byte a2, int cc){ //case = 0, control = 1 for int cc if (a1 == 5 && a2 == 5){ counts[cc][0]++; counts[cc][1]++; }else{ //seed the alleles as soon as they're found if (allele1 == 0){ allele1 = a1; } if (a1 != 0){ if (a1 == allele1){ counts[cc][0] ++; }else{ counts[cc][1] ++; } } if (a2 != 0){ if (a2 == allele1){ counts[cc][0]++; }else{ counts[cc][1]++; } } } } |
if(alleleT == 5 && alleleU == 5) { | if(alleleT >= 5 && alleleU >= 5) { | public void tallyTrioInd(byte alleleT, byte alleleU) { if(alleleT == 5 && alleleU == 5) { if(tallyHet){ counts[0][0]++; counts[1][1]++; counts[0][1]++; counts[1][0]++; this.tallyHet = false; } else { this.tallyHet = true; } } else if( (alleleT != alleleU) && (alleleT!=0) && (alleleU!=0) ) { if(allele1==0 && allele2==0 ) { allele1 = alleleT; allele2 = alleleU; } if(alleleT == allele1) { counts[0][0]++; } else if(alleleT==allele2) { counts[0][1]++; } if(alleleU == allele1){ counts[1][0]++; } else if(alleleU == allele2) { counts[1][1]++; } } //System.out.println( counts[0][0] + "\t" + counts[1][1] + "\t" + counts[0][1] + "\t" + counts[1][0]); } |
int size = entry.size; | private void findAllMatchingTestMail(String username) throws SamplingException { try { org.apache.commons.net.pop3.POP3Client pop3Client = openConnection(username); // retrieve all messages POP3MessageInfo[] entries = null; try { entries = pop3Client.listMessages(); } catch (Exception e) { String errorMessage = "failed to read pop3 account mail list for " + username; m_results.addError(500, errorMessage); log.info(errorMessage); return; } for (int i = 0; entries != null && i < entries.length; i++) {// TODO do we need to check the state? assertEquals(1, pop3Client.getState()); POP3MessageInfo entry = entries[i]; int size = entry.size; MailProcessingRecord mailProcessingRecord = new MailProcessingRecord(); mailProcessingRecord.setReceivingQueue("pop3"); mailProcessingRecord.setTimeFetchStart(System.currentTimeMillis()); String mailText; BufferedReader mailReader = null; Reader reader = null; try { reader = pop3Client.retrieveMessage(entry.number); mailReader = new BufferedReader(reader); analyzeAndMatch(mailReader, mailProcessingRecord, pop3Client, i); } catch (Exception e) { log.info("failed to read pop3 mail #" + i + " for " + username); continue; // mail processing record is discarded } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { log.warn("error closing mail reader"); } } } continue; } closeSession(pop3Client); } catch (PostageException e) { throw new SamplingException("sample failed", e); } } |
|
MailProcessingRecord mailProcessingRecord = new MailProcessingRecord(); mailProcessingRecord.setReceivingQueue("pop3"); mailProcessingRecord.setTimeFetchStart(System.currentTimeMillis()); String mailText; BufferedReader mailReader = null; Reader reader = null; | private void findAllMatchingTestMail(String username) throws SamplingException { try { org.apache.commons.net.pop3.POP3Client pop3Client = openConnection(username); // retrieve all messages POP3MessageInfo[] entries = null; try { entries = pop3Client.listMessages(); } catch (Exception e) { String errorMessage = "failed to read pop3 account mail list for " + username; m_results.addError(500, errorMessage); log.info(errorMessage); return; } for (int i = 0; entries != null && i < entries.length; i++) {// TODO do we need to check the state? assertEquals(1, pop3Client.getState()); POP3MessageInfo entry = entries[i]; int size = entry.size; MailProcessingRecord mailProcessingRecord = new MailProcessingRecord(); mailProcessingRecord.setReceivingQueue("pop3"); mailProcessingRecord.setTimeFetchStart(System.currentTimeMillis()); String mailText; BufferedReader mailReader = null; Reader reader = null; try { reader = pop3Client.retrieveMessage(entry.number); mailReader = new BufferedReader(reader); analyzeAndMatch(mailReader, mailProcessingRecord, pop3Client, i); } catch (Exception e) { log.info("failed to read pop3 mail #" + i + " for " + username); continue; // mail processing record is discarded } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { log.warn("error closing mail reader"); } } } continue; } closeSession(pop3Client); } catch (PostageException e) { throw new SamplingException("sample failed", e); } } |
|
reader = pop3Client.retrieveMessage(entry.number); mailReader = new BufferedReader(reader); analyzeAndMatch(mailReader, mailProcessingRecord, pop3Client, i); } catch (Exception e) { log.info("failed to read pop3 mail #" + i + " for " + username); continue; } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { log.warn("error closing mail reader"); } } } continue; | new POP3MailAnalyzeStrategy("pop3", m_results, pop3Client, entry.number, i).handle(); } catch (Exception exception) { log.warn("error processing pop3 mail", exception); } | private void findAllMatchingTestMail(String username) throws SamplingException { try { org.apache.commons.net.pop3.POP3Client pop3Client = openConnection(username); // retrieve all messages POP3MessageInfo[] entries = null; try { entries = pop3Client.listMessages(); } catch (Exception e) { String errorMessage = "failed to read pop3 account mail list for " + username; m_results.addError(500, errorMessage); log.info(errorMessage); return; } for (int i = 0; entries != null && i < entries.length; i++) {// TODO do we need to check the state? assertEquals(1, pop3Client.getState()); POP3MessageInfo entry = entries[i]; int size = entry.size; MailProcessingRecord mailProcessingRecord = new MailProcessingRecord(); mailProcessingRecord.setReceivingQueue("pop3"); mailProcessingRecord.setTimeFetchStart(System.currentTimeMillis()); String mailText; BufferedReader mailReader = null; Reader reader = null; try { reader = pop3Client.retrieveMessage(entry.number); mailReader = new BufferedReader(reader); analyzeAndMatch(mailReader, mailProcessingRecord, pop3Client, i); } catch (Exception e) { log.info("failed to read pop3 mail #" + i + " for " + username); continue; // mail processing record is discarded } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { log.warn("error closing mail reader"); } } } continue; } closeSession(pop3Client); } catch (PostageException e) { throw new SamplingException("sample failed", e); } } |
return text; | return "${" + text + "}"; | public Expression createExpression(final String text) throws Exception {/* org.apache.commons.jexl.Expression expr = org.apache.commons.jexl.ExpressionFactory.createExpression(text); if ( isSupportAntVariables() ) { expr.addPostResolver(new FlatResolver()); } return new JexlExpression( expr );*/ final Expression jexlExpression = new JexlExpression( org.apache.commons.jexl.ExpressionFactory.createExpression(text) ); if ( isSupportAntVariables() && isValidAntVariableName(text) ) { ExpressionSupport expr = new ExpressionSupport() { public Object evaluate(JellyContext context) { Object answer = jexlExpression.evaluate(context); if ( answer == null ) { answer = context.getVariable(text); } return answer; } public String getExpressionText() { return text; } public String toString() { return super.toString() + "[expression:" + text + "]"; } }; return expr; } return jexlExpression; } |
return text; | return "${" + text + "}"; | public String getExpressionText() { return text; } |
throw new MissingAttributeException( "var" ); | throw new MissingAttributeException( "delim" ); | public void doTag(final XMLOutput output) throws Exception { if ( this.var == null ) { throw new MissingAttributeException( "var" ); } if ( this.delim == null ) { throw new MissingAttributeException( "var" ); } StringTokenizer tokenizer = new StringTokenizer( getBodyText(), this.delim ); List tokens = new ArrayList(); while ( tokenizer.hasMoreTokens() ) { tokens.add( tokenizer.nextToken() ); } getContext().setVariable( this.var, tokens ); } |
String className = (String) entry.getValue(); context.registerTagLibrary("jelly:" + uri, className); | String className = (String) entry.getValue(); String libraryURI = "jelly:" + uri; if ( context.getTagLibrary(libraryURI) == null ) { context.registerTagLibrary(libraryURI, className); } | protected void configure() { // load the properties file of libraries available InputStream in = null; URL url = getClassLoader().getResource("org/apache/commons/jelly/jelly.properties"); if (url != null) { log.debug("Loading Jelly default tag libraries from: " + url); Properties properties = new Properties(); try { in = url.openStream(); properties.load(in); for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String uri = (String) entry.getKey(); String className = (String) entry.getValue(); context.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) { // ignore } } } } |
public String getElementName(); | String getElementName(); | public String getElementName(); |
public void setColumnNumber(int columnNumber); | void setColumnNumber(int columnNumber); | public void setColumnNumber(int columnNumber); |
public void setElementName(String elementName); | void setElementName(String elementName); | public void setElementName(String elementName); |
public void setFileName(String fileName); | void setFileName(String fileName); | public void setFileName(String fileName); |
public void setLineNumber(int lineNumber); | void setLineNumber(int lineNumber); | public void setLineNumber(int lineNumber); |
return super.getMessage() + " At line: " | return super.getMessage() + " File: " + fileName + " At tag <" + elementName + ">: line: " | public String getMessage() { return super.getMessage() + " At line: " + lineNumber + " column: " + columnNumber; } |
fc.setSelectedFile(null); | public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command == "Open"){ int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try{ theData = new HaploData(fc.getSelectedFile()); infileName = fc.getSelectedFile().getName(); //compute D primes and monitor progress progressMonitor = new ProgressMonitor(this, "Computing " + theData.getToBeCompleted() + " values of D prime","", 0, theData.getToBeCompleted()); progressMonitor.setProgress(0); progressMonitor.setMillisToDecideToPopup(2000); final SwingWorker worker = new SwingWorker(){ public Object construct(){ theData.doMonitoredComputation(); return ""; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ progressMonitor.setProgress(theData.getComplete()); if (theData.finished){ timer.stop(); progressMonitor.close(); infoKnown=false; drawPicture(theData); loadInfoMenuItem.setEnabled(true); hapMenuItem.setEnabled(true); customizeHapsMenuItem.setEnabled(true); exportMenuItem.setEnabled(true); saveDprimeMenuItem.setEnabled(true); clearBlocksMenuItem.setEnabled(true); guessBlocksMenuItem.setEnabled(true); } } }); worker.start(); timer.start(); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } } else if (command == loadInfoStr){ int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try{ int good = theData.prepareMarkerInput(fc.getSelectedFile()); if (good == -1){ JOptionPane.showMessageDialog(this, "Number of markers in info file does not match number of markers in dataset.", "Error", JOptionPane.ERROR_MESSAGE); }else{ infoKnown=true; // loadInfoMenuItem.setEnabled(false); drawPicture(theData); } }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } }else if (command == "Clear All Blocks"){ theBlocks.clearBlocks(); }else if (command == "Define Blocks"){ defineBlocks(); }else if (command == "Customize Haplotype Output"){ customizeHaps(); }else if (command == "Tutorial"){ showHelp(); }else if (command == "Export LD Picture to JPG"){ doExportDPrime(); }else if (command == "Dump LD Output to Text"){ saveDprimeToText(); }else if (command == "Save Haplotypes to Text"){ saveHapsToText(); }else if (command == "Save Haplotypes to JPG"){ saveHapsPic(); }else if (command == "Generate Haplotypes"){ try{ drawHaplos(theData.generateHaplotypes(theData.blocks, haploThresh)); saveHapsMenuItem.setEnabled(true); saveHapsPicMenuItem.setEnabled(true); }catch (IOException ioe){} } else if (command == "Exit"){ System.exit(0); } } |
|
else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-haps")) { | else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-haps")) { | private void argHandler(String[] args){ argHandlerMessages = new Vector(); int maxDistance = -1; //this means that user didn't specify any output type if it doesn't get changed below blockOutputType = -1; double hapThresh = -1; double minimumMAF=-1; double spacingThresh = -1; double minimumGenoPercent = -1; double hwCutoff = -1; double missingCutoff = -1; int maxMendel = -1; boolean assocTDT = false; boolean assocCC = false; permutationCount = 0; tagging = Tagger.NONE; maxNumTags = Tagger.DEFAULT_MAXNUMTAGS; findTags = true; double cutHighCI = -1; double cutLowCI = -1; double mafThresh = -1; double recHighCI = -1; double informFrac = -1; double fourGameteCutoff = -1; double spineDP = -1; for(int i =0; i < args.length; i++) { if(args[i].equalsIgnoreCase("-help") || args[i].equalsIgnoreCase("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equalsIgnoreCase("-n") || args[i].equalsIgnoreCase("-nogui")) { nogui = true; } else if(args[i].equalsIgnoreCase("-log")){ i++; if (i >= args.length || args[i].charAt(0) == '-'){ logName = "haploview.log"; i--; }else{ logName = args[i]; } } else if(args[i].equalsIgnoreCase("-p") || args[i].equalsIgnoreCase("-pedfile")) { i++; if( i>=args.length || (args[i].charAt(0) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(pedFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-pcloadletter")){ die("PC LOADLETTER?! What the fuck does that mean?!"); } else if (args[i].equalsIgnoreCase("-skipcheck") || args[i].equalsIgnoreCase("--skipcheck")){ skipCheck = true; } else if (args[i].equalsIgnoreCase("-excludeMarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ die("-excludeMarkers requires a list of markers"); } else { StringTokenizer str = new StringTokenizer(args[i],","); try { StringBuffer sb = new StringBuffer(); if (!quietMode) sb.append("Excluding markers: "); while(str.hasMoreTokens()) { String token = str.nextToken(); if(token.indexOf("..") != -1) { int lastIndex = token.indexOf(".."); int rangeStart = Integer.parseInt(token.substring(0,lastIndex)); int rangeEnd = Integer.parseInt(token.substring(lastIndex+2,token.length())); for(int j=rangeStart;j<=rangeEnd;j++) { if (!quietMode) sb.append(j+" "); excludedMarkers.add(new Integer(j)); } } else { if (!quietMode) sb.append(token+" "); excludedMarkers.add(new Integer(token)); } } argHandlerMessages.add(sb.toString()); } catch(NumberFormatException nfe) { die("-excludeMarkers argument should be of the format: 1,3,5..8,12"); } } } else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-haps")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapsFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-i") || args[i].equalsIgnoreCase("-info")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(infoFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-hapmap")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapmapFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpdata")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpdataFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap data file listed will be used"); } phasedhmpdataFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpsample")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpsampleFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap sample file listed will be used"); } phasedhmpsampleFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmplegend")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmplegendFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap legend file listed will be used"); } phasedhmplegendFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhapmapdl")){ phasedhapmapDownload = true; } else if (args[i].equalsIgnoreCase("-plink")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last PLINK file listed will be used"); } plinkFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-map")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last map file listed will be used"); } mapFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-k") || args[i].equalsIgnoreCase("-blocks")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; blockOutputType = BLOX_CUSTOM; }else{ die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-png")){ outputPNG = true; } else if (args[i].equalsIgnoreCase("-smallpng") || args[i].equalsIgnoreCase("-compressedPNG")){ outputCompressedPNG = true; } else if (args[i].equalsIgnoreCase("-track")){ i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ trackFileName = args[i]; }else{ die("-track requires a filename"); } } else if(args[i].equalsIgnoreCase("-o") || args[i].equalsIgnoreCase("-output") || args[i].equalsIgnoreCase("-blockoutput")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(blockOutputType != -1){ die("Only one block output type argument is allowed."); } if(args[i].equalsIgnoreCase("SFS") || args[i].equalsIgnoreCase("GAB")){ blockOutputType = BLOX_GABRIEL; } else if(args[i].equalsIgnoreCase("GAM")){ blockOutputType = BLOX_4GAM; } else if(args[i].equalsIgnoreCase("MJD") || args[i].equalsIgnoreCase("SPI")){ blockOutputType = BLOX_SPINE; } else if(args[i].equalsIgnoreCase("ALL")) { blockOutputType = BLOX_ALL; } } else { //defaults to SFS output blockOutputType = BLOX_GABRIEL; i--; } } else if(args[i].equalsIgnoreCase("-d") || args[i].equalsIgnoreCase("--dprime") || args[i].equalsIgnoreCase("-dprime")) { outputDprime = true; } else if (args[i].equalsIgnoreCase("-c") || args[i].equalsIgnoreCase("-check")){ outputCheck = true; } else if (args[i].equalsIgnoreCase("-indcheck")){ individualCheck = true; } else if (args[i].equalsIgnoreCase("-mendel")){ mendel = true; } else if (args[i].equalsIgnoreCase("-malehets")){ malehets = true; } else if(args[i].equalsIgnoreCase("-m") || args[i].equalsIgnoreCase("-maxdistance")) { i++; maxDistance = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-batch")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(batchFileName != null){ argHandlerMessages.add("multiple " + args[i-1] + " arguments found. only last batch file listed will be used"); } batchFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-hapthresh")) { i++; hapThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-spacing")) { i++; spacingThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-minMAF")) { i++; minimumMAF = getDoubleArg(args,i,0,0.5); } else if(args[i].equalsIgnoreCase("-minGeno") || args[i].equalsIgnoreCase("-minGenoPercent")) { i++; minimumGenoPercent = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-hwcutoff")) { i++; hwCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-maxMendel") ) { i++; maxMendel = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-missingcutoff")) { i++; missingCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-assoctdt")) { assocTDT = true; } else if(args[i].equalsIgnoreCase("-assoccc")) { assocCC = true; } else if(args[i].equalsIgnoreCase("-randomcc")){ assocCC = true; randomizeAffection = true; } else if(args[i].equalsIgnoreCase("-ldcolorscheme")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(args[i].equalsIgnoreCase("default")){ Options.setLDColorScheme(STD_SCHEME); } else if(args[i].equalsIgnoreCase("RSQ")){ Options.setLDColorScheme(RSQ_SCHEME); } else if(args[i].equalsIgnoreCase("DPALT") ){ Options.setLDColorScheme(WMF_SCHEME); } else if(args[i].equalsIgnoreCase("GAB")) { Options.setLDColorScheme(GAB_SCHEME); } else if(args[i].equalsIgnoreCase("GAM")) { Options.setLDColorScheme(GAM_SCHEME); } else if(args[i].equalsIgnoreCase("GOLD")) { Options.setLDColorScheme(GOLD_SCHEME); } } else { //defaults to STD color scheme Options.setLDColorScheme(STD_SCHEME); i--; } } else if(args[i].equalsIgnoreCase("-blockCutHighCI")) { i++; cutHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockCutLowCI")) { i++; cutLowCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockMafThresh")) { i++; mafThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockRecHighCI")) { i++; recHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockInformFrac")) { i++; informFrac = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-block4GamCut")) { i++; fourGameteCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockSpineDP")) { i++; spineDP = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-permtests")) { i++; doPermutationTest = true; permutationCount = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-customassoc")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ customAssocTestsFileName = args[i]; }else{ die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-aggressiveTagging")) { tagging = Tagger.AGGRESSIVE_TRIPLE; } else if (args[i].equalsIgnoreCase("-pairwiseTagging")){ tagging = Tagger.PAIRWISE_ONLY; } else if (args[i].equalsIgnoreCase("-printalltags")){ Options.setPrintAllTags(true); } else if(args[i].equalsIgnoreCase("-maxNumTags")){ i++; maxNumTags = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-tagrSqCutoff")) { i++; tagRSquaredCutOff = getDoubleArg(args,i,0,1); } else if (args[i].equalsIgnoreCase("-dontaddtags")){ findTags = false; } else if(args[i].equalsIgnoreCase("-tagLODCutoff")) { i++; Options.setTaggerLODCutoff(getDoubleArg(args,i,0,100000)); } else if(args[i].equalsIgnoreCase("-includeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die(args[i-1] + " requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceIncludeTags = new Vector(); while(str.hasMoreTokens()) { forceIncludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-includeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceIncludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-excludeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die("-excludeTags requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceExcludeTags = new Vector(); while(str.hasMoreTokens()) { forceExcludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-excludeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceExcludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-captureAlleles")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { captureAllelesFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-designScores")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { designScoresFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-mintagdistance")){ i++; minTagDistance = args[i]; } else if(args[i].equalsIgnoreCase("-chromosome") || args[i].equalsIgnoreCase("-chr")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { chromosomeArg =args[i]; }else { die(args[i-1] + " requires a chromosome name"); } if(!(chromosomeArg.equalsIgnoreCase("X")) && !(chromosomeArg.equalsIgnoreCase("Y"))){ try{ if (Integer.parseInt(chromosomeArg) > 22){ die("-chromosome requires a chromsome name of 1-22, X, or Y"); } }catch(NumberFormatException nfe){ die("-chromosome requires a chromsome name of 1-22, X, or Y"); } } } else if(args[i].equalsIgnoreCase("-population")){ i++; if(!(i>=args.length) && !(args[i].charAt(0)== '-')) { populationArg = args[i]; }else { die(args[i-1] + "requires a population name"); } } else if(args[i].equalsIgnoreCase("-startpos")){ i++; startPos = args[i]; } else if(args[i].equalsIgnoreCase("-endPos")){ i++; endPos = args[i]; } else if(args[i].equalsIgnoreCase("-release")){ i++; release = args[i]; } else if(args[i].equalsIgnoreCase("-q") || args[i].equalsIgnoreCase("-quiet")) { quietMode = true; } else if(args[i].equalsIgnoreCase("-gzip")){ Options.setGzip(true); } else { die("invalid parameter specified: " + args[i]); } } if (logName != null){ logString = "*****************************************************\n" + TITLE_STRING + "\tJava Version: " + JAVA_VERSION + "\n*****************************************************\n\n\n" + "Arguments:\t"; for (int i = 0; i < args.length; i++){ logString = logString + args[i] + "\t"; } logString = logString + "\n\n"; } int countOptions = 0; if(pedFileName != null) { countOptions++; } if(hapsFileName != null) { countOptions++; } if(hapmapFileName != null) { countOptions++; } if(phasedhmpdataFileName != null) { countOptions++; if(phasedhmpsampleFileName == null){ die("You must specify a sample file for phased hapmap input."); }else if(phasedhmplegendFileName == null){ die("You must specify a legend file for phased hapmap input."); } } if(phasedhapmapDownload) { countOptions++; } if(plinkFileName != null){ countOptions++; if(mapFileName == null){ die("You must specify a map file for plink format input."); } } if(batchFileName != null) { countOptions++; } if(countOptions > 1) { die("Only one genotype input file may be specified on the command line."); } else if(countOptions == 0 && nogui) { die("You must specify a genotype input file."); } //mess with vars, set defaults, etc if(skipCheck) { argHandlerMessages.add("Skipping genotype file check"); } if(maxDistance == -1){ maxDistance = MAXDIST_DEFAULT; }else{ argHandlerMessages.add("Max LD comparison distance = " +maxDistance + "kb"); } Options.setMaxDistance(maxDistance); if(hapThresh != -1) { Options.setHaplotypeDisplayThreshold(hapThresh); argHandlerMessages.add("Haplotype display threshold = " + hapThresh); } if(minimumMAF != -1) { CheckData.mafCut = minimumMAF; argHandlerMessages.add("Minimum MAF = " + minimumMAF); } if(minimumGenoPercent != -1) { CheckData.failedGenoCut = (int)(minimumGenoPercent*100); argHandlerMessages.add("Minimum SNP genotype % = " + minimumGenoPercent); } if(hwCutoff != -1) { CheckData.hwCut = hwCutoff; argHandlerMessages.add("Hardy Weinberg equilibrium p-value cutoff = " + hwCutoff); } if(maxMendel != -1) { CheckData.numMendErrCut = maxMendel; argHandlerMessages.add("Maximum number of Mendel errors = "+maxMendel); } if(spacingThresh != -1) { Options.setSpacingThreshold(spacingThresh); argHandlerMessages.add("LD display spacing value = "+spacingThresh); } if(missingCutoff != -1) { Options.setMissingThreshold(missingCutoff); argHandlerMessages.add("Maximum amount of missing data allowed per individual = "+missingCutoff); } if(cutHighCI != -1) { FindBlocks.cutHighCI = cutHighCI; } if(cutLowCI != -1) { FindBlocks.cutLowCI = cutLowCI; } if(mafThresh != -1) { FindBlocks.mafThresh = mafThresh; } if(recHighCI != -1) { FindBlocks.recHighCI = recHighCI; } if(informFrac != -1) { FindBlocks.informFrac = informFrac; } if(fourGameteCutoff != -1) { FindBlocks.fourGameteCutoff = fourGameteCutoff; } if(spineDP != -1) { FindBlocks.spineDP = spineDP; } if(assocTDT) { Options.setAssocTest(ASSOC_TRIO); }else if(assocCC) { Options.setAssocTest(ASSOC_CC); } if (Options.getAssocTest() != ASSOC_NONE && infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when performing association tests."); } if(doPermutationTest) { if(!assocCC && !assocTDT) { die("An association test type must be specified for permutation tests to be performed."); } } if(customAssocTestsFileName != null) { if(!assocCC && !assocTDT) { die("An association test type must be specified when using a custom association test file."); } if(infoFileName == null) { die("A marker info file must be specified when using a custom association test file."); } } if(tagging != Tagger.NONE) { if(infoFileName == null && hapmapFileName == null && batchFileName == null && phasedhmpdataFileName == null && !phasedhapmapDownload) { die("A marker info file must be specified when tagging."); } if(forceExcludeTags == null) { forceExcludeTags = new Vector(); } else if (forceExcludeFileName != null) { die("-excludeTags and -excludeTagsFile cannot both be used"); } if(forceExcludeFileName != null) { File excludeFile = new File(forceExcludeFileName); forceExcludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(excludeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceExcludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -excludeTagsFile."); } } if(forceIncludeTags == null ) { forceIncludeTags = new Vector(); } else if (forceIncludeFileName != null) { die("-includeTags and -includeTagsFile cannot both be used"); } if(forceIncludeFileName != null) { File includeFile = new File(forceIncludeFileName); forceIncludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(includeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceIncludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -includeTagsFile."); } } if (captureAllelesFileName != null) { File captureFile = new File(captureAllelesFileName); captureAlleleTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(captureFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ line = line.trim(); captureAlleleTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (designScoresFileName != null) { File designFile = new File(designScoresFileName); designScores = new Hashtable(1,1); try { BufferedReader br = new BufferedReader(new FileReader(designFile)); String line; int lines = 0; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ StringTokenizer st = new StringTokenizer(line); int length = st.countTokens(); if (length != 2){ die("Invalid formatting on line " + lines); } String marker = st.nextToken(); Double score = new Double(st.nextToken()); designScores.put(marker,score); } lines++; } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (minTagDistance != null) { try{ if (Integer.parseInt(minTagDistance) < 0){ die("minimum tag distance cannot be negative"); } }catch(NumberFormatException nfe){ die("minimum tag distance must be a positive integer"); } Options.setTaggerMinDistance(Integer.parseInt(minTagDistance)); } //check that there isn't any overlap between include/exclude lists Vector tempInclude = (Vector) forceIncludeTags.clone(); tempInclude.retainAll(forceExcludeTags); if(tempInclude.size() > 0) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < tempInclude.size(); i++) { String s = (String) tempInclude.elementAt(i); sb.append(s).append(","); } die("The following markers appear in both the include and exclude lists: " + sb.toString()); } if(tagRSquaredCutOff != -1) { Options.setTaggerRsqCutoff(tagRSquaredCutOff); } } else if(forceExcludeTags != null || forceIncludeTags != null || tagRSquaredCutOff != -1) { die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without a tagging option"); } if(chromosomeArg != null && hapmapFileName != null) { argHandlerMessages.add("-chromosome flag ignored when loading hapmap file"); chromosomeArg = null; } if(chromosomeArg != null) { Chromosome.setDataChrom("chr" + chromosomeArg); }else{ chromosomeArg = ""; } if (phasedhapmapDownload){ if (chromosomeArg == null){ die("-phasedhapmapdl requires a chromosome specification"); }else if (!(populationArg.equalsIgnoreCase("CEU") || populationArg.equalsIgnoreCase("YRI") || populationArg.equalsIgnoreCase("CHB+JPT"))){ die("-phasedhapmapdl requires a population specification of CEU, YRI, or CHB+JPT"); } if (Integer.parseInt(chromosomeArg) < 1 && Integer.parseInt(chromosomeArg) > 22){ if (!(chromosomeArg.equalsIgnoreCase("X")) && !(chromosomeArg.equalsIgnoreCase("Y"))){ die("-chromosome must be betweeen 1 and 22, X, or Y"); } } try{ if (Integer.parseInt(startPos) > Integer.parseInt(endPos)){ die("-endpos must be greater then -startpos"); } }catch(NumberFormatException nfe){ die("-startpos and -endpos must be integer values"); } if (release == null){ release = "21"; } if (!(release.equals("21")) && !(release.startsWith("16"))){ die("release must be either 16a or 21"); } } } |
UserActivityLogger.getInstance().logActivity(userName, userName+" logged out successfully"); | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { Subject subject = context.getSubject(); if(subject != null){ LoginContext loginContext = new LoginContext(AuthConstants.AUTH_CONFIG_INDEX, subject, new LoginCallbackHandler()); loginContext.logout(); context.removeSubject(); } return mapping.findForward(Forwards.SUCCESS); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.