rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
System.out.println("Usage: Jelly scriptFile [outputFile]"); | System.out.println("Usage: jelly [scriptFile] [-script scriptFile -o outputFile -Dsysprop=syspropval]"); | public static void main(String[] args) throws Exception { try { if (args.length <= 0) { System.out.println("Usage: Jelly scriptFile [outputFile]"); return; } Jelly jelly = new Jelly(); jelly.setScript(args[0]); // later we might wanna add some command line arguments // checking stuff using commons-cli to specify the output file // and input file via command line arguments final XMLOutput output = (args.length > 1) ? XMLOutput.createXMLOutput(new FileWriter(args[1])) : XMLOutput.createXMLOutput(System.out); Script script = jelly.compileScript(); // add the system properties and the command line arguments JellyContext context = jelly.getJellyContext(); context.setVariable("args", args); script.run(context, output); // now lets wait for all threads to close Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { output.close(); } catch (Exception e) { // ignore errors } } } ); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause != null) { cause.printStackTrace(); } else { e.printStackTrace(); } } } |
jelly.setScript(args[0]); final XMLOutput output = (args.length > 1) ? XMLOutput.createXMLOutput(new FileWriter(args[1])) : XMLOutput.createXMLOutput(System.out); | jelly.setScript(scriptFile); | public static void main(String[] args) throws Exception { try { if (args.length <= 0) { System.out.println("Usage: Jelly scriptFile [outputFile]"); return; } Jelly jelly = new Jelly(); jelly.setScript(args[0]); // later we might wanna add some command line arguments // checking stuff using commons-cli to specify the output file // and input file via command line arguments final XMLOutput output = (args.length > 1) ? XMLOutput.createXMLOutput(new FileWriter(args[1])) : XMLOutput.createXMLOutput(System.out); Script script = jelly.compileScript(); // add the system properties and the command line arguments JellyContext context = jelly.getJellyContext(); context.setVariable("args", args); script.run(context, output); // now lets wait for all threads to close Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { output.close(); } catch (Exception e) { // ignore errors } } } ); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause != null) { cause.printStackTrace(); } else { e.printStackTrace(); } } } |
context.setVariable("commandLine", cmdLine); | public static void main(String[] args) throws Exception { try { if (args.length <= 0) { System.out.println("Usage: Jelly scriptFile [outputFile]"); return; } Jelly jelly = new Jelly(); jelly.setScript(args[0]); // later we might wanna add some command line arguments // checking stuff using commons-cli to specify the output file // and input file via command line arguments final XMLOutput output = (args.length > 1) ? XMLOutput.createXMLOutput(new FileWriter(args[1])) : XMLOutput.createXMLOutput(System.out); Script script = jelly.compileScript(); // add the system properties and the command line arguments JellyContext context = jelly.getJellyContext(); context.setVariable("args", args); script.run(context, output); // now lets wait for all threads to close Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { output.close(); } catch (Exception e) { // ignore errors } } } ); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause != null) { cause.printStackTrace(); } else { e.printStackTrace(); } } } |
|
setModified(true); | public void componentMoveEnd(PlayPenComponentEvent e) { // TODO Auto-generated method stub } |
|
setModified(false); | public void load(InputStream in) throws IOException, ArchitectException { dbcsIdMap = new HashMap(); objectIdMap = new HashMap(); // use digester to read from file try { setupDigester().parse(in); } catch (SAXException ex) { logger.error("SAX Exception in config file parse!", ex); throw new ArchitectException("Syntax error in Project file", ex); } catch (IOException ex) { logger.error("IO Exception in config file parse!", ex); throw new ArchitectException("I/O Error", ex); } catch (Exception ex) { logger.error("General Exception in config file parse!", ex); throw new ArchitectException("Unexpected Exception", ex); } ((SQLObject) sourceDatabases.getModel().getRoot()).addChild(0, playPen.getDatabase()); } |
|
SQLDatabase mydb = new SQLDatabase(db.getDataSource()); Connection con = mydb.getConnection(); Statement stmt = con.createStatement(); try { stmt.executeUpdate("DROP TABLE REGRESSION_TEST1"); stmt.executeUpdate("DROP TABLE REGRESSION_TEST2"); } catch (SQLException sqle ){ System.out.println("+++ TestSQLDatabase exception should be for dropping a non-existant table"); sqle.printStackTrace(); } stmt.executeUpdate("CREATE TABLE REGRESSION_TEST1 (t1_c1 numeric(10))"); stmt.executeUpdate("CREATE TABLE REGRESSION_TEST2 (t2_c1 char(10))"); stmt.close(); mydb.disconnect(); | protected void setUp() throws Exception { super.setUp(); SQLDatabase mydb = new SQLDatabase(db.getDataSource()); Connection con = mydb.getConnection(); /* * Setting up a clean db for each of the tests */ Statement stmt = con.createStatement(); try { stmt.executeUpdate("DROP TABLE REGRESSION_TEST1"); stmt.executeUpdate("DROP TABLE REGRESSION_TEST2"); } catch (SQLException sqle ){ System.out.println("+++ TestSQLDatabase exception should be for dropping a non-existant table"); sqle.printStackTrace(); } stmt.executeUpdate("CREATE TABLE REGRESSION_TEST1 (t1_c1 numeric(10))"); stmt.executeUpdate("CREATE TABLE REGRESSION_TEST2 (t2_c1 char(10))"); stmt.close(); mydb.disconnect(); } |
|
orderings.add(OrderedProperty.get(prop, null)); | orderings.add(OrderedProperty.get(prop, Direction.ASCENDING)); | protected QueryExecutor<UserAddress> addressExecutor() throws Exception { Storage<UserAddress> addressStorage = mRepository.storageFor(UserAddress.class); QueryExecutor<UserAddress> addressExecutor = new ScanQueryExecutor<UserAddress>(addressStorage.query()); addressExecutor = new FilteredQueryExecutor<UserAddress> (addressExecutor, Filter.filterFor(UserAddress.class, "state = ?")); StorableProperty<UserAddress> prop = StorableIntrospector .examine(UserAddress.class).getAllProperties().get("country"); List<OrderedProperty<UserAddress>> orderings = new ArrayList<OrderedProperty<UserAddress>>(); orderings.add(OrderedProperty.get(prop, null)); addressExecutor = new ArraySortedQueryExecutor<UserAddress> (addressExecutor, null, orderings); return addressExecutor; } |
assertEquals("address.country", userExecutor.getOrdering().get(0).toString()); | assertEquals("+address.country", userExecutor.getOrdering().get(0).toString()); | public void testJoin() throws Exception { QueryExecutor<UserAddress> addressExecutor = addressExecutor(); QueryExecutor<UserInfo> userExecutor = new JoinedQueryExecutor<UserAddress, UserInfo> (mRepository, UserInfo.class, "address", addressExecutor); assertEquals("address.state = ?", userExecutor.getFilter().toString()); assertEquals("address.country", userExecutor.getOrdering().get(0).toString()); // Create some addresses Storage<UserAddress> addressStorage = mRepository.storageFor(UserAddress.class); UserAddress addr = addressStorage.prepare(); addr.setAddressID(1); addr.setLine1("4567, 123 Street"); addr.setCity("Springfield"); addr.setState("IL"); addr.setCountry("USA"); addr.insert(); addr = addressStorage.prepare(); addr.setAddressID(2); addr.setLine1("1111 Apt 1, 1st Ave"); addr.setCity("Somewhere"); addr.setState("AA"); addr.setCountry("USA"); addr.setNeighborAddressID(1); addr.insert(); addr = addressStorage.prepare(); addr.setAddressID(3); addr.setLine1("9999"); addr.setCity("Chicago"); addr.setState("IL"); addr.setCountry("USA"); addr.insert(); // Create some users Storage<UserInfo> userStorage = mRepository.storageFor(UserInfo.class); UserInfo user = userStorage.prepare(); user.setUserID(1); user.setStateID(1); user.setFirstName("Bob"); user.setLastName("Loblaw"); user.setAddressID(1); user.insert(); user = userStorage.prepare(); user.setUserID(2); user.setStateID(1); user.setFirstName("Deb"); user.setLastName("Loblaw"); user.setAddressID(1); user.insert(); user = userStorage.prepare(); user.setUserID(3); user.setStateID(1); user.setFirstName("No"); user.setLastName("Body"); user.setAddressID(2); user.insert(); // Now do a basic join, finding everyone in IL. FilterValues<UserInfo> values = Filter .filterFor(UserInfo.class, "address.state = ?").initialFilterValues().with("IL"); Cursor<UserInfo> cursor = userExecutor.fetch(values); assertTrue(cursor.hasNext()); assertEquals(1, cursor.next().getUserID()); assertEquals(2, cursor.next().getUserID()); assertFalse(cursor.hasNext()); cursor.close(); assertEquals(2L, userExecutor.count(values)); // Now do a multi join, finding everyone with an explicit neighbor in IL. userExecutor = new JoinedQueryExecutor<UserAddress, UserInfo> (mRepository, UserInfo.class, "address.neighbor", addressExecutor); assertEquals("address.neighbor.state = ?", userExecutor.getFilter().toString()); assertEquals("address.neighbor.country", userExecutor.getOrdering().get(0).toString()); values = Filter .filterFor(UserInfo.class, "address.neighbor.state = ?") .initialFilterValues().with("IL"); cursor = userExecutor.fetch(values); assertTrue(cursor.hasNext()); assertEquals(3, cursor.next().getUserID()); assertFalse(cursor.hasNext()); cursor.close(); assertEquals(1L, userExecutor.count(values)); } |
assertEquals("address.neighbor.country", userExecutor.getOrdering().get(0).toString()); | assertEquals("+address.neighbor.country", userExecutor.getOrdering().get(0).toString()); | public void testJoin() throws Exception { QueryExecutor<UserAddress> addressExecutor = addressExecutor(); QueryExecutor<UserInfo> userExecutor = new JoinedQueryExecutor<UserAddress, UserInfo> (mRepository, UserInfo.class, "address", addressExecutor); assertEquals("address.state = ?", userExecutor.getFilter().toString()); assertEquals("address.country", userExecutor.getOrdering().get(0).toString()); // Create some addresses Storage<UserAddress> addressStorage = mRepository.storageFor(UserAddress.class); UserAddress addr = addressStorage.prepare(); addr.setAddressID(1); addr.setLine1("4567, 123 Street"); addr.setCity("Springfield"); addr.setState("IL"); addr.setCountry("USA"); addr.insert(); addr = addressStorage.prepare(); addr.setAddressID(2); addr.setLine1("1111 Apt 1, 1st Ave"); addr.setCity("Somewhere"); addr.setState("AA"); addr.setCountry("USA"); addr.setNeighborAddressID(1); addr.insert(); addr = addressStorage.prepare(); addr.setAddressID(3); addr.setLine1("9999"); addr.setCity("Chicago"); addr.setState("IL"); addr.setCountry("USA"); addr.insert(); // Create some users Storage<UserInfo> userStorage = mRepository.storageFor(UserInfo.class); UserInfo user = userStorage.prepare(); user.setUserID(1); user.setStateID(1); user.setFirstName("Bob"); user.setLastName("Loblaw"); user.setAddressID(1); user.insert(); user = userStorage.prepare(); user.setUserID(2); user.setStateID(1); user.setFirstName("Deb"); user.setLastName("Loblaw"); user.setAddressID(1); user.insert(); user = userStorage.prepare(); user.setUserID(3); user.setStateID(1); user.setFirstName("No"); user.setLastName("Body"); user.setAddressID(2); user.insert(); // Now do a basic join, finding everyone in IL. FilterValues<UserInfo> values = Filter .filterFor(UserInfo.class, "address.state = ?").initialFilterValues().with("IL"); Cursor<UserInfo> cursor = userExecutor.fetch(values); assertTrue(cursor.hasNext()); assertEquals(1, cursor.next().getUserID()); assertEquals(2, cursor.next().getUserID()); assertFalse(cursor.hasNext()); cursor.close(); assertEquals(2L, userExecutor.count(values)); // Now do a multi join, finding everyone with an explicit neighbor in IL. userExecutor = new JoinedQueryExecutor<UserAddress, UserInfo> (mRepository, UserInfo.class, "address.neighbor", addressExecutor); assertEquals("address.neighbor.state = ?", userExecutor.getFilter().toString()); assertEquals("address.neighbor.country", userExecutor.getOrdering().get(0).toString()); values = Filter .filterFor(UserInfo.class, "address.neighbor.state = ?") .initialFilterValues().with("IL"); cursor = userExecutor.fetch(values); assertTrue(cursor.hasNext()); assertEquals(3, cursor.next().getUserID()); assertFalse(cursor.hasNext()); cursor.close(); assertEquals(1L, userExecutor.count(values)); } |
public void run(Context context, XMLOutput output) throws Exception { if ( value != null ) { String text = value.evaluateAsString( context ); if ( text != null ) { output.write( text ); } } } | public void run(JellyContext context, XMLOutput output) throws Exception { if (value != null) { String text = value.evaluateAsString(context); if (text != null) { output.write(text); } } } | public void run(Context context, XMLOutput output) throws Exception { if ( value != null ) { String text = value.evaluateAsString( context ); if ( text != null ) { output.write( text ); } } } |
ham.setCountsOrRatios(SHOW_COUNTS); | ham.setCountsOrRatios(SHOW_HAP_COUNTS); | public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if(command.equals("Show CC counts")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_COUNTS); jtt.repaint(); } else if (command.equals("Show CC ratios")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_RATIOS); jtt.repaint(); } } |
else if (command.equals("Show CC ratios")) { | else if (command.equals("Show CC frequencies")) { | public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if(command.equals("Show CC counts")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_COUNTS); jtt.repaint(); } else if (command.equals("Show CC ratios")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_RATIOS); jtt.repaint(); } } |
ham.setCountsOrRatios(SHOW_RATIOS); | ham.setCountsOrRatios(SHOW_HAP_RATIOS); | public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if(command.equals("Show CC counts")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_COUNTS); jtt.repaint(); } else if (command.equals("Show CC ratios")) { HaplotypeAssociationModel ham = (HaplotypeAssociationModel)jtt.getTree().getModel(); ham.setCountsOrRatios(SHOW_RATIOS); jtt.repaint(); } } |
saveDprimeWriter.write(i + "\t" + j + "\t" + dPrimeTable[i][j] + "\t" + dist + "\n"); | saveDprimeWriter.write((i+1) + "\t" + (j+1) + "\t" + dPrimeTable[i][j] + "\t" + dist + "\n"); | public void saveDprimeToText(String[][] dPrimeTable, File dumpDprimeFile, boolean info, Vector markerinfo) throws IOException{ FileWriter saveDprimeWriter = new FileWriter(dumpDprimeFile); if (info){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; for (int i = 0; i < dPrimeTable.length; i++){ for (int j = 0; j < dPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = ((SNP)markerinfo.elementAt(j)).getPosition() - ((SNP)markerinfo.elementAt(i)).getPosition(); saveDprimeWriter.write(i + "\t" + j + "\t" + dPrimeTable[i][j] + "\t" + dist + "\n"); } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); for (int i = 0; i < dPrimeTable.length; i++){ for (int j = 0; j < dPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ saveDprimeWriter.write(i + "\t" + j + "\t" + dPrimeTable[i][j] + "\n"); } } } } saveDprimeWriter.close(); } |
saveDprimeWriter.write(i + "\t" + j + "\t" + dPrimeTable[i][j] + "\n"); | saveDprimeWriter.write((i+1) + "\t" + (j+1) + "\t" + dPrimeTable[i][j] + "\n"); | public void saveDprimeToText(String[][] dPrimeTable, File dumpDprimeFile, boolean info, Vector markerinfo) throws IOException{ FileWriter saveDprimeWriter = new FileWriter(dumpDprimeFile); if (info){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; for (int i = 0; i < dPrimeTable.length; i++){ for (int j = 0; j < dPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = ((SNP)markerinfo.elementAt(j)).getPosition() - ((SNP)markerinfo.elementAt(i)).getPosition(); saveDprimeWriter.write(i + "\t" + j + "\t" + dPrimeTable[i][j] + "\t" + dist + "\n"); } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); for (int i = 0; i < dPrimeTable.length; i++){ for (int j = 0; j < dPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ saveDprimeWriter.write(i + "\t" + j + "\t" + dPrimeTable[i][j] + "\n"); } } } } saveDprimeWriter.close(); } |
String[] inputs = {null,null,fullName}; | String[] inputs = {null,null,fullName,null}; | public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals("Filter")){ doFilters(); }else if (command.equals("top filter")){ numResults = Integer.parseInt(topField.getText()); doTopFilter(); }else if (command.equals("Reset Filters")){ clearFilters(); }else if (command.equals("Load Additional Results")){ HaploView.fc.setSelectedFile(new File("")); int returned = HaploView.fc.showOpenDialog(this); if (returned != JFileChooser.APPROVE_OPTION) return; File file = HaploView.fc.getSelectedFile(); String fullName = file.getParent()+File.separator+file.getName(); String[] inputs = {null,null,fullName}; hv.readWGA(inputs); }else if (command.equals("Go to Selected Region")){ gotoRegion(); } } |
registerTag("subscribe", SubscribeTag.class); | public JMSTagLibrary() { registerTag("connection", ConnectionTag.class); registerTag("destination", DestinationTag.class); registerTag("mapEntry", MapEntryTag.class); registerTag("mapMessage", MapMessageTag.class); registerTag("message", MessageTag.class); registerTag("objectMessage", ObjectMessageTag.class); registerTag("property", PropertyTag.class); registerTag("receive", ReceiveTag.class); registerTag("send", SendTag.class); registerTag("textMessage", TextMessageTag.class); } |
|
getBody().run(context, output); | invokeBody(output); | public void doTag(XMLOutput output) throws Exception { connection = MessengerManager.get( name ); if ( var != null ) { context.setVariable( var, connection ); } getBody().run(context, output); } |
System.out.println(TITLE_STRING); | public HaploText(String[] args) { this.argHandler(args); if(!this.arg_batchMode.equals("")) { this.doBatch(); } if(!(this.arg_pedfile.equals("")) || !(this.arg_hapsfile.equals("")) || !(this.arg_hapmapfile.equals(""))){ if(arg_nogui){ processTextOnly(); } } } |
|
&& !outputDprime && !outputCheck) { | && !outputDprime && !outputCheck && !outputPNG && !outputSmallPNG) { | private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; String hapmapFileName = ""; String blockFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; boolean outputCheck=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } //todo: fix ignoremarkers /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha") || args[i].equals("-l")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equals("-a")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-a requires a filename"); System.exit(1); } else{ if(!hapmapFileName.equals("")){ System.out.println("multiple -a arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equals("-k")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; outputType = BLOX_CUSTOM; }else{ System.out.println("-k requires a filename"); System.exit(1); } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one output argument is allowed"); System.exit(1); } if(args[i].equals("SFS") || args[i].equals("GAB")){ outputType = BLOX_GABRIEL; } else if(args[i].equals("GAM")){ outputType = BLOX_4GAM; } else if(args[i].equals("MJD") || args[i].equals("SPI")){ outputType = BLOX_SPINE; } else if(args[i].equals("ALL")) { outputType = BLOX_ALL; } } else { //defaults to SFS output outputType = BLOX_GABRIEL; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = true; } else if (args[i].equals("-c")){ outputCheck = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("") || !hapmapFileName.equals("")) && !outputDprime && !outputCheck) { outputType = BLOX_GABRIEL; if(nogui && !quietMode) { System.out.println("No output type specified. Default of Gabriel will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_hapmapfile = hapmapFileName; arg_blockfile = blockFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; arg_check = outputCheck; } |
arg_png = outputPNG; arg_smallpng = outputSmallPNG; | private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; String hapmapFileName = ""; String blockFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; boolean outputCheck=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } //todo: fix ignoremarkers /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha") || args[i].equals("-l")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equals("-a")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-a requires a filename"); System.exit(1); } else{ if(!hapmapFileName.equals("")){ System.out.println("multiple -a arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equals("-k")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; outputType = BLOX_CUSTOM; }else{ System.out.println("-k requires a filename"); System.exit(1); } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one output argument is allowed"); System.exit(1); } if(args[i].equals("SFS") || args[i].equals("GAB")){ outputType = BLOX_GABRIEL; } else if(args[i].equals("GAM")){ outputType = BLOX_4GAM; } else if(args[i].equals("MJD") || args[i].equals("SPI")){ outputType = BLOX_SPINE; } else if(args[i].equals("ALL")) { outputType = BLOX_ALL; } } else { //defaults to SFS output outputType = BLOX_GABRIEL; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = true; } else if (args[i].equals("-c")){ outputCheck = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("") || !hapmapFileName.equals("")) && !outputDprime && !outputCheck) { outputType = BLOX_GABRIEL; if(nogui && !quietMode) { System.out.println("No output type specified. Default of Gabriel will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_hapmapfile = hapmapFileName; arg_blockfile = blockFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; arg_check = outputCheck; } |
|
private void processFile(String fileName,int fileType,String infoFileName){ System.out.println(TITLE_STRING); | private void processFile(String fileName, int fileType, String infoFileName){ | private void processFile(String fileName,int fileType,String infoFileName){ System.out.println(TITLE_STRING); try { int outputType; long maxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; outputType = this.arg_output; textData = new HaploData(0); Vector result = null; if(fileType == 0){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == 1) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ result = textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile result = textData.linkageToChrom(inputFile,4,arg_skipCheck); } File infoFile; if(infoFileName.equals("")) { infoFile = null; }else{ infoFile = new File(infoFileName); } if (result != null){ textData.prepareMarkerInput(infoFile,maxDistance,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,maxDistance,null); } if(!arg_quiet && infoFile != null){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; if(this.arg_showCheck && result != null) { CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(null); } if(this.arg_check && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(new File (fileName + ".CHECK")); } Vector cust = new Vector(); if(outputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; switch(outputType){ case BLOX_GABRIEL: OutputFile = new File(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = new File(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = new File(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = new File(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(arg_blockfile); cust = textData.readBlocks(blocksFile); break; default: OutputFile = new File(fileName + ".GABRIELblocks"); break; } //this handles output type ALL int start = 0; int stop = Chromosome.getFilteredSize(); if(outputType == BLOX_ALL) { OutputFile = new File(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType, cust); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getFilteredSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getFilteredSize()); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
textData.infoKnown = true; | private void processFile(String fileName,int fileType,String infoFileName){ System.out.println(TITLE_STRING); try { int outputType; long maxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; outputType = this.arg_output; textData = new HaploData(0); Vector result = null; if(fileType == 0){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == 1) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ result = textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile result = textData.linkageToChrom(inputFile,4,arg_skipCheck); } File infoFile; if(infoFileName.equals("")) { infoFile = null; }else{ infoFile = new File(infoFileName); } if (result != null){ textData.prepareMarkerInput(infoFile,maxDistance,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,maxDistance,null); } if(!arg_quiet && infoFile != null){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; if(this.arg_showCheck && result != null) { CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(null); } if(this.arg_check && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(new File (fileName + ".CHECK")); } Vector cust = new Vector(); if(outputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; switch(outputType){ case BLOX_GABRIEL: OutputFile = new File(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = new File(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = new File(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = new File(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(arg_blockfile); cust = textData.readBlocks(blocksFile); break; default: OutputFile = new File(fileName + ".GABRIELblocks"); break; } //this handles output type ALL int start = 0; int stop = Chromosome.getFilteredSize(); if(outputType == BLOX_ALL) { OutputFile = new File(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType, cust); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getFilteredSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getFilteredSize()); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
|
if (this.arg_png || this.arg_smallpng){ OutputFile = new File(fileName + ".LD.PNG"); if (textData.filteredDPrimeTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (this.arg_trackName != null){ textData.readAnalysisTrack(new File(arg_trackName)); } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getSize(),this.arg_smallpng); try{ Jimi.putImage("image/png", i, OutputFile.getName()); }catch(JimiException je){ System.out.println(je.getMessage()); } } | private void processFile(String fileName,int fileType,String infoFileName){ System.out.println(TITLE_STRING); try { int outputType; long maxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; outputType = this.arg_output; textData = new HaploData(0); Vector result = null; if(fileType == 0){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == 1) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ result = textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile result = textData.linkageToChrom(inputFile,4,arg_skipCheck); } File infoFile; if(infoFileName.equals("")) { infoFile = null; }else{ infoFile = new File(infoFileName); } if (result != null){ textData.prepareMarkerInput(infoFile,maxDistance,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,maxDistance,null); } if(!arg_quiet && infoFile != null){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; if(this.arg_showCheck && result != null) { CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(null); } if(this.arg_check && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(new File (fileName + ".CHECK")); } Vector cust = new Vector(); if(outputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; switch(outputType){ case BLOX_GABRIEL: OutputFile = new File(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = new File(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = new File(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = new File(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(arg_blockfile); cust = textData.readBlocks(blocksFile); break; default: OutputFile = new File(fileName + ".GABRIELblocks"); break; } //this handles output type ALL int start = 0; int stop = Chromosome.getFilteredSize(); if(outputType == BLOX_ALL) { OutputFile = new File(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType, cust); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getFilteredSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getFilteredSize()); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
|
}else{ g.setColor(dullBlue); | public void paintComponent(Graphics graphics) { if (filteredHaplos == null){ super.paintComponent(graphics); return; } Graphics2D g = (Graphics2D) graphics; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //System.out.println(getSize()); Dimension size = getSize(); Dimension pref = getPreferredSize(); g.setColor(this.getBackground()); g.fillRect(0,0,pref.width, pref.height); if (!forExport){ g.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } //g.drawRect(0, 0, pref.width, pref.height); final BasicStroke thinStroke = new BasicStroke(0.5f); final BasicStroke thickStroke = new BasicStroke(2.0f); // width of one letter of the haplotype block //int letterWidth = haploMetrics.charWidth('G'); //int percentWidth = pctMetrics.stringWidth(".000"); //final int verticalOffset = 43; // room for tags and diamonds int left = BORDER; int top = BORDER; //verticalOffset; //int totalWidth = 0; // percentages for each haplotype NumberFormat nf = NumberFormat.getInstance(Locale.US); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); nf.setMinimumIntegerDigits(0); nf.setMaximumIntegerDigits(0); // multi reading, between the columns NumberFormat nfMulti = NumberFormat.getInstance(Locale.US); nfMulti.setMinimumFractionDigits(2); nfMulti.setMaximumFractionDigits(2); nfMulti.setMinimumIntegerDigits(0); nfMulti.setMaximumIntegerDigits(0); int[][] lookupPos = new int[filteredHaplos.length][]; for (int p = 0; p < lookupPos.length; p++) { lookupPos[p] = new int[filteredHaplos[p].length]; for (int q = 0; q < lookupPos[p].length; q++){ lookupPos[p][filteredHaplos[p][q].getListOrder()] = q; } } // set number formatter to pad with appropriate number of zeroes NumberFormat nfMarker = NumberFormat.getInstance(Locale.US); int markerCount = Chromosome.getSize(); // the +0.0000001 is because there is // some suckage where log(1000) / log(10) isn't actually 3 int markerDigits = (int) (0.0000001 + Math.log(markerCount) / Math.log(10)) + 1; nfMarker.setMinimumIntegerDigits(markerDigits); nfMarker.setMaximumIntegerDigits(markerDigits); //int tagShapeX[] = new int[3]; //int tagShapeY[] = new int[3]; //Polygon tagShape; int textRight = 0; // gets updated for scooting over // i = 0 to number of columns - 1 for (int i = 0; i < filteredHaplos.length; i++) { int[] markerNums = filteredHaplos[i][0].getMarkers(); boolean[] tags = filteredHaplos[i][0].getTags(); //int headerX = x; for (int z = 0; z < markerNums.length; z++) { //int tagMiddle = tagMetrics.getAscent() / 2; //int tagLeft = x + z*letterWidth + tagMiddle; //g.translate(tagLeft, 20); // if tag snp, draw little triangle pooper if (tags[z]) { g.drawImage(tagImage, left + z*CHAR_WIDTH, top + markerDigits*MARKER_CHAR_WIDTH + -(CHAR_HEIGHT - TAG_SPAN), null); } //g.rotate(-Math.PI / 2.0); //g.drawLine(0, 0, 0, 0); //g.setColor(Color.black); //g.drawString(nfMarker.format(markerNums[z]), 0, tagMiddle); char markerChars[] = nfMarker.format(Chromosome.realIndex[markerNums[z]]+1).toCharArray(); for (int m = 0; m < markerDigits; m++) { g.drawImage(markerNumImages[markerChars[m] - '0'], left + z*CHAR_WIDTH + (1 + CHAR_WIDTH - MARKER_CHAR_HEIGHT)/2, top + (markerDigits-m-1)*MARKER_CHAR_WIDTH, null); } // undo the transform.. no push/pop.. arrgh //g.rotate(Math.PI / 2.0); //g.translate(-tagLeft, -20); } // y position of the first image for the haplotype letter // top + the size of the marker digits + the size of the tag + // the character height centered in the row's height int above = top + markerDigits*MARKER_CHAR_WIDTH + TAG_SPAN + (ROW_HEIGHT - CHAR_HEIGHT) / 2; //figure out which allele is the major allele double[][] alleleCounts = new double[filteredHaplos[i][0].getGeno().length][9]; //zero this out for (int j = 0; j < alleleCounts.length; j++){ for (int k = 0; k < alleleCounts[j].length; k++){ alleleCounts[j][k] = 0; } } for (int j = 0; j < filteredHaplos[i].length; j++){ int curHapNum = lookupPos[i][j]; int[] theGeno = filteredHaplos[i][curHapNum].getGeno(); double theFreq = filteredHaplos[i][curHapNum].getPercentage(); for (int k = 0; k < theGeno.length; k++){ alleleCounts[k][theGeno[k]] += theFreq; } } int[] majorAllele = new int[filteredHaplos[i][0].getGeno().length]; for (int k = 0; k < majorAllele.length; k++){ double maj = 0; for (int z = 0; z < alleleCounts[k].length; z++){ if (alleleCounts[k][z] > maj){ majorAllele[k] = z; maj = alleleCounts[k][z]; } } } for (int j = 0; j < filteredHaplos[i].length; j++){ int curHapNum = lookupPos[i][j]; //String theHap = new String(); //String thePercentage = new String(); int[] theGeno = filteredHaplos[i][curHapNum].getGeno(); //getGeno(); // j is the row of haplotype for (int k = 0; k < theGeno.length; k++) { // theGeno[k] will be 1,2,3,4 (acgt) or 8 (for bad) if (alleleDisp == 0){ g.drawImage(charImages[theGeno[k] - 1], left + k*CHAR_WIDTH, above + j*ROW_HEIGHT, null); }else if (alleleDisp == 1){ g.drawImage(blackNumImages[theGeno[k]], left + k*CHAR_WIDTH, above + j*ROW_HEIGHT, null); }else{ if (theGeno[k] == majorAllele[k]){ g.setColor(dullRed); }else{ g.setColor(dullBlue); } g.fillRect(left + k*CHAR_WIDTH, above + j*ROW_HEIGHT + (ROW_HEIGHT - CHAR_WIDTH)/2, CHAR_WIDTH, CHAR_WIDTH); } } //draw the percentage value in non mono font double percent = filteredHaplos[i][curHapNum].getPercentage(); //thePercentage = " " + nf.format(percent); char percentChars[] = nf.format(percent).toCharArray(); // perhaps need an exceptional case for 1.0 being the percent for (int m = 0; m < percentChars.length; m++) { g.drawImage(grayNumImages[(m == 0) ? 10 : percentChars[m]-'0'], left + theGeno.length*CHAR_WIDTH + m*CHAR_WIDTH, above + j*ROW_HEIGHT, null); } // 4 is the number of chars in .999 for the percent textRight = left + theGeno.length*CHAR_WIDTH + 4*CHAR_WIDTH; g.setColor(Color.black); if (i < filteredHaplos.length - 1) { //draw crossovers for (int crossCount = 0; crossCount < filteredHaplos[i+1].length; crossCount++) { double crossVal = filteredHaplos[i][curHapNum].getCrossover(crossCount); //draw thin and thick lines int crossValue = (int) (crossVal*100); if (crossValue > thinThresh) { g.setStroke(crossValue > thickThresh ? thickStroke : thinStroke); int connectTo = filteredHaplos[i+1][crossCount].getListOrder(); g.drawLine(textRight + LINE_LEFT, above + j*ROW_HEIGHT + ROW_HEIGHT/2, textRight + LINE_RIGHT, above + connectTo*ROW_HEIGHT + ROW_HEIGHT/2); } } } } left = textRight; // add the multilocus d prime if appropriate if (i < filteredHaplos.length - 1) { //put the numbers in the right place vertically int depth; if (filteredHaplos[i].length > filteredHaplos[i+1].length){ depth = filteredHaplos[i].length; }else{ depth = filteredHaplos[i+1].length; } char multiChars[] = nfMulti.format(multidprimeArray[i]).toCharArray(); if (multidprimeArray[i] > 0.99){ //draw 1.0 vals specially g.drawImage(blackNumImages[1], left + (LINE_SPAN - 7*CHAR_WIDTH/2)/2 + CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); g.drawImage(blackNumImages[10], left + (LINE_SPAN - 9*CHAR_WIDTH/2)/2 + 2*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); g.drawImage(blackNumImages[0], left + (LINE_SPAN - 9*CHAR_WIDTH/2)/2 + 3*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); }else{ for (int m = 0; m < 3; m++) { g.drawImage(blackNumImages[(m == 0) ? 10 : multiChars[m]-'0'], left + (LINE_SPAN - 7*CHAR_WIDTH/2)/2 + m*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); } } } left += LINE_SPAN; } } |
|
public void run(Context context, XMLOutput output) throws Exception { | public void run(JellyContext context, XMLOutput output) throws Exception { | public void run(Context context, XMLOutput output) throws Exception { if ( trim && ! hasTrimmed ) { trimBody(); hasTrimmed = true; } if ( log.isDebugEnabled() ) { log.debug( "Running body: " + getBody() ); } getBody().run( context, output ); } |
try { | log.error( t.getMessage() ); t.printStackTrace(); try { | public static boolean initODMG( String user, String passwd, String dbName ) { getODMGImplementation(); db = odmg.newDatabase(); boolean success = false; try { log.debug( "Opening database" ); db.open( dbName + "#" + user + "#" + passwd, Database.OPEN_READ_WRITE ); log.debug( "Success!!!" ); } catch ( Exception e ) { log.error( "Failed to get connection" ); } // Test the connection by fetching something try { PhotoFolder folder = PhotoFolder.getRoot(); if ( folder != null ) { success = true; } else { log.error( "Could not open database connection" ); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } } } catch ( Throwable t ) { log.error( "Could not open database connection" ); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } } return ( success ); } |
registerTag("replaceNamespace", ReplaceNamespaceTag.class); | public XMLTagLibrary() { registerTag("out", ExprTag.class); registerTag("if", IfTag.class); registerTag("forEach", ForEachTag.class); registerTag("parse", ParseTag.class); registerTag("set", SetTag.class); registerTag("transform", TransformTag.class); registerTag("param", ParamTag.class); // extensions to JSTL registerTag("expr", ExprTag.class); registerTag("element", ElementTag.class); registerTag("attribute", AttributeTag.class); registerTag("copy", CopyTag.class); registerTag("copyOf", CopyOfTag.class); registerTag("comment", CommentTag.class); registerTag("doctype", DoctypeTag.class); registerTag("sort", SortTag.class); this.jexlFactory = new JexlExpressionFactory(); } |
|
dadTb[i] = 0; dadUb[i] = 0; | dadTb[i] = (byte)(4+dad1); dadUb[i] = (byte)(4+dad2); | public Vector linkageToChrom(File infile, int type) throws IllegalArgumentException, HaploViewException, PedFileException, IOException{ //okay, for now we're going to assume the ped file has no header Vector pedFileStrings = new Vector(); BufferedReader reader = new BufferedReader(new FileReader(infile)); String line; while((line = reader.readLine())!=null){ if (line.length() == 0){ //skip blank lines continue; } if (line.startsWith("#")){ //skip comments continue; } pedFileStrings.add(line); } pedFile = new PedFile(); if (type == PED){ pedFile.parseLinkage(pedFileStrings); }else{ pedFile.parseHapMap(pedFileStrings); } Vector result = pedFile.check(); Vector indList = pedFile.getOrder(); int numMarkers = 0; numSingletons = 0; numTrios = 0; numPeds = pedFile.getNumFamilies(); Individual currentInd; Family currentFamily; Vector usedParents = new Vector(); Vector chrom = new Vector(); Vector chromTrios = new Vector(); for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.elementAt(x); currentFamily = pedFile.getFamily(currentInd.getFamilyID()); byte[] zeroArray = {0,0}; if(!currentInd.hasEitherParent()){ if (!currentInd.hasKids()){ //ind has no parents or kids -- he's a singleton numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (currentInd.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = currentInd.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1, currentInd.getAffectedStatus())); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2,currentInd.getAffectedStatus())); numSingletons++; } }else if (currentInd.hasBothParents()){ //if indiv has both parents Individual mom = currentFamily.getMember(currentInd.getMomID()); Individual dad = currentFamily.getMember(currentInd.getDadID()); //but doesn't have grandparents (i.e. is the kid in a founding trio) //and his parents haven't already been counted if (!(mom.hasBothParents() || dad.hasBothParents()) && !(usedParents.contains(mom) || usedParents.contains(dad))){ //we note that we've used these founders so we won't re use them if more of their kids //are in the file usedParents.add(mom); usedParents.add(dad); numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (currentInd.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = currentInd.getMarker(i); } byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; if (currentFamily.getMember(currentInd.getMomID()).getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); } byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; if (currentFamily.getMember(currentInd.getDadID()).getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); } byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { //kid missing if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else if (dad1 != 0 && dad2 != 0) { dadTb[i] = 0; dadUb[i] = 0; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else if (mom1 != 0 && mom2 != 0){ momTb[i] = 0; momUb[i] = 0; } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadTb[i] = 0; dadUb[i] = 0; momTb[i] = (byte)(4+mom1); momUb[i] = (byte)(4+mom2); } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadTb[i] = (byte)(4+dad1); dadUb[i] = (byte)(4+dad2); momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { //everybody het dadTb[i] = (byte)(4+dad1); dadUb[i] = (byte)(4+dad2); momTb[i] = (byte)(4+mom1); momUb[i] = (byte)(4+mom2); } } } chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadTb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadUb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momTb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momUb, currentInd.getAffectedStatus())); numTrios++; }else if (mom.hasBothParents() && !dad.hasBothParents() && !usedParents.contains(dad)){ //in this case dad is a founder so we toss him in as a singleton. //this only happens in the bizarre case where we have grandparents on one side //of a family but not the other usedParents.add(dad); numMarkers = dad.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (dad.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = dad.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(dad.getFamilyID(),dad.getIndividualID(),chrom1,dad.getAffectedStatus())); chrom.add(new Chromosome(dad.getFamilyID(),dad.getIndividualID(),chrom2,dad.getAffectedStatus())); numSingletons++; }else if (dad.hasBothParents() && !mom.hasBothParents() && !usedParents.contains(mom)){ //in this case mom is a founder so we toss here in as a singleton //rarely occurs, see above usedParents.add(mom); numMarkers = mom.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (mom.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = mom.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(mom.getFamilyID(),mom.getIndividualID(),chrom1,mom.getAffectedStatus())); chrom.add(new Chromosome(mom.getFamilyID(),mom.getIndividualID(),chrom2,mom.getAffectedStatus())); numSingletons++; } } } chromTrios.addAll(chrom); chromosomes = chromTrios; //wipe clean any existing marker info so we know we're starting with a new file Chromosome.markers = null; return result; } |
momTb[i] = 0; momUb[i] = 0; | momTb[i] = (byte)(4+mom1); momUb[i] = (byte)(4+mom2); | public Vector linkageToChrom(File infile, int type) throws IllegalArgumentException, HaploViewException, PedFileException, IOException{ //okay, for now we're going to assume the ped file has no header Vector pedFileStrings = new Vector(); BufferedReader reader = new BufferedReader(new FileReader(infile)); String line; while((line = reader.readLine())!=null){ if (line.length() == 0){ //skip blank lines continue; } if (line.startsWith("#")){ //skip comments continue; } pedFileStrings.add(line); } pedFile = new PedFile(); if (type == PED){ pedFile.parseLinkage(pedFileStrings); }else{ pedFile.parseHapMap(pedFileStrings); } Vector result = pedFile.check(); Vector indList = pedFile.getOrder(); int numMarkers = 0; numSingletons = 0; numTrios = 0; numPeds = pedFile.getNumFamilies(); Individual currentInd; Family currentFamily; Vector usedParents = new Vector(); Vector chrom = new Vector(); Vector chromTrios = new Vector(); for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.elementAt(x); currentFamily = pedFile.getFamily(currentInd.getFamilyID()); byte[] zeroArray = {0,0}; if(!currentInd.hasEitherParent()){ if (!currentInd.hasKids()){ //ind has no parents or kids -- he's a singleton numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (currentInd.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = currentInd.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1, currentInd.getAffectedStatus())); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2,currentInd.getAffectedStatus())); numSingletons++; } }else if (currentInd.hasBothParents()){ //if indiv has both parents Individual mom = currentFamily.getMember(currentInd.getMomID()); Individual dad = currentFamily.getMember(currentInd.getDadID()); //but doesn't have grandparents (i.e. is the kid in a founding trio) //and his parents haven't already been counted if (!(mom.hasBothParents() || dad.hasBothParents()) && !(usedParents.contains(mom) || usedParents.contains(dad))){ //we note that we've used these founders so we won't re use them if more of their kids //are in the file usedParents.add(mom); usedParents.add(dad); numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (currentInd.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = currentInd.getMarker(i); } byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; if (currentFamily.getMember(currentInd.getMomID()).getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); } byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; if (currentFamily.getMember(currentInd.getDadID()).getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); } byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { //kid missing if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else if (dad1 != 0 && dad2 != 0) { dadTb[i] = 0; dadUb[i] = 0; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else if (mom1 != 0 && mom2 != 0){ momTb[i] = 0; momUb[i] = 0; } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadTb[i] = 0; dadUb[i] = 0; momTb[i] = (byte)(4+mom1); momUb[i] = (byte)(4+mom2); } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadTb[i] = (byte)(4+dad1); dadUb[i] = (byte)(4+dad2); momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { //everybody het dadTb[i] = (byte)(4+dad1); dadUb[i] = (byte)(4+dad2); momTb[i] = (byte)(4+mom1); momUb[i] = (byte)(4+mom2); } } } chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadTb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadUb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momTb, currentInd.getAffectedStatus())); chromTrios.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momUb, currentInd.getAffectedStatus())); numTrios++; }else if (mom.hasBothParents() && !dad.hasBothParents() && !usedParents.contains(dad)){ //in this case dad is a founder so we toss him in as a singleton. //this only happens in the bizarre case where we have grandparents on one side //of a family but not the other usedParents.add(dad); numMarkers = dad.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (dad.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = dad.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(dad.getFamilyID(),dad.getIndividualID(),chrom1,dad.getAffectedStatus())); chrom.add(new Chromosome(dad.getFamilyID(),dad.getIndividualID(),chrom2,dad.getAffectedStatus())); numSingletons++; }else if (dad.hasBothParents() && !mom.hasBothParents() && !usedParents.contains(mom)){ //in this case mom is a founder so we toss here in as a singleton //rarely occurs, see above usedParents.add(mom); numMarkers = mom.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker; if (mom.getZeroed(i)){ thisMarker = zeroArray; }else{ thisMarker = mom.getMarker(i); } if (thisMarker[0] == thisMarker[1] || thisMarker[0] == 0 || thisMarker[1] == 0){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = (byte)(4+thisMarker[0]); chrom2[i] = (byte)(4+thisMarker[1]); } } chrom.add(new Chromosome(mom.getFamilyID(),mom.getIndividualID(),chrom1,mom.getAffectedStatus())); chrom.add(new Chromosome(mom.getFamilyID(),mom.getIndividualID(),chrom2,mom.getAffectedStatus())); numSingletons++; } } } chromTrios.addAll(chrom); chromosomes = chromTrios; //wipe clean any existing marker info so we know we're starting with a new file Chromosome.markers = null; return result; } |
getBody().run( context, output); | invokeBody( output); | public void doTag(final XMLOutput output) throws Exception { getGoal(getName()).addPreActionCallback( new PreActionCallback() { public void firePreAction(Goal goal) throws Exception { // lets run the body log.debug( "Running pre action: " + getName() ); getBody().run( context, output); } } ); } |
getBody().run( context, output); | invokeBody( output); | public void firePreAction(Goal goal) throws Exception { // lets run the body log.debug( "Running pre action: " + getName() ); getBody().run( context, output); } |
System.out.println("No output type specified. Default of SFS will be used"); | System.out.println("No output type specified. Default of Gabriel will be used"); | private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; String hapmapFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; boolean outputCheck=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println("HaploView command line options\n" + "-h, -help print this message\n" + "-n command line output only\n" + "-q quiet mode- doesnt print any warnings or information to screen\n" + "-p <pedfile> specify an input file in pedigree file format\n" + " pedfile specific options (nogui mode only): \n" + " --showcheck displays the results of the various pedigree integrity checks\n" + " --skipcheck skips the various pedfile checks\n" + //TODO: fix ignoremarkers //" --ignoremarkers <markers> ignores the specified markers.<markers> is a comma\n" + //" seperated list of markers. eg. 1,5,7,19,25\n" + "-a <hapmapfile> specify an input file in HapMap format\n" + "-l <hapsfile> specify an input file in .haps format\n" + "-i <infofile> specify a marker info file\n" + "-b <batchfile> batch mode. batchfile should contain a list of files either all genotype or alternating genotype/info\n" + "-d outputs dprime to <inputfile>.DPRIME\n" + "-c outputs marker checks to <inputfile>.CHECK\n" + " note: -d and -c default to no blocks output. use -o to also output blocks\n" + "-o <GAB,GAM,SPI,ALL> output type. Gabriel, 4 gamete, spine output or all 3. default is Gabriel.\n" + "-m <distance> maximum comparison distance in kilobases (integer). default is 500"); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha") || args[i].equals("-l")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equals("-a")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-a requires a filename"); System.exit(1); } else{ if(!hapmapFileName.equals("")){ System.out.println("multiple -a arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one -o argument is allowed"); System.exit(1); } if(args[i].equals("SFS") || args[i].equals("GAB")){ outputType = BLOX_GABRIEL; } else if(args[i].equals("GAM")){ outputType = BLOX_4GAM; } else if(args[i].equals("MJD") || args[i].equals("SPI")){ outputType = BLOX_SPINE; } else if(args[i].equals("ALL")) { outputType = BLOX_ALL; } } else { //defaults to SFS output outputType = BLOX_GABRIEL; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = true; } else if (args[i].equals("-c")){ outputCheck = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("") || !hapmapFileName.equals("")) && !outputDprime && !outputCheck) { outputType = BLOX_GABRIEL; if(nogui && !quietMode) { System.out.println("No output type specified. Default of SFS will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_hapmapfile = hapmapFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; arg_check = outputCheck; } |
exportMenuItems[2].setEnabled(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]); } exportMenuItems[2].setEnabled(true); fileMenu.addSeparator(); fileMenu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem("Quit"); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); displayMenu.setMnemonic(KeyEvent.VK_D); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); viewMenuItems[i].setEnabled(false); group.add(viewMenuItems[i]); } displayMenu.addSeparator(); //a submenu ButtonGroup zg = new ButtonGroup(); JMenu zoomMenu = new JMenu("LD zoom"); zoomMenu.setMnemonic(KeyEvent.VK_Z); zoomMenuItems = new JRadioButtonMenuItem[zoomItems.length]; for (int i = 0; i < zoomItems.length; i++){ zoomMenuItems[i] = new JRadioButtonMenuItem(zoomItems[i], i==0); zoomMenuItems[i].addActionListener(this); zoomMenuItems[i].setActionCommand("zoom" + i); zoomMenu.add(zoomMenuItems[i]); zg.add(zoomMenuItems[i]); } displayMenu.add(zoomMenu); //another submenu ButtonGroup cg = new ButtonGroup(); JMenu colorMenu = new JMenu("LD color scheme"); colorMenu.setMnemonic(KeyEvent.VK_C); colorMenuItems = new JRadioButtonMenuItem[colorItems.length]; for (int i = 0; i< colorItems.length; i++){ colorMenuItems[i] = new JRadioButtonMenuItem(colorItems[i],i==0); colorMenuItems[i].addActionListener(this); colorMenuItems[i].setActionCommand("color" + i); colorMenu.add(colorMenuItems[i]); cg.add(colorMenuItems[i]); } displayMenu.add(colorMenu); //analysis menu JMenu analysisMenu = new JMenu("Analysis"); analysisMenu.setMnemonic(KeyEvent.VK_A); menuBar.add(analysisMenu); //a submenu ButtonGroup bg = new ButtonGroup(); JMenu blockMenu = new JMenu("Define Blocks"); blockMenu.setMnemonic(KeyEvent.VK_B); blockMenuItems = new JRadioButtonMenuItem[blockItems.length]; for (int i = 0; i < blockItems.length; i++){ blockMenuItems[i] = new JRadioButtonMenuItem(blockItems[i], i==0); blockMenuItems[i].addActionListener(this); blockMenuItems[i].setActionCommand("block" + i); blockMenu.add(blockMenuItems[i]); bg.add(blockMenuItems[i]); } blockMenuItems[3].setEnabled(false); analysisMenu.add(blockMenu); clearBlocksItem = new JMenuItem(CLEAR_BLOCKS); setAccelerator(clearBlocksItem, 'C', false); clearBlocksItem.addActionListener(this); clearBlocksItem.setEnabled(false); analysisMenu.add(clearBlocksItem); JMenuItem customizeBlocksItem = new JMenuItem(CUST_BLOCKS); customizeBlocksItem.addActionListener(this); analysisMenu.add(customizeBlocksItem); //color key keyMenu = new JMenu("Key"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(keyMenu); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); addComponentListener(new ResizeListener()); } |
|
if (format == PNG_MODE){ | if (format == PNG_MODE || format == COMPRESSED_PNG_MODE){ | void export(int tabNum, int format, int start, int stop){ fc.setSelectedFile(new File("")); if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){ File outfile = fc.getSelectedFile(); if (format == PNG_MODE){ BufferedImage image; if (tabNum == VIEW_D_NUM){ image = dPrimeDisplay.export(start, stop); }else if (tabNum == VIEW_HAP_NUM){ image = hapDisplay.export(); }else{ image = new BufferedImage(1,1,BufferedImage.TYPE_3BYTE_BGR); } try{ String filename = outfile.getPath(); if (! (filename.endsWith(".png") || filename.endsWith(".PNG"))){ filename += ".png"; } Jimi.putImage("image/png", image, filename); }catch(JimiException je){ JOptionPane.showMessageDialog(this, je.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } else if (format == TXT_MODE){ try{ if (tabNum == VIEW_D_NUM){ theData.saveDprimeToText(outfile, TABLE_TYPE, start, stop); }else if (tabNum == VIEW_HAP_NUM){ theData.saveHapsToText(hapDisplay.filteredHaplos,hapDisplay.multidprimeArray, outfile); }else if (tabNum == VIEW_CHECK_NUM){ checkPanel.printTable(outfile); }else if (tabNum == VIEW_TDT_NUM){ JTable table = tdtPanel.getTable(); FileWriter checkWriter = new FileWriter(outfile); int numCols = table.getColumnCount(); StringBuffer header = new StringBuffer(); for (int i = 0; i < numCols; i++){ header.append(table.getColumnName(i)).append("\t"); } header.append("\n"); checkWriter.write(header.toString()); for (int i = 0; i < table.getRowCount(); i++){ StringBuffer sb = new StringBuffer(); for (int j = 0; j < numCols; j++){ sb.append(table.getValueAt(i,j)).append("\t"); } sb.append("\n"); checkWriter.write(sb.toString()); } checkWriter.close(); } }catch(IOException ioe){ JOptionPane.showMessageDialog(this, ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } } |
image = dPrimeDisplay.export(start, stop); | if (format == PNG_MODE){ image = dPrimeDisplay.export(start, stop, false); }else{ image = dPrimeDisplay.export(start, stop, true); } | void export(int tabNum, int format, int start, int stop){ fc.setSelectedFile(new File("")); if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){ File outfile = fc.getSelectedFile(); if (format == PNG_MODE){ BufferedImage image; if (tabNum == VIEW_D_NUM){ image = dPrimeDisplay.export(start, stop); }else if (tabNum == VIEW_HAP_NUM){ image = hapDisplay.export(); }else{ image = new BufferedImage(1,1,BufferedImage.TYPE_3BYTE_BGR); } try{ String filename = outfile.getPath(); if (! (filename.endsWith(".png") || filename.endsWith(".PNG"))){ filename += ".png"; } Jimi.putImage("image/png", image, filename); }catch(JimiException je){ JOptionPane.showMessageDialog(this, je.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } else if (format == TXT_MODE){ try{ if (tabNum == VIEW_D_NUM){ theData.saveDprimeToText(outfile, TABLE_TYPE, start, stop); }else if (tabNum == VIEW_HAP_NUM){ theData.saveHapsToText(hapDisplay.filteredHaplos,hapDisplay.multidprimeArray, outfile); }else if (tabNum == VIEW_CHECK_NUM){ checkPanel.printTable(outfile); }else if (tabNum == VIEW_TDT_NUM){ JTable table = tdtPanel.getTable(); FileWriter checkWriter = new FileWriter(outfile); int numCols = table.getColumnCount(); StringBuffer header = new StringBuffer(); for (int i = 0; i < numCols; i++){ header.append(table.getColumnName(i)).append("\t"); } header.append("\n"); checkWriter.write(header.toString()); for (int i = 0; i < table.getRowCount(); i++){ StringBuffer sb = new StringBuffer(); for (int j = 0; j < numCols; j++){ sb.append(table.getValueAt(i,j)).append("\t"); } sb.append("\n"); checkWriter.write(sb.toString()); } checkWriter.close(); } }catch(IOException ioe){ JOptionPane.showMessageDialog(this, ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } } |
exportMenuItems[2].setEnabled(true); | void readGenotypes(String[] inputOptions, int type){ //input is a 3 element array with //inputOptions[0] = ped file //inputOptions[1] = info file ("" if none) //inputOptions[2] = max comparison distance (don't compute d' if markers are greater than this dist apart) //type is either 3 or 4 for ped and hapmap files respectively final File inFile = new File(inputOptions[0]); //deal with max comparison distance if (inputOptions[2].equals("")){ inputOptions[2] = "0"; } maxCompDist = Long.parseLong(inputOptions[2])*1000; try { if (inFile.length() < 1){ throw new HaploViewException("Genotype file is empty or nonexistent: " + inFile.getName()); } if (type == HAPS){ //these are not available for non ped files viewMenuItems[VIEW_CHECK_NUM].setEnabled(false); viewMenuItems[VIEW_TDT_NUM].setEnabled(false); assocTest = 0; } theData = new HaploData(assocTest); if (type == HAPS){ theData.prepareHapsInput(new File(inputOptions[0])); }else{ theData.linkageToChrom(inFile, type); } //deal with marker information theData.infoKnown = false; File markerFile; if (inputOptions[1].equals("")){ markerFile = null; }else{ markerFile = new File(inputOptions[1]); } checkPanel = null; if (type == HAPS){ readMarkers(markerFile, null); }else{ readMarkers(markerFile, theData.getPedFile().getHMInfo()); checkPanel = new CheckDataPanel(theData); checkPanel.setAlignmentX(Component.CENTER_ALIGNMENT); } //let's start the math this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; changeKey(1); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); //theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first colorMenuItems[0].setSelected(true); blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(window); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); viewMenuItems[VIEW_D_NUM].setEnabled(true); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); //LOD panel /*panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); LODDisplay ld = new LODDisplay(theData); JScrollPane lodScroller = new JScrollPane(ld); panel.add(lodScroller); tabs.addTab(viewItems[VIEW_LOD_NUM], panel); viewMenuItems[VIEW_LOD_NUM].setEnabled(true);*/ //int optionalTabCount = 1; //check data panel if (checkPanel != null){ //optionalTabCount++; //VIEW_CHECK_NUM = optionalTabCount; //viewItems[VIEW_CHECK_NUM] = VIEW_CHECK_PANEL; JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //TDT panel if(assocTest > 0) { //optionalTabCount++; //VIEW_TDT_NUM = optionalTabCount; //viewItems[VIEW_TDT_NUM] = VIEW_TDT; tdtPanel = new TDTPanel(theData.chromosomes, assocTest); tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inFile.getName()); return null; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); for (int i = 0; i < blockMenuItems.length; i++){ blockMenuItems[i].setEnabled(true); } clearBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); blocksItem.setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); worker.start(); timer.start(); }catch(IOException ioexec) { JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } catch(PedFileException pfe){ JOptionPane.showMessageDialog(this, pfe.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (HaploViewException hve){ JOptionPane.showMessageDialog(this, hve.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } } |
|
exportMenuItems[2].setEnabled(true); | public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); for (int i = 0; i < blockMenuItems.length; i++){ blockMenuItems[i].setEnabled(true); } clearBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); blocksItem.setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } |
|
return genotypes[i]; | return genotypes[realIndex[i]]; | public byte elementAt(int i){ return genotypes[i]; } |
public int size(){ return genotypes.length; | public static int size(){ return realIndex.length; | public int size(){ return genotypes.length; } |
private void deleteReplica(S replica) throws PersistException { | void deleteReplica(Storable replica) throws PersistException { | private void deleteReplica(S replica) throws PersistException { // Disable replication to prevent trigger from being invoked by // deleting replica. setReplicationDisabled(true); try { replica.tryDelete(); } finally { setReplicationDisabled(false); } } |
replica.tryDelete(); | replica.delete(); | private void deleteReplica(S replica) throws PersistException { // Disable replication to prevent trigger from being invoked by // deleting replica. setReplicationDisabled(true); try { replica.tryDelete(); } finally { setReplicationDisabled(false); } } |
public void run(Context context, XMLOutput output) throws Exception { | public void run(JellyContext context, XMLOutput output) throws Exception { | public void run(Context context, XMLOutput output) throws Exception { if ( select != null ) { Iterator iter = select.selectNodes(null).iterator(); while ( iter.hasNext() ) { Object value = iter.next(); if (var != null) { context.setVariable( var, value ); } getBody().run( context, output ); } } } |
public void run(Context context, XMLOutput output) throws Exception { | public void run(JellyContext context, XMLOutput output) throws Exception { | public void run(Context context, XMLOutput output) throws Exception { for ( int i = 0, size = whenTags.length; i < size; i++ ) { TagScript script = whenTags[i]; script.run( context, output ); WhenTag tag = (WhenTag) script.getTag(); if ( tag.getValue() ) { return; } } if ( otherwiseTag != null ) { otherwiseTag.run( context, output ); } } |
int index = attribute.indexOf('.'); | final int index = attribute.indexOf(COMPOSITE_ATTR_SEPARATOR); | private String getAttributeType(ServerConnection connection, ObjectAttributeInfo[] objAttributes, String attribute, ObjectName objectName){ String itemName = null; int index = attribute.indexOf('.'); if(index != -1){ itemName = attribute.substring(index + 1); attribute = attribute.substring(0, index); } for(int i=0; i<objAttributes.length; i++){ if(objAttributes[i].getName().equals(attribute)){ if(itemName != null){ // it is a CompositeData type CompositeType type = getCompositeType(connection, objectName, objAttributes[i]); return type.getType(itemName).getClassName(); } return objAttributes[i].getType(); } } throw new ServiceException(ErrorCodes.INVALID_MBEAN_ATTRIBUTE, attribute, objectName); } |
} for(int i=0; i<objAttributes.length; i++){ if(objAttributes[i].getName().equals(attribute)){ if(itemName != null){ | for(int i=0; i<objAttributes.length; i++){ if(objAttributes[i].getName().equals(attribute)){ | private String getAttributeType(ServerConnection connection, ObjectAttributeInfo[] objAttributes, String attribute, ObjectName objectName){ String itemName = null; int index = attribute.indexOf('.'); if(index != -1){ itemName = attribute.substring(index + 1); attribute = attribute.substring(0, index); } for(int i=0; i<objAttributes.length; i++){ if(objAttributes[i].getName().equals(attribute)){ if(itemName != null){ // it is a CompositeData type CompositeType type = getCompositeType(connection, objectName, objAttributes[i]); return type.getType(itemName).getClassName(); } return objAttributes[i].getType(); } } throw new ServiceException(ErrorCodes.INVALID_MBEAN_ATTRIBUTE, attribute, objectName); } |
return objAttributes[i].getType(); | private String getAttributeType(ServerConnection connection, ObjectAttributeInfo[] objAttributes, String attribute, ObjectName objectName){ String itemName = null; int index = attribute.indexOf('.'); if(index != -1){ itemName = attribute.substring(index + 1); attribute = attribute.substring(0, index); } for(int i=0; i<objAttributes.length; i++){ if(objAttributes[i].getName().equals(attribute)){ if(itemName != null){ // it is a CompositeData type CompositeType type = getCompositeType(connection, objectName, objAttributes[i]); return type.getType(itemName).getClassName(); } return objAttributes[i].getType(); } } throw new ServiceException(ErrorCodes.INVALID_MBEAN_ATTRIBUTE, attribute, objectName); } |
|
String itemName = null; int index = attribute.indexOf("."); String attributeName = attribute; if(index != -1){ attributeName = attribute.substring(0, index); itemName = attribute.substring(index + 1); | List attrList = connection.getAttributes(context.getObjectName(), new String[]{attribute}); ObjectAttribute attrValue = (ObjectAttribute)attrList.get(0); if(attrValue.getStatus() != ObjectAttribute.STATUS_NOT_FOUND){ return attrValue; | public ObjectAttribute getObjectAttribute(ServiceContext context, String attribute) throws ServiceException{ assert context.getObjectName() != null; assert context.getApplicationConfig() != null; canAccessThisMBean(context); AccessController.checkAccess(context, ACLConstants.ACL_VIEW_MBEAN_ATTRIBUTES, attribute); // we don't support clustering here assert !context.getApplicationConfig().isCluster(); ServerConnection connection = context.getServerConnection(); String itemName = null; int index = attribute.indexOf("."); String attributeName = attribute; if(index != -1){ // composite data attribute attributeName = attribute.substring(0, index); itemName = attribute.substring(index + 1); } List attrList = connection.getAttributes(context.getObjectName(), new String[]{attributeName}); ObjectAttribute attrValue = (ObjectAttribute)attrList.get(0); if(itemName != null){ CompositeData compositeData = (CompositeData)attrValue.getValue(); attrValue = new ObjectAttribute(attribute, compositeData.get(itemName)); } return attrValue; } |
List attrList = | String attributeName = null; String itemName = null; int index = attribute.indexOf(COMPOSITE_ATTR_SEPARATOR); if(index == -1) return attrValue; itemName = attribute.substring(index + 1); attributeName = attribute.substring(0, index); attrList = | public ObjectAttribute getObjectAttribute(ServiceContext context, String attribute) throws ServiceException{ assert context.getObjectName() != null; assert context.getApplicationConfig() != null; canAccessThisMBean(context); AccessController.checkAccess(context, ACLConstants.ACL_VIEW_MBEAN_ATTRIBUTES, attribute); // we don't support clustering here assert !context.getApplicationConfig().isCluster(); ServerConnection connection = context.getServerConnection(); String itemName = null; int index = attribute.indexOf("."); String attributeName = attribute; if(index != -1){ // composite data attribute attributeName = attribute.substring(0, index); itemName = attribute.substring(index + 1); } List attrList = connection.getAttributes(context.getObjectName(), new String[]{attributeName}); ObjectAttribute attrValue = (ObjectAttribute)attrList.get(0); if(itemName != null){ CompositeData compositeData = (CompositeData)attrValue.getValue(); attrValue = new ObjectAttribute(attribute, compositeData.get(itemName)); } return attrValue; } |
ObjectAttribute attrValue = (ObjectAttribute)attrList.get(0); if(itemName != null){ | attrValue = (ObjectAttribute)attrList.get(0); if(attrValue.getStatus() == ObjectAttribute.STATUS_OK){ | public ObjectAttribute getObjectAttribute(ServiceContext context, String attribute) throws ServiceException{ assert context.getObjectName() != null; assert context.getApplicationConfig() != null; canAccessThisMBean(context); AccessController.checkAccess(context, ACLConstants.ACL_VIEW_MBEAN_ATTRIBUTES, attribute); // we don't support clustering here assert !context.getApplicationConfig().isCluster(); ServerConnection connection = context.getServerConnection(); String itemName = null; int index = attribute.indexOf("."); String attributeName = attribute; if(index != -1){ // composite data attribute attributeName = attribute.substring(0, index); itemName = attribute.substring(index + 1); } List attrList = connection.getAttributes(context.getObjectName(), new String[]{attributeName}); ObjectAttribute attrValue = (ObjectAttribute)attrList.get(0); if(itemName != null){ CompositeData compositeData = (CompositeData)attrValue.getValue(); attrValue = new ObjectAttribute(attribute, compositeData.get(itemName)); } return attrValue; } |
new ObjectAttributeInfo(attrInfo.getName() + "." + itemName, | new ObjectAttributeInfo( attrInfo.getName() + COMPOSITE_ATTR_SEPARATOR + itemName, | private void handleCompositeData(ServerConnection connection, ObjectName objectName, ObjectAttributeInfo attrInfo, String[] dataTypes, List attributesList){ CompositeType type = getCompositeType(connection, objectName, attrInfo); for(Iterator it=type.keySet().iterator(); it.hasNext(); ){ String itemName = (String)it.next(); OpenType itemType = type.getType(itemName); Class itemTypeClass = getClass(itemType.getClassName(), this.getClass().getClassLoader()); for(int j=0; j<dataTypes.length; j++){ Class dataType = getClass(dataTypes[j], this.getClass().getClassLoader()); if(dataType.isAssignableFrom(itemTypeClass)){ attributesList.add( new ObjectAttributeInfo(attrInfo.getName() + "." + itemName, type.getDescription(itemName), itemType.getClassName(), false, true, false)); } } } } |
int id = Integer.parseInt(let.toString()); | int id = let.getIdentifier().intValue(); | public PresentationObject getLettersHeads() { Table T = new Table(); if (letters != null && letters.size() > 0) { Iterator iter = letters.iterator(); EmailLetter let; int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); row++; Link link; while (iter.hasNext()) { let = (EmailLetter) iter.next(); int id = Integer.parseInt(let.toString()); if (id == letter) theLetter = let; link = getStyleLink(let.getSubject(), SN_SUBJ); link.addParameter(prmTopic, String.valueOf(topic)); link.addParameter(prmLetter, String.valueOf(let.toString())); T.add(link, 1, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } return T; } |
link.addParameter(prmLetter, String.valueOf(let.toString())); | link.addParameter(prmLetter, String.valueOf(let.getIdentifier().toString())); | public PresentationObject getLettersHeads() { Table T = new Table(); if (letters != null && letters.size() > 0) { Iterator iter = letters.iterator(); EmailLetter let; int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); row++; Link link; while (iter.hasNext()) { let = (EmailLetter) iter.next(); int id = Integer.parseInt(let.toString()); if (id == letter) theLetter = let; link = getStyleLink(let.getSubject(), SN_SUBJ); link.addParameter(prmTopic, String.valueOf(topic)); link.addParameter(prmLetter, String.valueOf(let.toString())); T.add(link, 1, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } return T; } |
int id = Integer.parseInt(tpc.toString()); | int id = tpc.getIdentifier().intValue(); | private PresentationObject getTopics() { Table T = new Table(); //T.add(getStyleText(iwrb.getLocalizedString("topic","Topic"),SN_TITLE),1,1); //T.add(getStyleText(iwrb.getLocalizedString("issue","Issue"),SN_TITLE),2,1); if (topics != null && topics.size() > 0) { Iterator iter = topics.iterator(); EmailTopic tpc; Link link; int row = 2; while (iter.hasNext()) { tpc = (EmailTopic) iter.next(); int id = Integer.parseInt(tpc.toString()); if (letter > 0) { if (topic == id) { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; } } } } else { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (topic > 0 && topic == id) { //T.add(getLettersHeads(),2,row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); //row++; Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; subject = getStyleLink(let.getSubject(), SN_SUBJ); subject.addParameter(prmTopic, String.valueOf(topic)); subject.addParameter(prmLetter, String.valueOf(let.toString())); T.add(subject, 2, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } } } } } return T; } |
link.addParameter(prmTopic, tpc.toString()); | link.addParameter(prmTopic, tpc.getIdentifier().toString()); | private PresentationObject getTopics() { Table T = new Table(); //T.add(getStyleText(iwrb.getLocalizedString("topic","Topic"),SN_TITLE),1,1); //T.add(getStyleText(iwrb.getLocalizedString("issue","Issue"),SN_TITLE),2,1); if (topics != null && topics.size() > 0) { Iterator iter = topics.iterator(); EmailTopic tpc; Link link; int row = 2; while (iter.hasNext()) { tpc = (EmailTopic) iter.next(); int id = Integer.parseInt(tpc.toString()); if (letter > 0) { if (topic == id) { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; } } } } else { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (topic > 0 && topic == id) { //T.add(getLettersHeads(),2,row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); //row++; Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; subject = getStyleLink(let.getSubject(), SN_SUBJ); subject.addParameter(prmTopic, String.valueOf(topic)); subject.addParameter(prmLetter, String.valueOf(let.toString())); T.add(subject, 2, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } } } } } return T; } |
int lid = Integer.parseInt(let.toString()); | int lid = let.getIdentifier().intValue(); | private PresentationObject getTopics() { Table T = new Table(); //T.add(getStyleText(iwrb.getLocalizedString("topic","Topic"),SN_TITLE),1,1); //T.add(getStyleText(iwrb.getLocalizedString("issue","Issue"),SN_TITLE),2,1); if (topics != null && topics.size() > 0) { Iterator iter = topics.iterator(); EmailTopic tpc; Link link; int row = 2; while (iter.hasNext()) { tpc = (EmailTopic) iter.next(); int id = Integer.parseInt(tpc.toString()); if (letter > 0) { if (topic == id) { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; } } } } else { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (topic > 0 && topic == id) { //T.add(getLettersHeads(),2,row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); //row++; Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; subject = getStyleLink(let.getSubject(), SN_SUBJ); subject.addParameter(prmTopic, String.valueOf(topic)); subject.addParameter(prmLetter, String.valueOf(let.toString())); T.add(subject, 2, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } } } } } return T; } |
subject.addParameter(prmLetter, String.valueOf(let.toString())); | subject.addParameter(prmLetter, let.getIdentifier().toString()); | private PresentationObject getTopics() { Table T = new Table(); //T.add(getStyleText(iwrb.getLocalizedString("topic","Topic"),SN_TITLE),1,1); //T.add(getStyleText(iwrb.getLocalizedString("issue","Issue"),SN_TITLE),2,1); if (topics != null && topics.size() > 0) { Iterator iter = topics.iterator(); EmailTopic tpc; Link link; int row = 2; while (iter.hasNext()) { tpc = (EmailTopic) iter.next(); int id = Integer.parseInt(tpc.toString()); if (letter > 0) { if (topic == id) { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; } } } } else { link = getStyleLink(tpc.getName(), SN_TOPIC); link.addParameter(prmTopic, tpc.toString()); T.add(link, 1, row++); if (topic > 0 && topic == id) { //T.add(getLettersHeads(),2,row++); if (letters != null && letters.size() > 0) { Iterator iter2 = letters.iterator(); EmailLetter let; //int row = 1; //T.add(getStyleText(iwrb.getLocalizedString("from","From"),SN_TITLE),1,row); //T.add(getStyleText(iwrb.getLocalizedString("subject","Subject"),SN_TITLE),2,row); //row++; Link subject; while (iter2.hasNext()) { let = (EmailLetter) iter2.next(); int lid = Integer.parseInt(let.toString()); if (lid == letter) theLetter = let; subject = getStyleLink(let.getSubject(), SN_SUBJ); subject.addParameter(prmTopic, String.valueOf(topic)); subject.addParameter(prmLetter, String.valueOf(let.toString())); T.add(subject, 2, row); //T.add(getStyleText(let.getFromName(),SN_FROM),2,row); row++; } } } } } } return T; } |
topic = Integer.parseInt(((EmailTopic) topics.iterator().next()).toString()); | topic =(((EmailTopic) topics.iterator().next()).getIdentifier().intValue()); | public void main(IWContext iwc) { iwb = getBundle(iwc); core = iwc.getApplication().getCoreBundle(); iwrb = getResourceBundle(iwc); Table T = new Table(); int row = 1; df = DateFormat.getDateInstance(DateFormat.LONG, iwc.getCurrentLocale()); if (iwc.isParameterSet(prmTopic)) { topic = Integer.parseInt(iwc.getParameter(prmTopic)); } if (iwc.isParameterSet(prmLetter)) { letter = Integer.parseInt(iwc.getParameter(prmLetter)); } if(iwc.isParameterSet(prmLetterDelete) && letter >0){ MailBusiness.getInstance().deleteLetter(letter); } if (getCategoryId() > 0) { topics = MailFinder.getInstance().getTopics(this.getICObjectInstanceID()); if (topic > 0) letters = MailFinder.getInstance().getEmailLetters(topic); } if (iwc.hasEditPermission(this)) { T.add(getAdminView(iwc), 1, row); T.setAlignment(1, row, "left"); T.mergeCells(1, row, 2, row); row++; } if (topics != null && !topics.isEmpty()) { T.add(getTopics(), 1, row++); if (topic < 0) topic = Integer.parseInt(((EmailTopic) topics.iterator().next()).toString()); } if (theLetter != null) T.add(getLetter(iwc), 2, row); T.setAlignment(1, 2, T.VERTICAL_ALIGN_TOP); T.setAlignment(2, 2, T.VERTICAL_ALIGN_TOP); Form F = new Form(); F.add(T); add(F); } |
Chromosome.setDataChrom("none"); | private void doBatch() { Vector files; File batchFile; File dataFile; String line; StringTokenizer tok; String infoMaybe =null; files = new Vector(); if(batchFileName == null) { return; } batchFile = new File(this.batchFileName); if(!batchFile.exists()) { System.out.println("batch file " + batchFileName + " does not exist"); System.exit(1); } if (!quietMode) System.out.println("Processing batch input file: " + batchFile); try { BufferedReader br = new BufferedReader(new FileReader(batchFile)); while( (line = br.readLine()) != null ) { files.add(line); } br.close(); for(int i = 0;i<files.size();i++){ line = (String)files.get(i); tok = new StringTokenizer(line); infoMaybe = null; if(tok.hasMoreTokens()){ dataFile = new File(tok.nextToken()); if(tok.hasMoreTokens()){ infoMaybe = tok.nextToken(); } if(dataFile.exists()) { String name = dataFile.getName(); if( name.substring(name.length()-4,name.length()).equalsIgnoreCase(".ped") ) { processFile(name,PED_FILE,infoMaybe); } else if(name.substring(name.length()-5,name.length()).equalsIgnoreCase(".haps")) { processFile(name,HAPS_FILE,infoMaybe); } else if(name.substring(name.length()-4,name.length()).equalsIgnoreCase(".hmp")){ processFile(name,HMP_FILE,null); } else{ if (!quietMode){ System.out.println("Filenames in batch file must end in .ped, .haps or .hmp\n" + name + " is not properly formatted."); } } } else { if(!quietMode){ System.out.println("file " + dataFile.getName() + " listed in the batch file could not be found"); } } } } } catch(FileNotFoundException e){ System.out.println("the following error has occured:\n" + e.toString()); } catch(IOException e){ System.out.println("the following error has occured:\n" + e.toString()); } } |
|
throw new RuntimeException("Notifications not supported"); | NotificationListener notifListener = (NotificationListener)notifications.remove(listener); NotificationFilter notifFilter = (NotificationFilter)notifFilters.remove(filter); assert notifListener != null; assert notifFilter != null; Class[] methodSignature = new Class[]{javax.management.ObjectName.class, NotificationListener.class, NotificationFilter.class, Object.class}; Object[] methodArgs = new Object[]{toJMXObjectName(objectName), notifListener, notifFilter, handback}; callMBeanServer("removeNotificationListener", methodSignature, methodArgs); | public void removeNotificationListener(ObjectName objectName, ObjectNotificationListener listener, ObjectNotificationFilter filter, Object handback){ throw new RuntimeException("Notifications not supported"); } |
resultData.setOutput(result.toString()); | resultData.setOutput(result != null?result.toString():"null"); | private static OperationResultData executeMBeanOperation( ServiceContext context, ApplicationConfig appConfig, ObjectName objectName, String operationName, String[] params, String[] signature){ OperationResultData resultData = new OperationResultData(appConfig.getName()); try { final ServerConnection serverConnection = ServerConnector.getServerConnection(appConfig); Object[] typedParams = CoreUtils.getTypedArray(params, signature); final Object result = serverConnection.invoke(objectName, operationName, typedParams, signature); resultData.setOutput(result.toString()); UserActivityLogger.getInstance().logActivity( context.getUser().getUsername(), "Performed "+operationName+" on "+objectName.getCanonicalName() + " in application " + appConfig.getName()); } catch (ConnectionFailedException e) { logger.log(Level.INFO, "Error executing operation " + operationName + " on " + objectName, e); resultData.setResult(OperationResultData.RESULT_ERROR); resultData.setErrorString(ErrorCatalog.getMessage(ErrorCodes.CONNECTION_FAILED)); } catch (Exception e){ logger.log(Level.SEVERE, "Error executing operation " + operationName + " on " + objectName, e); resultData.setResult(OperationResultData.RESULT_ERROR); resultData.setErrorString(e.getMessage()); } return resultData; } |
filter = Filter.filterFor(Shipment.class, "orderID > ?"); filter = filter.bind(); result = iqa.analyze(filter, null); assertTrue(result.handlesAnything()); assertTrue(result.getCompositeScore().getFilteringScore().hasRangeStart()); assertFalse(result.getCompositeScore().getFilteringScore().hasRangeEnd()); List<PropertyFilter<Shipment>> rangeFilters = result.getCompositeScore().getFilteringScore().getRangeStartFilters(); assertEquals(1, rangeFilters.size()); assertEquals(filter, rangeFilters.get(0)); assertEquals(makeIndex(Shipment.class, "orderID"), result.getLocalIndex()); assertEquals(null, result.getForeignIndex()); assertEquals(null, result.getForeignProperty()); | public void testBasic() throws Exception { IndexedQueryAnalyzer iqa = new IndexedQueryAnalyzer(Shipment.class, IxProvider.INSTANCE); Filter<Shipment> filter = Filter.filterFor(Shipment.class, "shipmentID = ?"); filter = filter.bind(); IndexedQueryAnalyzer.Result result = iqa.analyze(filter, null); assertTrue(result.handlesAnything()); assertEquals(filter, result.getCompositeScore().getFilteringScore().getIdentityFilter()); assertEquals(makeIndex(Shipment.class, "shipmentID"), result.getLocalIndex()); assertEquals(null, result.getForeignIndex()); assertEquals(null, result.getForeignProperty()); filter = Filter.filterFor(Shipment.class, "orderID = ?"); filter = filter.bind(); result = iqa.analyze(filter, null); assertTrue(result.handlesAnything()); assertEquals(filter, result.getCompositeScore().getFilteringScore().getIdentityFilter()); assertEquals(makeIndex(Shipment.class, "orderID"), result.getLocalIndex()); assertEquals(null, result.getForeignIndex()); assertEquals(null, result.getForeignProperty()); } |
|
public void doTag(XMLOutput output) throws Exception { | public void doTag(XMLOutput output) throws JellyTagException { | public void doTag(XMLOutput output) throws Exception { suite = createSuite(); TestSuite parent = (TestSuite) context.getVariable("org.apache.commons.jelly.junit.suite"); if ( parent == null ) { context.setVariable("org.apache.commons.jelly.junit.suite", suite ); } else { parent.addTest( suite ); } invokeBody(output); if ( var != null ) { context.setVariable(var, suite); } } |
if (skip == 5){ Chromosome.setDataBuild(s); } | public void parseHapMap(Vector lines, Vector hapsData) throws PedFileException { int colNum = -1; int numLines = lines.size(); if (numLines < 2){ throw new PedFileException("Hapmap data format error: empty file"); } if (hapsData != null){ String indName; for (int i=0; i < hapsData.size(); i++){ StringTokenizer db = new StringTokenizer((String)hapsData.get(i)); if (db.countTokens() < 6){ throw new PedFileException("Hapmap data format error: pedigree data on line " + (i+1) + "."); } if (db.countTokens() > 7){ throw new PedFileException("Hapmap data format error: pedigree data on line " + (i+1) + "."); } db.nextToken(); indName = db.nextToken(); hapMapTranslate.put(indName, (String)hapsData.get(i)); } } Individual ind; this.allIndividuals = new Vector(); //enumerate indivs StringTokenizer st = new StringTokenizer((String)lines.get(0), "\n\t\" \""); int numMetaColumns = 0; boolean doneMeta = false; boolean genoErrorB = false; while(!doneMeta && st.hasMoreTokens()){ String thisfield = st.nextToken(); numMetaColumns++; //first indiv ID will be a string beginning with "NA" if (thisfield.startsWith("NA")){ doneMeta = true; } } numMetaColumns--; st = new StringTokenizer((String)lines.get(0), "\n\t\" \""); for (int i = 0; i < numMetaColumns; i++){ st.nextToken(); } Vector namesIncludingDups = new Vector(); StringTokenizer dt; while (st.hasMoreTokens()){ //todo: sort out how this used to work. now it's counting the header line so we subtract 1 ind = new Individual(numLines-1); String name = st.nextToken(); namesIncludingDups.add(name); if (name.endsWith("dup")){ //skip dups (i.e. don't add 'em to ind array) continue; } String details = (String)hapMapTranslate.get(name); if (details == null){ throw new PedFileException("Hapmap data format error: " + name); } dt = new StringTokenizer(details, "\n\t\" \""); ind.setFamilyID(dt.nextToken().trim()); ind.setIndividualID(dt.nextToken().trim()); ind.setDadID(dt.nextToken().trim()); ind.setMomID(dt.nextToken().trim()); try { ind.setGender(Integer.parseInt(dt.nextToken().trim())); ind.setAffectedStatus(Integer.parseInt(dt.nextToken().trim())); }catch(NumberFormatException nfe) { throw new PedFileException("File error: invalid gender or affected status for indiv " + name); } //check if the family exists already in the Hashtable Family fam = (Family)this.families.get(ind.getFamilyID()); if(fam == null){ //it doesnt exist, so create a new Family object fam = new Family(ind.getFamilyID()); } fam.addMember(ind); this.families.put(ind.getFamilyID(),fam); this.allIndividuals.add(ind); } //start at k=1 to skip header which we just processed above. hminfo = new String[numLines-1][]; for(int k=1;k<numLines;k++){ StringTokenizer tokenizer = new StringTokenizer((String)lines.get(k)); //reading the first line if(colNum < 0){ //only check column number count for the first line colNum = tokenizer.countTokens(); } if(colNum != tokenizer.countTokens()) { //this line has a different number of columns //should send some sort of error message //TODO: add something which stores number of markers for all lines and checks that they're consistent throw new PedFileException("Line number mismatch in input file. line " + (k+1)); } if(tokenizer.hasMoreTokens()){ hminfo[k-1] = new String[2]; for (int skip = 0; skip < numMetaColumns; skip++){ //meta-data crap String s = tokenizer.nextToken().trim(); //get marker name, chrom and pos if (skip == 0){ hminfo[k-1][0] = s; } if (skip == 2){ String dc = Chromosome.getDataChrom(); if (dc != null && !dc.equals("none")){ if (!dc.equalsIgnoreCase(s)){ throw new PedFileException("Hapmap file format error on line " + (k+1) + ":\n The file appears to contain multiple chromosomes:" + "\n" + dc + ", " + s); } }else{ Chromosome.setDataChrom(s); } } if (skip == 3){ hminfo[k-1][1] = s; } } int index = 0; int indexIncludingDups = -1; while(tokenizer.hasMoreTokens()){ String alleles = tokenizer.nextToken(); indexIncludingDups++; //we've skipped the dups in the ind array, so we skip their genotypes if (((String)namesIncludingDups.elementAt(indexIncludingDups)).endsWith("dup")){ continue; } ind = (Individual)allIndividuals.elementAt(index); int[] checker1, checker2; try{ checker1 = checkGenotype(alleles.substring(0,1)); checker2 = checkGenotype(alleles.substring(1,2)); }catch(NumberFormatException nfe){ throw new PedFileException("Invalid genotype on individual " + ind.getIndividualID() + "."); } if (checker1[1] != checker2[1]){ genoErrorB = !genoErrorB; } byte allele1 = (byte)checker1[0]; byte allele2 = (byte)checker2[0]; ind.addMarker(allele1, allele2); if (genoErrorB){ throw new PedFileException("File input error: individual " + ind.getIndividualID() + ", marker " + this.hminfo[ind.getNumMarkers()-1][0] + ".\nFor any marker, an individual's genotype must be only letters or only numbers."); } index++; } } } } |
|
Writer writer = new FileWriter(name); | String encoding = (this.encoding != null) ? this.encoding : "UTF-8"; Writer writer = new OutputStreamWriter( new FileOutputStream( name ), encoding ); | public void doTag(final XMLOutput output) throws Exception { if ( name != null ) { Writer writer = new FileWriter(name); writeBody(writer); } else if (var != null) { StringWriter writer = new StringWriter(); writeBody(writer); context.setVariable(var, writer.toString()); } else { throw new JellyException( "This tag must have either the 'name' or the 'var' variables defined" ); } } |
if (inputOptions[1].equals("")){ | if (inputOptions[1] == null){ | void readGenotypes(String[] inputOptions, int type){ //input is a 3 element array with //inputOptions[0] = ped file //inputOptions[1] = info file ("" if none) //inputOptions[2] = max comparison distance (don't compute d' if markers are greater than this dist apart) //type is either 3 or 4 for ped and hapmap files respectively final File inFile = new File(inputOptions[0]); //deal with max comparison distance if (inputOptions[2].equals("")){ inputOptions[2] = "0"; } maxCompDist = Long.parseLong(inputOptions[2])*1000; try { if (inFile.length() < 1){ throw new HaploViewException("Genotype file is empty or nonexistent: " + inFile.getName()); } if (type == HAPS){ //these are not available for non ped files viewMenuItems[VIEW_CHECK_NUM].setEnabled(false); viewMenuItems[VIEW_TDT_NUM].setEnabled(false); assocTest = 0; } theData = new HaploData(); if (type == HAPS){ theData.prepareHapsInput(new File(inputOptions[0])); }else{ theData.linkageToChrom(inFile, type); } //deal with marker information theData.infoKnown = false; File markerFile; if (inputOptions[1].equals("")){ markerFile = null; }else{ markerFile = new File(inputOptions[1]); } checkPanel = null; if (type == HAPS){ readMarkers(markerFile, null); }else{ readMarkers(markerFile, theData.getPedFile().getHMInfo()); checkPanel = new CheckDataPanel(theData, true); checkPanel.setAlignmentX(Component.CENTER_ALIGNMENT); } //let's start the math this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; changeKey(1); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); //theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first colorMenuItems[0].setSelected(true); blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(window); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); viewMenuItems[VIEW_D_NUM].setEnabled(true); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); //LOD panel /*panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); LODDisplay ld = new LODDisplay(theData); JScrollPane lodScroller = new JScrollPane(ld); panel.add(lodScroller); tabs.addTab(viewItems[VIEW_LOD_NUM], panel); viewMenuItems[VIEW_LOD_NUM].setEnabled(true);*/ //int optionalTabCount = 1; //check data panel if (checkPanel != null){ //optionalTabCount++; //VIEW_CHECK_NUM = optionalTabCount; //viewItems[VIEW_CHECK_NUM] = VIEW_CHECK_PANEL; JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //TDT panel if(assocTest > 0) { //optionalTabCount++; //VIEW_TDT_NUM = optionalTabCount; //viewItems[VIEW_TDT_NUM] = VIEW_TDT; try{ tdtPanel = new TDTPanel(theData.getPedFile(), assocTest); } catch(PedFileException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inFile.getName()); return null; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); for (int i = 0; i < blockMenuItems.length; i++){ blockMenuItems[i].setEnabled(true); } clearBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); blocksItem.setEnabled(true); exportMenuItems[2].setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); worker.start(); timer.start(); }catch(IOException ioexec) { JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } catch(PedFileException pfe){ JOptionPane.showMessageDialog(this, pfe.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (HaploViewException hve){ JOptionPane.showMessageDialog(this, hve.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } } |
printQualified(t.getPhysicalName()); | print( DDLUtils.toQualifiedName(t.getCatalogName(),t.getSchemaName(),t.getPhysicalName()) ); | public void addColumn(SQLColumn c, SQLTable t) throws ArchitectDiffException { Map colNameMap = new HashMap(); print("\n ALTER TABLE "); printQualified(t.getPhysicalName()); print(" ADD COLUMN "); print(columnDefinition(c,colNameMap)); endStatement(DDLStatement.StatementType.CREATE, c); } |
printQualified(r.getFkTable().getPhysicalName()); | print( DDLUtils.toQualifiedName(r.getFkTable().getCatalogName(),r.getFkTable().getSchemaName(),r.getFkTable().getPhysicalName()) ); | public void addRelationship(SQLRelationship r) throws ArchitectDiffException { print("\n ALTER TABLE "); printQualified(r.getFkTable().getPhysicalName()); print(" ADD CONSTRAINT "); print(r.getName()); print(" FOREIGN KEY ( "); Map<String, SQLColumn> colNameMap = new HashMap<String, SQLColumn> (); boolean firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getFkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" ) REFERENCES "); printQualified(r.getPkTable().getPhysicalName()); print(" ( "); colNameMap = new HashMap<String, SQLColumn> (); firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getPkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" )"); endStatement(DDLStatement.StatementType.CREATE, r); } |
printQualified(r.getPkTable().getPhysicalName()); | print( DDLUtils.toQualifiedName(r.getPkTable().getCatalogName(),r.getPkTable().getSchemaName(),r.getPkTable().getPhysicalName()) ); | public void addRelationship(SQLRelationship r) throws ArchitectDiffException { print("\n ALTER TABLE "); printQualified(r.getFkTable().getPhysicalName()); print(" ADD CONSTRAINT "); print(r.getName()); print(" FOREIGN KEY ( "); Map<String, SQLColumn> colNameMap = new HashMap<String, SQLColumn> (); boolean firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getFkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" ) REFERENCES "); printQualified(r.getPkTable().getPhysicalName()); print(" ( "); colNameMap = new HashMap<String, SQLColumn> (); firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getPkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" )"); endStatement(DDLStatement.StatementType.CREATE, r); } |
printQualified(t.getPhysicalName()); | print( DDLUtils.toQualifiedName(t.getCatalogName(),t.getSchemaName(),t.getPhysicalName()) ); | public void dropColumn(SQLColumn c, SQLTable t) throws ArchitectDiffException { Map colNameMap = new HashMap(); print("\n ALTER TABLE "); printQualified(t.getPhysicalName()); print(" DROP COLUMN "); print(getPhysicalName(colNameMap,c)); endStatement(DDLStatement.StatementType.DROP, c); } |
printQualified(r.getFkTable().getPhysicalName()); | print( DDLUtils.toQualifiedName(r.getFkTable().getCatalogName(),r.getFkTable().getSchemaName(),r.getFkTable().getPhysicalName()) ); | public void dropRelationship(SQLRelationship r) { print("\n ALTER TABLE "); printQualified(r.getFkTable().getPhysicalName()); print(" DROP CONSTRAINT "); print(r.getName()); endStatement(DDLStatement.StatementType.DROP, r); } |
printQualified(rel.getFkTable().getPhysicalName()); | print( DDLUtils.toQualifiedName(rel.getFkTable().getCatalogName(),rel.getFkTable().getSchemaName(),rel.getFkTable().getPhysicalName()) ); | protected void writeExportedRelationships(SQLTable t) throws ArchitectException { Iterator it = t.getExportedKeys().iterator(); while (it.hasNext()) { SQLRelationship rel = (SQLRelationship) it.next(); // geneate a physical name for this relationship getPhysicalName(topLevelNames,rel); // println(""); print("ALTER TABLE "); // this works because all the tables have had their physical names generated already... printQualified(rel.getFkTable().getPhysicalName()); print(" ADD CONSTRAINT "); print(rel.getPhysicalName()); println(""); print("FOREIGN KEY ("); StringBuffer pkCols = new StringBuffer(); StringBuffer fkCols = new StringBuffer(); boolean firstCol = true; Iterator mappings = rel.getChildren().iterator(); while (mappings.hasNext()) { SQLRelationship.ColumnMapping cmap = (SQLRelationship.ColumnMapping) mappings.next(); if (!firstCol) { pkCols.append(", "); fkCols.append(", "); } // append(pkCols, cmap.getPkColumn().getPhysicalName()); append(fkCols, cmap.getFkColumn().getPhysicalName()); firstCol = false; } print(fkCols.toString()); println(")"); print("REFERENCES "); printQualified(rel.getPkTable().getPhysicalName()); print(" ("); print(pkCols.toString()); print(")"); endStatement(DDLStatement.StatementType.ADD_FK, t); } } |
printQualified(rel.getPkTable().getPhysicalName()); | print( DDLUtils.toQualifiedName(rel.getPkTable().getCatalogName(),rel.getPkTable().getSchemaName(),rel.getPkTable().getPhysicalName()) ); | protected void writeExportedRelationships(SQLTable t) throws ArchitectException { Iterator it = t.getExportedKeys().iterator(); while (it.hasNext()) { SQLRelationship rel = (SQLRelationship) it.next(); // geneate a physical name for this relationship getPhysicalName(topLevelNames,rel); // println(""); print("ALTER TABLE "); // this works because all the tables have had their physical names generated already... printQualified(rel.getFkTable().getPhysicalName()); print(" ADD CONSTRAINT "); print(rel.getPhysicalName()); println(""); print("FOREIGN KEY ("); StringBuffer pkCols = new StringBuffer(); StringBuffer fkCols = new StringBuffer(); boolean firstCol = true; Iterator mappings = rel.getChildren().iterator(); while (mappings.hasNext()) { SQLRelationship.ColumnMapping cmap = (SQLRelationship.ColumnMapping) mappings.next(); if (!firstCol) { pkCols.append(", "); fkCols.append(", "); } // append(pkCols, cmap.getPkColumn().getPhysicalName()); append(fkCols, cmap.getFkColumn().getPhysicalName()); firstCol = false; } print(fkCols.toString()); println(")"); print("REFERENCES "); printQualified(rel.getPkTable().getPhysicalName()); print(" ("); print(pkCols.toString()); print(")"); endStatement(DDLStatement.StatementType.ADD_FK, t); } } |
printQualified(t.getPhysicalName()); | print( DDLUtils.toQualifiedName(t.getCatalogName(),t.getSchemaName(),t.getPhysicalName()) ); | protected void writePrimaryKey(SQLTable t) throws ArchitectException { boolean firstCol = true; Iterator it = t.getColumns().iterator(); while (it.hasNext()) { SQLColumn col = (SQLColumn) it.next(); if (col.getPrimaryKeySeq() == null) break; if (firstCol) { // generate a unique primary key name getPhysicalPrimaryKeyName(topLevelNames,t); // println(""); print("ALTER TABLE "); printQualified(t.getPhysicalName()); print(" ADD CONSTRAINT "); print(t.getPhysicalPrimaryKeyName()); println(""); print("PRIMARY KEY ("); firstCol = false; } else { print(", "); } print(col.getPhysicalName()); } if (!firstCol) { print(")"); endStatement(DDLStatement.StatementType.ADD_PK, t); } } |
printQualified(t.getPhysicalName()); | print( DDLUtils.toQualifiedName(t.getCatalogName(),t.getSchemaName(),t.getPhysicalName()) ); | public void writeTable(SQLTable t) throws SQLException, ArchitectException { Map colNameMap = new HashMap(); // for detecting duplicate column names // generate a new physical name if necessary getPhysicalName(topLevelNames,t); // also adds generated physical name to the map print("\nCREATE TABLE "); printQualified(t.getPhysicalName()); println(" ("); boolean firstCol = true; Iterator it = t.getColumns().iterator(); while (it.hasNext()) { SQLColumn c = (SQLColumn) it.next(); // generate a new physical name if necessary if (!firstCol) println(","); print(" "); print(columnDefinition(c,colNameMap)); // XXX: default values handled only in ETL? firstCol = false; } println(""); print(")"); endStatement(DDLStatement.StatementType.CREATE, t); } |
public boolean evaluateAsBoolean(Context context) { | public boolean evaluateAsBoolean(JellyContext context) { | public boolean evaluateAsBoolean(Context context) { Object value = evaluate(context); if ( value instanceof Boolean ) { Boolean b = (Boolean) value; return b.booleanValue(); } else if ( value instanceof String ) { return Boolean.getBoolean( (String) value ); } return false; } |
public Iterator evaluateAsIterator(Context context) { | public Iterator evaluateAsIterator(JellyContext context) { | public Iterator evaluateAsIterator(Context context) { Object value = evaluate(context); if ( value == null ) { return EMPTY_ITERATOR; } else if ( value instanceof Iterator ) { return (Iterator) value; } else if ( value instanceof List ) { List list = (List) value; return list.iterator(); } else if ( value instanceof Map ) { Map map = (Map) value; return map.entrySet().iterator(); } else if ( value.getClass().isArray() ) { return new ArrayIterator( value ); } else { // XXX: should we return single iterator? return new SingletonIterator( value ); } } |
public String evaluateAsString(Context context) { | public String evaluateAsString(JellyContext context) { | public String evaluateAsString(Context context) { Object value = evaluate(context); if ( value != null ) { return value.toString(); } return null; } |
if ( project == null ) { | if ( project == null && context != null ) { | public Project getProject() { if ( project == null ) { // we may be invoked inside a child script, so lets try find the parent project project = (Project) context.findVariable( "org.apache.commons.jelly.werkz.Project" ); if ( project == null ) { project = new Project(); context.setVariable( "org.apache.commons.jelly.werkz.Project", project ); } } return project; } |
System.out.println(col.getName()+ " Unknown DataType:(" + | logger.debug(col.getName()+ " Unknown DataType:(" + | private void doColumnProfile(List<SQLColumn> columns, Connection conn) throws SQLException, ArchitectException { Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { if ( columns.size() == 0 ) return; SQLColumn col1 = columns.get(0); DDLGenerator ddlg = null; try { ddlg = (DDLGenerator) DDLUtils.createDDLGenerator( col1.getParentTable().getParentDatabase().getDataSource()); } catch (InstantiationException e1) { throw new ArchitectException("problem running Profile Manager", e1); } catch ( IllegalAccessException e1 ) { throw new ArchitectException("problem running Profile Manager", e1); } stmt = conn.createStatement(); stmt.setEscapeProcessing(false); for (SQLColumn col : columns ) { synchronized (monitorableMutex) { if (userCancel) { remove(col.getParentTable()); return; } } ProfileFunctionDescriptor pfd = ddlg.getProfileFunctionMap().get(col.getSourceDataTypeName()); ColumnProfileResult colResult = null; long profileStartTime = System.currentTimeMillis(); if ( pfd == null ) { System.out.println(col.getName()+ " Unknown DataType:(" + col.getSourceDataTypeName() + ")."); pfd = discoverProfileFunctionDescriptor(col,ddlg,conn); } try { colResult = execProfileFunction(pfd,col,ddlg,conn); } catch ( Exception ex ) { colResult = new ColumnProfileResult(col); colResult.setCreateStartTime(profileStartTime); colResult.setError(true); colResult.setException(ex); colResult.setCreateEndTime(System.currentTimeMillis()); logger.error("Error in Column Profiling: "+lastSQL, ex); } finally { putResult(colResult); } synchronized (monitorableMutex) { progress++; if (userCancel) { remove(col.getParentTable()); break; } } } // XXX: add where filter later } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } } } |
suite.addTestSuite(TestTablePane.class); | public static Test suite() { TestSuite suite = new TestSuite("Test for Architect's Swing GUI"); //$JUnit-BEGIN$ suite.addTestSuite(TestSwingUIProject.class); suite.addTestSuite(TestArchitectFrame.class); suite.addTestSuite(TestAutoLayoutAction.class); suite.addTestSuite(TestPlayPen.class); suite.addTestSuite(TestUndoManager.class); suite.addTestSuite(TestColumnEditPanel.class); suite.addTestSuite(TestSQLObjectUndoableEventAdapter.class); suite.addTestSuite(TestFruchtermanReingoldForceLayout.class); suite.addTestSuite(TestCompareDMPanel.class); //$JUnit-END$ return suite; } |
|
g2.setStroke(oldStroke); | public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space try { Point pktloc = r.getPkConnectionPoint(); Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = r.getFkConnectionPoint(); Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 5); } else { path.reset(); } orientation = getFacingEdges(relationship.getPkTable(), relationship.getFkTable()); if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } g2.draw(path); logger.debug("Drew path "+path); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } } |
|
RelationshipUI ui = (RelationshipUI) BasicRelationshipUI.createUI(this); | RelationshipUI ui = (RelationshipUI) IERelationshipUI.createUI(this); | public void updateUI() { RelationshipUI ui = (RelationshipUI) BasicRelationshipUI.createUI(this); ui.installUI(this); setUI(ui); revalidate(); } |
NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); | public void dPrimeDraw(String[][] table, boolean info, Vector snps, Graphics g){ int scale = table.length*30; int activeOffset = 0; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); if (info) activeOffset = labeloffset; //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale+activeOffset,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", activeOffset + shifts[0], shifts[1]); //if we know the marker names, print them down the side if (info){ g.setFont(regFont); for (int y = 0; y < table.length; y++){ String name = ((SNP)snps.elementAt(y)).getName(); g.drawString(name, labeloffset-3-regfm.stringWidth(name), y*30 + shifts[1]); } //now draw a diagonal bar showing marker spacings if (table.length > 3){ g.drawLine(labeloffset+90,5,labeloffset+scale-5,scale-90); double lineLength = Math.sqrt((scale-95)*(scale-95)*2); double start = ((SNP)snps.elementAt(0)).getPosition(); double totalLength = ((SNP)snps.elementAt(table.length-1)).getPosition() - start; int numKB = (int)(totalLength/1000); g.drawString(numKB+" Kb", labeloffset+150, 30); for (int y = 0; y < table.length; y++){ double fracLength = (((SNP)snps.elementAt(y)).getPosition() - start)/totalLength; double xOrYDist = Math.sqrt((fracLength*lineLength*fracLength*lineLength)/2); g.drawLine(labeloffset+25+y*30, 5+y*30,(int)(labeloffset+90+xOrYDist),(int)(5+xOrYDist)); } } } //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(nf.format(Float.parseFloat(st.nextToken()))); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1+activeOffset, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30+activeOffset, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30)+activeOffset,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30+activeOffset, shifts[1]+(x+1)*30); } } |
|
d = Float.parseFloat(nf.format(Float.parseFloat(st.nextToken()))); | d = Float.parseFloat(st.nextToken()); | public void dPrimeDraw(String[][] table, boolean info, Vector snps, Graphics g){ int scale = table.length*30; int activeOffset = 0; float d, l, blgr; Color myColor; int[] shifts; Font regFont = new Font("Lucida Sans Regular", Font.PLAIN, 10); FontMetrics regfm = g.getFontMetrics(regFont); Font boldFont = new Font("Lucida Sans Bold", Font.BOLD, 14); FontMetrics boldfm = g.getFontMetrics(boldFont); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); if (info) activeOffset = labeloffset; //background color g.setColor(new Color(192,192,192)); g.fillRect(0,0,scale+activeOffset,scale); //first label: g.setColor(Color.black); g.setFont(boldFont); shifts = centerString("1", boldfm); g.drawString("1", activeOffset + shifts[0], shifts[1]); //if we know the marker names, print them down the side if (info){ g.setFont(regFont); for (int y = 0; y < table.length; y++){ String name = ((SNP)snps.elementAt(y)).getName(); g.drawString(name, labeloffset-3-regfm.stringWidth(name), y*30 + shifts[1]); } //now draw a diagonal bar showing marker spacings if (table.length > 3){ g.drawLine(labeloffset+90,5,labeloffset+scale-5,scale-90); double lineLength = Math.sqrt((scale-95)*(scale-95)*2); double start = ((SNP)snps.elementAt(0)).getPosition(); double totalLength = ((SNP)snps.elementAt(table.length-1)).getPosition() - start; int numKB = (int)(totalLength/1000); g.drawString(numKB+" Kb", labeloffset+150, 30); for (int y = 0; y < table.length; y++){ double fracLength = (((SNP)snps.elementAt(y)).getPosition() - start)/totalLength; double xOrYDist = Math.sqrt((fracLength*lineLength*fracLength*lineLength)/2); g.drawLine(labeloffset+25+y*30, 5+y*30,(int)(labeloffset+90+xOrYDist),(int)(5+xOrYDist)); } } } //draw table column by column for (int x = 0; x < table.length-1; x++){ for (int y = x + 1; y < table.length; y++){ StringTokenizer st = new StringTokenizer(table[x][y]); d = Float.parseFloat(nf.format(Float.parseFloat(st.nextToken()))); l = Float.parseFloat(st.nextToken()); //set coloring based on LOD and D' if (l > 2){ if (d < 0.5) { //high LOD, low D' bluish color myColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red blgr = (255-32)*2*(1-d); myColor = new Color(255, (int) blgr, (int) blgr); } }else if (d > 0.99){ //high D', low LOD gray color myColor = new Color(192, 192, 240); }else { //no LD myColor = Color.white; } //draw the boxes g.setColor(myColor); g.fillRect(x*30+1+activeOffset, y*30+1, 28, 28); g.setColor(Color.black); g.drawRect(x*30+activeOffset, y*30, 30, 30); g.setFont(regFont); shifts=centerString(Float.toString(d), regfm); g.drawString(Float.toString(d), shifts[0]+(x*30)+activeOffset,(y*30)+shifts[1]); } //draw the labels g.setColor(Color.black); g.setFont(boldFont); shifts = centerString(Integer.toString(x+2), boldfm); g.drawString(Integer.toString(x+2), shifts[0]+(x+1)*30+activeOffset, shifts[1]+(x+1)*30); } } |
if (logger.isDebugEnabled()) { logger.debug("TablePane got object changed event." + " Source="+e.getSource()+" Property="+e.getPropertyName()+ " oldVal="+e.getOldValue()+" newVal="+e.getNewValue()); } | public void dbObjectChanged(SQLObjectEvent e) { firePropertyChange("model."+e.getPropertyName(), null, null); //repaint(); } |
|
logger.debug("TablePane got db structure change event. source="+e.getSource()); | public void dbStructureChanged(SQLObjectEvent e) { if (e.getSource() == model.getColumnsFolder()) { int numCols = e.getChildren().length; columnSelection = new ArrayList<Boolean>(numCols); for (int i = 0; i < numCols; i++) { columnSelection.add(Boolean.FALSE); } columnHighlight = new ArrayList<Color>(numCols); for (int i = 0; i < numCols; i++) { columnHighlight.add(null); } firePropertyChange("model.children", null, null); //revalidate(); } } |
|
messages[1] = new JLabel(cr.toConflictTree()); | JTextArea conflictsPane = new JTextArea(cr.toConflictTree()); conflictsPane.setRows(15); conflictsPane.setEditable(false); messages[1] = new JScrollPane(conflictsPane); | private void runFinished() { if (!SwingUtilities.isEventDispatchThread()) { logger.error("runFinished is running on the wrong thread!"); } if (errorMessage != null) { JOptionPane.showMessageDialog(parentDialog, errorMessage, "Error", JOptionPane.ERROR_MESSAGE); } else if (!cr.isEmpty()) { Object[] messages = new Object[3]; messages[0] = "The following objects in the target database" +"\nconflict with those you wish to create:"; messages[1] = new JLabel(cr.toConflictTree()); //FIXME: needs to be in a scrollpane, but there seems to be a serious issue when this is done. messages[2] = "Do you want the Architect to drop these objects" +"\nbefore attempting to create the new ones?"; int choice = JOptionPane.showConfirmDialog( parentDialog, messages, "Conflicting Objects Found", JOptionPane.YES_NO_CANCEL_OPTION); if (choice == JOptionPane.YES_OPTION) { shouldDropConflicts = true; } else if (choice == JOptionPane.NO_OPTION) { shouldDropConflicts = false; } else if (choice == JOptionPane.CANCEL_OPTION) { shouldDropConflicts = false; nextProcess = null; } } if (nextProcess != null) { new Thread(nextProcess).start(); } } |
"-ha <hapsfile> specify an input file in .haps format\n" + | private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; String hapmapFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println("HaploView command line options\n" + "-h, -help print this message\n" + "-n command line output only\n" + "-q quiet mode- doesnt print any warnings or information to screen\n" + "-p <pedfile> specify an input file in pedigree file format\n" + " pedfile specific options (nogui mode only): \n" + " --showcheck displays the results of the various pedigree integrity checks\n" + " --skipcheck skips the various pedfile checks\n" + //TODO: fix ignoremarkers //" --ignoremarkers <markers> ignores the specified markers.<markers> is a comma\n" + //" seperated list of markers. eg. 1,5,7,19,25\n" + "-ha <hapsfile> specify an input file in .haps format\n" + "-a <hapmapfile> specify an input file in HapMap format\n" + "-i <infofile> specify a marker info file\n" + "-b <batchfile> batch mode. batchfile should contain a list of files either all genotype or alternating genotype/info\n" + "-d outputs dprime to <inputfile>.DPRIME\n" + " note: -d defaults to no blocks output. use -o to also output blocks\n" + "-o <SFS,GAM,MJD,ALL> output type. SFS, 4 gamete, MJD output or all 3. default is SFS.\n" + "-m <distance> maximum comparison distance in kilobases (integer). default is 500"); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equals("-a")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-a requires a filename"); System.exit(1); } else{ if(!hapmapFileName.equals("")){ System.out.println("multiple -a arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one -o argument is allowed"); System.exit(1); } if(args[i].equals("SFS")){ outputType = 0; } else if(args[i].equals("GAM")){ outputType = 1; } else if(args[i].equals("MJD")){ outputType = 2; } else if(args[i].equals("ALL")) { outputType = 3; } } else { //defaults to SFS output outputType =0; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("")) && !outputDprime ) { outputType = 0; if(nogui && !quietMode) { System.out.println("No output type specified. Default of SFS will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_hapmapfile = hapmapFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; } |
|
"-d outputs dprime to <inputfile>.DPRIME\n" + " note: -d defaults to no blocks output. use -o to also output blocks\n" + | "-d outputs dprime to <inputfile>.DPRIME\n" + "-c outputs marker checks to <inputfile>.CHECK\n" + " note: -d and -c default to no blocks output. use -o to also output blocks\n" + | private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; String hapmapFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println("HaploView command line options\n" + "-h, -help print this message\n" + "-n command line output only\n" + "-q quiet mode- doesnt print any warnings or information to screen\n" + "-p <pedfile> specify an input file in pedigree file format\n" + " pedfile specific options (nogui mode only): \n" + " --showcheck displays the results of the various pedigree integrity checks\n" + " --skipcheck skips the various pedfile checks\n" + //TODO: fix ignoremarkers //" --ignoremarkers <markers> ignores the specified markers.<markers> is a comma\n" + //" seperated list of markers. eg. 1,5,7,19,25\n" + "-ha <hapsfile> specify an input file in .haps format\n" + "-a <hapmapfile> specify an input file in HapMap format\n" + "-i <infofile> specify a marker info file\n" + "-b <batchfile> batch mode. batchfile should contain a list of files either all genotype or alternating genotype/info\n" + "-d outputs dprime to <inputfile>.DPRIME\n" + " note: -d defaults to no blocks output. use -o to also output blocks\n" + "-o <SFS,GAM,MJD,ALL> output type. SFS, 4 gamete, MJD output or all 3. default is SFS.\n" + "-m <distance> maximum comparison distance in kilobases (integer). default is 500"); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equals("-a")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-a requires a filename"); System.exit(1); } else{ if(!hapmapFileName.equals("")){ System.out.println("multiple -a arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one -o argument is allowed"); System.exit(1); } if(args[i].equals("SFS")){ outputType = 0; } else if(args[i].equals("GAM")){ outputType = 1; } else if(args[i].equals("MJD")){ outputType = 2; } else if(args[i].equals("ALL")) { outputType = 3; } } else { //defaults to SFS output outputType =0; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("")) && !outputDprime ) { outputType = 0; if(nogui && !quietMode) { System.out.println("No output type specified. Default of SFS will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_hapmapfile = hapmapFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; } |
else if(args[i].equals("-ha")) { | else if(args[i].equals("-ha") || args[i].equals("-l")) { | private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; String hapmapFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println("HaploView command line options\n" + "-h, -help print this message\n" + "-n command line output only\n" + "-q quiet mode- doesnt print any warnings or information to screen\n" + "-p <pedfile> specify an input file in pedigree file format\n" + " pedfile specific options (nogui mode only): \n" + " --showcheck displays the results of the various pedigree integrity checks\n" + " --skipcheck skips the various pedfile checks\n" + //TODO: fix ignoremarkers //" --ignoremarkers <markers> ignores the specified markers.<markers> is a comma\n" + //" seperated list of markers. eg. 1,5,7,19,25\n" + "-ha <hapsfile> specify an input file in .haps format\n" + "-a <hapmapfile> specify an input file in HapMap format\n" + "-i <infofile> specify a marker info file\n" + "-b <batchfile> batch mode. batchfile should contain a list of files either all genotype or alternating genotype/info\n" + "-d outputs dprime to <inputfile>.DPRIME\n" + " note: -d defaults to no blocks output. use -o to also output blocks\n" + "-o <SFS,GAM,MJD,ALL> output type. SFS, 4 gamete, MJD output or all 3. default is SFS.\n" + "-m <distance> maximum comparison distance in kilobases (integer). default is 500"); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equals("-a")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-a requires a filename"); System.exit(1); } else{ if(!hapmapFileName.equals("")){ System.out.println("multiple -a arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one -o argument is allowed"); System.exit(1); } if(args[i].equals("SFS")){ outputType = 0; } else if(args[i].equals("GAM")){ outputType = 1; } else if(args[i].equals("MJD")){ outputType = 2; } else if(args[i].equals("ALL")) { outputType = 3; } } else { //defaults to SFS output outputType =0; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("")) && !outputDprime ) { outputType = 0; if(nogui && !quietMode) { System.out.println("No output type specified. Default of SFS will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_hapmapfile = hapmapFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; } |
if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("")) && !outputDprime ) { | if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("")) && !outputDprime && !outputCheck) { | private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; String hapmapFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println("HaploView command line options\n" + "-h, -help print this message\n" + "-n command line output only\n" + "-q quiet mode- doesnt print any warnings or information to screen\n" + "-p <pedfile> specify an input file in pedigree file format\n" + " pedfile specific options (nogui mode only): \n" + " --showcheck displays the results of the various pedigree integrity checks\n" + " --skipcheck skips the various pedfile checks\n" + //TODO: fix ignoremarkers //" --ignoremarkers <markers> ignores the specified markers.<markers> is a comma\n" + //" seperated list of markers. eg. 1,5,7,19,25\n" + "-ha <hapsfile> specify an input file in .haps format\n" + "-a <hapmapfile> specify an input file in HapMap format\n" + "-i <infofile> specify a marker info file\n" + "-b <batchfile> batch mode. batchfile should contain a list of files either all genotype or alternating genotype/info\n" + "-d outputs dprime to <inputfile>.DPRIME\n" + " note: -d defaults to no blocks output. use -o to also output blocks\n" + "-o <SFS,GAM,MJD,ALL> output type. SFS, 4 gamete, MJD output or all 3. default is SFS.\n" + "-m <distance> maximum comparison distance in kilobases (integer). default is 500"); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equals("-a")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-a requires a filename"); System.exit(1); } else{ if(!hapmapFileName.equals("")){ System.out.println("multiple -a arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one -o argument is allowed"); System.exit(1); } if(args[i].equals("SFS")){ outputType = 0; } else if(args[i].equals("GAM")){ outputType = 1; } else if(args[i].equals("MJD")){ outputType = 2; } else if(args[i].equals("ALL")) { outputType = 3; } } else { //defaults to SFS output outputType =0; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("")) && !outputDprime ) { outputType = 0; if(nogui && !quietMode) { System.out.println("No output type specified. Default of SFS will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_hapmapfile = hapmapFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; } |
arg_check = outputCheck; | private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; String hapmapFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println("HaploView command line options\n" + "-h, -help print this message\n" + "-n command line output only\n" + "-q quiet mode- doesnt print any warnings or information to screen\n" + "-p <pedfile> specify an input file in pedigree file format\n" + " pedfile specific options (nogui mode only): \n" + " --showcheck displays the results of the various pedigree integrity checks\n" + " --skipcheck skips the various pedfile checks\n" + //TODO: fix ignoremarkers //" --ignoremarkers <markers> ignores the specified markers.<markers> is a comma\n" + //" seperated list of markers. eg. 1,5,7,19,25\n" + "-ha <hapsfile> specify an input file in .haps format\n" + "-a <hapmapfile> specify an input file in HapMap format\n" + "-i <infofile> specify a marker info file\n" + "-b <batchfile> batch mode. batchfile should contain a list of files either all genotype or alternating genotype/info\n" + "-d outputs dprime to <inputfile>.DPRIME\n" + " note: -d defaults to no blocks output. use -o to also output blocks\n" + "-o <SFS,GAM,MJD,ALL> output type. SFS, 4 gamete, MJD output or all 3. default is SFS.\n" + "-m <distance> maximum comparison distance in kilobases (integer). default is 500"); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equals("-a")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-a requires a filename"); System.exit(1); } else{ if(!hapmapFileName.equals("")){ System.out.println("multiple -a arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one -o argument is allowed"); System.exit(1); } if(args[i].equals("SFS")){ outputType = 0; } else if(args[i].equals("GAM")){ outputType = 1; } else if(args[i].equals("MJD")){ outputType = 2; } else if(args[i].equals("ALL")) { outputType = 3; } } else { //defaults to SFS output outputType =0; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("")) && !outputDprime ) { outputType = 0; if(nogui && !quietMode) { System.out.println("No output type specified. Default of SFS will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_hapmapfile = hapmapFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; } |
|
textData.linkageToChrom(inputFile, 3, arg_skipCheck); | result = textData.linkageToChrom(inputFile, 3, arg_skipCheck); | private void processFile(String fileName,int fileType,String infoFileName){ try { int outputType; long maxDistance; long negMaxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; negMaxDistance = -maxDistance; outputType = this.arg_output; textData = new HaploData(); Vector result = null; if(fileType == 0){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == 1) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile textData.linkageToChrom(inputFile,4,arg_skipCheck); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); if(!infoFileName.equals("")) { File infoFile = new File(infoFileName); if(infoFile.exists()) { textData.prepareMarkerInput(infoFile,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; } else if(!this.arg_quiet) { System.out.println("info file " + infoFileName + " does not exist"); } } else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } if(this.arg_showCheck && result != null) { System.out.println("Data check results:\n" + "Name\t\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } if(outputType != -1){ textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; switch(outputType){ case 0: OutputFile = new File(fileName + ".SFSblocks"); break; case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } //this handles output type ALL if(outputType == 3) { OutputFile = new File(fileName + ".SFSblocks"); textData.guessBlocks(0); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(1); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".MJDblocks"); textData.guessBlocks(2); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile); }else{ //this means that we're just writing dprime so we won't //keep the (potentially huge) dprime table in memory but instead //write out one line at a time forget FileWriter saveDprimeWriter = new FileWriter(OutputFile); if (textData.infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + linkageResult.toString() + "\t" + dist + "\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + linkageResult + "\n"); } } } } } saveDprimeWriter.close(); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
textData.linkageToChrom(inputFile,4,arg_skipCheck); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); | result = textData.linkageToChrom(inputFile,4,arg_skipCheck); } | private void processFile(String fileName,int fileType,String infoFileName){ try { int outputType; long maxDistance; long negMaxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; negMaxDistance = -maxDistance; outputType = this.arg_output; textData = new HaploData(); Vector result = null; if(fileType == 0){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == 1) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile textData.linkageToChrom(inputFile,4,arg_skipCheck); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); if(!infoFileName.equals("")) { File infoFile = new File(infoFileName); if(infoFile.exists()) { textData.prepareMarkerInput(infoFile,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; } else if(!this.arg_quiet) { System.out.println("info file " + infoFileName + " does not exist"); } } else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } if(this.arg_showCheck && result != null) { System.out.println("Data check results:\n" + "Name\t\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } if(outputType != -1){ textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; switch(outputType){ case 0: OutputFile = new File(fileName + ".SFSblocks"); break; case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } //this handles output type ALL if(outputType == 3) { OutputFile = new File(fileName + ".SFSblocks"); textData.guessBlocks(0); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(1); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".MJDblocks"); textData.guessBlocks(2); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile); }else{ //this means that we're just writing dprime so we won't //keep the (potentially huge) dprime table in memory but instead //write out one line at a time forget FileWriter saveDprimeWriter = new FileWriter(OutputFile); if (textData.infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + linkageResult.toString() + "\t" + dist + "\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + linkageResult + "\n"); } } } } } saveDprimeWriter.close(); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } | private void processFile(String fileName,int fileType,String infoFileName){ try { int outputType; long maxDistance; long negMaxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; negMaxDistance = -maxDistance; outputType = this.arg_output; textData = new HaploData(); Vector result = null; if(fileType == 0){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == 1) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile textData.linkageToChrom(inputFile,4,arg_skipCheck); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); if(!infoFileName.equals("")) { File infoFile = new File(infoFileName); if(infoFile.exists()) { textData.prepareMarkerInput(infoFile,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; } else if(!this.arg_quiet) { System.out.println("info file " + infoFileName + " does not exist"); } } else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } if(this.arg_showCheck && result != null) { System.out.println("Data check results:\n" + "Name\t\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } if(outputType != -1){ textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; switch(outputType){ case 0: OutputFile = new File(fileName + ".SFSblocks"); break; case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } //this handles output type ALL if(outputType == 3) { OutputFile = new File(fileName + ".SFSblocks"); textData.guessBlocks(0); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(1); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".MJDblocks"); textData.guessBlocks(2); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile); }else{ //this means that we're just writing dprime so we won't //keep the (potentially huge) dprime table in memory but instead //write out one line at a time forget FileWriter saveDprimeWriter = new FileWriter(OutputFile); if (textData.infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + linkageResult.toString() + "\t" + dist + "\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + linkageResult + "\n"); } } } } } saveDprimeWriter.close(); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
|
"Name\t\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); | "Name\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); | private void processFile(String fileName,int fileType,String infoFileName){ try { int outputType; long maxDistance; long negMaxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; negMaxDistance = -maxDistance; outputType = this.arg_output; textData = new HaploData(); Vector result = null; if(fileType == 0){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == 1) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile textData.linkageToChrom(inputFile,4,arg_skipCheck); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); if(!infoFileName.equals("")) { File infoFile = new File(infoFileName); if(infoFile.exists()) { textData.prepareMarkerInput(infoFile,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; } else if(!this.arg_quiet) { System.out.println("info file " + infoFileName + " does not exist"); } } else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } if(this.arg_showCheck && result != null) { System.out.println("Data check results:\n" + "Name\t\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } if(outputType != -1){ textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; switch(outputType){ case 0: OutputFile = new File(fileName + ".SFSblocks"); break; case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } //this handles output type ALL if(outputType == 3) { OutputFile = new File(fileName + ".SFSblocks"); textData.guessBlocks(0); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(1); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".MJDblocks"); textData.guessBlocks(2); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile); }else{ //this means that we're just writing dprime so we won't //keep the (potentially huge) dprime table in memory but instead //write out one line at a time forget FileWriter saveDprimeWriter = new FileWriter(OutputFile); if (textData.infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + linkageResult.toString() + "\t" + dist + "\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + linkageResult + "\n"); } } } } } saveDprimeWriter.close(); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
if(this.arg_check && result != null){ OutputFile = new File (fileName + ".CHECK"); FileWriter saveCheckWriter = new FileWriter(OutputFile); saveCheckWriter.write("Name\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr\n"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); saveCheckWriter.write( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum() +"\n"); } saveCheckWriter.close(); } | private void processFile(String fileName,int fileType,String infoFileName){ try { int outputType; long maxDistance; long negMaxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; negMaxDistance = -maxDistance; outputType = this.arg_output; textData = new HaploData(); Vector result = null; if(fileType == 0){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == 1) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile textData.linkageToChrom(inputFile,4,arg_skipCheck); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); if(!infoFileName.equals("")) { File infoFile = new File(infoFileName); if(infoFile.exists()) { textData.prepareMarkerInput(infoFile,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; } else if(!this.arg_quiet) { System.out.println("info file " + infoFileName + " does not exist"); } } else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } if(this.arg_showCheck && result != null) { System.out.println("Data check results:\n" + "Name\t\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } if(outputType != -1){ textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; switch(outputType){ case 0: OutputFile = new File(fileName + ".SFSblocks"); break; case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } //this handles output type ALL if(outputType == 3) { OutputFile = new File(fileName + ".SFSblocks"); textData.guessBlocks(0); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(1); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".MJDblocks"); textData.guessBlocks(2); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile); }else{ //this means that we're just writing dprime so we won't //keep the (potentially huge) dprime table in memory but instead //write out one line at a time forget FileWriter saveDprimeWriter = new FileWriter(OutputFile); if (textData.infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + linkageResult.toString() + "\t" + dist + "\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + linkageResult + "\n"); } } } } } saveDprimeWriter.close(); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
|
typeMap.put(new Integer(Types.VARBINARY), new GenericTypeDescriptor("LONG RAW", Types.VARBINARY, 2000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); | typeMap.put(new Integer(Types.LONGVARCHAR), new GenericTypeDescriptor("LONG", Types.LONGVARCHAR, 2000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.VARBINARY), new GenericTypeDescriptor("LONG RAW", Types.VARBINARY, 2000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); | protected void createTypeMap() throws SQLException { typeMap = new HashMap(); typeMap.put(new Integer(Types.BIGINT), new GenericTypeDescriptor("NUMBER", Types.BIGINT, 38, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.BINARY), new GenericTypeDescriptor("RAW", Types.BINARY, 2000, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.BIT), new GenericTypeDescriptor("NUMBER", Types.BIT, 1, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.BLOB), new GenericTypeDescriptor("BLOB", Types.BLOB, 4000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.CHAR), new GenericTypeDescriptor("CHAR", Types.CHAR, 2000, "'", "'", DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.CLOB), new GenericTypeDescriptor("CLOB", Types.CLOB, 4000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.DATE), new GenericTypeDescriptor("DATE", Types.DATE, 0, "'", "'", DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.DECIMAL), new GenericTypeDescriptor("NUMBER", Types.DECIMAL, 38, null, null, DatabaseMetaData.columnNullable, true, true)); typeMap.put(new Integer(Types.DOUBLE), new GenericTypeDescriptor("NUMBER", Types.DOUBLE, 38, null, null, DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.FLOAT), new GenericTypeDescriptor("NUMBER", Types.FLOAT, 38, null, null, DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.INTEGER), new GenericTypeDescriptor("NUMBER", Types.INTEGER, 38, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.LONGVARBINARY), new GenericTypeDescriptor("LONG RAW", Types.LONGVARBINARY, 2000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.LONGVARCHAR), new GenericTypeDescriptor("VARCHAR2", Types.LONGVARCHAR, 4000, "'", "'", DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.NUMERIC), new GenericTypeDescriptor("NUMBER", Types.NUMERIC, 38, null, null, DatabaseMetaData.columnNullable, true, true)); typeMap.put(new Integer(Types.REAL), new GenericTypeDescriptor("NUMBER", Types.REAL, 38, null, null, DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.SMALLINT), new GenericTypeDescriptor("NUMBER", Types.SMALLINT, 38, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.TIME), new GenericTypeDescriptor("DATE", Types.TIME, 0, "'", "'", DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.TIMESTAMP), new GenericTypeDescriptor("DATE", Types.TIMESTAMP, 0, "'", "'", DatabaseMetaData.columnNullable, false, false)); typeMap.put(new Integer(Types.TINYINT), new GenericTypeDescriptor("NUMBER", Types.TINYINT, 38, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.VARBINARY), new GenericTypeDescriptor("LONG RAW", Types.VARBINARY, 2000000000L, null, null, DatabaseMetaData.columnNullable, true, false)); typeMap.put(new Integer(Types.VARCHAR), new GenericTypeDescriptor("VARCHAR2", Types.VARCHAR, 4000, "'", "'", DatabaseMetaData.columnNullable, true, false)); } |
if (connection != null) return; connection = (Connection) dbConnections.get(connectionSpec); if (connection != null) return; | public synchronized void connect() throws ArchitectException { if (connection != null) return; connection = (Connection) dbConnections.get(connectionSpec); if (connection != null) return; try { Class.forName(connectionSpec.getDriverClass()); logger.info("Driver Class "+connectionSpec.getDriverClass()+" loaded without exception"); connection = DriverManager.getConnection(connectionSpec.getUrl(), connectionSpec.getUser(), connectionSpec.getPass()); dbConnections.put(connectionSpec, connection); } catch (ClassNotFoundException e) { logger.warn("Driver Class not found"); throw new ArchitectException("dbconnect.noDriver", e); } catch (SQLException e) { throw new ArchitectException("dbconnect.connectionFailed", e); } } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.