forked from smith-chem-wisc/mzLib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'smith-chem-wisc:master' into master
- Loading branch information
Showing
12 changed files
with
491 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using Readers.ExternalResults.BaseClasses; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FlashLFQ | ||
{ | ||
public static class MzLibExtensions | ||
{ | ||
/// <summary> | ||
/// Makes a list of identification objects usable by FlashLFQ from an IQuantifiableResultFile | ||
/// </summary> | ||
public static List<Identification> MakeIdentifications(this IQuantifiableResultFile quantifiable) | ||
{ | ||
IEnumerable<IQuantifiableRecord> quantifiableRecords = quantifiable.GetQuantifiableResults(); | ||
List<Identification> identifications = new List<Identification>(); | ||
Dictionary<string, ProteinGroup> allProteinGroups = new Dictionary<string, ProteinGroup>(); | ||
Dictionary<string, SpectraFileInfo> allFiles = new Dictionary<string, SpectraFileInfo>(); | ||
|
||
foreach (var record in quantifiableRecords) | ||
{ | ||
string baseSequence = record.BaseSequence; | ||
string modifiedSequence = record.ModifiedSequence; | ||
double ms2RetentionTimeInMinutes = record.RetentionTime; | ||
double monoisotopicMass = record.MonoisotopicMass; | ||
int precursurChargeState = record.ChargeState; | ||
|
||
SpectraFileInfo file = null; | ||
if (allFiles.TryGetValue(record.FileName, out var fileInfo)) | ||
{ | ||
// placeholder values for SpectraFileInfo that will be edited later | ||
file = new SpectraFileInfo(record.FileName, "", 1, 1, 1); | ||
} | ||
else | ||
{ | ||
file = new SpectraFileInfo(record.FileName, "", 1, 1, 1); | ||
allFiles.Add(record.FileName, fileInfo); | ||
} | ||
|
||
List<ProteinGroup> proteinGroups = new(); | ||
foreach (var info in record.ProteinGroupInfos) | ||
{ | ||
if (allProteinGroups.TryGetValue(info.proteinAccessions, out var proteinGroup)) | ||
{ | ||
proteinGroups.Add(proteinGroup); | ||
} | ||
else | ||
{ | ||
allProteinGroups.Add(info.proteinAccessions, new ProteinGroup(info.proteinAccessions, info.geneName, info.organism)); | ||
proteinGroups.Add(allProteinGroups[info.proteinAccessions]); | ||
} | ||
} | ||
Identification id = new Identification(file, baseSequence, modifiedSequence, monoisotopicMass, ms2RetentionTimeInMinutes, precursurChargeState, proteinGroups); | ||
identifications.Add(id); | ||
|
||
} | ||
|
||
return identifications; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
mzLib/Readers/ExternalResults/BaseClasses/IQuantifiableRecord.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Readers.ExternalResults.BaseClasses | ||
{ | ||
/// <summary> | ||
/// Defines the information needed to create the identification object usable by FlashLFQ | ||
/// </summary> | ||
public interface IQuantifiableRecord | ||
{ | ||
/// <summary> | ||
/// The file name of the MS Data file in which the identification was made | ||
/// </summary> | ||
public string FileName { get; } | ||
|
||
/// <summary> | ||
/// A list of tuples, each of which represent a protein. | ||
/// Each tuple contains the accession number, gene name, and organism associated with the given result. | ||
/// </summary> | ||
public List<(string proteinAccessions, string geneName, string organism)> ProteinGroupInfos { get; } | ||
|
||
/// <summary> | ||
/// The amino acid sequence of the identified peptide | ||
/// </summary> | ||
public string BaseSequence { get; } | ||
|
||
/// <summary> | ||
/// The amino acid sequence and the associated post-translation modifications of the identified peptide | ||
/// </summary> | ||
public string ModifiedSequence { get; } | ||
|
||
/// <summary> | ||
/// The retention time (in minutes) associated with the result | ||
/// </summary> | ||
public double RetentionTime { get; } | ||
|
||
/// <summary> | ||
/// The charge state associated with the result | ||
/// </summary> | ||
public int ChargeState { get; } | ||
|
||
/// <summary> | ||
/// Defines whether or not the result is a decoy identification | ||
/// </summary> | ||
public bool IsDecoy { get; } | ||
|
||
/// <summary> | ||
/// The mass of the monoisotopic peptide (i.e., no c13 or n15 atoms are present, the lowest possible mass) | ||
/// </summary> | ||
public double MonoisotopicMass { get; } | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
mzLib/Readers/ExternalResults/BaseClasses/IQuantifiableResultFile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Readers.ExternalResults.BaseClasses | ||
{ | ||
/// <summary> | ||
/// Outlines behavior to turn results into an IEnumerable of IQuantifiableRecords | ||
/// and to create the dictionary linking file names from the external result files | ||
/// to their local file paths which are used to make the identification object | ||
/// </summary> | ||
public interface IQuantifiableResultFile : IResultFile | ||
{ | ||
/// <summary> | ||
/// Returns every result in the result file as an IQuantifiableRecord | ||
/// </summary> | ||
/// <returns> Enumerable that contains identifications for a peptide </returns> | ||
public IEnumerable<IQuantifiableRecord> GetQuantifiableResults(); | ||
|
||
/// <summary> | ||
/// Links the file name associated with the protein to the raw file path of MassSpec data | ||
/// </summary> | ||
/// <param name="fullFilePath"> list of file paths associated with each distinct record </param> | ||
/// <returns> Dictionary of file names and their associted full paths </returns> | ||
public Dictionary<string, string> FileNametoFilePath(List<string> fullFilePath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.