Changeset 4074
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/servlet/src/org/proteios/action/file/UseSpectrumFileForMsInspectSearchExtension.java
r4073 r4074 30 30 import org.proteios.action.ProteiosAction; 31 31 import org.proteios.action.msInspect.RunMsInspect; 32 //import org.proteios.action.omssa.ViewActiveMsInspectParameterSetStorage;33 //import org.proteios.core.DbControl;34 //import org.proteios.core.Include;35 //import org.proteios.core.ItemQuery;36 //import org.proteios.core.MsInspectParameterSetStorage;37 //import org.proteios.gui.Scroller;38 32 import org.proteios.gui.Title; 39 33 import org.proteios.gui.TitledWindow; … … 43 37 import org.proteios.gui.form.FormFactory; 44 38 import org.proteios.gui.layout.RowLayout; 45 //import org.proteios.gui.table.Table;46 //import org.proteios.gui.table.TableFactory;47 39 48 40 import se.lu.thep.waf.ActionException; … … 128 120 //DbControl dc = newDbControl(); 129 121 /*********************************************************************** 130 * Table of MsInspect Inputs122 * MsInspect Form 131 123 */ 132 /*133 TableFactory tableFactory = getTableFactory();134 tableFactory.setItemClass(MsInspectParameterSetStorage.class);135 Integer from = getValidInteger(Scroller.VFROM);136 Integer max = getValidInteger(Scroller.VMAXRESULT);137 log.debug("from = " + from + " max = " + max);138 if (from != null)139 {140 tableFactory.setQueryFrom(from);141 }142 if (max != null)143 {144 tableFactory.setMaxResults(max);145 }146 ItemQuery<MsInspectParameterSetStorage> query = MsInspectParameterSetStorage.getQuery();147 // Only include MsInspectParameterSetStorage belonging to the active project.148 query.include(Include.IN_PROJECT);149 query.setCacheResult(false);150 tableFactory.setQuery(query);151 tableFactory.setSelectCheckBoxColumnHidden(false);152 // Build table153 Table table = tableFactory.build();154 table.setTitle("MsInspectParameterSetsInDatabase");155 if (table.getScroller() != null)156 {157 table.getScroller().setTableConfActionId(getActionFactory().getId(158 UseSpectrumFileForMsInspectSearchExtension.class));159 }160 */161 124 Form form = new Form("msInspectSearchForm"); 162 125 Fieldset fs = new Fieldset("MsInspect"); … … 175 138 nextSearch.addParameter(RunMsInspect.VMSINSPECTUSEWEBINTERFACEFLAG, false); 176 139 toolbar.add(nextSearch); 177 /*178 // Add 'Next' button to edit parameters before creating search jobs179 ActionLink nextEdit = getActionFactory().getActionLink(180 ViewActiveMsInspectParameterSetStorage.class, "NextMsInspectEditParametersBeforeCreatingSearchJobs");181 nextEdit.addParameter(RunMsInspect.VMSINSPECTUSEWEBINTERFACEFLAG, false);182 toolbar.add(nextEdit);183 */184 140 // 185 141 form.setToolbar(toolbar); … … 189 145 RowLayout layout = getLayoutFactory().getRowLayout(); 190 146 layout.add(new Title("MsInspectFeatureFinding")); 191 //layout.add(selectForm);192 147 layout.add(instructionArea); 193 148 layout.add(form); -
trunk/client/servlet/src/org/proteios/action/msInspect/RunMsInspect.java
r4073 r4074 44 44 import org.proteios.core.StringParameterType; 45 45 import org.proteios.core.User; 46 import org.proteios.gui.form.FormFactory; 47 //import org.proteios.core.MsInspectParameterSetStorage; 48 //import org.proteios.gui.form.FormFactory; 49 //import org.proteios.io.MsInspectParameterFileUtil; 50 //import org.proteios.io.MsInspectParameterSet; 51 52 //import java.io.FileOutputStream; 53 //import java.io.OutputStream; 46 54 47 import java.util.Calendar; 55 48 import java.util.GregorianCalendar; … … 60 53 import se.lu.thep.waf.constraints.VBoolean; 61 54 import se.lu.thep.waf.constraints.VInteger; 62 import se.lu.thep.waf.constraints.VString;63 55 64 56 … … 72 64 public static final VInteger VSPECTRUMFILEID = new VInteger( 73 65 "spectrumFileId", 0, false); 74 public static final VString VMSINSPECT_SEARCH_USER_NAME = new VString(75 "msinspectSearchUserName", 0, 255, false);76 public static final VString VMSINSPECT_SEARCH_USER_EMAIL = new VString(77 "msinspectSearchUserEmail", 0, 255, false);78 //public static final VString VMSINSPECT_SEARCH_TITLE = new VString("MsInspectSearchTitle", 0,79 // 255, false);80 66 public static final VBoolean VMSINSPECTUSEWEBINTERFACEFLAG = new VBoolean( 81 "active.msinspectusewebinterfaceflag", false); 82 public static final VBoolean VSAVEMSINSPECTPARAMETERSETFLAG = new VBoolean( 83 "saveMsInspectParameterSetFlag", false); 84 public static final VBoolean VSAVEASMSINSPECTPARAMETERSETFLAG = new VBoolean( 85 "saveAsMsInspectParameterSetFlag", false); 67 "active.msinspectusewebinterfaceflag", false); 86 68 87 69 @Override … … 102 84 return; 103 85 } 104 /*105 // Get MsInspect search user data106 String msinspectSearchUserName = getValidString(VMSINSPECT_SEARCH_USER_NAME);107 String msinspectSearchUserEmail = getValidString(VMSINSPECT_SEARCH_USER_EMAIL);108 log.debug("msinspectSearchUserName = " + msinspectSearchUserName);109 log.debug("msinspectSearchUserEmail = " + msinspectSearchUserEmail);110 //111 // Get the MsInspectParameterSetStorage item id to use for the search112 Integer msinspectpssId = getValidInteger(ViewActiveMsInspectParameterSetStorage.VMSINSPECTPARAMETERSETSTORAGEID);113 log.debug("msinspectParameterSetStorageId from ViewActiveMsInspectParameterSetStorage.VMSINSPECTPARAMETERSETSTORAGEID = " + msinspectpssId);114 // Make sure a MsInspect parameter set has been selected115 if (msinspectpssId == null || msinspectpssId == 0)116 {117 List<Integer> msinspectpssIds = getValidIntegerList(FormFactory.VID);118 log.debug("msinspectpssIds from FormFactory.VID = " + msinspectpssIds);119 // Make sure at least one file has been selected120 if (msinspectpssIds == null || msinspectpssIds.size() == 0)121 {122 setError("Please select a MsInspect parameter set");123 return;124 }125 // Use first file in list126 msinspectpssId = msinspectpssIds.get(0);127 }128 log.debug("msinspectpssId = " + msinspectpssId);129 */130 86 /*********************************************************************** 131 87 * Get MsInspect search constants from Properties file … … 151 107 log.error("NumberFormatException when parsing \"" + msInspectMemoryInMegaBytesStr + "\" to Integer: " + e); 152 108 } 153 /*154 // MsInspect web interface url155 // MsInspect web server URL string156 //String msInspectWebServerURLStr = "http://localhost";157 String msInspectWebServerURLStr = pf.getProperty("msinspect.server.url");158 // MsInspect web MsInspect search script path159 //String msInspectWebSearchScriptPath = "/cgi/nph-msinspect.exe";160 String msInspectWebSearchScriptPath = pf.getProperty("msinspect.search.script.path");161 // MsInspect web MsInspect export script path162 //String msinspectExportWebScriptPath = "/cgi/export_dat_2.pl";163 String msinspectWebExportScriptPath = pf.getProperty("msinspect.export.script.path");164 // MsInspect web MsInspect result archive directory path165 //String msinspectWebArchivePath = "/data";166 String msinspectWebArchivePath = pf.getProperty("msinspect.archive.path");167 // MsInspect web result filename prefix168 //String msinspectWebResultFilenamePrefix = "";169 String msinspectWebResultFilenamePrefix = pf.getProperty("msinspect.result.filename.prefix");170 // MsInspect web server time difference in hours171 // between the Proteios server and the MsInspect web server172 //String msinspectWebServerTimediffHours = "0";173 String msinspectWebServerTimediffHours = pf.getProperty("msinspect.web.server.timediff.hours");174 // MsInspect web server time correction in minutes175 // apart from time zone between the Proteios server and the MsInspect web server system clocks176 //String msinspectWebServerTimediffCorrectionMinutes = "0";177 String msinspectWebServerTimediffCorrectionMinutes = pf.getProperty("msinspect.web.server.timediff.correction.minutes");178 // MsInspect database directory path179 //String msinspectDatabaseDirectoryPath = "/msinspect-2.1.4.linux/db";180 String msinspectDatabaseDirectoryPath = pf.getProperty("msinspect.local.database.directory.path");181 // MsInspect input filename182 //String msinspectInputBasename = "proteios_autogenerated_input.xml";183 String msinspectInputBasename = pf.getProperty("msinspect.local.input.basename");184 */185 109 // Directory for temporary files 186 110 String tmpDir = null; … … 192 116 log.debug("msInspectProgramName = \"" + msInspectProgramName + "\""); 193 117 log.debug("msInspectMemoryInMegaBytes = " + msInspectMemoryInMegaBytes); 194 /*195 log.debug("msInspectWebServerURLStr = \"" + msInspectWebServerURLStr + "\"");196 log.debug("msInspectWebSearchScriptPath = \"" + msInspectWebSearchScriptPath + "\"");197 log.debug("msinspectWebExportScriptPath = \"" + msinspectWebExportScriptPath + "\"");198 log.debug("msinspectWebArchivePath = \"" + msinspectWebArchivePath + "\"");199 log.debug("msinspectWebResultFilenamePrefix = \"" + msinspectWebResultFilenamePrefix + "\"");200 log.debug("msinspectWebServerTimediffHours = \"" + msinspectWebServerTimediffHours + "\"");201 log.debug("msinspectWebServerTimediffCorrectionMinutes = \"" + msinspectWebServerTimediffCorrectionMinutes + "\"");202 log.debug("msinspectDatabaseDirectoryPath = \"" + msinspectDatabaseDirectoryPath + "\"");203 log.debug("msinspectInputBasename = \"" + msinspectInputBasename + "\"");204 */205 118 log.debug("tmpDir = \"" + tmpDir + "\""); 206 119 log.debug("uploadOutputFileFlag = " + uploadOutputFileFlag); … … 221 134 {} 222 135 log.debug("Active project = " + activeProject); 223 /*224 // Get the MsInspect web interface flag225 Boolean useWebInterfaceFlag = getValidBoolean(VMSINSPECTUSEWEBINTERFACEFLAG);226 log.debug("useWebInterfaceFlag from request = " + useWebInterfaceFlag);227 if (useWebInterfaceFlag == null)228 {229 useWebInterfaceFlag = true;230 }231 log.debug("useWebInterfaceFlag = " + useWebInterfaceFlag);232 // Get the save MsInspect parameter set flag233 Boolean saveMsInspectParameterSetFlag = getValidBoolean(VSAVEMSINSPECTPARAMETERSETFLAG);234 log.debug("saveMsInspectParameterSetFlag from request = " + saveMsInspectParameterSetFlag);235 if (saveMsInspectParameterSetFlag == null)236 {237 saveMsInspectParameterSetFlag = false;238 }239 log.debug("saveMsInspectParameterSetFlag = " + saveMsInspectParameterSetFlag);240 // Get the MsInspectParameterSetStorage item to use for the search241 MsInspectParameterSetStorage msinspectpss = factory.getById(MsInspectParameterSetStorage.class, msinspectpssId);242 log.debug("msinspectpss = " + msinspectpss);243 */244 /*245 // Get the spectrum file items to use for the search246 List<Integer> spectrumFileIds = getValidIntegerList(VSPECTRUMFILEID);247 log.debug("spectrumFileIds = " + spectrumFileIds);248 */249 136 // Get directory to use for optional upload of output file 250 137 Directory dir = null; … … 262 149 } 263 150 log.debug("dir = \"" + dir.getName() + "\", id = " + dir.getId()); 264 /*265 // Fetch MsInspect parameter set from MsInspectParameterSetStorage item266 MsInspectParameterSet msinspectParameterSet = msinspectpss.fetchMsInspectParameterSet();267 */268 /*269 * Append MsInspect install path to file references270 */271 /*272 String listPathDefaultParameters = msinspectParameterSet.getListPathDefaultParameters();273 listPathDefaultParameters = msinspectInstallPath + "/" + listPathDefaultParameters;274 msinspectParameterSet.setListPathDefaultParameters(listPathDefaultParameters);275 //276 String listPathTaxonomyInformation = msinspectParameterSet.getListPathTaxonomyInformation();277 listPathTaxonomyInformation = msinspectInstallPath + "/" + listPathTaxonomyInformation;278 msinspectParameterSet.setListPathTaxonomyInformation(listPathTaxonomyInformation);279 //280 //String spectrumPath = msinspectParameterSet.getSpectrumPath();281 //spectrumPath = msinspectInstallPath + "/" + spectrumPath;282 //msinspectParameterSet.setSpectrumPath(spectrumPath);283 //284 String outputPathBaseName = msinspectParameterSet.getOutputPath();285 log.debug("outputPathBaseName = \"" + outputPathBaseName + "\"");286 */287 151 /*********************************************************************** 288 152 * Create job … … 309 173 // Set estimated execution time to next fastest, SHORT 310 174 job.setEstimatedExecutionTime(Job.ExecutionTime.SHORT); 311 //job.setName(plugin.getName() + " File: " + file.getName());312 //job.setDescription("Gel: " + gelId + " File: " + file.getName());313 //job.setName("MsInspect Search: " + msinspectpss.getName());314 //job.setDescription("MsInspect Parameter Set: " + msinspectpss.getName() + "[" + msinspectpss.getId() + "]\n Spectrum File: " + spectrumFile.getName() + "[" + spectrumFile.getId() + "]");315 175 job.setName("MsInspect Search Spectrum File: " + spectrumFile.getName()); 316 176 job.setDescription("MsInspect Search Spectrum File: " + spectrumFile.getName() + "[" + spectrumFile.getId() + "]"); … … 339 199 StringParameterType timeStampParam = new StringParameterType(); 340 200 job.setParameterValue("timeStampStr", timeStampParam, timeStampStr); 341 /*342 //343 StringParameterType msinspectWebServerURLStrParam = new StringParameterType();344 job.setParameterValue("msinspectWebServerURLStr", msinspectWebServerURLStrParam, msinspectWebServerURLStr);345 //346 StringParameterType msinspectWebSearchScriptPathParam = new StringParameterType();347 job.setParameterValue("msinspectWebSearchScriptPath", msinspectWebSearchScriptPathParam, msinspectWebSearchScriptPath);348 //349 StringParameterType msinspectWebExportScriptPathParam = new StringParameterType();350 job.setParameterValue("msinspectWebExportScriptPath", msinspectWebExportScriptPathParam, msinspectWebExportScriptPath);351 //352 StringParameterType msinspectWebArchivePathParam = new StringParameterType();353 job.setParameterValue("msinspectWebArchivePath", msinspectWebArchivePathParam, msinspectWebArchivePath);354 //355 StringParameterType msinspectWebResultFilenamePrefixParam = new StringParameterType();356 job.setParameterValue("msinspectWebResultFilenamePrefix", msinspectWebResultFilenamePrefixParam, msinspectWebResultFilenamePrefix);357 //358 StringParameterType msinspectWebServerTimediffHoursParam = new StringParameterType();359 job.setParameterValue("msinspectWebServerTimediffHours", msinspectWebServerTimediffHoursParam, msinspectWebServerTimediffHours);360 //361 StringParameterType msinspectWebServerTimediffCorrectionMinutesParam = new StringParameterType();362 job.setParameterValue("msinspectWebServerTimediffCorrectionMinutes", msinspectWebServerTimediffCorrectionMinutesParam, msinspectWebServerTimediffCorrectionMinutes);363 //364 StringParameterType msinspectInstallPathParam = new StringParameterType();365 job.setParameterValue("msinspectInstallPath", msinspectInstallPathParam, msinspectInstallPath);366 //367 StringParameterType msinspectProgramNameParam = new StringParameterType();368 job.setParameterValue("msinspectProgramName", msinspectProgramNameParam, msinspectProgramName);369 //370 StringParameterType msinspectDatabaseDirectoryPathParam = new StringParameterType();371 job.setParameterValue("msinspectDatabaseDirectoryPath", msinspectDatabaseDirectoryPathParam, msinspectDatabaseDirectoryPath);372 //373 StringParameterType tmpDirParam = new StringParameterType();374 job.setParameterValue("tmpDir", tmpDirParam, tmpDir);375 //376 //StringParameterType msinspectWebInterfaceURLStrParam = new StringParameterType();377 //job.setParameterValue("msinspectWebInterfaceURLStr", msinspectWebInterfaceURLStrParam, msinspectWebInterfaceURLStr);378 //379 //StringParameterType msinspectInputFilenameParam = new StringParameterType();380 //job.setParameterValue("msinspectInputFilename", msinspectInputFilenameParam, msinspectInputFilename);381 //382 StringParameterType msinspectSearchUserNameParam = new StringParameterType();383 job.setParameterValue("msinspectSearchUserName", msinspectSearchUserNameParam, msinspectSearchUserName);384 //385 StringParameterType msinspectSearchUserEmailParam = new StringParameterType();386 job.setParameterValue("msinspectSearchUserEmail", msinspectSearchUserEmailParam, msinspectSearchUserEmail);387 //388 IntegerParameterType msinspectpssIdParam = new IntegerParameterType();389 job.setParameterValue("msinspectpssId", msinspectpssIdParam, msinspectpssId);390 //391 IntegerParameterType spectrumFileIdParam = new IntegerParameterType();392 job.setParameterValue("spectrumFileId", spectrumFileIdParam, spectrumFileId);393 //394 IntegerParameterType dirIdParam = new IntegerParameterType();395 job.setParameterValue("dirId", dirIdParam, dir.getId());396 //397 BooleanParameterType uploadOutputFileFlagParam = new BooleanParameterType();398 job.setParameterValue("uploadOutputFileFlag", uploadOutputFileFlagParam, uploadOutputFileFlag);399 //400 BooleanParameterType useWebInterfaceFlagParam = new BooleanParameterType();401 job.setParameterValue("useWebInterfaceFlag", useWebInterfaceFlagParam, useWebInterfaceFlag);402 */403 201 // 404 202 ItemParameterType<Project> projectParam = new ItemParameterType<Project>( 405 203 Project.class, null); 406 204 job.setParameterValue("project", projectParam, activeProject); 407 // File parameters 408 //FileParameterType filesParam = new FileParameterType(); 409 //job.setParameterValue("file", filesParam, file); 205 // 410 206 dc.saveItem(job); 411 207 dc.commit(); 412 /*413 // Use locally installed MsInspect program414 if (useWebInterfaceFlag != null && !useWebInterfaceFlag)415 {416 // Append job id to input base filename417 int jobId = job.getId();418 log.debug("jobId = " + jobId);419 String msinspectInputFilename = fetchXmlFilePathWithTimeStamp(msinspectInputBasename, jobId);420 log.debug("msinspectInputFilename = \"" + msinspectInputFilename + "\"");421 // Get MsInspect input file path422 String msinspectInputFilePath = msinspectInstallPath + "/" + msinspectInputFilename;423 log.debug("msinspectInputFilePath = \"" + msinspectInputFilePath + "\"");424 java.io.File msinspectInputFileLocal = new java.io.File(msinspectInputFilePath);425 // Append job id to output base filename426 StringBuilder sb = new StringBuilder();427 //sb.append(outputPathBaseName);428 // Remove ".xml" file extension429 if (sb.toString().endsWith(".xml"))430 {431 sb.setLength(sb.length() - 4);432 }433 sb.append("_");434 sb.append(jobId);435 sb.append(".xml");436 String outputPath = sb.toString();437 log.debug("outputPath = \"" + outputPath + "\"");438 String outputPathFull = msinspectInstallPath + "/" + outputPath;439 log.debug("outputPathFull = \"" + outputPathFull + "\"");440 //msinspectParameterSet.setOutputPath(outputPathFull);441 //442 String spectrumPath = tmpDir + "/" + spectrumFile.getName();443 //msinspectParameterSet.setSpectrumPath(spectrumPath);444 //445 saveMsInspectInputFileLocal(msinspectInputFileLocal, msinspectParameterSet);446 //447 dc = newDbControl();448 dc.reattachItem(job);449 //450 StringParameterType msinspectInputFilenameParam = new StringParameterType();451 job.setParameterValue("msinspectInputFilename", msinspectInputFilenameParam, msinspectInputFilename);452 //453 StringParameterType msinspectOutputPathParam = new StringParameterType();454 job.setParameterValue("msinspectOutputPath", msinspectOutputPathParam, outputPath);455 //456 dc.commit();457 }458 */459 208 log.debug("job.getId() = " + job.getId()); 460 209 } … … 464 213 */ 465 214 setForwardTo(ListJobs.class); 466 }467 468 469 /*470 private void saveMsInspectInputFileLocal(java.io.File localFile, MsInspectParameterSet msinspectParameterSet)471 throws ActionException472 {473 // Create an XML stream writer for the XML data474 OutputStream oStream = null;475 try476 {477 oStream = new FileOutputStream(localFile);478 }479 catch (Exception e)480 {481 throw new ActionException(482 "Exception when trying to get upload stream for file \"" + localFile.getAbsolutePath() + "\" : " + e);483 }484 // Save MsInspectParameterSet data in external MsInspect input file485 MsInspectParameterFileUtil msinspectParameterFileUtil = new MsInspectParameterFileUtil();486 //msinspectParameterFileUtil.setMsInspectParameterSet(msinspectParameterSet);487 msinspectParameterFileUtil.setXMLOutputStream(oStream);488 msinspectParameterFileUtil.exportMsInspectParameterSet(msinspectParameterSet);489 // Make sure that upload stream is closed490 try491 {492 if (oStream != null)493 {494 oStream.flush();495 // Close upload stream.496 oStream.close();497 }498 }499 catch (Exception e)500 {501 throw new ActionException(502 "Exception when trying to close upload stream for file: " + e);503 }504 }505 */506 507 508 /**509 * Appends time stamp to file base filename (filename510 * excluding optional file extension) for XML file path.511 * Adds ".xml" file extension, if not existing.512 *513 * Example:514 * Basic xml file path: proteios_autogenerated_input.xml515 * Discr id: 3516 * Time stamp: 2008-02-29 12:47:00517 * Returned xml file path: proteios_autogenerated_input_3.2008_02_29_12_47_00.xml518 *519 * @param xmlFilePath String Input file path520 * @param discrId Integer Index to discriminate between files created same second521 * @return String File path with time stamp appended to file name522 */523 public String fetchXmlFilePathWithTimeStamp(String xmlFilePath, Integer discrId)524 {525 /*526 * Appends time stamp to file base filename (filename527 * excluding optional file extension) for XML file path.528 * Adds ".xml" file extension, if not existing.529 *530 * Example:531 * Basic xml file path: proteios_autogenerated_input.xml532 * Discr id: 3533 * Time stamp: 2008-02-29 12:47:00534 * Returned xml file path: proteios_autogenerated_input_3.2008_02_29_12_47_00.xml535 */536 StringBuilder sb = new StringBuilder();537 sb.append(xmlFilePath);538 // Remove ".xml" file extension539 if (sb.toString().endsWith(".xml"))540 {541 sb.setLength(sb.length() - 4);542 }543 //544 if (discrId != null && discrId >= 0)545 {546 sb.append("_");547 sb.append(discrId);548 }549 //550 sb.append(".");551 Calendar cal = Calendar.getInstance();552 int year = cal.get(Calendar.YEAR);553 int month = cal.get(Calendar.MONTH) + 1;554 int day = cal.get(Calendar.DAY_OF_MONTH);555 int hour = cal.get(Calendar.HOUR_OF_DAY);556 int min = cal.get(Calendar.MINUTE);557 int sec = cal.get(Calendar.SECOND);558 String monthStr = leftPaddedString(Integer.toString(month), 2, '0');559 String dayStr = leftPaddedString(Integer.toString(day), 2, '0');560 String hourStr = leftPaddedString(Integer.toString(hour), 2, '0');561 String minStr = leftPaddedString(Integer.toString(min), 2, '0');562 String secStr = leftPaddedString(Integer.toString(sec), 2, '0');563 sb.append(year);564 sb.append("_");565 sb.append(monthStr);566 sb.append("_");567 sb.append(dayStr);568 sb.append("_");569 sb.append(hourStr);570 sb.append("_");571 sb.append(minStr);572 sb.append("_");573 sb.append(secStr);574 //575 sb.append(".xml");576 String xmlFilePathWithSuffix = sb.toString();577 log.debug("xmlFilePath = \"" + xmlFilePath + "\" xFilePathWithSuffix = \"" + xmlFilePathWithSuffix + "\"");578 //579 return xmlFilePathWithSuffix;580 215 } 581 216 -
trunk/plugin/src/org/proteios/plugins/RunMsInspectPlugin.java
r4073 r4074 31 31 import org.apache.commons.httpclient.HttpStatus; 32 32 import org.apache.commons.httpclient.methods.PostMethod; 33 import org.apache.commons.httpclient.methods.multipart.FilePart;34 import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;35 33 import org.apache.commons.httpclient.methods.multipart.Part; 36 34 import org.apache.commons.httpclient.methods.multipart.PartSource; … … 41 39 import org.proteios.core.Directory; 42 40 import org.proteios.core.File; 43 import org.proteios.core.FileType;44 41 import org.proteios.core.ItemFactory; 45 //import org.proteios.core.msInspectParameterSetStorage;46 //import org.proteios.core.MsInspectParameterSetStorage;47 42 import org.proteios.core.ProgressReporter; 48 43 import org.proteios.core.SessionControl; … … 53 48 import org.proteios.core.plugin.Request; 54 49 import org.proteios.core.plugin.Response; 55 //import org.proteios.io.msInspectParameterSet;56 //import org.proteios.plugins.SearchmsInspectPlugin.StreamGobbler;57 //import org.proteios.io.MsInspectParameterSet;58 50 59 51 import java.io.BufferedReader; … … 66 58 import java.io.PrintWriter; 67 59 import java.util.ArrayList; 68 import java.util.Calendar;69 import java.util.GregorianCalendar;70 import java.util.Hashtable;71 60 import java.util.List; 72 61 import java.util.regex.Matcher; … … 293 282 ProgressReporter progress) 294 283 { 295 String msInspectWebServerURLStr;296 String msInspectWebSearchScriptPath;297 String msInspectWebExportScriptPath;298 String msInspectWebArchivePath;299 String msInspectWebResultFilenamePrefix;300 String msInspectWebServerTimediffHoursStr;301 String msInspectWebServerTimediffCorrectionMinutesStr;302 284 String tmpDir; 303 285 String msInspectInstallPath; 304 286 String msInspectProgramName; 305 287 Integer msInspectMemoryInMegaBytes; 306 String msInspectDatabaseDirectoryPath;307 String msInspectInputFilename;308 String msInspectOutputPath;309 String msInspectSearchUserName;310 String msInspectSearchUserEmail;311 String msInspectProgramPath;312 String msInspectInputPath;313 Integer msInspectpssId;314 288 Integer spectrumFileId; 315 289 Integer dirId; 316 290 Boolean uploadOutputFileFlag; 317 Boolean useWebInterfaceFlag;318 291 String timeStampStr; 319 double msInspectWebServerTimediffHours; 320 double msInspectWebServerTimediffCorrectionMinutes; 321 double msInspectWebServerTimediffMinutes; 322 323 /* 324 msInspectWebServerURLStr = (String) job.getValue("msInspectWebServerURLStr"); 325 msInspectWebSearchScriptPath = (String) job 326 .getValue("msInspectWebSearchScriptPath"); 327 msInspectWebExportScriptPath = (String) job 328 .getValue("msInspectWebExportScriptPath"); 329 msInspectWebArchivePath = (String) job.getValue("msInspectWebArchivePath"); 330 msInspectWebResultFilenamePrefix = (String) job 331 .getValue("msInspectWebResultFilenamePrefix"); 332 msInspectWebServerTimediffHoursStr = (String) job 333 .getValue("msInspectWebServerTimediffHours"); 334 msInspectWebServerTimediffCorrectionMinutesStr = (String) job 335 .getValue("msInspectWebServerTimediffCorrectionMinutes"); 336 */ 292 337 293 msInspectInstallPath = (String) job.getValue("msInspectInstallPath"); 338 294 msInspectProgramName = (String) job.getValue("msInspectProgramName"); … … 343 299 uploadOutputFileFlag = (Boolean) job.getValue("uploadOutputFileFlag"); 344 300 timeStampStr = (String) job.getValue("timeStampStr"); 345 /*346 msInspectDatabaseDirectoryPath = (String) job347 .getValue("msInspectDatabaseDirectoryPath");348 msInspectInputFilename = (String) job.getValue("msInspectInputFilename");349 msInspectOutputPath = (String) job.getValue("msInspectOutputPath");350 msInspectSearchUserName = (String) job.getValue("msInspectSearchUserName");351 msInspectSearchUserEmail = (String) job.getValue("msInspectSearchUserEmail");352 msInspectpssId = (Integer) job.getValue("msInspectpssId");353 useWebInterfaceFlag = (Boolean) job.getValue("useWebInterfaceFlag");354 msInspectProgramPath = msInspectInstallPath + "/" + msInspectProgramName;355 msInspectInputPath = msInspectInstallPath + "/" + msInspectInputFilename;356 msInspectWebServerTimediffHours = 0;357 358 if (msInspectWebServerTimediffHoursStr != null && !msInspectWebServerTimediffHoursStr359 .equals(""))360 {361 msInspectWebServerTimediffHours = Double362 .parseDouble(msInspectWebServerTimediffHoursStr);363 }364 365 msInspectWebServerTimediffCorrectionMinutes = 0;366 if (msInspectWebServerTimediffCorrectionMinutesStr != null && !msInspectWebServerTimediffCorrectionMinutesStr367 .equals(""))368 {369 msInspectWebServerTimediffCorrectionMinutes = Double370 .parseDouble(msInspectWebServerTimediffCorrectionMinutesStr);371 }372 373 msInspectWebServerTimediffMinutes = 60 * msInspectWebServerTimediffHours + msInspectWebServerTimediffCorrectionMinutes;374 */375 //376 /*377 log.debug("msInspectWebServerURLStr = \"" + msInspectWebServerURLStr + "\"");378 log379 .debug("msInspectWebSearchScriptPath = \"" + msInspectWebSearchScriptPath + "\"");380 log381 .debug("msInspectWebExportScriptPath = \"" + msInspectWebExportScriptPath + "\"");382 log.debug("msInspectWebArchivePath = \"" + msInspectWebArchivePath + "\"");383 log384 .debug("msInspectWebResultFilenamePrefix = \"" + msInspectWebResultFilenamePrefix + "\"");385 log386 .debug("msInspectWebServerTimediffHoursStr = \"" + msInspectWebServerTimediffHoursStr + "\"");387 log388 .debug("msInspectWebServerTimediffHours = " + msInspectWebServerTimediffHours);389 log390 .debug("msInspectWebServerTimediffCorrectionMinutesStr = \"" + msInspectWebServerTimediffCorrectionMinutesStr + "\"");391 log392 .debug("msInspectWebServerTimediffCorrectionMinutes = " + msInspectWebServerTimediffCorrectionMinutes);393 log394 .debug("msInspectWebServerTimediffMinutes = " + msInspectWebServerTimediffMinutes);395 log.debug("tmpDir = \"" + tmpDir + "\"");396 */397 log.debug("msInspectInstallPath = \"" + msInspectInstallPath + "\"");398 log.debug("msInspectProgramName = \"" + msInspectProgramName + "\"");399 log.debug("msInspectMemoryInMegaBytes = " + msInspectMemoryInMegaBytes);400 log.debug("tmpDir = \"" + tmpDir + "\"");401 log.debug("spectrumFileId = " + spectrumFileId);402 log.debug("dirId = " + dirId);403 log.debug("uploadOutputFileFlag = " + uploadOutputFileFlag);404 log.debug("timeStampStr = \"" + timeStampStr + "\"");405 /*406 log.debug("msInspectProgramPath = \"" + msInspectProgramPath + "\"");407 log408 .debug("msInspectDatabaseDirectoryPath = \"" + msInspectDatabaseDirectoryPath + "\"");409 log.debug("msInspectInputFilename = \"" + msInspectInputFilename + "\"");410 log.debug("msInspectInputPath = \"" + msInspectInputPath + "\"");411 log.debug("msInspectOutputPath = \"" + msInspectOutputPath + "\"");412 log.debug("msInspectSearchUserName = \"" + msInspectSearchUserName + "\"");413 log.debug("msInspectSearchUserEmail = \"" + msInspectSearchUserEmail + "\"");414 log.debug("msInspectpssId = " + msInspectpssId);415 log.debug("spectrumFileId = " + spectrumFileId);416 log.debug("dirId = " + dirId);417 log.debug("uploadOutputFileFlag = " + uploadOutputFileFlag);418 log.debug("useWebInterfaceFlag = " + useWebInterfaceFlag);419 */420 301 421 302 // Perform msInspect search using local search engine … … 471 352 Boolean uploadOutputFileFlag, String timeStampStr) 472 353 { 473 String programPath = msInspectInstallPath + "/" + msInspectProgramName;474 //475 354 log.debug("msInspectInstallPath = \"" + msInspectInstallPath + "\""); 476 355 log.debug("msInspectProgramName = \"" + msInspectProgramName + "\""); … … 491 370 // Create output file in directory for temporary files 492 371 String msInspectOutputDirPath = new String(""); 493 //Calendar cal = GregorianCalendar.getInstance();494 /*495 String msInspectOutputDirPath = new String("msInspect_output_" + job.getId());496 msInspectOutputDirPath = msInspectOutputDirPath + "_" + fetchTimeStampString(cal, 0);497 */498 372 log.debug("msInspectOutputDirPath = \"" + msInspectOutputDirPath + "\""); 499 373 msInspectOutputDirPath = tmpDir + "/" + msInspectOutputDirPath; … … 540 414 .error("IOException when trying to save temporary spectrum file \"" + spectrumFileTmp + "\": " + e); 541 415 } 542 // msInspectParameterSet msInspectParameterSet = new msInspectParameterSet();543 //544 // String content = null;545 // Find option for spectrum file type546 //String spectrumFileOption = new String("-f");547 // Construct output file path548 //String msInspectOutputFilename = spectrumBaseFilename + ".peptides.tsv";549 416 String msInspectOutputFilename = msInspectInputBaseFilename + ".peptides.tsv"; 550 417 delimiter = "/"; … … 555 422 String msInspectOutputPath = msInspectOutputDirPath + delimiter + msInspectOutputFilename; 556 423 log.debug("msInspectOutputPath = \"" + msInspectOutputPath + "\""); 557 /*558 if (fileExtension.equals("dta") || fileExtension.equals("DTA"))559 {560 // Blank line delimited DTA561 spectrumFileOption = new String("-fb");562 }563 else if (fileExtension.equals("xml") || fileExtension.equals("XML"))564 {565 // XML encapsulated DTA566 spectrumFileOption = new String("-fx");567 }568 else if (fileExtension.equals("pkl") || fileExtension.equals("PKL"))569 {570 // PKL format571 spectrumFileOption = new String("-fp");572 }573 else if (fileExtension.equals("mgf") || fileExtension.equals("MGF"))574 {575 // MGF format576 spectrumFileOption = new String("-fm");577 }578 log.debug("spectrumFilename = \"" + spectrumFilename + "\", spectrumFileOption = \"" + spectrumFileOption + "\"");579 */580 424 // Prepare msInspect search command for use with local installation 581 425 boolean imported = false; 582 426 try 583 427 { 584 String option = null;585 String value = null;586 //String cmd = msInspectProgramPath + " " + msInspectInputPath;587 //String cmd = msInspectProgramPath + " -pm " + msInspectInputPath + " " + spectrumFileOption + " " + spectrumFileTmp + " -ox " + msInspectOutputPath;588 428 String cmd = msInspectProgramPath; 589 429 if (msInspectProgramPath.endsWith(".jar") || msInspectProgramPath.endsWith(".JAR")) … … 603 443 cmd = cmd + " --outdir=" + msInspectOutputDirPath; 604 444 cmd = cmd + " " + spectrumFileTmp; 605 /*606 //607 // msInspect - General608 //609 log.debug("Enzyme");610 option = new String("-e");611 value = msInspectParameterSet.getEnzyme();612 cmd = updateCommand(cmd, option, value);613 //614 log.debug("Maximum missed cleavages");615 option = new String("-v");616 value = msInspectParameterSet.getMissedCleave();617 cmd = updateCommand(cmd, option, value);618 //619 // To work with third-party databases, full path is used620 log.debug("Sequence library");621 option = new String("-d");622 //value = msInspectParameterSet.getDb();623 value = msInspectDatabaseDirectoryPath + "/" + msInspectParameterSet.getDb();624 cmd = updateCommand(cmd, option, value);625 //626 log.debug("Species to search (Taxon)");627 option = new String("-x");628 value = msInspectParameterSet.getSpecies();629 cmd = updateCommand(cmd, option, value);630 //631 log.debug("Hitlist max length");632 option = new String("-hl");633 value = msInspectParameterSet.getHitListLen();634 cmd = updateCommand(cmd, option, value);635 //636 log.debug("E-value cutoff");637 option = new String("-he");638 value = msInspectParameterSet.getCutoff();639 cmd = updateCommand(cmd, option, value);640 //641 log.debug("Fixed mods");642 option = new String("-mf");643 value = msInspectParameterSet.getFixed();644 cmd = updateCommand(cmd, option, value);645 //646 log.debug("Variable mods");647 option = new String("-mv");648 value = msInspectParameterSet.getVariable();649 cmd = updateCommand(cmd, option, value);650 //651 log.debug("Maximum variable mod combinations searched per peptide");652 option = new String("-mm");653 value = msInspectParameterSet.getMaxMods();654 cmd = updateCommand(cmd, option, value);655 //656 log.debug("Precursor mass tolerance");657 option = new String("-te");658 value = msInspectParameterSet.getPepTol();659 cmd = updateCommand(cmd, option, value);660 //661 log.debug("Product mass tolerance");662 option = new String("-to");663 value = msInspectParameterSet.getMsMsTol();664 cmd = updateCommand(cmd, option, value);665 //666 log.debug("Precursor mass search type");667 option = new String("-tem");668 value = msInspectParameterSet.getPrecursorSearchType();669 cmd = updateCommand(cmd, option, value);670 //671 log.debug("Product mass search type");672 option = new String("-tom");673 value = msInspectParameterSet.getProductSearchType();674 cmd = updateCommand(cmd, option, value);675 //676 log.debug("Lower bound of precursor charge");677 option = new String("-zl");678 value = msInspectParameterSet.getMinCharge();679 cmd = updateCommand(cmd, option, value);680 //681 log.debug("Upper bound of precursor charge");682 option = new String("-zh");683 value = msInspectParameterSet.getMaxCharge();684 cmd = updateCommand(cmd, option, value);685 //686 log.debug("Minimum charge to start using multiply charged products");687 option = new String("-zt");688 value = msInspectParameterSet.getConsiderMult();689 cmd = updateCommand(cmd, option, value);690 //691 log.debug("Fraction of product peaks below precursor to determine +1 precursor");692 option = new String("-z1");693 value = msInspectParameterSet.getPlusOne();694 cmd = updateCommand(cmd, option, value);695 //696 log.debug("Peak intensity cutoff");697 option = new String("-cl");698 value = msInspectParameterSet.getCutLo();699 cmd = updateCommand(cmd, option, value);700 //701 log.debug("Number of top intensity peaks in first pass");702 option = new String("-ht");703 value = msInspectParameterSet.getTopHitNum();704 cmd = updateCommand(cmd, option, value);705 //706 // Combine search option values to comma-separated list707 log.debug("Ions to search 1");708 option = new String("-i");709 String value1 = msInspectParameterSet.getIonsToSearch1();710 //711 log.debug("Ions to search 2");712 option = new String("-i");713 String value2 = msInspectParameterSet.getIonsToSearch2();714 // Combine search option values and update command715 value = value1 + "," + value2;716 cmd = updateCommand(cmd, option, value);717 //718 // msInspect - Extra (Not used for web search)719 //720 log.debug("Z dependence");721 option = new String("-tez");722 value = msInspectParameterSet.getZDep();723 cmd = updateCommand(cmd, option, value);724 //725 log.debug("Peak high intensity cutoff");726 option = new String("-ch");727 value = msInspectParameterSet.getCutHi();728 cmd = updateCommand(cmd, option, value);729 //730 log.debug("CutInc");731 option = new String("-ci");732 value = msInspectParameterSet.getCutInc();733 cmd = updateCommand(cmd, option, value);734 //735 log.debug("Single window");736 option = new String("-w1");737 value = msInspectParameterSet.getSingleWin();738 cmd = updateCommand(cmd, option, value);739 //740 log.debug("Double window");741 option = new String("-w2");742 value = msInspectParameterSet.getDoubleWin();743 cmd = updateCommand(cmd, option, value);744 //745 log.debug("Single number");746 option = new String("-h1");747 value = msInspectParameterSet.getSingleNum();748 cmd = updateCommand(cmd, option, value);749 //750 log.debug("Double number");751 option = new String("-h2");752 value = msInspectParameterSet.getDoubleNum();753 cmd = updateCommand(cmd, option, value);754 //755 log.debug("Min hit");756 option = new String("-hm");757 value = msInspectParameterSet.getMinHit();758 cmd = updateCommand(cmd, option, value);759 //760 log.debug("Min spectra");761 option = new String("-hs");762 value = msInspectParameterSet.getMinSpectra();763 cmd = updateCommand(cmd, option, value);764 //765 log.debug("Ms calc plus one");766 option = new String("-zc");767 value = msInspectParameterSet.getMsCalcPlusOne();768 cmd = updateCommand(cmd, option, value);769 //770 log.debug("Ms calc charge");771 option = new String("-zcc");772 value = msInspectParameterSet.getMsCalcCharge();773 cmd = updateCommand(cmd, option, value);774 //775 log.debug("Max product charge");776 option = new String("-zoh");777 value = msInspectParameterSet.getMaxProductCharge();778 cmd = updateCommand(cmd, option, value);779 //780 log.debug("Pseudo count");781 option = new String("-pc");782 value = msInspectParameterSet.getPseudoCount();783 cmd = updateCommand(cmd, option, value);784 //785 log.debug("Search b1");786 option = new String("-sb1");787 value = msInspectParameterSet.getSearchB1();788 cmd = updateCommand(cmd, option, value);789 //790 log.debug("Search C terminal product");791 option = new String("-sct");792 value = msInspectParameterSet.getSearchCTermProduct();793 cmd = updateCommand(cmd, option, value);794 //795 log.debug("Max productions");796 option = new String("-sp");797 value = msInspectParameterSet.getMaxProductions();798 cmd = updateCommand(cmd, option, value);799 //800 log.debug("Min no enzymes");801 option = new String("-no");802 value = msInspectParameterSet.getMinNoEnzyme();803 cmd = updateCommand(cmd, option, value);804 //805 log.debug("Max no enzymes");806 option = new String("-nox");807 value = msInspectParameterSet.getMaxNoEnzyme();808 cmd = updateCommand(cmd, option, value);809 //810 log.debug("Exact mass");811 option = new String("-tex");812 value = msInspectParameterSet.getExactMass();813 cmd = updateCommand(cmd, option, value);814 //815 log.debug("Research threshold");816 option = new String("-ii");817 value = msInspectParameterSet.getResearchThresh();818 cmd = updateCommand(cmd, option, value);819 //820 log.debug("Subset threshold");821 option = new String("-is");822 value = msInspectParameterSet.getSubsetThresh();823 cmd = updateCommand(cmd, option, value);824 //825 log.debug("Replace threshold");826 option = new String("-ir");827 value = msInspectParameterSet.getReplaceThresh();828 cmd = updateCommand(cmd, option, value);829 //830 log.debug("Precursor cull");831 option = new String("-cp");832 value = msInspectParameterSet.getPrecursorCull();833 cmd = updateCommand(cmd, option, value);834 //835 log.debug("No correlation score");836 option = new String("-scorr");837 value = msInspectParameterSet.getNoCorrelationScore();838 cmd = updateCommand(cmd, option, value);839 //840 log.debug("Prob following ion");841 option = new String("-scorp");842 value = msInspectParameterSet.getProbFollowingIon();843 cmd = updateCommand(cmd, option, value);844 //845 log.debug("NMethionine");846 option = new String("-mnm");847 value = msInspectParameterSet.getNMethionineAttribute();848 log.debug("NMethionine attribute value = \"" + value + "\"");849 if (value != null && (value.equals("false") || value.equals("FALSE")))850 {851 // Set flag that N-term methionine should not be cleaved852 log.debug("option = \"" + option + "\" (Flag set that N-term methionine should not be cleaved)");853 cmd = cmd + " " + option;854 }855 else856 {857 log.debug("option = \"" + option + "\" (Flag NOT set that N-term methionine should not be cleaved)");858 }859 //860 log.debug("Auto mass adjustment");861 option = new String("-ta");862 value = msInspectParameterSet.getAutoMassAdjust();863 cmd = updateCommand(cmd, option, value);864 //865 // Input and output files866 //867 log.debug("Include input parameter values in result file");868 option = new String("-w");869 // Set flag that input parameter values should be included in result file870 log.debug("option = \"" + option + "\" (Flag set that input parameter values should be included in result file)");871 cmd = cmd + " " + option;872 */873 //874 /*875 * Note: msInspect uses the option stored in876 * string "spectrumFileOption" to decide877 * how to parse a spectrum file, and if msInspect878 * supports the file type at all. The input local879 * file path stored in string "spectrumFileTmp"880 * may have a file extension indicating a881 * different type of file, but this is882 * not used by msInspect.883 */884 /*885 //886 log.debug("spectrum file");887 option = spectrumFileOption;888 value = spectrumFileTmp.getAbsolutePath();889 cmd = updateCommand(cmd, option, value);890 //891 log.debug("output file");892 option = new String("-ox");893 value = msInspectOutputPath;894 cmd = updateCommand(cmd, option, value);895 */896 445 // 897 446 // Execute msInspect search using local installation 898 //899 447 // 900 448 if (isJobAborted()) … … 953 501 { 954 502 boolean outputFileFound = false; 955 //if (localFileCanBeRead(tmpDir, msInspectOutputPath))956 /*957 if (localFileCanBeRead(null, msInspectOutputPath))958 {959 outputFileFound = true;960 }961 */962 503 // Test output filename excluding original file extension in name 963 504 String testOutputFilename = msInspectInputBaseFilename + ".peptides.tsv"; … … 985 526 log.debug("msInspectOutputFilename = \"" + msInspectOutputFilename + "\""); 986 527 log.debug("msInspectOutputPath = \"" + msInspectOutputPath + "\""); 987 /*988 // Get output file name including time stamp, check a number of989 // seconds back in time990 // Calendar cal = Calendar.getInstance();991 cal = GregorianCalendar.getInstance();992 String msInspectOutputPathWithTimeStamp = null;993 int maxSeconds = 10;994 for (int secToSubtract = 0; !outputFileFound && secToSubtract < maxSeconds; secToSubtract++)995 {996 String localPath = fetchmsInspectOutputPathWithTimeStamp(997 msInspectOutputPath, null, cal, -secToSubtract);998 if (localFileCanBeRead(msInspectInstallPath, localPath))999 {1000 msInspectOutputPathWithTimeStamp = localPath;1001 outputFileFound = true;1002 }1003 log1004 .debug("localPath = \"" + localPath + "\" outputFileFound = " + outputFileFound);1005 }1006 if (!outputFileFound)1007 {1008 String tmpStr = fetchmsInspectOutputPathWithTimeStamp(1009 msInspectOutputPath, null, cal, 0);1010 // Exchange time part, e.g. 12_47_00.xml with xx_xx_xx.xml1011 StringBuilder sb = new StringBuilder();1012 sb.append(tmpStr);1013 if (sb.length() > 14)1014 {1015 sb.setLength(sb.length() - 14);1016 }1017 sb.append("xx_xx_xx.xml");1018 msInspectOutputPathWithTimeStamp = sb.toString();1019 }1020 */1021 // Construct job done message1022 /*1023 String convertMessage = new String("");1024 if (mzDataConvertedToMgfUsed)1025 {1026 convertMessage = new String(" - mzData data converted to MGF used for search");1027 }1028 */1029 528 String doneMessage = new String("msInspect search finished"); 1030 /*1031 doneMessage = doneMessage + convertMessage;1032 */1033 529 // 1034 530 doneMessage = doneMessage + "\n" + "msInspect input file: " + originalSpectrumFilename; … … 1042 538 if (outputFileFound) 1043 539 { 1044 /*1045 String description = new String(1046 "msInspect search for " + spectrumFile.getName() + "[" + spectrumFile1047 .getId() + "] using parameter set " + msInspectpss1048 .getName() + "[" + msInspectpss.getId() + "]");1049 */1050 540 String description = new String( 1051 541 "msInspect search for " + spectrumFile.getName() + "[" + spectrumFile … … 1053 543 try 1054 544 { 1055 /*1056 uploadMsInspectOutputFile(msInspectInstallPath,1057 msInspectOutputPathWithTimeStamp, dirId, description);1058 */1059 545 // Construct filename to use for uploaded result file 1060 /*1061 String filenameOfUploadedFile = constructFilenameOfUploadedFile(1062 spectrumFile.getName(), msInspectOutputPathWithTimeStamp);1063 */1064 546 String filenameOfUploadedFile = new String(msInspectOutputFilename); 1065 547 log.debug("filenameOfUploadedFile = \"" + filenameOfUploadedFile + "\""); … … 1250 732 // Return command line 1251 733 return cmd; 1252 }1253 1254 1255 /**1256 * Construct filename for uploaded search result file. The constructed1257 * filename consists of the (possibly modified) base name of the input file,1258 * an underscore, plus the modified result filename consisting of the date,1259 * an underscore, and the result filename with file extension ".dat"1260 * exchanged for ".xml".1261 *1262 * @param inputFilename String Filename of input file for search.1263 * @param filename String Filename of the search result file to upload.1264 * @return String The constructed filename for the uploaded result file.1265 */1266 private String constructFilenameOfUploadedFile(String inputFilename,1267 String filename)1268 {1269 String tmpStr;1270 if (inputFilename != null)1271 {1272 int strIndex;1273 // Construct filename to use for uploaded result file1274 tmpStr = inputFilename;1275 log.debug("tmpStr from input filename = \"" + tmpStr + "\"");1276 // Remove optional prefix ending with '\'1277 strIndex = tmpStr.lastIndexOf("\\");1278 if (strIndex >= 0)1279 {1280 tmpStr = tmpStr.substring(strIndex + 1);1281 }1282 log1283 .debug("tmpStr after removing prefix ending with '\\' = \"" + tmpStr + "\"");1284 // Remove optional prefix ending with '/'1285 strIndex = tmpStr.lastIndexOf("/");1286 if (strIndex >= 0)1287 {1288 tmpStr = tmpStr.substring(strIndex + 1);1289 }1290 log1291 .debug("tmpStr after removing prefix ending with '/' = \"" + tmpStr + "\"");1292 // Remove optional prefix ending with ':'1293 strIndex = tmpStr.lastIndexOf(":");1294 if (strIndex >= 0)1295 {1296 tmpStr = tmpStr.substring(strIndex + 1);1297 }1298 log1299 .debug("tmpStr after removing prefix ending with ':' = \"" + tmpStr + "\"");1300 // Remove any initial blanks1301 tmpStr = tmpStr.replaceAll("^\\ *", "");1302 log1303 .debug("tmpStr after removing initial blanks = \"" + tmpStr + "\"");1304 // Remove optional file extension from input filename1305 strIndex = tmpStr.lastIndexOf(".");1306 if (strIndex >= 0)1307 {1308 tmpStr = tmpStr.substring(0, strIndex);1309 }1310 log1311 .debug("tmpStr after removing file extension = \"" + tmpStr + "\"");1312 // Replace any remaining blanks ' ' in input filename with1313 // underscores '_'1314 tmpStr = tmpStr.replaceAll(" ", "_");1315 log1316 .debug("tmpStr after replacing blanks ' ' with underscores '_' = \"" + tmpStr + "\"");1317 // Replace any remaining dots '.' in input filename with underscores1318 // '_'1319 tmpStr = tmpStr.replaceAll("\\.", "_");1320 log1321 .debug("tmpStr after replacing dots '.' with underscores '_' = \"" + tmpStr + "\"");1322 // Add underscore and modified result filename1323 tmpStr = tmpStr + "_" + filename;1324 log1325 .debug("tmpStr after adding underscore '_' and modified result filename = \"" + tmpStr + "\"");1326 }1327 else1328 {1329 tmpStr = filename;1330 }1331 // Remove optional ".dat" file extension from result filename1332 int dotIndex = tmpStr.indexOf(".dat");1333 if (dotIndex >= 0)1334 {1335 tmpStr = tmpStr.substring(0, dotIndex);1336 }1337 // Add "xml" file extension1338 tmpStr = tmpStr + ".xml";1339 return tmpStr;1340 }1341 1342 1343 /**1344 * Fetches MsInspect input filename from parsed result file via web interface1345 * from HTTPClient PostMethod.1346 *1347 * @param postMethod PostMethod HTTPClient PostMethod for getting input1348 * stream of MsInspect result file.1349 * @return String MsInspect input filename for result file, or null if not1350 * found.1351 */1352 private String fetchMsInspectInputFilename(PostMethod postMethod)1353 {1354 String inputFilename = null;1355 try1356 {1357 // Get HTTP client1358 HttpClient httpClient = new HttpClient();1359 int statusCode = httpClient.executeMethod(postMethod);1360 // Check status code1361 log.debug("Response status code: " + statusCode);1362 if (statusCode != HttpStatus.SC_OK)1363 {1364 log1365 .warn("Error when trying to execute PostMethod: " + postMethod1366 .getStatusLine());1367 }1368 // Get response1369 // InputStream inStream = postMethod.getResponseBodyAsStream();1370 String content = postMethod.getResponseBodyAsString();1371 String regexStr = new String("<FILENAME>.+</FILENAME>");1372 log.debug("regex string = \"" + regexStr + "\"");1373 Pattern p = Pattern.compile(regexStr);1374 Matcher m = p.matcher(content);1375 if (m.find())1376 {1377 // Extract filename from XML tag1378 String hitString = m.group(0);1379 log.debug("hitString = \"" + hitString + "\"");1380 hitString = hitString.replaceAll("<FILENAME>", "");1381 log.debug("hitString = \"" + hitString + "\"");1382 hitString = hitString.replaceAll("</FILENAME>", "");1383 log.debug("hitString = \"" + hitString + "\"");1384 if (hitString != null)1385 {1386 inputFilename = hitString;1387 }1388 }1389 else1390 {1391 log1392 .debug("regex string \"" + regexStr + "\" not found in file contents.");1393 }1394 }1395 catch (Exception e)1396 {1397 log.error(e.getMessage(), e);1398 }1399 finally1400 {1401 // Release current connection to the connection pool once you are1402 // done1403 if (postMethod != null)1404 {1405 log.debug("Trying to release connection to PostMethod");1406 postMethod.releaseConnection();1407 log.debug("After trying to release connection to PostMethod");1408 }1409 else1410 {1411 log.debug("Connection to PostMethod already closed.");1412 }1413 }1414 return inputFilename;1415 734 } 1416 735
Note: See TracChangeset
for help on using the changeset viewer.