Changeset 4074


Ignore:
Timestamp:
Dec 15, 2010, 3:51:07 PM (12 years ago)
Author:
olle
Message:

Refs #668. Support for running msInspect feature finding from Proteios SE updated by cleaning up code (removal of unused code sections and methods, except those that might be expected to be of use in future updates):

  1. Class/file action/file/UseSpectrumFileForMsInspectSearchExtension.java in client/servlet/ updated by cleaning up code.
  1. Class/file action/msInspect/RunMsInspect.java in client/servlet/ updated by cleaning up code.
  1. Class/file plugins/RunMsInspectPlugin.java in plugin/ updated by cleaning up code.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/servlet/src/org/proteios/action/file/UseSpectrumFileForMsInspectSearchExtension.java

    r4073 r4074  
    3030import org.proteios.action.ProteiosAction;
    3131import 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;
    3832import org.proteios.gui.Title;
    3933import org.proteios.gui.TitledWindow;
     
    4337import org.proteios.gui.form.FormFactory;
    4438import org.proteios.gui.layout.RowLayout;
    45 //import org.proteios.gui.table.Table;
    46 //import org.proteios.gui.table.TableFactory;
    4739
    4840import se.lu.thep.waf.ActionException;
     
    128120    //DbControl dc = newDbControl();
    129121    /***********************************************************************
    130      * Table of MsInspect Inputs
     122     * MsInspect Form
    131123     */
    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 table
    153     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     */
    161124    Form form = new Form("msInspectSearchForm");
    162125    Fieldset fs = new Fieldset("MsInspect");
     
    175138    nextSearch.addParameter(RunMsInspect.VMSINSPECTUSEWEBINTERFACEFLAG, false);
    176139    toolbar.add(nextSearch);
    177     /*
    178     // Add 'Next' button to edit parameters before creating search jobs
    179     ActionLink nextEdit = getActionFactory().getActionLink(
    180       ViewActiveMsInspectParameterSetStorage.class, "NextMsInspectEditParametersBeforeCreatingSearchJobs");
    181     nextEdit.addParameter(RunMsInspect.VMSINSPECTUSEWEBINTERFACEFLAG, false);
    182     toolbar.add(nextEdit);
    183     */
    184140    //
    185141    form.setToolbar(toolbar);
     
    189145    RowLayout layout = getLayoutFactory().getRowLayout();
    190146    layout.add(new Title("MsInspectFeatureFinding"));
    191     //layout.add(selectForm);
    192147    layout.add(instructionArea);
    193148    layout.add(form);
  • trunk/client/servlet/src/org/proteios/action/msInspect/RunMsInspect.java

    r4073 r4074  
    4444import org.proteios.core.StringParameterType;
    4545import 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
    5447import java.util.Calendar;
    5548import java.util.GregorianCalendar;
     
    6053import se.lu.thep.waf.constraints.VBoolean;
    6154import se.lu.thep.waf.constraints.VInteger;
    62 import se.lu.thep.waf.constraints.VString;
    6355
    6456
     
    7264  public static final VInteger VSPECTRUMFILEID = new VInteger(
    7365    "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);
    8066  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);
    8668 
    8769  @Override
     
    10284      return;
    10385    }
    104     /*
    105     // Get MsInspect search user data
    106     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 search
    112     Integer msinspectpssId = getValidInteger(ViewActiveMsInspectParameterSetStorage.VMSINSPECTPARAMETERSETSTORAGEID);
    113     log.debug("msinspectParameterSetStorageId from ViewActiveMsInspectParameterSetStorage.VMSINSPECTPARAMETERSETSTORAGEID = " + msinspectpssId);
    114     // Make sure a MsInspect parameter set has been selected
    115     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 selected
    120       if (msinspectpssIds == null || msinspectpssIds.size() == 0)
    121       {
    122         setError("Please select a MsInspect parameter set");
    123         return;
    124       }
    125       // Use first file in list
    126       msinspectpssId = msinspectpssIds.get(0);
    127     }
    128     log.debug("msinspectpssId = " + msinspectpssId);
    129     */
    13086    /***********************************************************************
    13187     * Get MsInspect search constants from Properties file
     
    151107      log.error("NumberFormatException when parsing \"" + msInspectMemoryInMegaBytesStr + "\" to Integer: " + e);
    152108    }
    153     /*
    154     // MsInspect web interface url
    155     // MsInspect web server URL string
    156     //String msInspectWebServerURLStr = "http://localhost";
    157     String msInspectWebServerURLStr = pf.getProperty("msinspect.server.url");
    158     // MsInspect web MsInspect search script path
    159     //String msInspectWebSearchScriptPath = "/cgi/nph-msinspect.exe";
    160     String msInspectWebSearchScriptPath = pf.getProperty("msinspect.search.script.path");
    161     // MsInspect web MsInspect export script path
    162     //String msinspectExportWebScriptPath = "/cgi/export_dat_2.pl";
    163     String msinspectWebExportScriptPath = pf.getProperty("msinspect.export.script.path");
    164     // MsInspect web MsInspect result archive directory path
    165     //String msinspectWebArchivePath = "/data";
    166     String msinspectWebArchivePath = pf.getProperty("msinspect.archive.path");
    167     // MsInspect web result filename prefix
    168     //String msinspectWebResultFilenamePrefix = "";
    169     String msinspectWebResultFilenamePrefix = pf.getProperty("msinspect.result.filename.prefix");
    170     // MsInspect web server time difference in hours
    171     // between the Proteios server and the MsInspect web server
    172     //String msinspectWebServerTimediffHours = "0";
    173     String msinspectWebServerTimediffHours = pf.getProperty("msinspect.web.server.timediff.hours");
    174     // MsInspect web server time correction in minutes
    175     // apart from time zone between the Proteios server and the MsInspect web server system clocks
    176     //String msinspectWebServerTimediffCorrectionMinutes = "0";
    177     String msinspectWebServerTimediffCorrectionMinutes = pf.getProperty("msinspect.web.server.timediff.correction.minutes");
    178     // MsInspect database directory path
    179     //String msinspectDatabaseDirectoryPath = "/msinspect-2.1.4.linux/db";
    180     String msinspectDatabaseDirectoryPath = pf.getProperty("msinspect.local.database.directory.path");
    181     // MsInspect input filename
    182     //String msinspectInputBasename = "proteios_autogenerated_input.xml";
    183     String msinspectInputBasename = pf.getProperty("msinspect.local.input.basename");
    184     */
    185109    // Directory for temporary files
    186110    String tmpDir = null;
     
    192116    log.debug("msInspectProgramName = \"" + msInspectProgramName + "\"");
    193117    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     */
    205118    log.debug("tmpDir = \"" + tmpDir + "\"");
    206119    log.debug("uploadOutputFileFlag = " + uploadOutputFileFlag);
     
    221134    {}
    222135    log.debug("Active project = " + activeProject);
    223     /*
    224     // Get the MsInspect web interface flag
    225     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  flag
    233     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 search
    241     MsInspectParameterSetStorage msinspectpss = factory.getById(MsInspectParameterSetStorage.class, msinspectpssId);
    242     log.debug("msinspectpss = " + msinspectpss);
    243     */
    244     /*
    245     // Get the spectrum file items to use for the search
    246     List<Integer> spectrumFileIds = getValidIntegerList(VSPECTRUMFILEID);
    247     log.debug("spectrumFileIds = " + spectrumFileIds);
    248     */
    249136    // Get directory to use for optional upload of output file
    250137    Directory dir = null;
     
    262149    }
    263150    log.debug("dir = \"" + dir.getName() + "\", id = " + dir.getId());
    264     /*
    265     // Fetch MsInspect parameter set from MsInspectParameterSetStorage item
    266     MsInspectParameterSet msinspectParameterSet = msinspectpss.fetchMsInspectParameterSet();
    267     */
    268     /*
    269      * Append MsInspect install path to file references
    270      */
    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     */
    287151    /***********************************************************************
    288152     * Create job
     
    309173      // Set estimated execution time to next fastest, SHORT
    310174      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() + "]");
    315175      job.setName("MsInspect Search Spectrum File: " + spectrumFile.getName());
    316176      job.setDescription("MsInspect Search Spectrum File: " + spectrumFile.getName() + "[" + spectrumFile.getId() + "]");
     
    339199      StringParameterType timeStampParam = new StringParameterType();
    340200      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       */
    403201      //
    404202      ItemParameterType<Project> projectParam = new ItemParameterType<Project>(
    405203        Project.class, null);
    406204      job.setParameterValue("project", projectParam, activeProject);
    407       // File parameters
    408       //FileParameterType filesParam = new FileParameterType();
    409       //job.setParameterValue("file", filesParam, file);
     205      //
    410206      dc.saveItem(job);
    411207      dc.commit();
    412       /*
    413       // Use locally installed MsInspect program
    414       if (useWebInterfaceFlag != null && !useWebInterfaceFlag)
    415       {
    416         // Append job id to input base filename
    417         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 path
    422         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 filename
    426         StringBuilder sb = new StringBuilder();
    427         //sb.append(outputPathBaseName);
    428         // Remove ".xml" file extension
    429         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       */
    459208      log.debug("job.getId() = " + job.getId());
    460209    }
     
    464213     */
    465214    setForwardTo(ListJobs.class);
    466   }
    467 
    468 
    469   /*
    470   private void saveMsInspectInputFileLocal(java.io.File localFile, MsInspectParameterSet msinspectParameterSet)
    471     throws ActionException
    472   {
    473     // Create an XML stream writer for the XML data
    474     OutputStream oStream = null;
    475     try
    476     {
    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 file
    485     MsInspectParameterFileUtil msinspectParameterFileUtil = new MsInspectParameterFileUtil();
    486     //msinspectParameterFileUtil.setMsInspectParameterSet(msinspectParameterSet);
    487     msinspectParameterFileUtil.setXMLOutputStream(oStream);
    488     msinspectParameterFileUtil.exportMsInspectParameterSet(msinspectParameterSet);
    489     // Make sure that upload stream is closed
    490     try
    491     {
    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 (filename
    510    * 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.xml
    515    * Discr id:               3
    516    * Time stamp:             2008-02-29 12:47:00
    517    * Returned xml file path: proteios_autogenerated_input_3.2008_02_29_12_47_00.xml
    518    *
    519    * @param xmlFilePath String Input file path
    520    * @param discrId Integer Index to discriminate between files created same second
    521    * @return String File path with time stamp appended to file name
    522    */
    523   public String fetchXmlFilePathWithTimeStamp(String xmlFilePath, Integer discrId)
    524   {
    525     /*
    526      * Appends time stamp to file base filename (filename
    527      * 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.xml
    532      * Discr id:              3
    533      * Time stamp:            2008-02-29 12:47:00
    534      * Returned xml file path: proteios_autogenerated_input_3.2008_02_29_12_47_00.xml
    535      */
    536     StringBuilder sb = new StringBuilder();
    537     sb.append(xmlFilePath);
    538     // Remove ".xml" file extension
    539     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;
    580215  }
    581216
  • trunk/plugin/src/org/proteios/plugins/RunMsInspectPlugin.java

    r4073 r4074  
    3131import org.apache.commons.httpclient.HttpStatus;
    3232import org.apache.commons.httpclient.methods.PostMethod;
    33 import org.apache.commons.httpclient.methods.multipart.FilePart;
    34 import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
    3533import org.apache.commons.httpclient.methods.multipart.Part;
    3634import org.apache.commons.httpclient.methods.multipart.PartSource;
     
    4139import org.proteios.core.Directory;
    4240import org.proteios.core.File;
    43 import org.proteios.core.FileType;
    4441import org.proteios.core.ItemFactory;
    45 //import org.proteios.core.msInspectParameterSetStorage;
    46 //import org.proteios.core.MsInspectParameterSetStorage;
    4742import org.proteios.core.ProgressReporter;
    4843import org.proteios.core.SessionControl;
     
    5348import org.proteios.core.plugin.Request;
    5449import org.proteios.core.plugin.Response;
    55 //import org.proteios.io.msInspectParameterSet;
    56 //import org.proteios.plugins.SearchmsInspectPlugin.StreamGobbler;
    57 //import org.proteios.io.MsInspectParameterSet;
    5850
    5951import java.io.BufferedReader;
     
    6658import java.io.PrintWriter;
    6759import java.util.ArrayList;
    68 import java.util.Calendar;
    69 import java.util.GregorianCalendar;
    70 import java.util.Hashtable;
    7160import java.util.List;
    7261import java.util.regex.Matcher;
     
    293282      ProgressReporter progress)
    294283  {
    295     String msInspectWebServerURLStr;
    296     String msInspectWebSearchScriptPath;
    297     String msInspectWebExportScriptPath;
    298     String msInspectWebArchivePath;
    299     String msInspectWebResultFilenamePrefix;
    300     String msInspectWebServerTimediffHoursStr;
    301     String msInspectWebServerTimediffCorrectionMinutesStr;
    302284    String tmpDir;
    303285    String msInspectInstallPath;
    304286    String msInspectProgramName;
    305287    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;
    314288    Integer spectrumFileId;
    315289    Integer dirId;
    316290    Boolean uploadOutputFileFlag;
    317     Boolean useWebInterfaceFlag;
    318291    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
    337293    msInspectInstallPath = (String) job.getValue("msInspectInstallPath");
    338294    msInspectProgramName = (String) job.getValue("msInspectProgramName");
     
    343299    uploadOutputFileFlag = (Boolean) job.getValue("uploadOutputFileFlag");
    344300    timeStampStr = (String) job.getValue("timeStampStr");
    345     /*
    346     msInspectDatabaseDirectoryPath = (String) job
    347       .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 && !msInspectWebServerTimediffHoursStr
    359       .equals(""))
    360     {
    361       msInspectWebServerTimediffHours = Double
    362         .parseDouble(msInspectWebServerTimediffHoursStr);
    363     }
    364 
    365     msInspectWebServerTimediffCorrectionMinutes = 0;
    366     if (msInspectWebServerTimediffCorrectionMinutesStr != null && !msInspectWebServerTimediffCorrectionMinutesStr
    367       .equals(""))
    368     {
    369       msInspectWebServerTimediffCorrectionMinutes = Double
    370         .parseDouble(msInspectWebServerTimediffCorrectionMinutesStr);
    371     }
    372 
    373     msInspectWebServerTimediffMinutes = 60 * msInspectWebServerTimediffHours + msInspectWebServerTimediffCorrectionMinutes;
    374     */
    375     //
    376     /*
    377     log.debug("msInspectWebServerURLStr = \"" + msInspectWebServerURLStr + "\"");
    378     log
    379       .debug("msInspectWebSearchScriptPath = \"" + msInspectWebSearchScriptPath + "\"");
    380     log
    381       .debug("msInspectWebExportScriptPath = \"" + msInspectWebExportScriptPath + "\"");
    382     log.debug("msInspectWebArchivePath = \"" + msInspectWebArchivePath + "\"");
    383     log
    384       .debug("msInspectWebResultFilenamePrefix = \"" + msInspectWebResultFilenamePrefix + "\"");
    385     log
    386       .debug("msInspectWebServerTimediffHoursStr = \"" + msInspectWebServerTimediffHoursStr + "\"");
    387     log
    388       .debug("msInspectWebServerTimediffHours = " + msInspectWebServerTimediffHours);
    389     log
    390       .debug("msInspectWebServerTimediffCorrectionMinutesStr = \"" + msInspectWebServerTimediffCorrectionMinutesStr + "\"");
    391     log
    392       .debug("msInspectWebServerTimediffCorrectionMinutes = " + msInspectWebServerTimediffCorrectionMinutes);
    393     log
    394       .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     log
    408       .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     */
    420301
    421302    // Perform msInspect search using local search engine
     
    471352      Boolean uploadOutputFileFlag, String timeStampStr)
    472353  {
    473     String programPath = msInspectInstallPath + "/" + msInspectProgramName;
    474     //
    475354    log.debug("msInspectInstallPath = \"" + msInspectInstallPath + "\"");
    476355    log.debug("msInspectProgramName = \"" + msInspectProgramName + "\"");
     
    491370    // Create output file in directory for temporary files
    492371    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     */
    498372    log.debug("msInspectOutputDirPath = \"" + msInspectOutputDirPath + "\"");
    499373    msInspectOutputDirPath = tmpDir + "/" + msInspectOutputDirPath;
     
    540414        .error("IOException when trying to save temporary spectrum file \"" + spectrumFileTmp + "\": " + e);
    541415    }
    542     // msInspectParameterSet msInspectParameterSet = new msInspectParameterSet();
    543     //
    544     // String content = null;
    545     // Find option for spectrum file type
    546     //String spectrumFileOption = new String("-f");
    547     // Construct output file path
    548     //String msInspectOutputFilename = spectrumBaseFilename + ".peptides.tsv";
    549416    String msInspectOutputFilename = msInspectInputBaseFilename + ".peptides.tsv";
    550417    delimiter = "/";
     
    555422    String msInspectOutputPath = msInspectOutputDirPath + delimiter + msInspectOutputFilename;
    556423    log.debug("msInspectOutputPath = \"" + msInspectOutputPath + "\"");
    557     /*
    558     if (fileExtension.equals("dta") || fileExtension.equals("DTA"))
    559     {
    560       // Blank line delimited DTA
    561       spectrumFileOption = new String("-fb");
    562     }
    563     else if (fileExtension.equals("xml") || fileExtension.equals("XML"))
    564     {
    565       // XML encapsulated DTA
    566       spectrumFileOption = new String("-fx");
    567     }
    568     else if (fileExtension.equals("pkl") || fileExtension.equals("PKL"))
    569     {
    570       // PKL format
    571       spectrumFileOption = new String("-fp");
    572     }
    573     else if (fileExtension.equals("mgf") || fileExtension.equals("MGF"))
    574     {
    575       // MGF format
    576       spectrumFileOption = new String("-fm");
    577     }
    578     log.debug("spectrumFilename = \"" + spectrumFilename + "\", spectrumFileOption = \"" + spectrumFileOption + "\"");
    579     */
    580424    // Prepare msInspect search command for use with local installation
    581425    boolean imported = false;
    582426    try
    583427    {
    584       String option = null;
    585       String value = null;
    586       //String cmd = msInspectProgramPath + " " + msInspectInputPath;
    587       //String cmd = msInspectProgramPath + " -pm " + msInspectInputPath + " " + spectrumFileOption + " " + spectrumFileTmp + " -ox " + msInspectOutputPath;
    588428      String cmd = msInspectProgramPath;
    589429      if (msInspectProgramPath.endsWith(".jar") || msInspectProgramPath.endsWith(".JAR"))
     
    603443      cmd = cmd + " --outdir=" + msInspectOutputDirPath;
    604444      cmd = cmd + " " + spectrumFileTmp;
    605       /*
    606       //
    607       // msInspect - General
    608       //
    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 used
    620       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 list
    707       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 command
    715       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 cleaved
    852         log.debug("option = \"" + option + "\" (Flag set that N-term methionine should not be cleaved)");
    853         cmd = cmd + " " + option;
    854       }
    855       else
    856       {
    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 files
    866       //
    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 file
    870       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 in
    876        * string "spectrumFileOption" to decide
    877        * how to parse a spectrum file, and if msInspect
    878        * supports the file type at all. The input local
    879        * file path stored in string "spectrumFileTmp"
    880        * may have a file extension indicating a
    881        * different type of file, but this is
    882        * 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       */
    896445      //
    897446      // Execute msInspect search using local installation
    898       //
    899447      //
    900448      if (isJobAborted())
     
    953501    {
    954502      boolean outputFileFound = false;
    955       //if (localFileCanBeRead(tmpDir, msInspectOutputPath))
    956       /*
    957       if (localFileCanBeRead(null, msInspectOutputPath))
    958       {
    959         outputFileFound = true;
    960       }
    961       */
    962503      // Test output filename excluding original file extension in name
    963504      String testOutputFilename = msInspectInputBaseFilename + ".peptides.tsv";
     
    985526      log.debug("msInspectOutputFilename = \"" + msInspectOutputFilename + "\"");
    986527      log.debug("msInspectOutputPath = \"" + msInspectOutputPath + "\"");
    987       /*
    988       // Get output file name including time stamp, check a number of
    989       // seconds back in time
    990       // 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         log
    1004           .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.xml
    1011         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 message
    1022       /*
    1023       String convertMessage = new String("");
    1024       if (mzDataConvertedToMgfUsed)
    1025       {
    1026         convertMessage = new String(" - mzData data converted to MGF used for search");
    1027       }
    1028       */
    1029528      String doneMessage = new String("msInspect search finished");
    1030       /*
    1031       doneMessage = doneMessage + convertMessage;
    1032       */
    1033529      //
    1034530      doneMessage = doneMessage + "\n" + "msInspect input file: " + originalSpectrumFilename;
     
    1042538        if (outputFileFound)
    1043539        {
    1044           /*
    1045           String description = new String(
    1046             "msInspect search for " + spectrumFile.getName() + "[" + spectrumFile
    1047               .getId() + "] using parameter set " + msInspectpss
    1048               .getName() + "[" + msInspectpss.getId() + "]");
    1049           */
    1050540          String description = new String(
    1051541            "msInspect search for " + spectrumFile.getName() + "[" + spectrumFile
     
    1053543          try
    1054544          {
    1055             /*
    1056             uploadMsInspectOutputFile(msInspectInstallPath,
    1057               msInspectOutputPathWithTimeStamp, dirId, description);
    1058             */
    1059545            // Construct filename to use for uploaded result file
    1060             /*
    1061             String filenameOfUploadedFile = constructFilenameOfUploadedFile(
    1062               spectrumFile.getName(), msInspectOutputPathWithTimeStamp);
    1063             */
    1064546            String filenameOfUploadedFile = new String(msInspectOutputFilename);
    1065547            log.debug("filenameOfUploadedFile = \"" + filenameOfUploadedFile + "\"");
     
    1250732    // Return command line
    1251733    return cmd;
    1252   }
    1253 
    1254 
    1255   /**
    1256    * Construct filename for uploaded search result file. The constructed
    1257    * 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 file
    1274       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       log
    1283         .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       log
    1291         .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       log
    1299         .debug("tmpStr after removing prefix ending with ':' = \"" + tmpStr + "\"");
    1300       // Remove any initial blanks
    1301       tmpStr = tmpStr.replaceAll("^\\ *", "");
    1302       log
    1303         .debug("tmpStr after removing initial blanks = \"" + tmpStr + "\"");
    1304       // Remove optional file extension from input filename
    1305       strIndex = tmpStr.lastIndexOf(".");
    1306       if (strIndex >= 0)
    1307       {
    1308         tmpStr = tmpStr.substring(0, strIndex);
    1309       }
    1310       log
    1311         .debug("tmpStr after removing file extension = \"" + tmpStr + "\"");
    1312       // Replace any remaining blanks ' ' in input filename with
    1313       // underscores '_'
    1314       tmpStr = tmpStr.replaceAll(" ", "_");
    1315       log
    1316         .debug("tmpStr after replacing blanks ' ' with underscores '_' = \"" + tmpStr + "\"");
    1317       // Replace any remaining dots '.' in input filename with underscores
    1318       // '_'
    1319       tmpStr = tmpStr.replaceAll("\\.", "_");
    1320       log
    1321         .debug("tmpStr after replacing dots '.' with underscores '_' = \"" + tmpStr + "\"");
    1322       // Add underscore and modified result filename
    1323       tmpStr = tmpStr + "_" + filename;
    1324       log
    1325         .debug("tmpStr after adding underscore '_' and modified result filename = \"" + tmpStr + "\"");
    1326     }
    1327     else
    1328     {
    1329       tmpStr = filename;
    1330     }
    1331     // Remove optional ".dat" file extension from result filename
    1332     int dotIndex = tmpStr.indexOf(".dat");
    1333     if (dotIndex >= 0)
    1334     {
    1335       tmpStr = tmpStr.substring(0, dotIndex);
    1336     }
    1337     // Add "xml" file extension
    1338     tmpStr = tmpStr + ".xml";
    1339     return tmpStr;
    1340   }
    1341 
    1342 
    1343   /**
    1344    * Fetches MsInspect input filename from parsed result file via web interface
    1345    * from HTTPClient PostMethod.
    1346    *
    1347    * @param postMethod PostMethod HTTPClient PostMethod for getting input
    1348    *        stream of MsInspect result file.
    1349    * @return String MsInspect input filename for result file, or null if not
    1350    *         found.
    1351    */
    1352   private String fetchMsInspectInputFilename(PostMethod postMethod)
    1353   {
    1354     String inputFilename = null;
    1355     try
    1356     {
    1357       // Get HTTP client
    1358       HttpClient httpClient = new HttpClient();
    1359       int statusCode = httpClient.executeMethod(postMethod);
    1360       // Check status code
    1361       log.debug("Response status code: " + statusCode);
    1362       if (statusCode != HttpStatus.SC_OK)
    1363       {
    1364         log
    1365           .warn("Error when trying to execute PostMethod: " + postMethod
    1366             .getStatusLine());
    1367       }
    1368       // Get response
    1369       // 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 tag
    1378         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       else
    1390       {
    1391         log
    1392           .debug("regex string \"" + regexStr + "\" not found in file contents.");
    1393       }
    1394     }
    1395     catch (Exception e)
    1396     {
    1397       log.error(e.getMessage(), e);
    1398     }
    1399     finally
    1400     {
    1401       // Release current connection to the connection pool once you are
    1402       // done
    1403       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       else
    1410       {
    1411         log.debug("Connection to PostMethod already closed.");
    1412       }
    1413     }
    1414     return inputFilename;
    1415734  }
    1416735
Note: See TracChangeset for help on using the changeset viewer.