本文整理汇总了C#中ISequence.Select方法的典型用法代码示例。如果您正苦于以下问题:C# ISequence.Select方法的具体用法?C# ISequence.Select怎么用?C# ISequence.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISequence
的用法示例。
在下文中一共展示了ISequence.Select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateParserGeneralTestCases
/// <summary>
/// Validates GenBank Parser for each sequence.
/// which takes sequence list as input.
/// <param name="seq">Original Sequence.</param>
/// <param name="expectedSequence">Expected Sequence.</param>
/// </summary>
private static void ValidateParserGeneralTestCases(ISequence seq,
string expectedSequence)
{
Assert.AreEqual(Utility.GetAlphabet(AlphabetName),
seq.Alphabet);
Assert.AreEqual(SeqId, seq.ID);
ApplicationLog.WriteLine(
"GenBank Parser : Successfully validated the Alphabet, Molecular type, Sequence ID and Display ID");
// test the metadata that is tricky to parse, and will not be tested implicitly by
// testing the formatting
GenBankMetadata metadata =
(GenBankMetadata)seq.Metadata["GenBank"];
if (metadata.Locus.Strand != SequenceStrandType.None)
{
Assert.AreEqual(StrandType, metadata.Locus.Strand.ToString());
}
if (metadata.Locus.Strand != SequenceStrandType.None)
{
Assert.AreEqual(StrandTopology.ToUpper(CultureInfo.CurrentCulture),
metadata.Locus.StrandTopology.ToString().ToUpper(CultureInfo.CurrentCulture));
}
Assert.AreEqual(Div, metadata.Locus.DivisionCode.ToString());
Assert.AreEqual(DateTime.Parse(SequenceDate, null),
metadata.Locus.Date);
if (0 != string.Compare(AlphabetName, "rna",
CultureInfo.CurrentCulture, CompareOptions.IgnoreCase))
{
Assert.AreEqual(Version, metadata.Version.Version.ToString((IFormatProvider)null));
Assert.AreEqual(PrimaryId, metadata.Version.GiNumber);
ApplicationLog.WriteLine(
"GenBank Parser : Successfully validated the StrandType, StrandTopology, Division, Date, Version, PrimaryID Properties");
}
else
{
ApplicationLog.WriteLine(
"GenBank Parser : Successfully validated the StrandType, StrandTopology, Division, Date Properties");
}
// Replace all the empty spaces, paragraphs and new line for validation
string updatedExpSequence =
expectedSequence.Replace("\r", "").Replace("\n", "").Replace(" ", "").ToUpper(CultureInfo.CurrentCulture);
string updatedActualSequence =
new string(seq.Select(a => (char)a).ToArray()).Replace("\r", "").Replace("\n", "").Replace(" ", "").ToUpper(CultureInfo.CurrentCulture);
Assert.AreEqual(updatedExpSequence, updatedActualSequence);
ApplicationLog.WriteLine(
"GenBank Parser : Successfully validated the Sequence");
}
示例2: ComputeFeatures
/// <summary>
/// Computes features for current difference
/// </summary>
/// <param name="sequence1Start">Start index of difference in first sequence</param>
/// <param name="sequence2Start">Start index of difference in second sequence</param>
/// <param name="sequence1End">End index of difference in first sequence</param>
/// <param name="sequence2End">End index of difference in second sequence</param>
/// <param name="sequence1">First sequence</param>
/// <param name="sequence2">Second sequence</param>
/// <param name="sequence1Index">First sequence index</param>
/// <param name="sequence2Index">Second sequence index</param>
/// <returns>List of features</returns>
private static List<CompareFeature> ComputeFeatures(
int sequence1Start,
int sequence2Start,
int sequence1End,
int sequence2End,
ISequence sequence1,
ISequence sequence2,
int sequence1Index,
int sequence2Index)
{
List<CompareFeature> features = new List<CompareFeature>();
string noteStr, replaceStr, conflictStr, sourceStr;
int sequence1Length = sequence1End - sequence1Start + 1;
int sequence2Length = sequence2End - sequence2Start + 1;
if (sequence1Length != 0)
{
if (sequence1Length == 1 && sequence2Length == 1)
{
noteStr = string.Format(
CultureInfo.CurrentCulture,
"SNP in Sequence {0}: {1}",
sequence1Index,
sequence1.ID);
}
else if (sequence2Length == 0)
{
noteStr = string.Format(
CultureInfo.CurrentCulture,
"Insertion of {0} bases in {1} {2}",
sequence1Length,
sequence1Index,
sequence1.ID);
}
else
{
noteStr = string.Format(
CultureInfo.CurrentCulture,
"{0} {1}",
sequence2Index,
sequence2.ID);
}
// Add feature
features.Add(new CompareFeature(sequence1Start, sequence1End, "NOTE", noteStr));
if (sequence2Length > 0)
{
replaceStr = new string(sequence2.Select(a => (char)a).ToArray()).Substring(sequence2Start, sequence2Length);
}
else
{
replaceStr = string.Empty;
}
if (sequence1.Alphabet == Alphabets.Protein)
{
if (replaceStr.Length > 0)
{
string seqstring = new string(sequence1.Select(a => (char)a).ToArray());
sourceStr = seqstring .Substring(sequence1Start, sequence1Length);
conflictStr = string.Format(CultureInfo.CurrentCulture, "{0} -> {1}", sourceStr, replaceStr);
}
else
{
conflictStr = "MISSING";
}
// Add feature
features.Add(new CompareFeature(sequence1Start, sequence1End, "NOTE", conflictStr));
}
else
{
// Add feature
features.Add(new CompareFeature(sequence1Start, sequence1End, "REPLACE", replaceStr));
}
}
return features;
}