本文整理汇总了C#中Bio.IO.FastA.FastAParser.Parse方法的典型用法代码示例。如果您正苦于以下问题:C# FastAParser.Parse方法的具体用法?C# FastAParser.Parse怎么用?C# FastAParser.Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.IO.FastA.FastAParser
的用法示例。
在下文中一共展示了FastAParser.Parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestFastaFor186972391
public void TestFastaFor186972391()
{
string expectedSequence =
"IFYEPVEILGYDNKSSLVLVKRLITRMYQQKSLISSLNDSNQNEFWGHKNSFSSHFSSQMVSEGFGVILE" +
"IPFSSRLVSSLEEKRIPKSQNLRSIHSIFPFLEDKLSHLNYVSDLLIPHPIHLEILVQILQCWIKDVPSL" +
"HLLRLFFHEYHNLNSLITLNKSIYVFSKRKKRFFGFLHNSYVYECEYLFLFIRKKSSYLRSISSGVFLER" +
"THFYGKIKYLLVVCCNSFQRILWFLKDTFIHYVRYQGKAIMASKGTLILMKKWKFHLVNFWQSYFHFWFQ" +
"PYRINIKQLPNYSFSFLGYFSSVRKNPLVVRNQMLENSFLINTLTQKLDTIVPAISLIGSLSKAQFCTVL" +
"GHPISKPIWTDLSDSDILDRFCRICRNLCRYHSGSSKKQVLYRIKYIFRLSCARTLARKHKSTVRTFMRR" +
"LGSGFLEEFFLEEE";
// parse
string filepath = System.IO.Path.Combine("TestUtils","Fasta", "186972391.fasta");
Assert.IsTrue(File.Exists(filepath));
FastAParser parser = new FastAParser { Alphabet = Alphabets.Protein };
foreach (ISequence seq in parser.Parse(filepath))
{
Assert.IsNotNull(seq);
Assert.AreEqual(434, seq.Count);
string actual = seq.Aggregate("", (current, b) => current + (char)b);
Assert.AreEqual(expectedSequence, actual);
Assert.AreEqual(seq.Alphabet.Name, "Protein");
Assert.AreEqual("gi|186972391|gb|ACC99454.1| maturase K [Scaphosepalum rapax]", seq.ID);
}
}
示例2: MismatchTest
public MismatchTest()
{
//
// TODO: Add constructor logic here
//
FastAParser Reference = new FastAParser(@"Reference.txt");
Mismatch_Test = new Mismatcher(Reference.Parse().First());
}
示例3: ValidateMUMmerAlignGeneralTestCases
private void ValidateMUMmerAlignGeneralTestCases(string nodeName)
{
// Gets the reference sequence from the configuration file
string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
Assert.IsNotNull(filePath);
ApplicationLog.WriteLine(string.Format(null, "MUMmer P2 : Successfully validated the File Path '{0}'.", filePath));
var fastaParserObj = new FastAParser();
IEnumerable<ISequence> referenceSeqs = fastaParserObj.Parse(filePath);
ISequence referenceSeq = referenceSeqs.ElementAt(0);
// Gets the reference sequence from the configuration file
string queryFilePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SearchSequenceFilePathNode);
Assert.IsNotNull(queryFilePath);
ApplicationLog.WriteLine(string.Format(null, "MUMmer P2 : Successfully validated the Search File Path '{0}'.", queryFilePath));
var fastaParserObj1 = new FastAParser();
IEnumerable<ISequence> querySeqs = fastaParserObj1.Parse(queryFilePath);
string mumLength = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode);
var mum = new MUMmerAligner
{
LengthOfMUM = long.Parse(mumLength, null),
StoreMUMs = true,
PairWiseAlgorithm = new NeedlemanWunschAligner(),
GapOpenCost = int.Parse(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.GapOpenCostNode), null)
};
IList<IPairwiseSequenceAlignment> align = mum.Align(referenceSeq, querySeqs);
// Validate FinalMUMs and MUMs Properties.
Assert.IsNotNull(mum.MUMs);
string expectedScore = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ScoreNodeName);
string[] expectedSequences = utilityObj.xmlUtil.GetTextValues(nodeName, Constants.ExpectedSequencesNode);
IList<IPairwiseSequenceAlignment> expectedOutput = new List<IPairwiseSequenceAlignment>();
IPairwiseSequenceAlignment seqAlign = new PairwiseSequenceAlignment();
var alignedSeq = new PairwiseAlignedSequence
{
FirstSequence = new Sequence(referenceSeq.Alphabet, expectedSequences[0]),
SecondSequence = new Sequence(referenceSeq.Alphabet, expectedSequences[1]),
Score = Convert.ToInt32(expectedScore, null),
FirstOffset = Int32.MinValue,
SecondOffset = Int32.MinValue,
};
seqAlign.PairwiseAlignedSequences.Add(alignedSeq);
expectedOutput.Add(seqAlign);
Assert.IsTrue(AlignmentHelpers.CompareAlignment(align, expectedOutput));
ApplicationLog.WriteLine("MUMmer P2 : Successfully validated the aligned sequences.");
}
示例4: TestMethod1
public void TestMethod1()
{
FastAParser Query = new FastAParser(@"Query.txt");
var Mismatches_query = Mismatch_Test.GetMismatches(Query.Parse().First());
Assert.AreEqual(2,Mismatches_query.Count());
var first = Mismatches_query.First();
Assert.AreEqual(0, first.QuerySequenceOffset);
var last = Mismatches_query.Last();
Assert.AreEqual(179, last.QuerySequenceOffset);
}
示例5: Execute
/// <summary>
/// Executes the cross-link search for LC-IMS-TOF data.
/// </summary>
/// <param name="settings">Settings object to control parameters for cross-linking.</param>
/// <param name="fastAFile">The FileInfo object for the FASTA file containg all protein sequences you want to search.</param>
/// <param name="featureFile">The FileInfo object for the LC-IMS-MS features file, created by the LC-IMS-MS Feature Finder. (email [email protected] for more info)</param>
/// <param name="peaksFile">The FileInfo object for the Isotopic Peaks file, created by DeconTools. (email [email protected] for more info)</param>
/// <returns>An enumerable of CrossLinkResult objects.</returns>
public static IList<CrossLinkResult> Execute(CrossLinkSettings settings, FileInfo fastAFile, FileInfo featureFile, FileInfo peaksFile)
{
IEnumerable<ISequence> sequenceEnumerable;
List<LcImsMsFeature> featureList;
List<IsotopicPeak> peakEnumerable;
Console.WriteLine();
try
{
// Read in FASTA File
var fastAParser = new FastAParser(fastAFile.FullName);
sequenceEnumerable = fastAParser.Parse();
Console.WriteLine("FASTA file: " + GetRelativePath(fastAFile.FullName));
}
catch (Exception ex)
{
Console.WriteLine("Error reading the FASTA file: " + ex.Message);
throw;
}
try
{
// Read in LC-IMS-MS Features
featureList = LcImsMsFeatureReader.ReadFile(featureFile);
Console.WriteLine("Features file: " + GetRelativePath(featureFile.FullName));
}
catch (Exception ex)
{
Console.WriteLine("Error reading the LCMSFeatures file: " + ex.Message);
throw;
}
try
{
// Read in Isotopic Peaks (not Isotopic Profile)
peakEnumerable = IsotopicPeakReader.ReadFile(peaksFile);
Console.WriteLine("Peaks file: " + GetRelativePath(peaksFile.FullName));
}
catch (Exception ex)
{
Console.WriteLine("Error reading the Isotopic Peaks file: " + ex.Message);
throw;
}
// Now call the executor that expects the opbjects instead of the file locations
return Execute(settings, sequenceEnumerable, featureList, peakEnumerable);
}
示例6: TestFastaWhenParsingOneOfMany
public void TestFastaWhenParsingOneOfMany()
{
// parse
string filepath = System.IO.Path.Combine("TestUtils","Fasta","5_sequences.fasta");
FastAParser parser = new FastAParser { Alphabet = Alphabets.Protein };
using (parser.Open(filepath))
{
int[] sequenceCountArray = { 27, 29, 30, 35, 32 };
int i = 0;
foreach (ISequence seq in parser.Parse())
{
Assert.IsNotNull(seq);
Assert.AreEqual(seq.Count, sequenceCountArray[i]);
i++;
}
}
}
示例7: ValidateSequenceToString
public void ValidateSequenceToString()
{
ISequence seqSmall = new Sequence(Alphabets.DNA, "ATCG");
string seqLargeString = this.utilityObj.xmlUtil.GetTextValue(Constants.ToStringNodeName,
Constants.seqLargeStringNode);
ISequence seqLarge = new Sequence(Alphabets.DNA, seqLargeString);
string ActualSmallString = seqSmall.ToString();
string ActualLargeString = seqLarge.ToString();
string ExpectedSmallString = "ATCG";
string seqLargeExpected = this.utilityObj.xmlUtil.GetTextValue(Constants.ToStringNodeName,
Constants.seqLargeExpected2Node);
string expectedLargeString = string.Format(CultureInfo.CurrentCulture,
seqLargeExpected,
(seqLarge.Count - Helper.AlphabetsToShowInToString));
Assert.AreEqual(ExpectedSmallString, ActualSmallString);
Assert.AreEqual(expectedLargeString, ActualLargeString);
//check with blank sequence
var seqBlank = new Sequence(Alphabets.DNA, "");
string blankString = seqBlank.ToString();
Assert.AreEqual(string.Empty, blankString);
// Gets the expected sequence from the Xml
string filePath = this.utilityObj.xmlUtil.GetTextValue(Constants.SimpleFastaNodeName,
Constants.FilePathNode);
//read sequence from file
var parser = new FastAParser { Alphabet = Alphabets.Protein };
List<ISequence> seqsList = parser.Parse(filePath).ToList();
var seqString = new string(seqsList[0].Select(a => (char) a).ToArray());
if (seqString.Length > Helper.AlphabetsToShowInToString)
{
//check if the whole sequence string contains the string retrieved from ToString
Assert.IsTrue(seqString.Contains(seqsList[0].ToString().Substring(0, Helper.AlphabetsToShowInToString)));
Assert.IsTrue(seqsList[0].ToString().Contains("... +["));
}
else
{
Assert.AreEqual(seqString, seqsList[0].ToString());
}
}
示例8: ValidateSAMFormatter
/// <summary>
/// General method to validate SAM Formatter method.
/// </summary>
/// <param name="nodeName">xml node name</param>
/// <param name="parseTypes">enum type to execute different overload</param>
void ValidateSAMFormatter(string nodeName)
{
// Gets the expected sequence from the Xml
string filePath = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.FilePathNode);
string expectedSequenceFile = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.ExpectedSequence);
SAMParser parser = new SAMParser();
{
SequenceAlignmentMap alignments = (SequenceAlignmentMap) parser.ParseOne(filePath);
SAMFormatter formatter = new SAMFormatter();
using (var writer =
File.Create(Constants.SAMTempFileName))
{
formatter.Format(writer, alignments);
}
alignments = parser.ParseOne<SequenceAlignmentMap>(Constants.SAMTempFileName);
// Get expected sequences
FastAParser parserObj = new FastAParser();
{
IEnumerable<ISequence> expectedSequences =
parserObj.Parse(expectedSequenceFile);
IList<ISequence> expectedSequencesList = expectedSequences.ToList();
// Validate parsed output with expected output
for (int index = 0;
index < alignments.QuerySequences.Count;
index++)
{
for (int count = 0;
count < alignments.QuerySequences[index].Sequences.Count;
count++)
{
Assert.AreEqual(
new string(expectedSequencesList[index].Select(a => (char)a).ToArray()),
new string(alignments.QuerySequences[index].Sequences[count].Select(a => (char)a).ToArray()));
}
}
}
}
}
示例9: ValidateSAMParser
/// <summary>
/// General method to validate SAM parser method.
/// </summary>
/// <param name="nodeName">xml node name</param>
/// <param name="parseTypes">enum type to execute different overload</param>
void ValidateSAMParser(string nodeName)
{
// Gets the expected sequence from the Xml
string filePath = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.FilePathNode);
string expectedSequenceFile = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.ExpectedSequence);
var parser = new SAMParser();
{
SequenceAlignmentMap alignments = null;
// Parse SAM File
using (var reader = File.OpenRead(filePath))
{
alignments = parser.Parse(reader);
}
// Get expected sequences
FastAParser parserObj = new FastAParser();
{
IEnumerable<ISequence> expectedSequences = parserObj.Parse(expectedSequenceFile);
IList<ISequence> expectedSequencesList = expectedSequences.ToList();
// Validate parsed output with expected output
for (int index = 0;
index < alignments.QuerySequences.Count;
index++)
{
for (int count = 0;
count < alignments.QuerySequences[index].Sequences.Count;
count++)
{
Assert.AreEqual(new string(expectedSequencesList[index].Select(a => (char)a).ToArray()),
new string(alignments.QuerySequences[index].Sequences[count].Select(a => (char)a).ToArray()));
}
}
}
}
}
示例10: GetReads
/// <summary>
/// Method to get the reads from file/xml.
/// </summary>
/// <param name="nodeName">Parent node in Xml</param>
/// <returns></returns>
public List<ISequence> GetReads(string nodeName)
{
List<ISequence> readSeqList = new List<ISequence>();
// Gets the reads from the FastA file
string readFilePath = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.FilePathNode2);
Assert.IsNotNull(readFilePath);
ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
"Comparative P1 : Successfully validated the File Path '{0}'.", readFilePath));
using (FastAParser queryParser = new FastAParser(readFilePath))
{
IEnumerable<ISequence> querySeqList = queryParser.Parse();
foreach (ISequence seq in querySeqList)
{
readSeqList.Add(seq);
}
}
return readSeqList;
}
示例11: ValidateComparativeAssembleMethod
/// <summary>
/// Validates Assemble method .Step 1-5.
/// </summary>
/// <param name="nodeName">Parent Node name in Xml</param>
/// <param name="isFilePath">Sequence location.</param>
public void ValidateComparativeAssembleMethod(string nodeName, bool isEcOli)
{
ComparativeGenomeAssembler assemble = new ComparativeGenomeAssembler();
List<ISequence> referenceSeqList = new List<ISequence>();
string expectedSequence = null;
string LengthOfMUM = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.MUMLengthNode);
string kmerLength = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.KmerLengthNode);
string fixedSeparation = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.FixedSeparationNode);
string minimumScore = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.MinimumScoreNode);
string separationFactor = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.SeparationFactorNode);
string maximumSeparation = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.MaximumSeparationNode);
string breakLength = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.BreakLengthNode);
// Gets the reference sequence from the FastA file
string filePath = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.FilePathNode1);
Assert.IsNotNull(filePath);
ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
"Comparative P1 : Successfully validated the File Path '{0}'.", filePath));
using (FastAParser parser = new FastAParser(filePath))
{
IEnumerable<ISequence> referenceList = parser.Parse();
foreach (ISequence seq in referenceList)
{
referenceSeqList.Add(seq);
}
}
//Get the reads from configurtion file .
string readFilePath = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.FilePathNode2);
assemble.LengthOfMum = int.Parse(LengthOfMUM, CultureInfo.InvariantCulture);
assemble.KmerLength = int.Parse(kmerLength, CultureInfo.InvariantCulture);
assemble.FixedSeparation = int.Parse(fixedSeparation, CultureInfo.InvariantCulture);
assemble.MinimumScore = int.Parse(minimumScore, CultureInfo.InvariantCulture);
assemble.SeparationFactor = float.Parse(separationFactor, CultureInfo.InvariantCulture);
assemble.MaximumSeparation = int.Parse(maximumSeparation, CultureInfo.InvariantCulture);
assemble.BreakLength = int.Parse(breakLength, CultureInfo.InvariantCulture);
using (FastASequencePositionParser queryparser = new FastASequencePositionParser(readFilePath))
{
IEnumerable<ISequence> outputAssemble = assemble.Assemble(referenceSeqList, queryparser);
if (isEcOli)
{
expectedSequence = utilityObj.xmlUtil.GetFileTextValue(nodeName,
Constants.ExpectedSequenceNode);
}
else
{
expectedSequence = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.ExpectedSequenceNode);
}
var outputStrings = outputAssemble.Select(seq => seq.ConvertToString()).ToList();
outputStrings.Sort();
Assert.AreEqual(expectedSequence.ToUpperInvariant(), String.Join("", outputStrings).ToUpperInvariant());
}
}
示例12: ValidateSAMParseAndFormatWithCIGARFormat
/// <summary>
/// Validate parser and formatter by parsing the same file which contains
/// extended CIGAR string. Validate the CIGAR property in aligned sequence
/// metadata information is updated as expected.
/// </summary>
/// <param name="nodeName">xml node name</param>
void ValidateSAMParseAndFormatWithCIGARFormat(string nodeName)
{
// Gets the expected sequence from the Xml
string filePath = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.FilePathNode);
string expectedSequenceFile = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.ExpectedSequence);
string expectedCIGARString = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.CIGARNode);
// Create parser using encoding
ISequenceAlignmentParser parser = new SAMParser();
try
{
var alignments = parser.Parse(filePath).ToList();
// Get expected sequences
FastAParser parserObj = new FastAParser();
{
IEnumerable<ISequence> expectedSequences = parserObj.Parse(expectedSequenceFile);
IList<ISequence> expectedSequencesList = expectedSequences.ToList();
// Validate parsed output with expected output
int count = 0;
for (int index = 0; index < alignments.Count; index++)
{
for (int ialigned = 0; ialigned <
alignments[index].AlignedSequences.Count; ialigned++)
{
for (int iseq = 0; iseq <
alignments[index].AlignedSequences[ialigned].Sequences.Count; iseq++)
{
Assert.AreEqual(new string(expectedSequencesList[count].Select(a => (char)a).ToArray()),
new string(alignments[index].AlignedSequences[ialigned].Sequences[iseq].Select(a => (char)a).ToArray()));
foreach (string key in alignments[index].AlignedSequences[ialigned].Metadata.Keys)
{
SAMAlignedSequenceHeader header = (SAMAlignedSequenceHeader)
alignments[index].AlignedSequences[ialigned].Metadata[key];
Assert.AreEqual(expectedCIGARString, header.CIGAR);
}
count++;
}
}
}
}
}
finally
{
}
}
示例13: ValidateSAMParseAndFormatWithQualityValues
/// <summary>
/// Validate parser and formatter by parsing the sam file with quality values
/// </summary>
/// <param name="nodeName">xml node name</param>
void ValidateSAMParseAndFormatWithQualityValues(string nodeName)
{
// Gets the expected sequence from the Xml
string filePath = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.FilePathNode);
string expectedSequenceFile = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.ExpectedSequence);
// Create parser using encoding
ISequenceAlignmentParser parser = new SAMParser();
try
{
var alignments = parser.Parse(filePath).ToList();
// Get expected sequences
FastAParser parserObj = new FastAParser();
{
var expectedSequencesList = parserObj.Parse(expectedSequenceFile).ToList();
// Validate parsed output with expected output
int count = 0;
for (int index = 0; index < alignments.Count; index++)
{
for (int ialigned = 0; ialigned <
alignments[index].AlignedSequences.Count; ialigned++)
{
for (int iseq = 0; iseq <
alignments[index].AlignedSequences[ialigned].Sequences.Count; iseq++)
{
Assert.IsInstanceOf<QualitativeSequence>(alignments[index].AlignedSequences[ialigned].Sequences[iseq]);
QualitativeSequence qualSequence =
(QualitativeSequence)alignments[index].AlignedSequences[ialigned].Sequences[iseq];
Assert.AreEqual(
new string(expectedSequencesList[count].Select(a => (char)a).ToArray()),
new string(qualSequence.Select(a => (char)a).ToArray()));
count++;
}
}
}
}
}
finally
{
}
}
示例14: ValidatePairwiseOverlapAlignment
/// <summary>
/// Validates PairwiseOverlapAlignment algorithm for the parameters passed.
/// </summary>
/// <param name="nodeName">Node Name in the xml.</param>
/// <param name="alignParam">parameter based on which certain validations are done.</param>
/// <param name="similarityMatrixParam">Similarity Matrix Parameter.</param>
/// <param name="alignType">Alignment Type</param>
private void ValidatePairwiseOverlapAlignment(string nodeName, AlignParameters alignParam,
SimilarityMatrixParameters similarityMatrixParam,
AlignmentType alignType)
{
ISequence aInput;
ISequence bInput;
IAlphabet alphabet = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.AlphabetNameNode));
if (alignParam.ToString().Contains("Code"))
{
string sequence1 = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SequenceNode1);
string sequence2 = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SequenceNode2);
aInput = new Sequence(alphabet, sequence1);
bInput = new Sequence(alphabet, sequence2);
}
else
{
// Read the xml file for getting both the files for aligning.
string filePath1 = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode1);
string filePath2 = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode2);
var parser1 = new FastAParser { Alphabet = alphabet };
aInput = parser1.Parse(filePath1).ElementAt(0);
bInput = parser1.Parse(filePath2).ElementAt(0);
}
string blosumFilePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.BlosumFilePathNode);
SimilarityMatrix sm;
switch (similarityMatrixParam)
{
case SimilarityMatrixParameters.TextReader:
using (TextReader reader = new StreamReader(blosumFilePath))
sm = new SimilarityMatrix(reader);
break;
case SimilarityMatrixParameters.DiagonalMatrix:
string matchValue = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MatchScoreNode);
string misMatchValue = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MisMatchScoreNode);
sm = new DiagonalSimilarityMatrix(int.Parse(matchValue, null), int.Parse(misMatchValue, null));
break;
default:
sm = new SimilarityMatrix(new StreamReader(blosumFilePath));
break;
}
int gapOpenCost = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.GapOpenCostNode), null);
int gapExtensionCost = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.GapExtensionCostNode), null);
var pairwiseOverlapObj = new PairwiseOverlapAligner();
if (AlignParameters.AllParam != alignParam)
{
pairwiseOverlapObj.SimilarityMatrix = sm;
pairwiseOverlapObj.GapOpenCost = gapOpenCost;
}
IList<IPairwiseSequenceAlignment> result = null;
switch (alignParam)
{
case AlignParameters.AlignList:
case AlignParameters.AlignListCode:
var sequences = new List<ISequence> {aInput, bInput};
switch (alignType)
{
case AlignmentType.Align:
pairwiseOverlapObj.GapExtensionCost = gapExtensionCost;
result = pairwiseOverlapObj.Align(sequences);
break;
default:
result = pairwiseOverlapObj.AlignSimple(sequences);
break;
}
break;
case AlignParameters.AllParam:
case AlignParameters.AllParamCode:
switch (alignType)
{
case AlignmentType.Align:
pairwiseOverlapObj.GapExtensionCost = gapExtensionCost;
result = pairwiseOverlapObj.Align(sm, gapOpenCost, gapExtensionCost, aInput, bInput);
break;
default:
result = pairwiseOverlapObj.AlignSimple(sm, gapOpenCost, aInput, bInput);
break;
}
break;
case AlignParameters.AlignTwo:
case AlignParameters.AlignTwoCode:
switch (alignType)
{
case AlignmentType.Align:
//.........这里部分代码省略.........
示例15: ValidateNUCmerAlignSimpleGeneralTestCases
private void ValidateNUCmerAlignSimpleGeneralTestCases(string nodeName, bool isFilePath, bool isAlignList)
{
IList<ISequence> refSeqList = new List<ISequence>();
IList<ISequence> searchSeqList = new List<ISequence>();
if (isFilePath)
{
// Gets the reference sequence from the FastA file
string filePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
Assert.IsNotNull(filePath);
ApplicationLog.WriteLine(string.Format(null, "NUCmer P1 : Successfully validated the File Path '{0}'.", filePath));
var fastaparserobj = new FastAParser();
IEnumerable<ISequence> referenceSeqList = fastaparserobj.Parse(filePath);
foreach (ISequence seq in referenceSeqList)
{
refSeqList.Add(seq);
}
// Gets the query sequence from the FastA file
string queryFilePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SearchSequenceFilePathNode);
Assert.IsNotNull(queryFilePath);
ApplicationLog.WriteLine(string.Format(null,"NUCmer P1 : Successfully validated the File Path '{0}'.", queryFilePath));
var fastaParserobj = new FastAParser();
IEnumerable<ISequence> querySeqList = fastaParserobj.Parse(queryFilePath);
foreach (ISequence seq in querySeqList)
{
searchSeqList.Add(seq);
}
}
else
{
// Gets the reference & search sequences from the configuration file
string[] referenceSequences = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.ReferenceSequencesNode);
string[] searchSequences = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.SearchSequencesNode);
IAlphabet seqAlphabet = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.AlphabetNameNode));
foreach (Sequence referSeq in referenceSequences.Select(t => new Sequence(seqAlphabet, Encoding.ASCII.GetBytes(t))))
{
refSeqList.Add(referSeq);
}
foreach (Sequence searchSeq in searchSequences.Select(t => new Sequence(seqAlphabet, Encoding.ASCII.GetBytes(t))))
{
searchSeqList.Add(searchSeq);
}
}
// Gets the mum length from the xml
string mumLength = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode);
var nucmerObj = new NucmerPairwiseAligner
{
MaximumSeparation = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode), null),
MinimumScore = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode), null),
SeparationFactor = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode), null),
BreakLength = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode), null),
LengthOfMUM = long.Parse(mumLength, null)
};
IList<ISequenceAlignment> alignSimple = null;
if (isAlignList)
{
var listOfSeq = new List<ISequence> {refSeqList[0], searchSeqList[0]};
alignSimple = nucmerObj.AlignSimple(listOfSeq);
}
string expectedSequences = isFilePath
? this.utilityObj.xmlUtil.GetFileTextValue(nodeName, Constants.ExpectedSequencesNode)
: this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequencesNode);
string[] expSeqArray = expectedSequences.Split(',');
int j = 0;
// Gets all the aligned sequences in comma separated format
foreach (PairwiseAlignedSequence alignedSeq in alignSimple.Cast<IPairwiseSequenceAlignment>().SelectMany(seqAlignment => seqAlignment))
{
Assert.AreEqual(expSeqArray[j], alignedSeq.FirstSequence.ConvertToString());
++j;
Assert.AreEqual(expSeqArray[j], alignedSeq.SecondSequence.ConvertToString());
j++;
}
ApplicationLog.WriteLine("NUCmer P1 : Successfully validated all the aligned sequences.");
}