📄 buildjembossform.java
字号:
String rangeSuffix = rangeText.substring(blank+1,rangeText.length()); rangeText = rangePrefix.concat(rangeSuffix); } options = options.concat(" -" + val + " " + rangeText + " "); } } else if ( att.startsWith("infile") || att.startsWith("datafile") || att.startsWith("matrix") ) { if(!(textf[h].getText()).equals("") && textf[h].isVisible() && textf[h].isEnabled()) { if(withSoap) options = filesForSoap(textf[h].getText(),options,val,filesToMove); else options = options.concat(" -" + val + " " + textf[h].getText()); } } else if ( att.startsWith("filelist") ) { if(withSoap) { String fns = filelist[h].getListFile(); String ls = System.getProperty("line.separator"); options = filesForSoap("internalList::internalList"+ls+ fns,options,val,filesToMove); } else { String fl[] = filelist[h].getArrayListFile(); String flist = fl[0]; for(int i=1;i<fl.length;i++) flist = flist.concat(","+fl[i]); options = options.concat(" -" + val + " " + flist); } } else if ( att.startsWith("seqset") || att.startsWith("seqall") || att.startsWith("sequence") ) { int seq = h+1; if(inSeq[h].isFileName()) // file or database { fn = new String(inSeq[h].getFileChosen()); fn = fn.trim(); if((fn.indexOf(":")>-1) && (fn.indexOf(":\\") < 0)) //remove spaces { //from db entries int n; while((n = fn.indexOf(" ")) > -1) fn = new String(fn.substring(0,n) + fn.substring(n+1)); } if(withSoap) options = filesForSoap(fn,options,val,filesToMove); else options = options.concat(" -" + val + " " + fn); if(fn.endsWith(":") || fn.endsWith(":*")) { String ls = PlafMacros.getLineSeparator(); int n = JOptionPane.showConfirmDialog(f, "Do you really want to extract"+ls+ "the whole of " + fn + " database?", "Confirm the sequence entry", JOptionPane.YES_NO_OPTION); if(n == JOptionPane.NO_OPTION) { options = "NOT OK"; break; } } } else if(inSeq[h].isListFile()) // list file { String fns = inSeq[h].getListFile(); String ls = System.getProperty("line.separator"); if(withSoap) { options = filesForSoap("internalList::internalList"+ls+ fns,options,val,filesToMove); } else { String fna = System.getProperty("user.dir")+ System.getProperty("file.separator")+"seq.list"; boolean ok = inSeq[h].writeListFile(fna); options = options.concat(" -" + val + " list::" + fna); } } else // cut 'n paste { String cp = inSeq[h].getCutNPasteText(); fn = new String(applName + (new Integer(h)).toString()); if(withSoap) { MakeFileSafe sf = new MakeFileSafe(fn); sfn = sf.getSafeFileName(); filesToMove.put(sfn,cp.getBytes()); options = options.concat(" -" + val + " " + sfn); } else { String tmp = null; try { File tf; try { if(mysettings.isCygwin()) tmp = mysettings.getCygwinRoot()+System.getProperty("file.separator")+"tmp"; else tmp = System.getProperty("java.io.tmpdir"); tf = File.createTempFile(fn, ".jembosstmp", new File(tmp)); } catch(IOException ioe) { tf = File.createTempFile(fn, ".jembosstmp", new File(cwd)); } PrintWriter out = new PrintWriter(new FileWriter(tf)); out.println(cp); out.close(); fn = tf.getCanonicalPath(); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Cannot write to\n"+ tmp+"\n"+ "or\n"+ cwd, "Problem creating a temporary file!", JOptionPane.ERROR_MESSAGE); } options = options.concat(" -" + val + " " + fn ); } } options = options.concat(inSeqAttr[h].getInputSeqAttr(seq)); } } return options; } private String filesForSoap(String fn, String options, String val, Hashtable filesToMove) { String sfn; if (fn.startsWith("@")||fn.startsWith("list::")|| fn.startsWith("internalList::")) // list file { String lfn = ""; if (fn.startsWith("@")) lfn = fn.substring(1); else if(fn.startsWith("list::")) lfn = fn.substring(6); File inFile = new File(lfn); if( (inFile.exists() && inFile.canRead() && inFile.isFile())|| fn.startsWith("internalList::") ) // local list file { ListFile.parse(fn, filesToMove); if(fn.startsWith("internalList::")) options = options.concat(" -" + val + " list::internalList"); else { MakeFileSafe sf = new MakeFileSafe(lfn); String sfs = sf.getSafeFileName(); options = options.concat(" -" + val + " list::" + sfs); } } else // presume remote {// System.out.println("Can't find list file "+lfn); options = options.concat(" -" + val + " list::" + lfn); } sfn=lfn; } else // not list file { MakeFileSafe sf = new MakeFileSafe(fn); sfn = sf.getSafeFileName(); File inFile = new File(fn); if(inFile.exists() && inFile.canRead() && inFile.isFile()) // read & add to transfer list { filesToMove.put(sfn,getLocalFile(inFile)); options = options.concat(" -" + val + " " + sfn); } else //presume remote {// System.out.println("Can't find plain file "+fn); options = options.concat(" -" + val + " " + fn); } } return options; } private byte[] getLocalFile(File name) { byte[] b = null; try { long s = name.length(); b = new byte[(int)s]; FileInputStream fi = new FileInputStream(name); fi.read(b); fi.close(); } catch (IOException ioe) { System.out.println("Cannot read file: " + name); } return b; }/**** Get the command line for the Standalone version.* @param Hashtable of the files to be transferrred* @return String command line to use**//* private String getCommand() { String command = embossBin.concat(applName); int numofFields = parseAcd.getNumofFields(); String options = checkParameters(parseAcd, numofFields, new Hashtable()); if(options.equals("NOT OK")) command = "NOT OK"; else command = command.concat(options + " -stdout -auto"); return command; }*//**** Get the command line for the SOAP version.* @param Hashtable of the files to be transferrred* @return String command line to use**/ private String getCommand(Hashtable filesToMove) { String command = applName; int numofFields = parseAcd.getNumofFields(); String options = checkParameters(parseAcd, numofFields, filesToMove); if(options.equals("NOT OK")) command = "NOT OK"; else command = command.concat(options + " -auto"); return command; }/**** Ensures garbaged collected when there are* no more pointers to this.* */ public void finalize() throws Throwable { super.finalize(); } public class BatchSoapProcess extends Thread { private String embossCommand; private Hashtable filesToMove; private JembossParams mysettings; private boolean withSoap = true; public BatchSoapProcess(String embossCommand, Hashtable filesToMove, JembossParams mysettings) { this.embossCommand = embossCommand; this.filesToMove = filesToMove; this.mysettings = mysettings; } public void setWithSoap(boolean withSoap) { this.withSoap = withSoap; } public void run() { try { JFrame fsend = new JFrame("Batch"); final int max = 20; final JProgressBar progressBar = new JProgressBar(0,max); progressBar.setStringPainted(true); progressBar.setString("Sending batch process now!"); progressBar.setBackground(Color.white); SwingWorker batchWorker = new SwingWorker() { public Object construct() { try { for(int i=0; i<max; i++) { sleep(500); progressBar.setValue(i); } } catch(InterruptedException intr){} return null; } }; fsend.getContentPane().add(progressBar); fsend.pack(); Dimension d = f.getToolkit().getScreenSize(); fsend.setLocation( (int)(d.getWidth()-fsend.getWidth())/2, (int)(d.getHeight()-fsend.getHeight())/2 ); fsend.setVisible(true); batchWorker.start(); final JembossProcess er; if(withSoap) { JembossRun thisrun = new JembossRun(embossCommand,"", filesToMove,mysettings); er = new JembossProcess((String)thisrun.get("jobid")); } else { JembossServer js = new JembossServer(mysettings.getResultsHome()); Vector result = js.run_prog(embossCommand,mysettings.getCurrentMode(), filesToMove); Hashtable resultHash = convert(result, false); er = new JembossProcess((String)resultHash.get("jobid")); } Jemboss.resultsManager.addResult(er); Jemboss.resultsManager.updateStatus(); if(!Jemboss.resultsManager.isAutoUpdate()) { Jemboss.resultsManager.setAutoUpdate(true); String freq = (String)AdvancedOptions.jobMgr.getSelectedItem(); int ind = freq.indexOf(" "); new BatchUpdateTimer(Integer.parseInt(freq.substring(0,ind))); } fsend.setVisible(false); fsend.dispose(); } catch (JembossSoapException eae) { AuthPopup ap = new AuthPopup(mysettings,f); ap.setBottomPanel(); ap.setSize(380,170); ap.pack(); ap.setVisible(true); f.setCursor(cdone); } } } public class NameComparator implements Comparator { public int compare(Object o1, Object o2) { int obj1 = findInt((String)o1); int obj2 = findInt((String)o2); if(obj1 < obj2) return -1; else if(obj1 > obj2) return 1; return 0; } public boolean equals(Object obj) { return ((Object)this).equals(obj); } /** * * Find the number in a string expression * @param exp string expression * @return number in a string expression or -1 * if none found * */ private int findInt(String exp) { RECompiler rec = new RECompiler(); try { REProgram rep = rec.compile("^(.*?)([:digit:]+)"); RE regexp = new RE(rep); if(regexp.match(exp)) { int ia = (new Integer(regexp.getParen(2))).intValue(); return ia; } } catch (RESyntaxException rese) { System.out.println("RESyntaxException "); } return -1; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -