Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/AScorePro/Interface/PeptidesFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public struct PeptidesFileEntry {
/// Not used in AScore, can be any unique number for
/// identification purposes.
/// </summary>
public int Id;
public string Id;

/// <summary>
/// The scan number is used to look up the scan from the
Expand Down Expand Up @@ -73,7 +73,7 @@ public IEnumerator GetEnumerator()
private PeptidesFileEntry ParsePeptide(string line) {
var entry = new PeptidesFileEntry();
string[] pieces = line.Split("\t");
entry.Id = int.Parse(pieces[0]);
entry.Id = pieces[0];
entry.ScanNumber = int.Parse(pieces[1]);
entry.Peptide = pieces[2];
entry.PrecursorMz = double.Parse(pieces[3]);
Expand Down
72 changes: 41 additions & 31 deletions src/AScorePro/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ static void Main(string[] args)
}
else
{
AScoreMulti(aScore, scans, peptideParser, ascoreOptions);
AScoreMulti(aScore, scans, peptideParser, peptidesPath, ascoreOptions);
}
}
catch (Exception ex)
{
if (ex.Message.Length > 0) {
Console.WriteLine("An error occurred: " + ex.Message);
Console.WriteLine("Stack trace:");
Console.WriteLine(ex.StackTrace);
try {
using (StreamWriter writer = new StreamWriter("error.log", true)) {
writer.WriteLine("[" + DateTime.Now.ToString() + "]");
Expand Down Expand Up @@ -96,8 +98,9 @@ private static void AScoreSingle(AScoreCalculator aScore, Peptide peptide, Scan
/// <param name="aScore">Instance of AScore used on all peptides</param>
/// <param name="scans">Collection of scans</param>
/// <param name="parser">Unserializes peptides from the text input</param>
/// <param name="peptidesPath">Path to peptides file (may override options)</param>
/// <param name="options">AScore options</param>
private static void AScoreMulti(AScoreCalculator aScore, ScanCache scans, PeptideParser parser, AScoreOptions options)
private static void AScoreMulti(AScoreCalculator aScore, ScanCache scans, PeptideParser parser, string peptidesPath, AScoreOptions options)
{
var stream = new FileStream(options.Out, FileMode.Create, FileAccess.Write);
using (var writer = new StreamWriter(stream))
Expand All @@ -111,41 +114,48 @@ private static void AScoreMulti(AScoreCalculator aScore, ScanCache scans, Peptid
}
writer.Write("\n");

var peptides = new PeptidesFile(options.PeptidesFile);
var peptides = new PeptidesFile(peptidesPath);
foreach (PeptidesFileEntry entry in peptides)
{
var peptide = parser.Parse(entry.Peptide);
peptide.PrecursorMz = entry.PrecursorMz;
peptide.Id = entry.Id;
peptide.ScanNumber = entry.ScanNumber;
var scan = scans.GetScan(peptide.ScanNumber);
var result = aScore.Run(peptide, scan);
try
{
var peptide = parser.Parse(entry.Peptide);
peptide.PrecursorMz = entry.PrecursorMz;
peptide.Id = entry.Id;
peptide.ScanNumber = entry.ScanNumber;
var scan = scans.GetScan(peptide.ScanNumber);
var result = aScore.Run(peptide, scan);

Peptide topPeptide = result.Peptides[0];
writer.Write(topPeptide.Id);
writer.Write("\t");
writer.Write(result.ModCount);
writer.Write("\t");
writer.Write(result.Peptides.Count);
writer.Write("\t");
writer.Write(topPeptide.ToString());
writer.Write("\t");
writer.Write(topPeptide.Score.ToString("F9"));
Peptide topPeptide = result.Peptides[0];
writer.Write(topPeptide.Id);
writer.Write("\t");
writer.Write(result.ModCount);
writer.Write("\t");
writer.Write(result.Peptides.Count);
writer.Write("\t");
writer.Write(topPeptide.ToString());
writer.Write("\t");
writer.Write(topPeptide.Score.ToString("F9"));

// Flatten output. Show up to six mods.
for (int i = 0; i < 6; ++i) {
if (i < result.Sites.Count) {
var site = result.Sites[i];
writer.Write("\t");
writer.Write(site.Position);
writer.Write("\t");
writer.Write(site.Score.ToString("F9"));
}
else {
writer.Write("\t\\N\t\\N");
// Flatten output. Show up to six mods.
for (int i = 0; i < 6; ++i) {
if (i < result.Sites.Count) {
var site = result.Sites[i];
writer.Write("\t");
writer.Write(site.Position);
writer.Write("\t");
writer.Write(site.Score.ToString("F9"));
}
else {
writer.Write("\t\\N\t\\N");
}
}
writer.Write("\n");
}
catch (Exception ex)
{
Console.WriteLine($"Warning: Skipping peptide {entry.Id} scan {entry.ScanNumber}: {ex.Message}");
}
writer.Write("\n");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Sequence/Peptide.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Peptide
/// <summary>
/// A unique number used to identify the peptide.
/// </summary>
public int Id;
public string Id;

/// <summary>
/// The scan number for the peptide
Expand Down
Loading