Esempio n. 1
0
        ////Uses OpenMS to create a concacenated reversed database, reversed at each peptide segment with C terminus kept
        //public static String CreateConcacenatedDecoyDB(String fastaFilePath, String outputFolder)
        //{
        //	String DecoyDBGenerator= IOUtils.getAbsolutePath( InputFileOrganizer.DecoyDatabaseOpenMSEXE);
        //	String enzyme = "Trypsin";
        //	String outputFilePath = Path.Combine( outputFolder , IOUtils.getBaseName(fastaFilePath)+"_decoyConcacenated.fasta");
        //	String method = "reverse";
        //	String decoyString = GlobalVar.DecoyPrefix;

        //	String command = DecoyDBGenerator+" -in "+ fastaFilePath + " -out " +outputFilePath + " -enzyme "+ enzyme + " -decoy_string " + decoyString +" -decoy_string_position prefix "
        //		+" -method " +method  +" -Decoy:keepPeptideNTerm false -Decoy:keepPeptideCTerm true";
        //	Logger.debug("Command: " +command);


        //	//Logger.debug("running OpenMS DecoyDatabase.exe to generate concacenated decoy database");
        //	ExecuteShellCommand.executeCommand(command);
        //	Logger.debug("DecoyDatabase at: "+outputFilePath);

        //	return outputFilePath;
        //}

        //public static String CreateConcacenatedDecoyDB_TPP(String fastaFilePath, String outputFolder)
        //{
        //	String DecoyDBGenerator = IOUtils.getAbsolutePath(InputFileOrganizer.TPPDecoyGenerator);
        //	String outputFilePath = Path.Combine(outputFolder, IOUtils.getBaseName(fastaFilePath) + "_TPPDECOY.fasta");
        //	String decoyString = GlobalVar.DecoyPrefix;

        //	String command = "\""+DecoyDBGenerator + "\" -t \"" + decoyString + "\" \"" + fastaFilePath + "\" \"" + outputFilePath + "\"";

        //	Logger.debug("Command: " + command);

        //	//Logger.debug("running OpenMS DecoyDatabase.exe to generate concacenated decoy database");
        //	ExecuteShellCommand.executeCommand(command);
        //	Logger.debug("DecoyDatabase at: " + outputFilePath);

        //	return outputFilePath;
        //}

        //public static String CreateConcacenatedDecoyDB_improved(String fastaFilePath, String outputFolder)
        //{

        //	//Fixes the problem of openMS-CometIDX chain.
        //	//in the faulty method, real sequences such as ABCDKEFGR
        //	//would be processed by openMS into DCBAKGFER
        //	//in comet idx that would turn into decoy peptide sequences: DCBAK, GFER, and DCBAKGFER
        //	//However, in an "offline" comet processing, the sequences with 1 misscleavage should be: DCBAK, GFER, and GFEKDCBAR
        //	//This new method ensures that happens.
        //	String outputFilePath = Path.Combine(outputFolder, IOUtils.getBaseName(fastaFilePath) + "_decoyConcacenated.fasta");
        //	outputFilePath = DecoyConcacenatedDatabaseGenerator.GenerateConcacenatedDecoyFasta(fastaFilePath, outputFilePath); //pretty redundant to re-set the outputFilePath, but it is what it is
        //	return outputFilePath;

        //}

        //Uses Comet to generate an IDX database file from a fasta file
        public static String FastaToIDXConverter(String fastaFilePath, String outputFolder)
        {
            Logger.debug("Converting fasta to idx");
            String cometEXE    = InputFileOrganizer.CometExe;
            String cometParams = InputFileOrganizer.CometParamsFile;
            String command     = cometEXE + " -D" + fastaFilePath + " -P" + cometParams + " -i";

            Logger.debug("Command: " + command);

            ExecuteShellCommand.executeCommand(command);
            String outputfileName         = IOUtils.getBaseName(fastaFilePath) + ".fasta.idx";
            String currentOutputDirectory = Path.Combine(IOUtils.getDirectory(fastaFilePath), outputfileName);             //because comet just generates the idx wherever the fasta originally is located
            String targetOutputDirectory  = Path.Combine(outputFolder, outputfileName);

            if (File.Exists(targetOutputDirectory))
            {
                return(targetOutputDirectory);
            }
            else
            {
                ExecuteShellCommand.MoveFile(currentOutputDirectory, outputFolder);
            }
            Logger.debug("DecoyDatabase at: " + targetOutputDirectory);

            return(targetOutputDirectory);
        }
Esempio n. 2
0
        public static Dictionary <String, Double> calculateRetentionTime(String peptideList)
        {
            log.Debug("Calculating retention times using RTCalc...");
            Console.WriteLine("Calculating peptide retention times using RTCalc... This might take a while");
            // Dictionary<String, RetentionTime> rtmap = new Dictionary<String,
            // RetentionTime>();

            // This is the output file path
            String rtOutput = InputFileOrganizer.preExperimentFilesFolder + "\\" + IOUtils.getBaseName(peptideList) + "_rtOutput.txt";
            String rtCalc   = InputFileOrganizer.RTCalc; // tool location

            // This is the RTCalc command to be run on the terminal
            String rtCalcCommand = rtCalc + " COEFF=" + InputFileOrganizer.RTCalcCoeff + " PEPS=" + peptideList + " OUTFILE=" + rtOutput;

            // perform in-silico digestion
            log.Debug(rtCalcCommand);
            String rtTerminalOutput = ExecuteShellCommand.executeCommand(rtCalcCommand);

            log.Debug(rtTerminalOutput);
            // parse rtcalc output
            Dictionary <String, Double> parsedOutput = Loader.parseRTCalcOutput(rtOutput);

            // foreach (String peptideSequence  in parsedOutput.Keys) {
            // // unsure whether or not d is a rt peak or rt start
            // double d = parsedOutput[&*peptideSequence);
            // rtmap.Add(peptideSequence, convertDoubleToRetentionTime(d));
            // }
            log.Debug("Parsed " + parsedOutput.Count + " retention times");

            // remove files
            //ExecuteShellCommand.executeCommand("rm " + rtOutput);
            log.Debug("Done calculating retention times using RTCalc.");

            return(parsedOutput);
        }
Esempio n. 3
0
        public static DigestedFastaFile performDigest(String fastaFilePath, int numMissedCleavages, Boolean keepFile)
        {
            if (GlobalVar.useChainsawComputedFile)
            {
                return(Loader.parseDigestedFasta(InputFileOrganizer.ChainSawResult));
            }

            // These are the output file paths
            String outputTSVFile   = fastaFilePath + "_digestedPeptides.tsv";
            String outputIndexFile = fastaFilePath + ".index";


            /* Peptide chainsaw parameters */
            String chainsaw = InputFileOrganizer.ChainSaw; // tool location
            //String enzyme = "Trypsin/P";
            String enzyme               = "Trypsin";
            String specificity          = "fully";
            int    minimumPeptideLength = GlobalVar.MinimumPeptideLength;
            int    maximumPeptideLength = 200;
            // minimum and maximum peptide length is what typically is analyzed well by the
            // mass spectrometer

            // This is the chainsaw command to be run on the terminal
            String chainsawCommand = chainsaw + " -c " + enzyme + " -s " + specificity + " -m " + minimumPeptideLength
                                     + " -M " + maximumPeptideLength + " -n " + numMissedCleavages + " " + fastaFilePath;

            log.Info("Digesting database using ChainSaw");
            // perform in-silico digestion
            String chainsawOutput = ExecuteShellCommand.executeCommand(chainsawCommand);

            log.Info(chainsawCommand);
            log.Debug(chainsawOutput);

            // parse new tsv file
            DigestedFastaFile df = Loader.parseDigestedFasta(outputTSVFile);

            // this tool automatically outputs file in the same folder as the input database, move file to output folder,
            if (keepFile)
            {
                ExecuteShellCommand.executeCommand("move " + outputTSVFile + " " + InputFileOrganizer.preExperimentFilesFolder);
                InputFileOrganizer.ChainSawResult = InputFileOrganizer.preExperimentFilesFolder + "\\" + IOUtils.getBaseName(outputTSVFile);
            }
            else
            {
                ExecuteShellCommand.executeCommand("rm " + outputTSVFile);
            }
            //ExecuteShellCommand.executeCommand("rm " + outputIndexFile);

            return(df);
        }
Esempio n. 4
0
        public static void deleteFile(String fileName)
        {
            String command = "rm " + fileName;

            ExecuteShellCommand.executeCommand(command);
        }