/****************************************************************************
* 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: class for representing a petide with associated *
* operations/data: composition, modifications, *
* theoretical isotope pattern, fragment ion series, *
* *
* Usually the underlying representation is by composition and is retained *
* *
* This class has knowlegde of elemental composition of amino acids. Is this the right place? *
* *
* *
****************************************************************************/
/****************************************************************************
* 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: PILpeptide.cs *
* TYPE: CSHARP *
* *
* CREATED: PM 2008-01-25 Vrs 1.0. *
* UPDATED: PM 2008-xx-xx *
* *
* *
* *
****************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
/****************************************************************************
* <placeholder for header> *
****************************************************************************/
namespace massSpectrometryBase
{
/****************************************************************************
* <placeholder for header> *
****************************************************************************/
public class PILpeptide
{
private string mSequence;
private PILmolecule mRep;
private PILperiodicTable mPeriTable;
//Perhaps later: char or Int16
//private Dictionary<char, elementalCompositionStructure> mAAcomposition;
private Dictionary<char, PILmolecule> mAAcomposition;
//We lazy instantiate the amino acid table and we only add those that are needed.
//How about a static amino acid table?
/****************************************************************************
* <placeholder for header> *
****************************************************************************/
public PILpeptide(string aSequence)
{
mPeriTable = null; //Lazy instantiation.
this.newSequence(aSequence);
} //Constructor.
/****************************************************************************
* <placeholder for header> *
****************************************************************************/
public void newSequence(string aSequence)
{
mSequence = aSequence;
mRep = null; //Lazy instantiation.
} //newSequence.
/****************************************************************************
* <placeholder for header> *
****************************************************************************/
public void getResidueComposition (
out int aCarbons ,
out int aHydrogens ,
out int aNitrogens ,
out int aOxygens ,
out int aSulphors ,
out int aElectrons ,
out int aPhosphors
)
{
//Use class PILmolecule for building up peptide molecule.
if (mPeriTable == null) //Lazy instantiation.
{
mPeriTable = new PILperiodicTable(-7);
}
if (mRep == null) //Lazy instantiation.
{
mRep = new PILmolecule(ref mPeriTable);
//Perhaps a class to cache instances of PILmolecule for
//each amino acids, registered under some key (e.g.
//key for unmodified, SILAC, some set of variable modification).
//For now: one table for each instance of this
//class. Later: zero diffence for most and a static
//table for non-modified amino acids (SILAC or otherwise).
this.buildAAtable();
char[] charStr = mSequence.ToCharArray();
int len = mSequence.Length;
for (int i = 0; i < len; i++)
{
char ch = charStr[ i];
PILmolecule someMol = mAAcomposition[ch];
//Return an instance of PILmolecule instead?
mRep.addMolecule(someMol);
} //for
}
elementalCompositionStructure comb = mRep.getComposition();
aCarbons = comb.carbons;
aHydrogens = comb.hydrogens;
aNitrogens = comb.nitrogens;
aOxygens = comb.oxygens;
aSulphors = comb.sulphors;
aElectrons = comb.electrons;
aPhosphors = comb.phosphors;
} //getResidueComposition.
/****************************************************************************
* <placeholder for header> *
****************************************************************************/
private void addComp(
string anAA,
int aCarbons,
int aHydrogens,
int aNitrogens,
int aOxygens,
int aSulphors
)
{
char[] asChars = anAA.ToCharArray();
char AAcode = asChars[0];
//elementalCompositionStructure someItem;
//someItem.carbons = aCarbons ;
//someItem.hydrogens = aHydrogens;
//someItem.nitrogens = aNitrogens;
//someItem.oxygens = aOxygens ;
//someItem.sulphors = aSulphors ;
//someItem.electrons = aElectrons;
//someItem.phosphors = aPhosphors;
PILmolecule someMol = new PILmolecule(
anAA,
aCarbons ,
aHydrogens,
aNitrogens,
aOxygens ,
aSulphors ,
0,
0,
ref mPeriTable
);
mAAcomposition.Add(AAcode, someMol);
} //addComp
/****************************************************************************
* <placeholder for header> *
****************************************************************************/
private void buildAAtable()
{
mAAcomposition = new Dictionary<char, PILmolecule>();
addComp("A", 3, 5, 1, 1, 0);
addComp("B", 0, 0, 0, 0, 0);
addComp("C", 3, 5, 1, 1, 1);
addComp("D", 4, 5, 1, 3, 0);
addComp("E", 5, 7, 1, 3, 0);
addComp("F", 9, 9, 1, 1, 0);
addComp("G", 2, 3, 1, 1, 0);
addComp("H", 6, 7, 3, 1, 0);
addComp("I", 6, 11, 1, 1, 0);
addComp("J", 0, 0, 0, 0, 0);
addComp("K", 6, 12, 2, 1, 0);
addComp("L", 6, 11, 1, 1, 0);
addComp("M", 5, 9, 1, 1, 1);
addComp("N", 4, 6, 2, 2, 0);
addComp("O", 0, 0, 0, 0, 0);
addComp("P", 5, 7, 1, 1, 0);
addComp("Q", 5, 8, 2, 2, 0);
addComp("R", 6, 12, 4, 1, 0);
addComp("S", 3, 5, 1, 2, 0);
addComp("T", 4, 7, 1, 2, 0);
addComp("U", 0, 0, 0, 0, 0);
addComp("V", 5, 9, 1, 1, 0);
addComp("W", 11, 10, 2, 1, 0);
addComp("X", 0, 0, 0, 0, 0);
addComp("Y", 9, 9, 1, 2, 0);
addComp("Z", 0, 0, 0, 0, 0);
} //buildAAtable
//Changed PM_REFACTOR 2008-05-09. Moved to here from file MMaaSequence.vb.
////Changed PM_DTASC_COMPILE 2008-02-11. Moved to here
//// from clsMolShrStruct.vb. To remove difficult dependencies.
////'Changed PM_REFACTOR 2007-09-18
////'Changed PM_REFACTOR 2007-09-18. Moved to here from PTMscorer.vb.
//// ''Changed PM_BROADER_PTMSCORE 2007-03-23
//****************************************************************************
//* Purpose: computes actual peptide positions based on the *
//* specification for which part of a peptide a modification *
//* is active, e.g. -1,-1 for a C-terminal modification. *
//****************************************************************************
public static void findPositionsEtc(
int aInStartPos,
int anInEndPos,
int anInPeptideLength2,
out bool anOutAllPositions,
out int anOutStartPositionZeroBased,
out int anOutEndPositionZeroBased,
out int anOutMaxMods)
{
//Changed PM_REFACTOR 2007-09-18
//'Changed PM_TERMMOD 2007-09-10
// ''Default now: all positions.
// ''Later: from new fields in quantModificationStructure/ anInSomeMod.
//'Dim startPosition3 As Integer = 1
//'Dim endPosition3 As Integer = -1 'Negative: from C-terminal.
//Dim startPosition2 As Integer = anInSomeMod.startPosition
//Dim endPosition2 As Integer = anInSomeMod.endPosition 'Negative: from C-terminal.
int startPosition2 = aInStartPos;
int endPosition2 = anInEndPos;
int lastPepIndex = anInPeptideLength2 - 1;
//For now.
//Later: from new field in quantModificationStructure/ anInSomeMod.
anOutMaxMods = 1;
anOutAllPositions =
(startPosition2 == 1) && (endPosition2 == -1);
if (!anOutAllPositions)
{
if (startPosition2 < 0)
{
startPosition2 = Math.Abs(startPosition2);
startPosition2 -= 1;
//To zero based.
startPosition2 = anInPeptideLength2 - startPosition2;
}
else
{
startPosition2 -= 1;
//To zero based.
}
if (endPosition2 < 0)
{
endPosition2 = Math.Abs(endPosition2);
endPosition2 = anInPeptideLength2 - endPosition2;
}
else
{
endPosition2 -= 1;
//To zero based.
}
}
else
{
startPosition2 = 0;
endPosition2 = lastPepIndex;
}
if (endPosition2 < startPosition2)
{
int peter2 = 2;
//Empty subset. What to do?
}
//Changed PM_TERMMOD 2007-09-10
if (startPosition2 < 0)
{
//This can happen for a small
// peptide with a specification from the C-terminal.
startPosition2 = 0;
}
if (startPosition2 > lastPepIndex)
{
//This can happen for a small
// peptide with a start specification from the N-terminal, longer than
// the peptide.
startPosition2 = lastPepIndex;
//Avoid error. But is this
// the proper way?
//In this case the subset is empty. How do we handle that??
}
if (endPosition2 < 0)
{
//This can happen for a small
// peptide with an end specification from the C-terminal.
endPosition2 = 0;
//Avoid error. But is this
// the proper way?
//In this case the subset is empty. How do we handle that??
}
if (endPosition2 > lastPepIndex)
{
//This can happen for a small
// peptide with a specification from the N-terminal, longer than
// the peptide.
endPosition2 = lastPepIndex;
//Avoid error. But is this
// the proper way?
//In this case the subset is empty. How do we handle that??
}
anOutStartPositionZeroBased = startPosition2;
anOutEndPositionZeroBased = endPosition2;
} //findPositionsEtc
} //class PILpeptide
} //namespace massSpectrometryBase
Generated by script codePublish.pl at 2008-09-23T11:59:18.