本文整理汇总了C#中Sequence.GetComposition方法的典型用法代码示例。如果您正苦于以下问题:C# Sequence.GetComposition方法的具体用法?C# Sequence.GetComposition怎么用?C# Sequence.GetComposition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sequence
的用法示例。
在下文中一共展示了Sequence.GetComposition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindProteinDeltaMass
public void FindProteinDeltaMass()
{
var methodName = MethodBase.GetCurrentMethod().Name;
TestUtils.ShowStarting(methodName);
const string folderPath = @"D:\MassSpecFiles\Glyco\";
if (!Directory.Exists(folderPath))
{
Assert.Ignore(@"Skipping test {0} since folder not found: {1}", methodName, folderPath);
}
var fileSet = new string[]
{
"User_sample_test_02252015", "User_sample_test_MWCO_02262016", "User_sample_test_SEC_F3_03022105",
"User_sample_test_SEC_F1_02272015", "User_sample_test_SEC_F2_02282015"
};
const string fastaFilePath = folderPath + "ID_003836_DA9CC1E4.fasta";
for (var i = 0; i < fileSet.Length; i++)
{
var datasetName = fileSet[i];
var tagFilePath = folderPath + datasetName + ".seqtag";
//var outputFilePath = folderPath + datasetName + ".matchedtag";
var outputFilePath = folderPath + datasetName + ".dmass";
var fastaDb = new FastaDatabase(fastaFilePath);
var searchableDb = new SearchableDatabase(fastaDb);
using (var writer = new StreamWriter(outputFilePath))
{
var isHeader = true;
var nReadSeqTag = 0;
Console.WriteLine(@"Reading {0} file", tagFilePath);
var nColumn = 0;
foreach (var line in File.ReadAllLines(tagFilePath))
{
if (isHeader)
{
isHeader = false;
nColumn = line.Split('\t').Length;
writer.WriteLine(line + "\t" + "Protein" + "\t" + "DetectedFlankingMass" + "\t" + "ExpectedFlankingMass" + "\t" + "DeltaMass");
continue;
}
var token = line.Split('\t');
if (token.Length != nColumn) continue;
var tag = token[1];
//var scan = Convert.ToInt32(token[0]);
if (tag.Length < 6) continue;
var nTerminal = token[2].Equals("1");
var detectedFlankingMass = Double.Parse(token[3]);
if (!nTerminal) detectedFlankingMass -= Composition.H2O.Mass;
nReadSeqTag++;
var matchedProteins =
searchableDb.FindAllMatchedSequenceIndices(tag)
.Select(index => fastaDb.GetProteinName(index))
.Distinct().ToArray();
if (matchedProteins.Length < 1) continue;
foreach (var protName in matchedProteins)
{
var seqStr = fastaDb.GetProteinSequence(protName);
var oriSeq = new Sequence(seqStr, AminoAcidSet.GetStandardAminoAcidSet());
var startIdx = 0;
while (true)
{
var idx = seqStr.IndexOf(tag, startIdx);
if (idx < 0) break; //no matching
//var nClv = (nTerminal) ? idx : seqStr.Length - idx - tag.Length;
var nClv = (nTerminal) ? 2 : 1;
for (var j = 0; j < nClv; j++)
{
var flankComposition = (nTerminal)
? oriSeq.GetComposition(j, idx)
: oriSeq.GetComposition(idx + tag.Length, oriSeq.Count - j);
var massDiff = (detectedFlankingMass - flankComposition.Mass);
if (massDiff > -500 && massDiff < 2000)
{
//writer.WriteLine(massDiff);
writer.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", line, protName, detectedFlankingMass, flankComposition.Mass, massDiff);
}
if (massDiff > 2000) break;
}
startIdx = idx + tag.Length;
}
}
//.........这里部分代码省略.........
示例2: TestIonTypeFactory
public void TestIonTypeFactory()
{
var methodName = MethodBase.GetCurrentMethod().Name;
ShowStarting(methodName);
const string sequenceStr = "PEPTIDE";
var aminoAcidSet = new AminoAcidSet();
var sequence = new Sequence(sequenceStr, aminoAcidSet);
var compositionOfFirstPrefix = sequence.GetComposition(0, 2);
Console.WriteLine("{0}\t{1}", compositionOfFirstPrefix, compositionOfFirstPrefix.Mass);
var ionTypeFactory = new IonTypeFactory(new[] { BaseIonType.B, BaseIonType.Y }, new[] { NeutralLoss.NoLoss }, 10);
var bIon = ionTypeFactory.GetIonType("b");
var yIon = ionTypeFactory.GetIonType("y2");
Console.WriteLine("{0}\t{1}\t{2}", bIon, bIon.OffsetComposition, bIon.OffsetComposition.Mass);
Console.WriteLine("{0}\t{1}\t{2}", yIon, yIon.OffsetComposition, yIon.OffsetComposition.Mass);
// Compute mass of y2 = AveragineMass(DE) + OffsetY
var compositionOfSecondSuffix = sequence.GetComposition(sequenceStr.Length - 2, sequenceStr.Length);
var y2Ion = yIon.GetIon(compositionOfSecondSuffix);
Console.WriteLine("m/z of y++: {0}", y2Ion.GetMonoIsotopicMz());
}