//****************************************************************************
//* Copyright (C) 2008 Peter Mortensen and Matthias Mann *
//* This file is part of MSQuant. *
//* *
//* MSQuant is distributed under the terms of *
//* the GNU General Public License. See src/COPYING.TXT or *
//* <http://www.gnu.org/licenses/gpl.txt> for details. *
//* *
//* MSQuant is free software; you can redistribute it *
//* and/or modify it under the terms of the GNU *
//* General Public License as published by the Free *
//* Software Foundation; either version 2 of the *
//* License, or (at your option) any later version. *
//* *
//* MSQuant is distributed in the hope that it will be *
//* useful, but WITHOUT ANY WARRANTY; without even the *
//* implied warranty of MERCHANTABILITY or FITNESS FOR *
//* A PARTICULAR PURPOSE. See the GNU General Public *
//* License for more details. *
//* *
//* You should have received a copy of the GNU General *
//* Public License along with MSQuant; if not, write to *
//* the Free Software Foundation, Inc., 59 Temple *
//* Place, Suite 330, Boston, MA 02111-1307 USA *
//* *
//* Purpose: one of the main datastructures; peptide, representing a *
//* result from a sequence database search. *
//* *
//****************************************************************************
//****************************************************************************
//* CEBI *
//* Software Development Group *
//* Peter Mortensen *
//* E-mail: NUKESPAMMERSdrmortensen@get2netZZZZZZ.dk *
//* WWW: http://www.cebi.sdu.dk/ *
//* *
//* Program for post-processing of result from search in mass *
//* spectrometric data. *
//* *
//* FILENAME: PILpeptideDatastructures.cs *
//* TYPE: CSHARP *
//* *
//* CREATED: PM 2008-10-30 Vrs 1.0. Translated from VB.NET, *
// file clsMolShrStruct.vb *
//* UPDATED: PM 2008-xx-xx *
//* *
//****************************************************************************
//Future:
// 1. Move fields above functions (e.g. readFromStream2() and addToStream2())
//
//
//using System;
//using System.Collections.Generic;
//using System.Text;
using System.Runtime.Serialization; //For ISerializable and [Serializable()].
using System.Collections.Generic; //For List and Dictionary.
using System.Diagnostics; //For Trace. And its Assert.
using SimmoTech.Utils.Serialization; //For SerializationReader
// and SerializationWriter.
using massSpectrometryBase; //For spectrumSubTypeEnum.
//Main data structure is:
// public struct PeptideHitStructure
//Changed PM_REFACTOR 2004-06-30
//****************************************************************************
//* <placeholder for header> *
//****************************************************************************
public class peptideConstants
{
public const string SEQUENCE_BADPEPTIDE = "ZZZZZZ";
} //peptideConstants
//****************************************************************************
//d$ <summary>
//d$ Purpose: Namespace for lower layers of mass spectrometric
//d$ applications: raw data file handling, descriptive statistics,
//d$ fragment masses, digestion, file associations, etc.
//d$ <see cref="T:VBXMLDoc.CVBXMLDoc" />.
//d$ <isUnitTest></isUnitTest>
//d$ <applicationname>test_rawDataFileHandling</applicationname>
//d$ <author>Peter Mortensen</author>
//d$ <seealso>http://www.cebi.sdu.dk/</seealso>
//d$ <codetype>PLATFORM independent</codetype>
//d$ </summary>
namespace massSpectrometryBase
{
//Should signalStructure be here in this peptide datastructure file??
//Changed PM_MORE_MEMORY_WORKAROUND 2004-09-07. Now serializable
//****************************************************************************
//d$ <summary>
//d$ Purpose:
//d$ Note: borrowed from Module signalModule
//d$
//d$ </summary>
//[Serializable()]
public struct signalStructure //: ISerializable
{
//d$ <summary>XYZ.</summary>
public double Xsig;
//d$ <summary>Something representing signal intensity.
//d$ It is unspecified: it can be the original signal or some
//d$ derived quantitity: maximum signal strength, area (XIC),
//d$ sum of signal strengths in a window, etc.</summary>
public double Ysig;
//d$ <summary> Some value carried with each point. For
//d$ instance: neutral centroid mass for each signal
//d$ in a LC signal.</summary>
public double tagValue;
//Changed PM_FINNEGAN_BAD_LCPEAK_WINDOW 2003-10-21
//d$ <summary> Some other value carried with each point. For
//d$ instance: cycle number.</summary>
public int tagValue2;
//Changed PM_QUANT_AUTO_CENTERING 2006-11-13
public double tagValue3;
public quantResultStructure quantResult;
public massSpectrometryBase.spectrumSubTypeEnum MStype;
//Changed PM_FAST_SERIALISATION_READ 2007-01-03
//****************************************************************************
//* For signalStructure. *
//****************************************************************************
public static signalStructure readFromStream2(
ref SerializationReader anInReader, int aMBfileVersion)
{
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//signalStructure toReturn = default(signalStructure);
signalStructure toReturn;
toReturn.Xsig = anInReader.ReadDouble();
toReturn.Ysig = anInReader.ReadDouble();
toReturn.tagValue = anInReader.ReadDouble();
toReturn.tagValue2 = anInReader.ReadInt32();
toReturn.tagValue3 = anInReader.ReadDouble();
toReturn.quantResult =
quantResultStructure.readFromStream2(
ref anInReader, aMBfileVersion);
int MStypeInt = anInReader.ReadInt32();
toReturn.MStype = (spectrumSubTypeEnum)MStypeInt;
//Later: assert on the possible types.
Trace.Assert(
MStypeInt > 100 && MStypeInt < 70000,
"PIL ASSERT. MStype out of range: " + MStypeInt + ".");
return toReturn;
} //readFromStream2(). For signalStructure.
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-20
//****************************************************************************
//* For signalStructure. *
//****************************************************************************
public void addToStream2(
ref SerializationWriter anInOutWriter, int aMBfileVersion)
{
//aVersion: e.g. 300 for MB3, 400 for MB4.
//SERMARK03. A marker. Keep it.
anInOutWriter.Write(Xsig);
anInOutWriter.Write(Ysig);
anInOutWriter.Write(tagValue);
anInOutWriter.Write(tagValue2);
anInOutWriter.Write(tagValue3);
quantResult.addToStream2(ref anInOutWriter, aMBfileVersion);
//Changed PM_REFACTOR_MARKER 2008-10-31
anInOutWriter.Write((int)MStype); //Is 4-byte integer the right cast?
//Answer: yes, we have used ReadInt32() for reading
// in the older version. See above.
} //addToStream2(). For signalStructure.
} //signalStructure
} //namespace massSpectrometryBase
//****************************************************************************
//* <placeholder for header> *
//****************************************************************************
public enum mascotColourEnum
{
enumBoldRed,
enumLightRed,
enumBoldBlack,
enumLightBlack
} //mascotColourEnum
//Changed PM_EVENMORE_GENERALISED_QUANTMODES 2005-04-07
//****************************************************************************
//* <placeholder for header> *
//****************************************************************************
//[Serializable()]
public struct derivedQuantInfoStructure //: ISerializable
{
//Note: if fields are added readFromStream2() and
// addToStream2() should be updated!!!
public double MCRuncalib;
//Changed PM_REFACTOR 2006-10-03
//Not used anywhere. We also have difficulties computing it
// at parse time.
// Dim calibratedMCR2 As Double
//Needed?
public double MCRuncalibDiff;
//Changed PM_FAST_SERIALISATION_READ 2007-01-02
//****************************************************************************
//* For derivedQuantInfoStructure. *
//****************************************************************************
public static derivedQuantInfoStructure readFromStream2(
ref SerializationReader anInReader, int aMBfileVersion)
{
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//derivedQuantInfoStructure toReturn = default(derivedQuantInfoStructure);
derivedQuantInfoStructure toReturn;
double MCRuncalib = anInReader.ReadDouble();
Trace.Assert(
MCRuncalib >= 0.0 && MCRuncalib <= 99999.9,
"PIL ASSERT. Deserialisation of derivedQuantInfoStructure, " +
"MCRuncalib is out of range: " + MCRuncalib + ".");
toReturn.MCRuncalib = MCRuncalib;
toReturn.MCRuncalibDiff = anInReader.ReadDouble();
return toReturn;
} //readFromStream2(). For derivedQuantInfoStructure.
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-19
//****************************************************************************
//* For derivedQuantInfoStructure. *
//****************************************************************************
public void addToStream2(
ref SerializationWriter anInOutWriter, int aMBfileVersion)
{
//aVersion: e.g. 300 for MB3, 400 for MB4.
//SERMARK04. A marker. Keep it.
anInOutWriter.Write(MCRuncalib);
anInOutWriter.Write(MCRuncalibDiff);
} //addToStream2(). For derivedQuantInfoStructure.
} //derivedQuantInfoStructure
//Changed PM_TYPESAFE 2006-11-06. Moved to here from MascotResultParser.vb.
//'Changed PM_REFACTOR 2006-10-05
//****************************************************************************
//* <placeholder for header> *
//****************************************************************************
//[Serializable()]
public struct shortFormSILACinfoStructure //: ISerializable
{
//Note: if fields are added readFromStream2() and
// addToStream2() should be updated!!!
//Is truely mass (neutral) - is not MCR.
public double mass2;
public double quantCalibratedNeutralMass2;
//Sum of intensities in MS spectrum. Should
public double intensity4;
// not be used any more.
//Note: peak area in MS spectrum, not LC profile.
public double MSpeakArea2;
//Note: depends on the background
public double intensityRatioToBase3;
// level. It is ***not*** necessarily the ratio
// between intensity and intensity for base.
//
//Should not be used any more.
//Changed PM_QUANT_AUTO_CENTERING 2006-11-13
public double MCRoffset2;
//Changed PM_ONLY_MSPEAKAREA 2006-11-10
public double MSpeakAreaRatioToBase;
//Perhaps later:
//Dim peakAreaRatioToBase As Double
//dim maxYcentroid as double Maximum for y-centroids for one or more
// integration intervals (e.g. interval covering mono isotopic
// peak and some isotope peaks.)
//Dim maxY As Double 'Maximum for max y values for one or more
// integration intervals (e.g. interval covering mono isotopic
// peak and some isotope peaks.)
//Changed PM_MARKER_FOR_MB4 2008-01-30
//Changed PM_ISOTOPEDISTRIBUTION_PLOT 2008-01-30
public double maxYmono;
//Changed PM_MARKER_FOR_MB4 2008-01-31
//Changed PM_QUANT_ISOTOPES 2008-01-31
//Zero if only mono isotopic
public int isotopesQuantified;
// peak quantified.
//Changed PM_FAST_SERIALISATION_READ 2007-01-02
//****************************************************************************
//* For shortFormSILACinfoStructure. *
//****************************************************************************
public static shortFormSILACinfoStructure readFromStream2(
ref SerializationReader anInReader, int aMBfileVersion)
{
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//shortFormSILACinfoStructure toReturn = default(shortFormSILACinfoStructure);
shortFormSILACinfoStructure toReturn;
toReturn.mass2 = anInReader.ReadDouble();
toReturn.quantCalibratedNeutralMass2 = anInReader.ReadDouble();
toReturn.intensity4 = anInReader.ReadDouble();
toReturn.MSpeakArea2 = anInReader.ReadDouble();
toReturn.intensityRatioToBase3 = anInReader.ReadDouble();
double MCRoffset2 = anInReader.ReadDouble();
Trace.Assert(
MCRoffset2 >= -999.99 && MCRoffset2 <= 999.99,
"PIL ASSERT. Deserialisation, MCRoffset2 is out of range: " +
MCRoffset2 + ".");
toReturn.MCRoffset2 = MCRoffset2;
toReturn.MSpeakAreaRatioToBase = anInReader.ReadDouble();
//Changed PM_MB3_BROKEN 2008-11-27. Was not guarded...
toReturn.isotopesQuantified = 0;
toReturn.maxYmono = 0.0;
if (aMBfileVersion >= AppConstants.SAVEDFILEVERSION_MB4)
{
//Changed PM_SAVE_ALLRECALIB_MB4 2008-11-25
////Changed PM_CSHARP_DETECTED_PROBLEM 2008-10-30
//toReturn.isotopesQuantified = 0; //Not saved in MB3. Is it the
//// right value???
//toReturn.maxYmono = 0.0;
toReturn.isotopesQuantified = anInReader.ReadOptimizedInt32();
toReturn.maxYmono = anInReader.ReadDouble();
}
// About WriteOptimized(),
// from <http://www.codeproject.com/KB/dotnet/FastSerializer.aspx>:
//
// The WriteOptimized(xxx) methods use an alternative storage
// method that not only depends on the type but its value
// also. So, an Int32 that is less than 128 can be stored in
// a single byte (by using 7-bit encoding), but Int32 values
// of 268,435,456 or larger or negative numbers can't be
// stored using this technique (otherwise they would take 5
// bytes and so can't be considered optimizable!), but if you
// want to store a value, say the number of items in a list,
// that you know will never be negative and will never reach
// the limit, then use the WriteOptimized() method instead.
return toReturn;
} //readFromStream2(). For shortFormSILACinfoStructure.
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-19
//****************************************************************************
//* For shortFormSILACinfoStructure. *
//****************************************************************************
public void addToStream2(
ref SerializationWriter anInOutWriter, int aMBfileVersion)
{
//aVersion: e.g. 300 for MB3, 400 for MB4.
//SERMARK05. A marker. Keep it.
anInOutWriter.Write(mass2);
anInOutWriter.Write(quantCalibratedNeutralMass2);
anInOutWriter.Write(intensity4);
anInOutWriter.Write(MSpeakArea2);
anInOutWriter.Write(intensityRatioToBase3);
anInOutWriter.Write(MCRoffset2);
anInOutWriter.Write(MSpeakAreaRatioToBase);
//Note: not saved in MB3 files...:
// this.isotopesQuantified
// this.maxYmono
//Changed PM_MB3_BROKEN 2008-11-27. Was not guarded...
if (aMBfileVersion >= AppConstants.SAVEDFILEVERSION_MB4)
{
//Changed PM_SAVE_ALLRECALIB_MB4 2008-11-25
anInOutWriter.WriteOptimized(isotopesQuantified);
anInOutWriter.Write( maxYmono);
}
} //addToStream2(). For shortFormSILACinfoStructure.
} //shortFormSILACinfoStructure
//Changed PM_TYPESAFE 2006-11-06. Moved to here from MascotResultParser.vb.
//****************************************************************************
//* Information from one MS spectrum. *
//* *
//****************************************************************************
//[Serializable()]
public struct SpecQuantStructure //: ISerializable
{
//Note: if fields are added readFromStream2() and
// addToStream2() should be updated!!!
public bool useForQuant_WT;
//For both?
public bool useForMW;
public int cycle;//which cycle in the LC run.
public double retT; //Unit: seconds.
//Changed PM_FULL_LCWINDOW_DISPLAY 2003-03-27
public bool inLCwindow;
//Changed PM_MVC_QUANTIFY 2003-08-07.
//Derived values from intensities: intensityStableIsotope, etc., but
//cached here.
public bool allGoodQuant;
public bool allBadQuant;
public List<shortFormSILACinfoStructure> dishInfo;
//Changed PM_FAST_SERIALISATION_READ 2007-01-01
//****************************************************************************
//* For SpecQuantStructure. *
//****************************************************************************
public static SpecQuantStructure readFromStream2(
ref SerializationReader anInReader, int aMBfileVersion)
{
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//SpecQuantStructure toReturn = default(SpecQuantStructure);
SpecQuantStructure toReturn;
toReturn.useForQuant_WT = anInReader.ReadBoolean();
toReturn.useForMW = anInReader.ReadBoolean();
int cycle = anInReader.ReadInt32();
Trace.Assert(
cycle >= 0 && cycle <= 199999,
"PIL ASSERT. Deserialisation, cycle is out of range: " +
cycle + ".");
toReturn.cycle = cycle;
toReturn.retT = anInReader.ReadDouble();
toReturn.inLCwindow = anInReader.ReadBoolean();
toReturn.allGoodQuant = anInReader.ReadBoolean();
toReturn.allBadQuant = anInReader.ReadBoolean();
toReturn.dishInfo = null;
//Out here to keep compiler silent.. If
// it is inside the block then it claims dishInfo is not initialised.
//List
{
int items = anInReader.ReadOptimizedInt32();
if (items > 0)
{
toReturn.dishInfo =
new List<shortFormSILACinfoStructure>(items);
int lastIndex = items - 1;
int j = 0;
for (j = 0; j <= lastIndex; j++)
{
toReturn.dishInfo.Add(
shortFormSILACinfoStructure.readFromStream2(
ref anInReader, aMBfileVersion));
}
}
} //Block. Reading list.
return toReturn;
} //readFromStream2(). For SpecQuantStructure.
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-19
//****************************************************************************
//* For SpecQuantStructure. *
//****************************************************************************
public void addToStream2(
ref SerializationWriter anInOutWriter, int aMBfileVersion)
{
//aVersion: e.g. 300 for MB3, 400 for MB4.
//SERMARK06. A marker. Keep it.
anInOutWriter.Write(useForQuant_WT);
anInOutWriter.Write(useForMW);
anInOutWriter.Write(cycle);
anInOutWriter.Write(retT);
anInOutWriter.Write(inLCwindow);
anInOutWriter.Write(allGoodQuant);
anInOutWriter.Write(allBadQuant);
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-19. Loop on the
//client side.
//anInOutWriter.Write(dishInfo) 'List(Of shortFormSILACinfoStructure)
{
if (dishInfo != null)
{
int items = dishInfo.Count;
//This is our own encoding.
anInOutWriter.WriteOptimized(items);
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//shortFormSILACinfoStructure item =
// default(shortFormSILACinfoStructure);
foreach (shortFormSILACinfoStructure item in dishInfo)
{
item.addToStream2(ref anInOutWriter, aMBfileVersion);
}
}
else
{
int items = 0;
//Encode nothing as zero length
anInOutWriter.WriteOptimized(items);
}
} //Block. Delimiting one list.
} //addToStream2(). For SpecQuantStructure.
} //SpecQuantStructure
//Changed PM_REFACTOR 2008-10-30
//One for each (possible) PTM site in a peptide.
//****************************************************************************
//* <placeholder for header> *
//****************************************************************************
//[Serializable()]
public struct PTMinfoStructure
{
//Zero-based index into the peptide sequence, for AA2.
public int AAindex;
//An amino acid from the peptide sequence, one that may be
//modified. By number ref to avoid string/garbage collect?
public string AA2;
//Eliminate?
//Value depends on AA and on current set of
public double basicMassDiff;
// modifications for a peptide.
//Changed PM_MOD_PREFIX_AND_POSTFIX 2006-06-07
//For output notation, e.g. "p" for phosphorylations.
public int modID;
//Changed PM_FAST_SERIALISATION_READ 2007-01-04
//****************************************************************************
//* For PTMinfoStructure. *
//****************************************************************************
public static PTMinfoStructure readFromStream2(
ref SerializationReader anInReader, int aMBfileVersion)
{
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//PTMinfoStructure toReturn = default(PTMinfoStructure);
PTMinfoStructure toReturn;
int AAindex = anInReader.ReadInt32();
Trace.Assert(
AAindex >= 0 && AAindex <= 999,
"PIL ASSERT. Deserialisation of PTMinfoStructure, " +
"AAindex is out of range: " + AAindex + ".");
toReturn.AAindex = AAindex;
toReturn.AA2 = anInReader.ReadString();
toReturn.basicMassDiff = anInReader.ReadDouble();
toReturn.modID = anInReader.ReadInt32();
return toReturn;
} //readFromStream2(). For abc.
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-29
//****************************************************************************
//* For PTMinfoStructure. *
//****************************************************************************
public void addToStream2(
ref SerializationWriter anInOutWriter, int aMBfileVersion)
{
//aVersion: e.g. 300 for MB3, 400 for MB4.
//SERMARK07. A marker. Keep it.
anInOutWriter.Write(AAindex);
anInOutWriter.Write(AA2);
anInOutWriter.Write(basicMassDiff);
anInOutWriter.Write(modID);
} //addToStream2(). For PTMinfoStructure.
} //PTMinfoStructure
//****************************************************************************
//* <placeholder for header> *
//****************************************************************************
//[Serializable()]
public struct onePTMcombinationStructure
{
//Note: if fields are added addToStream() should be updated!!!
public double score;
//Dim forwardIonIndex As Integer
//Dim backwardIonIndex As Integer
//Changed PM_REFACTOR 2006-12-17
//Dim positions As ArrayList
//Real type is PTMinfoStructure. Information
public List<PTMinfoStructure> positions2;
// about each phophorylation: position, etc.
//Changed PM_PHOSPHO_SCORING_USERSEL 2005-12-16
//Used for deciding the result of the PTMing.
public bool checked7;
// If only one combination have this field set to true then there is not ambiguity.
// The user may have set it and there will be some default during
// scoring, e.g. highest scoring combination get set this field to true.
// Better name for this field?
//Changed PM_MARKER 2005-12-20
//Changed PM_FAST_SERIALISATION_READ 2007-01-04
//****************************************************************************
//* For onePTMcombinationStructure. *
//****************************************************************************
public static onePTMcombinationStructure readFromStream2(
ref SerializationReader anInReader, int aMBfileVersion)
{
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//onePTMcombinationStructure toReturn =
// default(onePTMcombinationStructure);
onePTMcombinationStructure toReturn;
toReturn.score = anInReader.ReadDouble();
toReturn.positions2 = null;
//List
{
int items = anInReader.ReadOptimizedInt32();
if (items > 0)
{
toReturn.positions2 = new List<PTMinfoStructure>(items);
int lastIndex = items - 1;
int j = 0;
for (j = 0; j <= lastIndex; j++)
{
toReturn.positions2.Add(
PTMinfoStructure.readFromStream2(
ref anInReader, aMBfileVersion));
}
}
} //Block. Reading list.
toReturn.checked7 = anInReader.ReadBoolean();
return toReturn;
} //readFromStream2(). For onePTMcombinationStructure.
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-29
//****************************************************************************
//* For onePTMcombinationStructure. *
//****************************************************************************
public void addToStream2(
ref SerializationWriter anInOutWriter, int aMBfileVersion)
{
//aVersion: e.g. 300 for MB3, 400 for MB4.
//SERMARK08. A marker. Keep it.
anInOutWriter.Write(score);
{
int items = positions2.Count;
//This is our own encoding.
anInOutWriter.WriteOptimized(items);
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//PTMinfoStructure item = default(PTMinfoStructure);
foreach (PTMinfoStructure item in positions2)
{
item.addToStream2(ref anInOutWriter, aMBfileVersion);
}
} //Block. Delimiting one list.
anInOutWriter.Write(checked7);
} //addToStream2(). For onePTMcombinationStructure.
} //onePTMcombinationStructure
//Changed PM_REFACTOR 2008-10-30. From somewhere else.
//Changed PM_REFACTOR 2006-12-17
//Information for one kind of PTM.
//****************************************************************************
//* <placeholder for header> *
//****************************************************************************
//[Serializable()]
public struct onePTMStructure
{
//Future: some fields to describe the PTM, e.g.
// name, mass diffs, affected AAs, etc.
public List<onePTMcombinationStructure> combinations2;
// Note: number of items may be lower than the actual, e.g. may
// only contain the top 3. Or only the user selected ones.
//Changed PM_PHOSPHO_SCORING_USERSEL 2005-12-16
//Note: these 2 are never set!!
public double minScore;
public double maxScore;
//Changed PM_FAST_SERIALISATION_READ 2007-01-04
//****************************************************************************
//* For onePTMStructure. *
//****************************************************************************
public static onePTMStructure readFromStream2(
ref SerializationReader anInReader, int aMBfileVersion)
{
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//onePTMStructure toReturn = default(onePTMStructure);
onePTMStructure toReturn;
toReturn.combinations2 = null;
//List
{
int items = anInReader.ReadOptimizedInt32();
if (items > 0)
{
toReturn.combinations2 =
new List<onePTMcombinationStructure>(items);
int lastIndex = items - 1;
int j = 0;
for (j = 0; j <= lastIndex; j++)
{
toReturn.combinations2.Add(
onePTMcombinationStructure.readFromStream2(
ref anInReader, aMBfileVersion));
}
}
} //Block. Reading list.
toReturn.minScore = anInReader.ReadDouble();
toReturn.maxScore = anInReader.ReadDouble();
return toReturn;
} //readFromStream2(). For onePTMStructure.
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-28
//****************************************************************************
//* For onePTMStructure. *
//****************************************************************************
public void addToStream2(
ref SerializationWriter anInOutWriter, int aMBfileVersion)
{
//aVersion: e.g. 300 for MB3, 400 for MB4.
//SERMARK11. A marker. Keep it.
//List
{
int items = combinations2.Count;
anInOutWriter.WriteOptimized(items);
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//onePTMcombinationStructure someItem =
// default(onePTMcombinationStructure);
foreach (onePTMcombinationStructure someItem in combinations2)
{
someItem.addToStream2(ref anInOutWriter, aMBfileVersion);
}
//Through checkBoxInfoList
} //Block. Delimiting one list/hash.
anInOutWriter.Write(minScore);
anInOutWriter.Write(maxScore);
} //addToStream2(). For onePTMStructure.
} //onePTMStructure
//Changed PM_MORE_MEMORY_WORKAROUND 2004-09-07. Now serializable
//Changed PM_REFACTOR 2003-04-09
//Changed PM_TRIPLE_ENCODING 2003-04-09
//****************************************************************************
//* <placeholder for header> *
//****************************************************************************
//[Serializable()]
public struct quantResultStructure //: ISerializable
{
//Sum of intensities in MS spectrum. Should
public double intensity5;
// not be used any more.
public double centroidMCR2;
public double maxSignal;
public double MSpeakArea3;
public double calibratedNeutralMass;
//Changed PM_QUANT_AUTO_CENTERING 2006-11-13
//The mass shift that was necessary
public double offsetMCR8;
// to center the integration window on the peak.
//Changed PM_REFACTOR_FINNEGAN 2003-07-25
//Flag to indicate there were no datapoints, etc.
public bool validResult;
//Changed PM_QUANT_ISOTOPES 2008-01-31
//Zero if only mono isotopic peak quantified.
public int isotopesQuantified2;
//Changed PM_FAST_SERIALISATION_READ 2007-01-03
//****************************************************************************
//* For quantResultStructure. *
//****************************************************************************
public static quantResultStructure readFromStream2(
ref SerializationReader anInReader, int aMBfileVersion)
{
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//quantResultStructure toReturn = default(quantResultStructure);
quantResultStructure toReturn;
toReturn.intensity5 = anInReader.ReadDouble();
toReturn.centroidMCR2 = anInReader.ReadDouble();
toReturn.maxSignal = anInReader.ReadDouble();
toReturn.MSpeakArea3 = anInReader.ReadDouble();
toReturn.calibratedNeutralMass = anInReader.ReadDouble();
toReturn.offsetMCR8 = anInReader.ReadDouble();
toReturn.validResult = anInReader.ReadBoolean();
//Changed PM_MB3_BROKEN 2008-11-27. Was not guarded...
toReturn.isotopesQuantified2 = 0;
if (aMBfileVersion >= AppConstants.SAVEDFILEVERSION_MB4)
{
//Changed PM_SAVE_ALLRECALIB_MB4 2008-11-25
////Changed PM_CSHARP_DETECTED_PROBLEM 2008-10-31
//toReturn.isotopesQuantified2 = 0; //Not saved in MB3. Is it the
//// right value???
toReturn.isotopesQuantified2 = anInReader.ReadOptimizedInt32();
}
return toReturn;
} //readFromStream2(). For quantResultStructure.
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-20
//****************************************************************************
//* For quantResultStructure. *
//****************************************************************************
public void addToStream2(
ref SerializationWriter anInOutWriter, int aMBfileVersion)
{
//aVersion: e.g. 300 for MB3, 400 for MB4.
//SERMARK09. A marker. Keep it.
anInOutWriter.Write(intensity5);
anInOutWriter.Write(centroidMCR2);
anInOutWriter.Write(maxSignal);
anInOutWriter.Write(MSpeakArea3);
anInOutWriter.Write(calibratedNeutralMass);
anInOutWriter.Write(offsetMCR8);
anInOutWriter.Write(validResult);
//Changed PM_MB3_BROKEN 2008-11-27. Was not guarded...
if (aMBfileVersion >= AppConstants.SAVEDFILEVERSION_MB4)
{
//Changed PM_SAVE_ALLRECALIB_MB4 2008-11-25
////Note: not added for MB3:
//// this.isotopesQuantified2
anInOutWriter.WriteOptimized(isotopesQuantified2);
}
} //addToStream2(). For quantResultStructure.
} //quantResultStructure
//****************************************************************************
//* <placeholder for header> *
//****************************************************************************
//[Serializable()]
public struct LCprofilesPropertiesStructure //: ISerializable
{
//Note: if fields are added readFromStream2() and
// addToStream2() should be updated!!!
//For I/base ratios: Average of the ratios from the
//clicked individual MS spectra - not weighted
//by absolute count.
public double averageOfRatios2;
//Error for 'averageOfRatios'.
public double ratioStDev;
//Integrated intensity over the LC peak in
//counts OR Integrated MS intensity. ?????
public double totalLCSignal;
//Background.... <add more>
public double backGround;
//Ratio of the current dish's sum of intensities to
//the base dish's (wild) sum of intensities.
public double ratioOfItensities3;
//Alias. XIC. Integrated over LC peak.
public double totalLCPeakArea;
//Changed PM_NO_RATIO_OF_INTENSITY_SUMS 2006-11-08
//Ratio of the current dish's XIC to the base dish's (wild) XIC.
public double ratioOfXICs;
//Changed PM_ONLY_MSPEAKAREA 2006-11-10
//Value of intensity from the spectrum with the
//highest value... A cached value.
public double maxMSpeakArea;
//Changed PM_FAST_SERIALISATION_READ 2007-01-03
//****************************************************************************
//* For LCprofilesPropertiesStructure. *
//****************************************************************************
public static LCprofilesPropertiesStructure readFromStream2(
ref SerializationReader anInReader, int aMBfileVersion)
{
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//LCprofilesPropertiesStructure toReturn = default(LCprofilesPropertiesStructure);
LCprofilesPropertiesStructure toReturn;
toReturn.averageOfRatios2 = anInReader.ReadDouble();
toReturn.ratioStDev = anInReader.ReadDouble();
toReturn.totalLCSignal = anInReader.ReadDouble();
toReturn.backGround = anInReader.ReadDouble();
toReturn.ratioOfItensities3 = anInReader.ReadDouble();
toReturn.totalLCPeakArea = anInReader.ReadDouble();
toReturn.ratioOfXICs = anInReader.ReadDouble();
toReturn.maxMSpeakArea = anInReader.ReadDouble();
return toReturn;
} //readFromStream2(). For LCprofilesPropertiesStructure.
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-20
//****************************************************************************
//* For LCprofilesPropertiesStructure. *
//****************************************************************************
public void addToStream2(
ref SerializationWriter anInOutWriter, int aMBfileVersion)
{
//aVersion: e.g. 300 for MB3, 400 for MB4.
//SERMARK10. A marker. Keep it.
anInOutWriter.Write(averageOfRatios2);
anInOutWriter.Write(ratioStDev);
anInOutWriter.Write(totalLCSignal);
anInOutWriter.Write(backGround);
anInOutWriter.Write(ratioOfItensities3);
anInOutWriter.Write(totalLCPeakArea);
anInOutWriter.Write(ratioOfXICs);
anInOutWriter.Write(maxMSpeakArea);
} //addToStream2(). For LCprofilesPropertiesStructure.
} //LCprofilesPropertiesStructure
//HHHHHHHHHH A marker...
//****************************************************************************
//* <placeholder for header> *
//****************************************************************************
//[Serializable()]
public struct PeptideHitStructure //: ISerializable
{
//Changed PM_MARKER_FOR_MB4 2008-02-06
//To add:
// 1. usedForRecalibration. Boolean. 'True if the MCR values for
// this peptide had affected the value of the calibration constants.
//
// 2. Relative paths for raw files and Mascot result files. Allows
// relocation of raw files and Mascot result files without
// breaking MB3 file. Save one or more base paths in the MB3 file.
// And save a prefered base path here in this structure.
//
// For relocated files there will be a user defined program
// wide set of base paths.
//Note: if fields are added readFromStream2() and
// addToStream2() should be updated!!!
//Changed PM_ELIMINATE_PEPTIDEFIELD 2008-11-25. Delete at any time.
////Version 1.0 is expressed as the integer 100,
//public int version2;
//// version 2.38 is expressed as the integer 238, etc.
//// Notes: the version is repeated for each and every peptide
//// hit. Is this good or bad??? There could be attributes
//// describing (including the version) the entire list
//// of peptides or the entire list of list of peptides.
////
//// History:
//// 1.00 2003-02-13 Introduced the version field
//// 1.xx 2003-xx-xx
public int queryNumber;
public double retentionTimeStartMinutes; //Unit: minutes.
//Changed PM_QUANTIFY_FROMFILE_RET_START_AND_END 2003-03-15. Update: if
// negative then it flags that this field should be used.....
//We leave this empty for now.
public double retentionTimeEndMinutes;
//Changed PM_LC_PEAKDETECTION 2003-03-20. Newly named variable to
//store the retention time MS/MS . retentionTimeStartMinutes is
//reserved to the actual start of the retention time window.
//Unit: minutes
public double MSMSretentionTimeMinutes;
//MM added 2002-12-18.
public double retTMax;
public int period2;
//Changed PM_SQLCOMMON_CHANGE 2003-07-31
//PM: what is the semantics?
public int experimentNumber;
public int cycle;
//Changed PM_FINNEGAN_RETENTION_TIME 2003-11-18
public int spectrumNumber;
public double measuredMCR;
public double measuredMass;
//MM added 2002-10-23.
public int charge;
public double MascotCalculatedMass;
//Changed PM_NOMODS_MASS 2003-10-08
public double calculatedMassNoMods;
//Changed PM_FINNEGAN_PPM_ERROR 2003-10-24
public double uncalibratedMSCentroidMass;
//Changed PM_FINNEGAN_PPM_ERROR 2003-10-28
public double calibratedMSCentroidMass;
//Changed PM_MSWINDOW 2003-03-27
//Derived fields
public double calibratedMeasuredMCR;
public double calibratedMeasuredMass;
public double neutralMScentroidForLCMax;
//Changed PM_CACHE_CALIBRATED_MASSES 2003-04-16
public double relativeErrorForPeptideMass_PPM;
public int missedCleavages;
public bool someAAsMatchingTheFilter; //To be phased out?
public double deltaMass;
public int rank; //Rank as in the Mascot list (for a query?).
public string AASequence;
//Changed PM_EXPORT_SEQ_WITHMODS 2003-10-08
//Directly from Mascot, the peptide sequence and
//modification text; stripped of the HTML formatting.
public string AASequencePlusMods;
public string seq1;
public string seq2;
//Changed PM_MASCOTSCORE_ASDOUBLE 2008-11-25
// //Changed PM_MARKER_SHOULD_BE_DOUBLE 2007-02-25. Change to
// // type "Double" whenever it is OK to move away from mb3.
// // Note: also change readFromStream2(), Structure PeptideHitStructure.
// //
// //Why isn't it double? It is an integer
// // value in the result file, but this could change. And isn't it
// // decimal number in .dat files?
// public int MascotScore;
public double MascotScore2;
//Bold red, light red.
public mascotColourEnum MascotColour;
public bool checkboxChecked;
//Changed PM_MS3INTEGRATION 2004-06-02
//Note: existence of this field is checked
//in frmMainForm.vb/frmMainForm_Load().
public double MascotScorePlusMS3Score;
public string MS3precursorStr;
public List<massSpectrometryBase.modificationCountStruct> modHits2;
// Reflects the modifications that Mascot has identified
// It will be Nothing if Mascot has not identified any modifications...
//Is the score in parenthesis. Because there is a better matching peptide.
public bool scoreInParens;
//Did this pept contribute to protein score.
public bool counted;
public double firstScore;
public double firstDeltaScore;
public string secSequence;
public double secScore;
//Is this sequence unique in the database?
public bool seq1Unique;
public bool seq2Unique;
//MM added 2002-10-25.
public bool verified;
//Reflects the "checked" setting (GUI, checkbox) for
//the peptide in the Quantiation Window.
//
//Is also set by the program during quantitation
//if there was an acceptable quantitation
//result (in AverageAndStDevFromMSLst()).
public bool useForQuantitation;
//Result of evaluation of peak in
public bool goodMSpeak;
// MS spectrum (at the specified MCR. Is
// false if:
// 1. is a C13 peak
// 2. charge state is not the expected
//Some text describing the reason a peak was detected
//as bad. Only applies when XXX.
public string badPeakReason;
//For quantitation warning such as overlaping isotope peaks etc.
public string comment;
//List of spectra.
public List<SpecQuantStructure> spectra;
public int savedStartCycle;
public int savedEndCycle;
//Changed PM_ACCESSIONNUMBER_IMPORT 2003-03-26
//Used when quantifying peptides from an external source
//where all peptides are put into a single psudo protein,
//but it is of interest to track which proteins the
//peptides originally came from.
public string importedAcc;
//Changed PM_SEVERALWIFFS 2003-08-26
public int rawFileID;
//Changed PM_PEPT_RAWFILE_PATH 2003-11-05
public string rawFileFullPath;
//It is Nothing if quantiation would not apply (invalidated peptide only?).
public List<derivedQuantInfoStructure> quantValues2;
//Changed PM_EVENMORE_GENERALISED_QUANTMODES 2005-04-08
public int SILACdishIndex;
// Indicates which SILAC dish the modifications match. Index
// is zero-based. Is 0 if the modifications do not
// match - a.k.a. wild type.
//
// Used for quantitation. The value is derived from the current
// quantitation mode and the modifications (for this peptide),
// field modHits.
//Values derived from the quantitation mode and this peptide's sequence.
//One value for each SILAC dish.
public List<double> uncalibratedSILACmasses2;
// Derived from observed (uncalibrated) mass, by a number
// of (theoretical) mass shifts. This is what we need for quantitation.
public List<onePTMStructure> PTMs2;
// This single field contain all the information
// about PTMs that have been scored. If the peptide has not been
// PTM scored then this field is 'Nothing'. For the time being
// (2005-10-14) there can only be one item, for phosphorylation.
// Real type of items in the list is onePTMStructure, in PTMscorer.vb
//Changed PM_MASCOTDLL_11_DETECTION 2005-12-15
//Note: change to structure definitions that can be in the field "PTMs",
// Thus earlier saved parses can not loaded if any peptide has
// been PTM scored.
// Changed:
// 1. new field checked in structure onePTMcombinationStructure
// 2. new fields minScore and maxScore in structure onePTMStructure
//Changed PM_PRECURSOR_INTENSITY 2005-09-08
public double precursorIntensity;
//Changed PM_OBSOLETED 2005-10-17. Disabled for now it does not
//seem to be used.
//'Changed PM_POLYDIMETHYLSILOXYSILANE 2005-09-08
//Dim polydimethylsiloxysilaneMCR As Double
public System.Int16 leftFlankAA;
// Last amino acid in the previous
// peptide (in the protein sequence).
// Stored as ASCII character code to avoid "string" dynamic
// memory allocation.
//Changed PM_STANDARDS_COMPLIANCE 2005-10-20
public System.Int16 rightFlankAA;
// First amino acid in the next
// peptide (in the protein sequence).
// Stored as ASCII character code to avoid "string" dynamic
// memory allocation.
public int startPositionInProtein; //One based.
public int endPositionInProtein; //One based.
public List<List<signalStructure>> LCpeakProfiles;
// Outer level is dish, e.g. 3 elements for triple
// encoding. Inner level is LC profile, number of
// elements is numbers of the points in the LC profile,
// e.g. 28.
//Changed PM_MSZOOM_TO_MAXLC 2003-04-08
public int LCMaxCycle;
//Changed PM_QUANT_AUTO_CENTERING 2006-11-13
//Index into LC profile(s).
public int LCMaxIndex;
//Changed PM_MAXWT_USEDFORQUANT 2003-10-01
public double usedForQuantitation_maxWTintensity;
// Out of set of
// spectra used for quantitation (selected by the program and/or the
// user): maximum value of quantitation of wild type.
// Or in other words: same as maxWTintensity, but only for those
// spectra that were selected by the program and/or the
// user.
//Changed PM_EXPORT_LCTIME_FOR_MAXCHECKED 2003-10-10
public double usedForQuantitation_maxWTintensity_LCtime;
// The retention time for usedForQuantitation_maxWTintensity.
public double retentionTimeCentroid_secs;
//Changed PM_LCPEAK_WIDTH 2003-03-14
public double estimatedLCPeakWidth;
//Changed PM_LC_PEAKDETECTION 2003-03-20
public double LCpeakDetectionTimeCentroidSeconds;
//Changed PM_EXPORT_MAXLC 2003-03-26
//May be the same as field retTMax...
public double LCMaxTimeSeconds;
public double LCMaxIntensity2;
//E.g. 3 items for triple encoding.
public List<LCprofilesPropertiesStructure> LCprofilesProperties;
//Changed PM_PEPTIDEFIELD_USEDFORRECALIBRATION 2008-11-25
public bool usedForRecalibration;
//Changed PM_FAST_SERIALISATION_READ 2007-01-01
//****************************************************************************
//* For PeptideHitStructure. *
//****************************************************************************
public static PeptideHitStructure readFromStream2(
ref SerializationReader anInReader, int aMBfileVersion)
{
//Remove the "helper.blankPeptide()" part.
PeptideHitStructure toReturn = blankPeptide();
//Changed PM_ELIMINATE_PEPTIDEFIELD 2008-11-25
if (aMBfileVersion < AppConstants.SAVEDFILEVERSION_MB4)
{
//Note: this is peptide version, but logically related
// to parameter aVersion.
int version = anInReader.ReadInt32();
Trace.Assert(
version >= 100 && version <= 1999,
"PIL ASSERT. Deserialisation of PeptideHitStructure, " +
"version is out of range: " + version + ".");
//toReturn.version2 = version; we now just read from the MB3
// but is ignoring the read version number.
}
toReturn.queryNumber = anInReader.ReadInt32();
toReturn.retentionTimeStartMinutes = anInReader.ReadDouble();
toReturn.retentionTimeEndMinutes = anInReader.ReadDouble();
toReturn.MSMSretentionTimeMinutes = anInReader.ReadDouble();
toReturn.retTMax = anInReader.ReadDouble();
toReturn.period2 = anInReader.ReadInt32();
toReturn.experimentNumber = anInReader.ReadInt32();
toReturn.cycle = anInReader.ReadInt32();
toReturn.spectrumNumber = anInReader.ReadInt32();
toReturn.measuredMCR = anInReader.ReadDouble();
toReturn.measuredMass = anInReader.ReadDouble();
toReturn.charge = anInReader.ReadInt32();
toReturn.MascotCalculatedMass = anInReader.ReadDouble();
toReturn.calculatedMassNoMods = anInReader.ReadDouble();
toReturn.uncalibratedMSCentroidMass = anInReader.ReadDouble();
toReturn.calibratedMSCentroidMass = anInReader.ReadDouble();
toReturn.calibratedMeasuredMCR = anInReader.ReadDouble();
toReturn.calibratedMeasuredMass = anInReader.ReadDouble();
toReturn.neutralMScentroidForLCMax = anInReader.ReadDouble();
toReturn.relativeErrorForPeptideMass_PPM = anInReader.ReadDouble();
toReturn.missedCleavages = anInReader.ReadInt32();
toReturn.someAAsMatchingTheFilter = anInReader.ReadBoolean();
toReturn.deltaMass = anInReader.ReadDouble();
toReturn.rank = anInReader.ReadInt32();
toReturn.AASequence = anInReader.ReadString();
toReturn.AASequencePlusMods = anInReader.ReadString();
toReturn.seq1 = anInReader.ReadString();
toReturn.seq2 = anInReader.ReadString();
////Changed PM_MARKER_SHOULD_BE_DOUBLE 2007-02-25. Later: double.
//Changed PM_MASCOTSCORE_ASDOUBLE 2008-11-25. We need to be able
//to read the old MB3 format...
double MascotScore3;
if (aMBfileVersion >= AppConstants.SAVEDFILEVERSION_MB4)
{
//MB4 or later. Score is now properly double.
MascotScore3 = anInReader.ReadDouble();
}
else
{
int MascotScore2 = anInReader.ReadInt32();
MascotScore3 = MascotScore2; //Implicit conversion from integer to
// double...
}
Trace.Assert(
MascotScore3 > 0.5 && MascotScore3 < 999.99,
"PIL ASSERT. Deserialise, MascotScore out of range: " +
MascotScore3 + ".");
toReturn.MascotScore2 = MascotScore3;
toReturn.MascotColour = (mascotColourEnum)anInReader.ReadInt32();
//ASSERT here on the few possible values. Remember to
toReturn.checkboxChecked = anInReader.ReadBoolean();
double MascotScorePlusMS3Score = anInReader.ReadDouble();
Trace.Assert(
MascotScorePlusMS3Score > 0.5 && MascotScorePlusMS3Score < 999.99,
"PIL ASSERT. Deserialise, MascotScorePlusMS3Score out of range: " +
MascotScorePlusMS3Score + ".");
toReturn.MascotScorePlusMS3Score = MascotScorePlusMS3Score;
toReturn.MS3precursorStr = anInReader.ReadString();
//List
{
toReturn.modHits2 = null;
int items = anInReader.ReadOptimizedInt32();
if (items > 0)
{
toReturn.modHits2 =
new List<massSpectrometryBase.modificationCountStruct>(items);
int lastIndex = items - 1;
int j = 0;
for (j = 0; j <= lastIndex; j++)
{
//Changed PM_REFACTOR_SPECIAL_MODFILTER_ON_MB3 2007-08-01
//toReturn.modHits2.Add( _
// modificationCountStructure.readFromStream(anInReader))
massSpectrometryBase.modificationCountStruct someMod =
massSpectrometryBase.modificationCountStruct.readFromStream2(
ref anInReader, aMBfileVersion);
//Changed PM_SPECIAL_MODFILTER_ON_MB3 2007-08-01
bool specialFilter = true;
//Set to false unless
// special version!!!!!!!!!!!!!!!!!!!!!!!!!
//
//What is this?????????????????????????????????????
//
if (!specialFilter | someMod.quantModificationID != 5050)
{
toReturn.modHits2.Add(someMod);
}
}
} //if any items.
} //Block. Reading list.
toReturn.scoreInParens = anInReader.ReadBoolean();
toReturn.counted = anInReader.ReadBoolean();
toReturn.firstScore = anInReader.ReadDouble();
toReturn.firstDeltaScore = anInReader.ReadDouble();
toReturn.secSequence = anInReader.ReadString();
toReturn.secScore = anInReader.ReadDouble();
toReturn.seq1Unique = anInReader.ReadBoolean();
toReturn.seq2Unique = anInReader.ReadBoolean();
toReturn.verified = anInReader.ReadBoolean();
toReturn.useForQuantitation = anInReader.ReadBoolean();
toReturn.goodMSpeak = anInReader.ReadBoolean();
toReturn.badPeakReason = anInReader.ReadString();
toReturn.comment = anInReader.ReadString();
//Changed PM_FAST_SERIALISATION_READ 2007-01-02
//List
{
toReturn.spectra = null;
int items = anInReader.ReadOptimizedInt32();
if (items > 0)
{
toReturn.spectra = new List<SpecQuantStructure>(items);
int lastIndex = items - 1;
int j = 0;
for (j = 0; j <= lastIndex; j++)
{
toReturn.spectra.Add(
SpecQuantStructure.readFromStream2(
ref anInReader, aMBfileVersion));
}
}
} //Block. Reading list.
toReturn.savedStartCycle = anInReader.ReadInt32();
toReturn.savedEndCycle = anInReader.ReadInt32();
toReturn.importedAcc = anInReader.ReadString();
{
int rawFileID = anInReader.ReadInt32();
Trace.Assert(
rawFileID >= -9999999 && rawFileID <= 9999999,
"PIL ASSERT. Deserialisation of PeptideHitStructure, " +
"rawFileID is out of range: " + rawFileID + ".");
toReturn.rawFileID = rawFileID;
}
toReturn.rawFileFullPath = anInReader.ReadString();
//Changed PM_FAST_SERIALISATION_READ 2007-01-02
//List
{
toReturn.quantValues2 = null;
int items = anInReader.ReadOptimizedInt32();
if (items > 0)
{
toReturn.quantValues2 =
new List<derivedQuantInfoStructure>(items);
int lastIndex = items - 1;
int j = 0;
for (j = 0; j <= lastIndex; j++)
{
toReturn.quantValues2.Add(
derivedQuantInfoStructure.readFromStream2(
ref anInReader, aMBfileVersion));
}
} //Block. Needed??
} //Block. Delimiting one list/hash.
{
int dIndex = anInReader.ReadInt32();
Trace.Assert(
dIndex >= 0 && dIndex <= 19,
"PIL ASSERT. Deserialisation of PeptideHitStructure, " +
"SILACdishIndex is out of range." + dIndex + ".");
toReturn.SILACdishIndex = dIndex;
}
toReturn.uncalibratedSILACmasses2 =
anInReader.ReadList<double>();
//List
{
toReturn.PTMs2 = null;
int items = anInReader.ReadOptimizedInt32();
if (items > 0)
{
toReturn.PTMs2 =
new List<onePTMStructure>(items);
int lastIndex = items - 1;
int j = 0;
for (j = 0; j <= lastIndex; j++)
{
toReturn.PTMs2.Add(
onePTMStructure.readFromStream2(
ref anInReader, aMBfileVersion));
}
}
} //Block. Reading list.
toReturn.precursorIntensity = anInReader.ReadDouble();
//Later: ASSERT on the limited range, ASCII A-Z.
toReturn.leftFlankAA = anInReader.ReadInt16();
{
System.Int16 rightFlankAA = anInReader.ReadInt16();
Trace.Assert(
rightFlankAA >= 32 && rightFlankAA <= 122,
"PIL ASSERT. Deserialisation of PeptideHitStructure, " +
"rightFlankAA is out of range: " + rightFlankAA + ".");
toReturn.rightFlankAA = rightFlankAA;
}
toReturn.startPositionInProtein = anInReader.ReadInt32();
toReturn.endPositionInProtein = anInReader.ReadInt32();
//List
{
toReturn.LCpeakProfiles = null;
int itemsOuter = anInReader.ReadOptimizedInt32();
if (itemsOuter > 0)
{
//Space for a number of lists.
toReturn.LCpeakProfiles =
new List<List<signalStructure>>(itemsOuter);
int lastIndex1 = itemsOuter - 1;
int j = 0;
for (j = 0; j <= lastIndex1; j++)
{
int itemsInner = anInReader.ReadOptimizedInt32();
List<signalStructure> newList =
new List<signalStructure>(itemsInner);
//toReturn.LCpeakProfiles.Add( _
// massSpectrometryBase.signalStructure.readFromStream( _
// anInReader))
int lastIndex2 = itemsInner - 1;
int n = 0;
for (n = 0; n <= lastIndex2; n++)
{
newList.Add(
signalStructure.readFromStream2(
ref anInReader, aMBfileVersion));
}
toReturn.LCpeakProfiles.Add(newList);
}
} //if any items.
} //Block. Reading list.
toReturn.LCMaxCycle = anInReader.ReadInt32();
Trace.Assert(
toReturn.LCMaxCycle > -10000 && toReturn.LCMaxCycle < 800000,
"PIL ASSERT. " +
"LCMaxCycle out of range: " + toReturn.LCMaxCycle + ".");
toReturn.LCMaxIndex = anInReader.ReadInt32();
toReturn.usedForQuantitation_maxWTintensity = anInReader.ReadDouble();
toReturn.usedForQuantitation_maxWTintensity_LCtime =
anInReader.ReadDouble();
toReturn.retentionTimeCentroid_secs = anInReader.ReadDouble();
toReturn.estimatedLCPeakWidth = anInReader.ReadDouble();
toReturn.LCpeakDetectionTimeCentroidSeconds = anInReader.ReadDouble();
toReturn.LCMaxTimeSeconds = anInReader.ReadDouble();
toReturn.LCMaxIntensity2 = anInReader.ReadDouble();
//List
{
toReturn.LCprofilesProperties = null;
int items = anInReader.ReadOptimizedInt32();
if (items > 0)
{
toReturn.LCprofilesProperties =
new List<LCprofilesPropertiesStructure>(items);
int lastIndex = items - 1;
int j = 0;
for (j = 0; j <= lastIndex; j++)
{
toReturn.LCprofilesProperties.Add(
LCprofilesPropertiesStructure.readFromStream2(
ref anInReader, aMBfileVersion));
}
}
} //Block. Reading list.
//Changed PM_PEPTIDEFIELD_USEDFORRECALIBRATION 2008-11-25
if (aMBfileVersion >= AppConstants.SAVEDFILEVERSION_MB4)
{
//MB4 or later.
toReturn.usedForRecalibration = anInReader.ReadBoolean();
}
return toReturn;
} //readFromStream2(). For PeptideHitStructure.
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-19
//****************************************************************************
//* For PeptideHitStructure. *
//****************************************************************************
public void addToStream2(
ref SerializationWriter anInOutWriter, int aMBfileVersion)
{
//aVersion: e.g. 300 for MB3, 400 for MB4.
//SERMARK12. A marker. Keep it.
//Changed PM_ELIMINATE_PEPTIDEFIELD 2008-11-25
//anInOutWriter.Write(version2);
if (aMBfileVersion < AppConstants.SAVEDFILEVERSION_MB4)
{
anInOutWriter.Write(100);
}
anInOutWriter.Write(queryNumber);
anInOutWriter.Write(retentionTimeStartMinutes);
anInOutWriter.Write(retentionTimeEndMinutes);
anInOutWriter.Write(MSMSretentionTimeMinutes);
anInOutWriter.Write(retTMax);
anInOutWriter.Write(period2);
anInOutWriter.Write(experimentNumber);
anInOutWriter.Write(cycle);
anInOutWriter.Write(spectrumNumber);
anInOutWriter.Write(measuredMCR);
anInOutWriter.Write(measuredMass);
anInOutWriter.Write(charge);
anInOutWriter.Write(MascotCalculatedMass);
anInOutWriter.Write(calculatedMassNoMods);
anInOutWriter.Write(uncalibratedMSCentroidMass);
anInOutWriter.Write(calibratedMSCentroidMass);
anInOutWriter.Write(calibratedMeasuredMCR);
anInOutWriter.Write(calibratedMeasuredMass);
anInOutWriter.Write(neutralMScentroidForLCMax);
anInOutWriter.Write(relativeErrorForPeptideMass_PPM);
anInOutWriter.Write(missedCleavages);
anInOutWriter.Write(someAAsMatchingTheFilter);
//Needed? Recreate
// from other fields?
anInOutWriter.Write(deltaMass);
anInOutWriter.Write(rank);
anInOutWriter.Write(AASequence);
anInOutWriter.Write(AASequencePlusMods);
anInOutWriter.Write(seq1);
anInOutWriter.Write(seq2);
Trace.Assert(
MascotScore2 > 0.5 && MascotScore2 < 999.99,
"PIL ASSERT. Serialise, MascotScore out of range: " +
MascotScore2 + ".");
if (aMBfileVersion >= AppConstants.SAVEDFILEVERSION_MB4)
{
anInOutWriter.Write(MascotScore2); //As double...
}
else
{
//Old MB3 format. We provide backward compatility, even writing in
//the old format...
int MascotScore_AsInteger = (int)MascotScore2;
anInOutWriter.Write(MascotScore_AsInteger);
}
anInOutWriter.Write((int)MascotColour); //As we read as ReadInt32(), see
// above.
anInOutWriter.Write(checkboxChecked);
anInOutWriter.Write(MascotScorePlusMS3Score);
Trace.Assert(
MascotScorePlusMS3Score > 0.5 && MascotScorePlusMS3Score < 999.99,
"PIL ASSERT. Serialise, MascotScorePlusMS3Score out of range: " +
MascotScorePlusMS3Score + ".");
anInOutWriter.Write(MS3precursorStr);
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-19. Loop on the
//client side.
//'anInOutWriter.Write(modHits2) 'List(Of modificationCountStructure)
//anInOutWriter.WriteObject(modHits2) 'List(Of modificationCountStructure)
{
if (modHits2 != null)
{
int items = modHits2.Count;
//This is our own encoding.
anInOutWriter.WriteOptimized(items);
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//massSpectrometryBase.modificationCountStruct item =
// default(massSpectrometryBase.modificationCountStruct);
foreach (massSpectrometryBase.modificationCountStruct item
in modHits2)
{
item.addToStream2(ref anInOutWriter, aMBfileVersion);
}
}
else
{
int items = 0;
//Encode nothing as zero length
anInOutWriter.WriteOptimized(items);
}
} //Block. Writing list.
anInOutWriter.Write(scoreInParens);
anInOutWriter.Write(counted);
anInOutWriter.Write(firstScore);
anInOutWriter.Write(firstDeltaScore);
anInOutWriter.Write(secSequence);
anInOutWriter.Write(secScore);
anInOutWriter.Write(seq1Unique);
anInOutWriter.Write(seq2Unique);
anInOutWriter.Write(verified);
anInOutWriter.Write(useForQuantitation);
anInOutWriter.Write(goodMSpeak);
//Needed? Set and displayed
// during quantitation?
anInOutWriter.Write(badPeakReason);
//Needed? Set and displayed
// during quantitation?
anInOutWriter.Write(comment);
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-19. Loop on the
//client side.
//'Write fails for Nothing.
//'anInOutWriter.Write(spectra) 'List(Of SpecQuantStructure)
//anInOutWriter.WriteObject(spectra) 'List(Of SpecQuantStructure)
{
if (spectra != null)
{
int items = spectra.Count;
//This is our own encoding.
anInOutWriter.WriteOptimized(items);
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//SpecQuantStructure item = default(SpecQuantStructure);
foreach (SpecQuantStructure item in spectra)
{
item.addToStream2(ref anInOutWriter, aMBfileVersion);
}
}
else
{
int items = 0;
//Encode nothing as zero length
anInOutWriter.WriteOptimized(items);
}
} //Block. Writing list.
anInOutWriter.Write(savedStartCycle);
anInOutWriter.Write(savedEndCycle);
anInOutWriter.Write(importedAcc);
anInOutWriter.Write(rawFileID);
anInOutWriter.Write(rawFileFullPath);
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-19. Loop on the
//client side.
//anInOutWriter.Write(quantValues2) 'List(Of derivedQuantInfoStructure)
{
if (quantValues2 != null)
{
int items = quantValues2.Count;
//This is our own encoding.
anInOutWriter.WriteOptimized(items);
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//derivedQuantInfoStructure item =
// default(derivedQuantInfoStructure);
foreach (derivedQuantInfoStructure item in quantValues2)
{
item.addToStream2(ref anInOutWriter, aMBfileVersion);
}
}
else
{
int items = 0;
//Encode nothing as zero length
anInOutWriter.WriteOptimized(items);
}
} //Block. Writing list.
anInOutWriter.Write(SILACdishIndex);
{
//Changed PM_SAVING_REMOVEDPEPTIDES_BUG 2007-09-07
Trace.Assert(
(uncalibratedSILACmasses2 != null),
"PIL ASSERT. While saving to file: " +
"field uncalibratedSILACmasses2 does not exist...");
//Note: uncalibratedSILACmasses2 is never null. Otherwise
//the read would fail...
//OK to have the library take care of this instead of a loop. It is
//acceptable because it is a list of a fundamental type (double) and
//the .NET serialiser is therefore NOT called.
anInOutWriter.Write(uncalibratedSILACmasses2);
//List(Of Double)
}
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-28
//'Write fails for Nothing.
//'anInOutWriter.Write(PTMs2) 'Now Generics!,
//anInOutWriter.WriteObject(PTMs2) 'Now Generics!,
//' List(Of massSpectrometryBase.onePTMStructure)
{
if (PTMs2 != null)
{
int items = PTMs2.Count;
//This is our own encoding.
anInOutWriter.WriteOptimized(items);
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//massSpectrometryBase.onePTMStructure item =
// default(massSpectrometryBase.onePTMStructure);
foreach (onePTMStructure item in PTMs2)
{
item.addToStream2(ref anInOutWriter, aMBfileVersion);
}
}
else
{
int items = 0;
//Encode nothing as zero length
anInOutWriter.WriteOptimized(items);
}
} //Block. Writing list.
anInOutWriter.Write(precursorIntensity);
anInOutWriter.Write(leftFlankAA);
anInOutWriter.Write(rightFlankAA);
anInOutWriter.Write(startPositionInProtein);
anInOutWriter.Write(endPositionInProtein);
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-20
//'Write fails for Nothing.
//'anInOutWriter.Write(LCpeakProfiles) 'List(Of _
//anInOutWriter.WriteObject(LCpeakProfiles) 'List(Of _
//' List(Of massSpectrometryBase.signalStructure))
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-19. Loop on the
//client side.
{
if (LCpeakProfiles != null)
{
int items1 = LCpeakProfiles.Count;
//This is our own encoding.
anInOutWriter.WriteOptimized(items1);
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//List<massSpectrometryBase.signalStructure> item1 =
// default(List<massSpectrometryBase.signalStructure>);
foreach (
List<signalStructure> item1
in LCpeakProfiles)
{
int items2 = item1.Count;
//This is our own encoding.
anInOutWriter.WriteOptimized(items2);
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//massSpectrometryBase.signalStructure item2 =
// default(massSpectrometryBase.signalStructure);
foreach (
signalStructure item2
in item1)
{
item2.addToStream2(ref anInOutWriter, aMBfileVersion);
}
}
}
else
{
int items = 0;
//Encode nothing as zero length
anInOutWriter.WriteOptimized(items);
}
} //Block. Writing list.
anInOutWriter.Write(LCMaxCycle);
anInOutWriter.Write(LCMaxIndex);
anInOutWriter.Write(usedForQuantitation_maxWTintensity);
anInOutWriter.Write(usedForQuantitation_maxWTintensity_LCtime);
anInOutWriter.Write(retentionTimeCentroid_secs);
anInOutWriter.Write(estimatedLCPeakWidth);
anInOutWriter.Write(LCpeakDetectionTimeCentroidSeconds);
anInOutWriter.Write(LCMaxTimeSeconds);
anInOutWriter.Write(LCMaxIntensity2);
//Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-20. Loop on the
//client side.
//'Write fails for Nothing.
//'anInOutWriter.Write(LCprofilesProperties) 'List(Of
//anInOutWriter.WriteObject(LCprofilesProperties) 'List(Of
//' LCprofilesPropertiesStructure)
{
if (LCprofilesProperties != null)
{
int items = LCprofilesProperties.Count;
//This is our own encoding.
anInOutWriter.WriteOptimized(items);
//Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
//converted. Disable it for now to stay faithful to
//the original.
//LCprofilesPropertiesStructure item =
// default(LCprofilesPropertiesStructure);
foreach (
LCprofilesPropertiesStructure item
in LCprofilesProperties)
{
item.addToStream2(ref anInOutWriter, aMBfileVersion);
}
}
else
{
int items = 0;
//Encode nothing as zero length
anInOutWriter.WriteOptimized(items);
}
} //Block. Writing list.
//Changed PM_PEPTIDEFIELD_USEDFORRECALIBRATION 2008-11-25
if (aMBfileVersion >= AppConstants.SAVEDFILEVERSION_MB4)
{
anInOutWriter.Write(usedForRecalibration);
}
} //addToStream2(). For PeptideHitStructure.
//Changed PM_VS2005 2006-06-15
//Utility function, moved from helper class in clsMolShrStruct.vb.
//****************************************************************************
//* This function was called into existence in order to keep *
//* the compiler happy... This may be expanded later to have only *
//* one place (this function) to invalidate a peptide. *
//* E.g. some fields (value or reference) could be set to values that *
//* eases error detection. *
//****************************************************************************
public static PeptideHitStructure blankPeptide()
{
//Changed PM_BLANK_PEPTIDE_PROBLEMS 2008-10-31. Use default anyway.
// Perhaps later: find which field is not reset.
//
////Changed PM_REFACTOR 2008-10-30. Generated by VB to C#
////converted. Disable it for now to stay faithful to
////the original.
////PeptideHitStructure somePeptide = default(PeptideHitStructure);
//PeptideHitStructure somePeptide;
PeptideHitStructure somePeptide = default(PeptideHitStructure);
somePeptide.badPeakReason = null;
somePeptide.comment = null;
//Changed PM_REFACTOR 2006-10-05
//somePeptide.lowerLCpeakProfile = Nothing
//somePeptide.evenHigherLCpeakProfile = Nothing
//somePeptide.higherLCpeakProfile = Nothing
somePeptide.LCpeakProfiles = null;
somePeptide.importedAcc = null;
somePeptide.modHits2 = null;
somePeptide.MS3precursorStr = null;
somePeptide.PTMs2 = null;
somePeptide.quantValues2 = null;
somePeptide.rawFileFullPath = null;
somePeptide.secSequence = null;
somePeptide.seq1 = null;
somePeptide.seq2 = null;
somePeptide.spectra = null;
somePeptide.AASequence = null;
somePeptide.AASequencePlusMods = null;
//Changed PM_REFACTOR 2006-10-03
somePeptide.uncalibratedSILACmasses2 = null;
//Changed PM_REFACTOR 2006-10-09
somePeptide.LCprofilesProperties = null;
return somePeptide;
} //blankPeptide()
//Changed PM_HIGHESTSCORINGUNIQUELYMODIFIED_BUG 2007-10-05. Moved
// from FindLCpeaks.vb.
//Changed PM_REFACTOR 2003-12-01
//Utility function, moved from helper class in clsMolShrStruct.vb.
//****************************************************************************
//* Purpose: set fields in peptide such that it will not be taken for a *
//* normal peptide. This is short of deleting a peptide *
//* for a protein. *
//****************************************************************************
public static void invalidatePeptide(
ref PeptideHitStructure anInOutPept)
{
//Changed PM_REFACTOR 2004-06-30
anInOutPept.AASequence = peptideConstants.SEQUENCE_BADPEPTIDE;
anInOutPept.calibratedMeasuredMass = 10.0;
anInOutPept.calculatedMassNoMods = 11.0;
anInOutPept.calibratedMeasuredMCR = 12.0;
anInOutPept.MascotCalculatedMass = 13.0;
//Changed PM_SCORE_FOR_ZZZZ_PEPTIDES 2006-03-14. Leave it unchanged.
//anInOutPept.MascotScore = 14
anInOutPept.measuredMass = 15.0;
anInOutPept.measuredMCR = 16.0;
anInOutPept.MSMSretentionTimeMinutes = 0.17;
//Changed PM_PRESELECTEDVALIDATED_CONDITIONS 2004-06-21
anInOutPept.verified = false;
} //invalidatePeptide()
//Changed PM_REFACTOR 2008-10-31. Placed here for now.
//****************************************************************************
//* This function is a transition function used when the new *
//* generalised quantitation modes were introduced. *
//* *
//****************************************************************************
public static double getLowerMCRuncalib(
PeptideHitStructure aPept)
{
double toReturn = 0.0;
if (aPept.quantValues2 == null)
{
Trace.Assert(
false, "Stop!",
"PIL ASSERT. Internal/development assert for stopping execution......");
}
else
{
derivedQuantInfoStructure firstItem = aPept.quantValues2[0];
toReturn = firstItem.MCRuncalib;
}
return toReturn;
} //getLowerMCRuncalib()
} //PeptideHitStructure
Generated by script codePublish.pl at 2009-01-05T15:20:59.