public static List <SQTScan2> CallComet(cometParams cp, string searchFile) { FileInfo fi = new FileInfo(searchFile); string cpf = CometWrapper.GenerateTheSearchParamsString(cp); //Write the comet result to the directory StreamWriter sw = new StreamWriter(fi.DirectoryName + "/" + "comet.params"); sw.WriteLine(cpf); sw.Close(); string cometCall = CometWrapper.GetCometPath(); CometWrapper.CallComet(fi, cometCall, cpf); string sqtFileTmp = fi.Name.Replace(fi.Extension, ".sqt"); string sqtFile = fi.Directory.FullName + "/" + sqtFileTmp; PatternTools.SQTParser2.SQTParser2 sqtParser = new SQTParser2(); List <SQTScan2> theResult = sqtParser.Parse(sqtFile); int removedNoMatch = theResult.RemoveAll(a => a.Matches.Count == 0); return(theResult); }
private static List <SQTScan2> Parse(List <string> SQTFiles) { List <SQTScan2> scans = new List <SQTScan2>(); //Parse the files foreach (string file in SQTFiles) { Console.WriteLine("Parsing file " + file); SQTParser2 sqtParser2 = new SQTParser2(); scans.AddRange(sqtParser2.Parse(file, 50)); Console.Write("."); } return(scans); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Parse AScore result string inputAscore = @"C:\Users\pcarvalho\Desktop\SyntheticLib\10\phosphoRS_HCD_10.csv"; string inputXDScore = @"C:\Users\pcarvalho\Desktop\SyntheticLib\10\10.sqt"; List <PhosphoAnalysis> phosfo = new List <PhosphoAnalysis>(); Console.WriteLine("Parsing PhosphoScores"); string line; StreamReader sr = new StreamReader(inputAscore); Regex pSplitter = new Regex(Regex.Escape(".")); int counter = 0; while ((line = sr.ReadLine()) != null) { counter++; if (counter <= 1) { continue; } string[] cols = Regex.Split(line, ","); string confidence = cols[0]; string sequence = cols[1]; int scanNo = int.Parse(cols[25]); PhosphoAnalysis p = new PhosphoAnalysis(sequence, scanNo, confidence, cols[12]); phosfo.Add(p); } //Remove all non-fosfo hits int removed = phosfo.RemoveAll(a => !Regex.IsMatch(a.Sequence, "[a-z]")); sr.Close(); Console.WriteLine("Parsing sqt file"); SQTParser2 sqtParser2 = new SQTParser2(); List <SQTScan2> sqts = sqtParser2.Parse(inputXDScore, 50); List <double> goodScores = new List <double>(); List <double> badScores = new List <double>(); foreach (PhosphoAnalysis p in phosfo) { int index = sqts.FindIndex(a => a.ScanNumber == p.ScanNo); if (index > -1) { double xdScore = XDScore.XDScore.GetDeltaScore(sqts[index], true); if (!double.IsNegativeInfinity(xdScore)) { if (p.Confidence.Equals("High") || p.Confidence.Equals("Medium")) { int noSites = Regex.Matches(p.Sequence, "[a-z]").Count; int NoConfidenceAssignments = Regex.Matches(p.FosfoScores, "100").Count; if (NoConfidenceAssignments == noSites) { goodScores.Add(xdScore); } else { badScores.Add(xdScore); } } } } } double avgGood = goodScores.Average(); double avgBad = badScores.Average(); double goodSTD = PatternTools.pTools.Stdev(goodScores, true); double badSTD = PatternTools.pTools.Stdev(badScores, true); double bothTails; double leftTail; double rightTail; alglib.studentttest2(goodScores.ToArray(), goodScores.Count, badScores.ToArray(), badScores.Count, out bothTails, out leftTail, out rightTail); Console.WriteLine("Done!"); //Application.Run(new Form1()); }
static void Main(string[] args) { // Generate DTA string dtaDir = @"C:\Users\pcarvalho\Desktop\Juli_fosfo\DTA\out"; string inputSQT = @"C:\Users\pcarvalho\Desktop\Colaborations\Juli_fosfo\DTA\20140410_JF_HAP50mmmS2.sqt"; string inputMS2 = @"C:\Users\pcarvalho\Desktop\Colaborations\Juli_fosfo\DTA\20140410_jf_hap50mmms2.ms2"; if (true) //Remove MSMS from a file { int targetNoSpectra = 9917; List <MSLight> theMS = PatternTools.MSParserLight.ParserLight.ParseLightMS2(inputMS2); string outputMS2 = @"C:\Users\pcarvalho\Desktop\Colaborations\Juli_fosfo\DTA\Removed3_20140410_jf_hap50mmms2.ms2"; while (theMS.Count > targetNoSpectra) { int scnRemove = PatternTools.pTools.getRandomNumber(theMS.Count - 1); theMS.RemoveAt(scnRemove); } PatternTools.MSParser.MSPrinter.PrintMSListToFile(theMS, outputMS2, "", MSFileFormat.ms2); Console.WriteLine("Done!"); } //Generate a side by side table of XDScores and AScores if (false) //Generate a side by side table of XDScores and AScores { XDScore.XDScore xdScore = new XDScore.XDScore(new List <string>() { inputSQT }, true); SQTParser2 sqtParser = new SQTParser2(); List <SQTScan2> theSQT = sqtParser.Parse(inputSQT); //Parse the aScore File StreamReader sr = new StreamReader(@"C:\Users\pcarvalho\Desktop\Juli_fosfo\DTA\AllResults.txt"); string line; StreamWriter sw = new StreamWriter(@"C:\Users\pcarvalho\Desktop\Juli_fosfo\DTA\AScoreXDScoreGoodScores.txt"); while ((line = sr.ReadLine()) != null) { string[] cols = Regex.Split(line, "[-|\t]"); double aScore = double.Parse(cols[2]); int scanNo = int.Parse(cols[0]); SQTScan2 theScan = theSQT.Find(a => a.ScanNumber == scanNo); if (theScan.Matches[0].PrimaryScore > 2 && theScan.ChargeState == 2) { double xd = xdScore.GetDeltaScore(theScan, false); sw.WriteLine(scanNo + "\t" + aScore + "\t" + xd); } } sr.Close(); sw.Close(); } if (false) { SQTParser2 sqtParser = new SQTParser2(); List <SQTScan2> myScans = sqtParser.Parse(inputSQT); List <MSLight> theMS2 = PatternTools.MSParserLight.ParserLight.ParseLightMS2(inputMS2); myScans.RemoveAll(a => a.Matches.Count == 0); myScans.RemoveAll(a => !a.Matches[0].PeptideSequence.Contains("79")); foreach (SQTScan2 scn in myScans) { try { Console.Write("."); MSLight thems = theMS2.Find(a => a.ScanNumber == (int)scn.ScanNumber); string pepSeq = scn.Matches[0].PeptideSequence; pepSeq = Regex.Replace(pepSeq, @"\(\+79\.966300\)", "Z"); StreamWriter sw = new StreamWriter(dtaDir + "/" + scn.ScanNumber + "-" + pepSeq + ".dta"); sw.WriteLine(thems.MHPrecursor[0] + " " + thems.Zs[0].ToString()); foreach (Ion i in thems.Ions) { sw.WriteLine(i.MZ + " " + i.Intensity); } sw.Close(); } catch { Console.Write("P"); } } } if (false) { DirectoryInfo di = new DirectoryInfo(dtaDir); FileInfo[] theFiles = di.GetFiles("*.dta"); StreamWriter sw = new StreamWriter(@"C:\Users\pcarvalho\Desktop\Juli_fosfo\DTA\result.txt"); foreach (FileInfo fi in theFiles) { // Read file data FileStream fs = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read); byte[] data = new byte[fs.Length]; fs.Read(data, 0, data.Length); fs.Close(); // Generate post objects Dictionary <string, object> postParameters = new Dictionary <string, object>(); postParameters.Add("fileformat", "txt"); postParameters.Add("userfile", new FormUpload.FileParameter(data, fi.Name, "application/msword")); postParameters.Add("mods", "1"); //Cystein postParameters.Add("MAX_FILE_SIZE", "40000"); string [] cols = Regex.Split(fi.Name, "[-|.]"); string pepS = Regex.Replace(cols[1], "Z", "*"); postParameters.Add("sequence", pepS); postParameters.Add("submit", "Calculate Ascore"); HttpWebResponse webResponse = FormUpload.MultipartFormDataPost(@"http://ascore.med.harvard.edu/trim/trim-single.php", "PhosphoPeptide", postParameters); // Process response StreamReader responseReader = new StreamReader(webResponse.GetResponseStream()); string fullResponse = responseReader.ReadToEnd(); webResponse.Close(); string[] cols2 = Regex.Split(fullResponse, "\n"); Regex getNo = new Regex("[0-9]+.[0-9]+"); try { foreach (var m in getNo.Matches(cols2[39])) { sw.WriteLine(fi.Name + "\t" + m.ToString()); Console.WriteLine(m.ToString()); sw.Flush(); } } catch { Console.Write("f"); } fi.Delete(); } sw.Close(); } if (false) { // Read file data string file = @"C:\Users\pcarvalho\Desktop\Juli_fosfo\ToMSAorNotToMSA\test.txt"; FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read); byte[] data = new byte[fs.Length]; fs.Read(data, 0, data.Length); fs.Close(); // Generate post objects Dictionary <string, object> postParameters = new Dictionary <string, object>(); //postParameters.Add("fileformat", "txt"); postParameters.Add("userfile", new FormUpload.FileParameter(data, file, "application/msword")); postParameters.Add("mods", "1"); //Cystein postParameters.Add("MAX_FILE_SIZE", "40000"); postParameters.Add("sequence", "IEDVGS*DEEDDSGK"); postParameters.Add("submit", "Calculate Ascore"); HttpWebResponse webResponse = FormUpload.MultipartFormDataPost(@"http://ascore.med.harvard.edu/trim/trim-single.php", "PhosphoPeptide", postParameters); // Process response StreamReader responseReader = new StreamReader(webResponse.GetResponseStream()); string fullResponse = responseReader.ReadToEnd(); webResponse.Close(); string[] cols = Regex.Split(fullResponse, "\n"); Regex getNo = new Regex("[0-9]+.[0-9]+"); foreach (var m in getNo.Matches(cols[39])) { Console.WriteLine(m.ToString()); } Console.WriteLine("Done"); } }