本文整理汇总了C#中Peptide.fragmentation方法的典型用法代码示例。如果您正苦于以下问题:C# Peptide.fragmentation方法的具体用法?C# Peptide.fragmentation怎么用?C# Peptide.fragmentation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Peptide
的用法示例。
在下文中一共展示了Peptide.fragmentation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public override void Update (GraphItem item, pwiz.MSGraph.MSPointList points, GraphObjList annotations)
{
if (!Enabled)
return;
if (!(item is MassSpectrum))
return; // throw exception?
GraphObjList list = annotations;
Peptide peptide;
try
{
peptide = new Peptide(sequence,
pwiz.CLI.proteome.ModificationParsing.ModificationParsing_Auto,
pwiz.CLI.proteome.ModificationDelimiter.ModificationDelimiter_Brackets);
}
catch (Exception)
{
return;
}
var spectrum = (item as MassSpectrum).Element;
if (ReferenceEquals(manualTolerance, null))
{
MZTolerance maxTolerance = new MZTolerance(0.5);
foreach (var scan in spectrum.scanList.scans.Where(o => o.instrumentConfiguration != null))
{
// assume the last analyzer of the instrument configuration is responsible for the resolution
if (scan.instrumentConfiguration.componentList.Count == 0)
continue;
var analyzer = scan.instrumentConfiguration.componentList.Where(o => o.type == ComponentType.ComponentType_Analyzer).Last().cvParamChild(CVID.MS_mass_analyzer_type);
if (analyzer.cvid == CVID.CVID_Unknown)
continue;
MZTolerance analyzerTolerance = null;
foreach (var kvp in mzToleranceByAnalyzer)
if (CV.cvIsA(analyzer.cvid, kvp.Key))
{
analyzerTolerance = kvp.Value;
break;
}
if (analyzerTolerance == null)
continue;
if (maxTolerance.units == analyzerTolerance.units)
{
if (maxTolerance.value < analyzerTolerance.value)
maxTolerance = analyzerTolerance;
}
else if (analyzerTolerance.units == MZTolerance.Units.PPM)
maxTolerance = analyzerTolerance;
}
tolerance = maxTolerance;
}
else
tolerance = manualTolerance;
if (ionSeriesIsEnabled(IonSeries.Auto))
foreach (var precursor in spectrum.precursors)
foreach (var method in precursor.activation.cvParamChildren(CVID.MS_dissociation_method))
{
if (!ionSeriesByDissociationMethod.Contains(method.cvid))
ionSeries = IonSeries.All;
else
ionSeries |= ionSeriesByDissociationMethod[method.cvid];
}
int nSeries = (ionSeriesIsEnabled(IonSeries.a) ? 1 : 0) +
(ionSeriesIsEnabled(IonSeries.b) ? 1 : 0) +
(ionSeriesIsEnabled(IonSeries.c) ? 1 : 0);
int cSeries = (ionSeriesIsEnabled(IonSeries.x) ? 1 : 0) +
(ionSeriesIsEnabled(IonSeries.y) ? 1 : 0) +
(ionSeriesIsEnabled(IonSeries.z) ? 1 : 0) +
(ionSeriesIsEnabled(IonSeries.zRadical) ? 1 : 0);
showLadders = showLadders && nSeries < 2 && cSeries < 2;
string unmodifiedSequence = peptide.sequence;
int sequenceLength = unmodifiedSequence.Length;
Fragmentation fragmentation = peptide.fragmentation(fragmentMassType == 0 ? true : false, true);
for (int i = 1; i <= sequenceLength; ++i)
{
if (ionSeriesIsEnabled(IonSeries.Immonium))
addFragment(list, points, "immonium-" + unmodifiedSequence[i - 1], 0, 1, immoniumIonByResidue[unmodifiedSequence[i - 1]]);
for (int charge = min; charge <= max; ++charge)
{
if (ionSeriesIsEnabled(IonSeries.a)) addFragment(list, points, "a", i, charge, fragmentation.a(i, charge));
if (ionSeriesIsEnabled(IonSeries.b)) addFragment(list, points, "b", i, charge, fragmentation.b(i, charge));
if (ionSeriesIsEnabled(IonSeries.y)) addFragment(list, points, "y", i, charge, fragmentation.y(i, charge));
if (ionSeriesIsEnabled(IonSeries.z)) addFragment(list, points, "z", i, charge, fragmentation.z(i, charge));
if (ionSeriesIsEnabled(IonSeries.zRadical)) addFragment(list, points, "z*", i, charge, fragmentation.zRadical(i, charge));
if (i < sequenceLength)
{
if (ionSeriesIsEnabled(IonSeries.c)) addFragment(list, points, "c", i, charge, fragmentation.c(i, charge));
//.........这里部分代码省略.........
示例2: Update
public override void Update( GraphItem item, pwiz.MSGraph.MSPointList points, GraphObjList annotations )
{
double basePeakIntensity = 0;
double cutoff = 0;
foreach (var pointlist in points)
{
if (basePeakIntensity < pointlist.Y)
basePeakIntensity = pointlist.Y;
}
cutoff = basePeakIntensity * basePeakPercentage * 0.01;
if( !Enabled )
return;
if( !( item is MassSpectrum ) )
return; // throw exception?
GraphObjList list = annotations;
Peptide peptide;
try
{
peptide = new Peptide( sequence,
pwiz.CLI.proteome.ModificationParsing.ModificationParsing_Auto,
pwiz.CLI.proteome.ModificationDelimiter.ModificationDelimiter_Brackets );
} catch( Exception )
{
return;
}
//if (annotationPanels.peptideInfoGridView.InvokeRequired)
//{
// annotationPanels.peptideInfoGridView.BeginInvoke(new MethodInvoker(() => Update(item, points, annotations)));
// //return;
//}
var spectrum = ( item as MassSpectrum ).Element;
if (spectrum.precursors.Count > 0 && ionSeriesIsEnabled(IonSeries.Auto))
{
bool cid = (item as MassSpectrum).Element.precursors[0].activation.hasCVParam(CVID.MS_CID);
bool etd = (item as MassSpectrum).Element.precursors[0].activation.hasCVParam(CVID.MS_ETD);
ionSeries |= cid ? IonSeries.b | IonSeries.y : IonSeries.Off;
ionSeries |= etd ? IonSeries.c | IonSeries.zRadical : IonSeries.Off;
}
string unmodifiedSequence = peptide.sequence;
int sequenceLength = unmodifiedSequence.Length;
Fragmentation fragmentation = peptide.fragmentation( fragmentMassType == 0 ? true : false, true );
//test neutral
ModificationMap modifications = peptide.modifications();
///
#region adding labels for series a/b/c/x/y/z:::::::::naive fragmentation modeling
if (!showBasophileModel)
{
for (int i = 1; i < sequenceLength; ++i)
{
//test neutral loss
//note here the Cseq is slightly different than those in addFragmentSummary
string Nseq = peptide.sequence.Substring(0, i);
string Cseq = peptide.sequence.Substring(sequenceLength - i, i);
string NTempSeq = peptide.sequence.Substring(0, sequenceLength - i);
char[] Nseqchars = Nseq.ToCharArray();
char[] NTempSeqchars = NTempSeq.ToCharArray();
char[] seqchars = peptide.sequence.ToCharArray();
int Nphosmodi = 0;
int NTempPhosmodi = 0;
int Cphosmodi = 0;
int phosmodi = 0;
for (int k = 0; k < i; k++)
{
if (Math.Round(modifications[k].monoisotopicDeltaMass()) == 80 && (seqchars[k] == 'S' || seqchars[k] == 'T' || seqchars[k] == 'Y'))
{
Nphosmodi++;
}
}
for (int k = 0; k < sequenceLength - i; k++)
{
if (Math.Round(modifications[k].monoisotopicDeltaMass()) == 80 && (seqchars[k] == 'S' || seqchars[k] == 'T' || seqchars[k] == 'Y'))
{
NTempPhosmodi++;
}
}
for (int k = 0; k < sequenceLength; k++)
{
if (Math.Round(modifications[k].monoisotopicDeltaMass()) == 80 && (seqchars[k] == 'S' || seqchars[k] == 'T' || seqchars[k] == 'Y'))
{
phosmodi++;
}
}
Cphosmodi = phosmodi - NTempPhosmodi;
for (int charge = min; charge <= max; ++charge)
{
if (ionSeriesIsEnabled(IonSeries.a)) addFragment(list, points, "a", i, charge, fragmentation.a(i, charge));
if (ionSeriesIsEnabled(IonSeries.b)) addFragment(list, points, "b", i, charge, fragmentation.b(i, charge));
if (ionSeriesIsEnabled(IonSeries.y)) addFragment(list, points, "y", i, charge, fragmentation.y(i, charge));
if (ionSeriesIsEnabled(IonSeries.z)) addFragment(list, points, "z", i, charge, fragmentation.z(i, charge));
//.........这里部分代码省略.........
示例3: Update
public override void Update( GraphItem item, pwiz.MSGraph.MSPointList points, GraphObjList annotations )
{
if( !Enabled )
return;
if( !( item is MassSpectrum ) )
return; // throw exception?
GraphObjList list = annotations;
Peptide peptide;
try
{
peptide = new Peptide( currentSequence,
pwiz.CLI.proteome.ModificationParsing.ModificationParsing_Auto,
pwiz.CLI.proteome.ModificationDelimiter.ModificationDelimiter_Brackets );
} catch( Exception )
{
return;
}
string unmodifiedSequence = peptide.sequence;
int sequenceLength = unmodifiedSequence.Length;
Fragmentation fragmentation = peptide.fragmentation( fragmentMassType == 0 ? true : false, true );
// Keeps track of number of fragments predicted and matched in each ion series
numFragmentsMatched.Clear();
numFragmentsPredicted.Clear();
for( int charge = min; charge <= max; ++charge )
{
for( int i = 1; i <= sequenceLength; ++i )
{
if( a ) addFragment( list, points, "a", i, charge, fragmentation.a( i, charge ) );
if( b ) addFragment( list, points, "b", i, charge, fragmentation.b( i, charge ) );
if( y ) addFragment( list, points, "y", i, charge, fragmentation.y( i, charge ) );
if( z ) addFragment( list, points, "z", i, charge, fragmentation.z( i, charge ) );
if( zRadical ) addFragment( list, points, "z*", i, charge, fragmentation.zRadical( i, charge ) );
if( i < sequenceLength )
{
if( c ) addFragment( list, points, "c", i, charge, fragmentation.c( i, charge ) );
if( x ) addFragment( list, points, "x", i, charge, fragmentation.x( i, charge ) );
}
}
}
if( showLadders )
{
string topSeries = a ? "a" : b ? "b" : c ? "c" : "";
string bottomSeries = x ? "x" : y ? "y" : z ? "z" : zRadical ? "z*" : "";
addIonSeries( list, points, peptide, fragmentation, topSeries, bottomSeries );
}
// fill peptide info table
annotationPanels.peptideInfoGridView.Rows.Clear();
var spectrum = ( item as MassSpectrum ).Element;
//if( spectrum.precursors.Count > 0 &&
// spectrum.precursors[0].selectedIons.Count > 0 &&
// spectrum.precursors[0].selectedIons[0].hasCVParam( pwiz.CLI.cv.CVID.MS_selected_ion_m_z ) &&
// spectrum.precursors[0].selectedIons[0].hasCVParam( pwiz.CLI.cv.CVID.MS_charge_state ) )
//{
// double selectedMz = (double) spectrum.precursors[0].selectedIons[0].cvParam( pwiz.CLI.cv.CVID.MS_selected_ion_m_z ).value;
// int chargeState = (int) spectrum.precursors[0].selectedIons[0].cvParam( pwiz.CLI.cv.CVID.MS_charge_state ).value;
// double calculatedMass = ( precursorMassType == 0 ? peptide.monoisotopicMass( chargeState ) : peptide.molecularWeight( chargeState ) ) * chargeState;
// double observedMass = selectedMz * chargeState;
// annotationPanels.peptideInfoGridView.Rows.Add( "Calculated mass:", calculatedMass, "Mass error (daltons):", observedMass - calculatedMass );
// annotationPanels.peptideInfoGridView.Rows.Add( "Observed mass:", observedMass, "Mass error (ppm):", ( ( observedMass - calculatedMass ) / calculatedMass ) * 1e6 );
//} else
// annotationPanels.peptideInfoGridView.Rows.Add( "Calculated neutral mass:", precursorMassType == 0 ? peptide.monoisotopicMass() : peptide.molecularWeight() );
if (spectrum.precursors.Count > 0 &&
spectrum.precursors[0].selectedIons.Count > 0 &&
spectrum.precursors[0].selectedIons[0].hasCVParam(pwiz.CLI.cv.CVID.MS_selected_ion_m_z))
{
double selectedMz = (double)spectrum.precursors[0].selectedIons[0].cvParam(pwiz.CLI.cv.CVID.MS_selected_ion_m_z).value;
// Add xcorr score
ZedGraph.IPointList peaks = (item as MassSpectrum).Points;
List<ScoringUtils.Peak> rawPeaks = new List<ScoringUtils.Peak>();
for (int i = 0; i < peaks.Count; ++i)
rawPeaks.Add(new ScoringUtils.Peak(peaks[i].X, peaks[i].Y));
// Remove the precursor and associated neutral loss peaks
ScoringUtils.erasePrecursorIons(selectedMz, ref rawPeaks); //selectedMz = precursorMz
if (spectrum.precursors[0].selectedIons[0].hasCVParam(pwiz.CLI.cv.CVID.MS_charge_state)) // known precursor charge state
{
int chargeState = (int)spectrum.precursors[0].selectedIons[0].cvParam(pwiz.CLI.cv.CVID.MS_charge_state).value;
double calculatedMass = (precursorMassType == 0 ? peptide.monoisotopicMass(chargeState) : peptide.molecularWeight(chargeState)) * chargeState;
double observedMass = selectedMz * chargeState;
// compute XCorr
double precursorMH = (selectedMz * chargeState) - ((chargeState - 1) * 1.007276);
double xcorr = ScoringUtils.computeXCorr(rawPeaks, peptide, precursorMH);
annotationPanels.peptideInfoGridView.Rows.Add("Observed precursor charge:", chargeState, "XCorr:", xcorr);
annotationPanels.peptideInfoGridView.Rows.Add("Calculated mass:", calculatedMass, "Mass error (daltons):", observedMass - calculatedMass);
annotationPanels.peptideInfoGridView.Rows.Add("Observed mass:", observedMass, "Mass error (ppm):", ((observedMass - calculatedMass) / calculatedMass) * 1e6);
}
else // unknown precursor charge state, assume +2 or +3
{
//.........这里部分代码省略.........
示例4: idpReader_original
///<summary>
///original code for grabbing the required ions
///get pepSequence,source,scanID, write into a csv file.
///have tons of information: theretical ion intensity, pep info, chargeLabel...
///</summary>
public static List<string> idpReader_original(string idpXMLFile, string mzMLFile, double TicCutoffPercentage, int z, List<string> pepList, List<string> output)
{
//get the path and filename of output csv file:
string fileName = Path.GetFileNameWithoutExtension(idpXMLFile);
string filePath = Path.GetDirectoryName(idpXMLFile);
IDPicker.Workspace workspace = new IDPicker.Workspace();
Package.loadWorkspace(ref workspace, idpXMLFile);
MSDataFile foo = new MSDataFile(mzMLFile);
SpectrumList sl = foo.run.spectrumList;
foreach (IDPicker.SourceGroupList.MapPair groupItr in workspace.groups)
foreach (IDPicker.SourceInfo source in groupItr.Value.getSources(true))
foreach (IDPicker.SpectrumList.MapPair sItr in source.spectra)
{
IDPicker.ResultInstance ri = sItr.Value.results[1];
IDPicker.VariantInfo vi = ri.info.peptides.Min;
string ss = vi.ToString() + "," + sItr.Value.id.source.name + "," + sItr.Value.nativeID;
bool boolCharge = sItr.Value.id.charge.Equals(z);
if (boolCharge)
{
string rawPepSequence = vi.ToString();
string pepSequence = vi.peptide.sequence;
int len = pepSequence.Length;
//make sure that the peptide is what we want
if (pepList.Contains(pepSequence))
{
// Look up the index with nativeID
object idOrIndex = null;
if (sItr.Value.nativeID != null && sItr.Value.nativeID.Length > 0)
idOrIndex = sItr.Value.nativeID;
int spectrumIndex = sl.find(idOrIndex as string);
// Trust the local index, if the nativeID lookup fails
if (spectrumIndex >= sl.size())
spectrumIndex = sItr.Value.id.index;
// Bail of the loca index is larger than the spectrum list size
if (spectrumIndex >= sl.size())
throw new Exception("Can't find spectrum associated with the index.");
//Console.WriteLine(idOrIndex.ToString());
//get base peak and TIC and converted to string
Spectrum spec1 = sl.spectrum(spectrumIndex, true);
MZIntensityPairList peaks = new MZIntensityPairList();
spec1.getMZIntensityPairs(ref peaks);
Set<Peak> peakList = new Set<Peak>();
//get base peak and TIC
double basePeakValue = 0;
double TICValue = 0;
CVParamList list = spec1.cvParams;
foreach (CVParam CVP in list)
{
if (CVP.name == "base peak intensity")
{
basePeakValue = CVP.value;
}
if (CVP.name == "total ion current")
{
TICValue = CVP.value;
}
}
string basePeak = basePeakValue.ToString();
string TIC = TICValue.ToString();
//very important. Surendra put them here
//to change those with modifications {} into a format
//that fragment method will accept.
string interpretation = vi.ToSimpleString();
Peptide peptide = new Peptide(interpretation, ModificationParsing.ModificationParsing_Auto, ModificationDelimiter.ModificationDelimiter_Brackets);
Fragmentation fragmentation = peptide.fragmentation(true, true);
//prepare the qualified peaklist
double intenThreshhold = 0;
int totalIntenClass = 0;
double[] intenArray = new double[peaks.Count];
//used during the foreach loop
int indexPeaks = 0;
//get all the peaks no matter how small they are
//then calculate the threshhold TIC
//test here
foreach (MZIntensityPair mzIntensity in peaks)
{
//Peak p = new Peak(mzIntensity.mz, mzIntensity.intensity);
//peakList.Add(p);
intenArray[indexPeaks] = mzIntensity.intensity;
indexPeaks++;
}
Array.Sort(intenArray);
Array.Reverse(intenArray, 0, peaks.Count);
//.........这里部分代码省略.........
示例5: idpReader
//get pepSequence,source,scanID, write into a csv file.
//have tons of information: theretical ion intensity, pep info, chargeLabel...
public static void idpReader(string idpXMLFile, string mzMLFile, double TicCutoffPercentage, int z, int model)
{
//get the path and filename of output csv file:
string fileName = Path.GetFileNameWithoutExtension(idpXMLFile);
string filePath = Path.GetDirectoryName(idpXMLFile);
string csvFile = Path.Combine(filePath, fileName) + "_" + z.ToString() + ".csv";
IDPicker.Workspace workspace = new IDPicker.Workspace();
Package.loadWorkspace(ref workspace, idpXMLFile);
using (StreamWriter file = new StreamWriter(csvFile))
{
//TODO idOrIndex + "," + pepSequence + "," + pepBond + "," + AA + "," + bIons + "," + yIons;
file.WriteLine("nativeID,pepSequence,bond,b1,b2,y1,y2");
MSDataFile foo = new MSDataFile(mzMLFile);
SpectrumList sl = foo.run.spectrumList;
foreach (IDPicker.SourceGroupList.MapPair groupItr in workspace.groups)
foreach (IDPicker.SourceInfo source in groupItr.Value.getSources(true))
foreach (IDPicker.SpectrumList.MapPair sItr in source.spectra)
{
IDPicker.ResultInstance ri = sItr.Value.results[1];
IDPicker.VariantInfo vi = ri.info.peptides.Min;
string ss = vi.ToString() + "," + sItr.Value.id.source.name + "," + sItr.Value.nativeID;
bool boolCharge = sItr.Value.id.charge.Equals(z);
if (boolCharge)
{
string rawPepSequence = vi.ToString();
string pepSequence = vi.peptide.sequence;
int len = pepSequence.Length;
// Look up the index with nativeID
object idOrIndex = null;
if( sItr.Value.nativeID != null && sItr.Value.nativeID.Length > 0 )
idOrIndex = sItr.Value.nativeID;
int spectrumIndex = sl.find(idOrIndex as string);
// Trust the local index, if the nativeID lookup fails
if( spectrumIndex >= sl.size() )
spectrumIndex = sItr.Value.id.index;
// Bail of the loca index is larger than the spectrum list size
if( spectrumIndex >= sl.size() )
throw new Exception( "Can't find spectrum associated with the index." );
//get base peak and TIC and converted to string
Spectrum spec1 = sl.spectrum(spectrumIndex, true);
MZIntensityPairList peaks = new MZIntensityPairList();
spec1.getMZIntensityPairs(ref peaks);
Set<Peak> peakList = new Set<Peak>();
//get base peak and TIC
double basePeakValue = 0;
double TICValue = 0;
CVParamList list = spec1.cvParams;
foreach (CVParam CVP in list)
{
if (CVP.name == "base peak intensity")
{
basePeakValue = CVP.value;
}
if (CVP.name == "total ion current")
{
TICValue = CVP.value;
}
}
string basePeak = basePeakValue.ToString();
string TIC = TICValue.ToString();
//very important. Surendra put them here
//to change those with modifications {} into a format
//that fragment method will accept.
string interpretation = vi.ToSimpleString();
Peptide peptide = new Peptide(interpretation, ModificationParsing.ModificationParsing_Auto, ModificationDelimiter.ModificationDelimiter_Brackets);
Fragmentation fragmentation = peptide.fragmentation(true, true);
//prepare the qualified peaklist
double intenThreshhold = 0;
int totalIntenClass = 0;
double[] intenArray = new double[peaks.Count];
//used during the foreach loop
int indexPeaks = 0;
//get all the peaks no matter how small they are
//then calculate the threshhold TIC
//test here
foreach (MZIntensityPair mzIntensity in peaks)
{
//Peak p = new Peak(mzIntensity.mz, mzIntensity.intensity);
//peakList.Add(p);
intenArray[indexPeaks] = mzIntensity.intensity;
indexPeaks++;
}
Array.Sort(intenArray);
Array.Reverse(intenArray, 0, peaks.Count);
//.........这里部分代码省略.........