本文整理汇总了C#中Bio.IO.FastA.FastAParser.Close方法的典型用法代码示例。如果您正苦于以下问题:C# FastAParser.Close方法的具体用法?C# FastAParser.Close怎么用?C# FastAParser.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.IO.FastA.FastAParser
的用法示例。
在下文中一共展示了FastAParser.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateAssembledPath
/// <summary>
/// Validate Assembled paths for a given input reads.
/// </summary>
/// <param name="nodeName">xml node name used for different testcases</param>
internal void ValidateAssembledPath(string nodeName)
{
string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
string kmerLength = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.KmerLengthNode);
string daglingThreshold = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.DanglingLinkThresholdNode);
string redundantThreshold = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.RedundantThreshold);
string libraray = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.LibraryName);
string stdDeviation = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.StdDeviation);
string mean = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.Mean);
string expectedDepth = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.DepthNode);
string expectedScaffoldPathCount = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ScaffoldPathCount);
string[] assembledPath = utilityObj.xmlUtil.GetTextValues(nodeName, Constants.SequencePathNode);
// Get the input reads and build kmers
FastAParser parser = new FastAParser();
parser.Open( filePath.Replace("\\", System.IO.Path.DirectorySeparatorChar.ToString()));
IEnumerable<ISequence> sequenceReads = parser.Parse().ToList();
parser.Close ();
// Build kmers from step1,graph in step2
// Remove the dangling links from graph in step3
// Remove bubbles form the graph in step4
// Pass the graph and build contigs
// Validate contig reads
this.KmerLength = Int32.Parse(kmerLength, null);
this.DanglingLinksThreshold = Int32.Parse(daglingThreshold, null); ;
this.DanglingLinksPurger = new DanglingLinksPurger(Int32.Parse(daglingThreshold, null));
this.RedundantPathsPurger = new RedundantPathsPurger(Int32.Parse(redundantThreshold, null));
this.RedundantPathLengthThreshold = Int32.Parse(redundantThreshold, (IFormatProvider)null);
this.SequenceReads.Clear();
this.SetSequenceReads(sequenceReads.ToList());
this.CreateGraph();
ContigGraph graph = new ContigGraph();
this.UnDangleGraph();
// Build contig.
this.ContigBuilder = new SimplePathContigBuilder();
this.RemoveRedundancy();
IEnumerable<ISequence> contigs = this.BuildContigs();
IList<ISequence> listContigs = contigs.ToList();
IList<ISequence> sortedContigs = SortContigsData(listContigs);
ReadContigMapper mapper = new ReadContigMapper();
ReadContigMap maps = mapper.Map(sortedContigs, sequenceReads, this.KmerLength);
// Find map paired reads.
CloneLibrary.Instance.AddLibrary(libraray, float.Parse(mean, null), float.Parse(stdDeviation, null));
MatePairMapper mapPairedReads = new MatePairMapper();
ContigMatePairs pairedReads = mapPairedReads.MapContigToMatePairs(sequenceReads, maps);
// Filter contigs based on the orientation.
OrientationBasedMatePairFilter filter = new OrientationBasedMatePairFilter();
ContigMatePairs contigpairedReads = filter.FilterPairedReads(pairedReads, 0);
DistanceCalculator dist = new DistanceCalculator(contigpairedReads);
dist.CalculateDistance();
graph.BuildContigGraph(contigs.ToList(), this.KmerLength);
// Validate ScaffoldPath using BFS.
TracePath trace = new TracePath();
IList<ScaffoldPath> paths = trace.FindPaths(graph, contigpairedReads, Int32.Parse(kmerLength, null), Int32.Parse(expectedDepth, null));
Assert.AreEqual(expectedScaffoldPathCount, paths.Count.ToString((IFormatProvider)null));
// Assemble paths.
PathPurger pathsAssembler = new PathPurger();
pathsAssembler.PurgePath(paths);
// Get sequences from assembled path.
IList<ISequence> seqList = paths.Select(temp => temp.BuildSequenceFromPath(graph, Int32.Parse(kmerLength, null))).ToList();
// Validate assembled sequence paths.
foreach (string sequence in seqList.Select(t => t.ConvertToString())) {
Assert.IsTrue (assembledPath.Contains (sequence), "Could not locate " + sequence);
}
ApplicationLog.WriteLine(
"Padena BVT : AssemblePath() validation for Padena step6:step7 completed successfully");
}
示例2: ValidateScaffoldPath
/// <summary>
/// Validate scaffold paths for a given input reads.
/// </summary>
/// <param name="nodeName">xml node name used for different testcases</param>
internal void ValidateScaffoldPath(string nodeName)
{
string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
string kmerLength = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.KmerLengthNode);
string daglingThreshold = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.DanglingLinkThresholdNode);
string redundantThreshold = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.RedundantThreshold);
string[] expectedScaffoldNodes = utilityObj.xmlUtil.GetTextValues(nodeName,Constants.ScaffoldNodes);
string libraray = utilityObj.xmlUtil.GetTextValue(nodeName,Constants.LibraryName);
string stdDeviation = utilityObj.xmlUtil.GetTextValue(nodeName,Constants.StdDeviation);
string mean = utilityObj.xmlUtil.GetTextValue(nodeName,Constants.Mean);
string expectedDepth = utilityObj.xmlUtil.GetTextValue(nodeName,Constants.DepthNode);
// Get the input reads and build kmers
FastAParser parser = new FastAParser();
parser.Open(filePath);
IEnumerable<ISequence> sequenceReads = parser.Parse().ToList();
parser.Close ();
// Build kmers from step1,graph in step2
// Remove the dangling links from graph in step3
// Remove bubbles form the graph in step4
// Pass the graph and build contigs
// Validate contig reads
this.KmerLength = Int32.Parse(kmerLength, null);
this.DanglingLinksThreshold = Int32.Parse(daglingThreshold, null);
this.DanglingLinksPurger = new DanglingLinksPurger(Int32.Parse(daglingThreshold, null));
this.RedundantPathsPurger = new RedundantPathsPurger(Int32.Parse(redundantThreshold, null));
this.RedundantPathLengthThreshold = Int32.Parse(redundantThreshold, null);
this.SequenceReads.Clear();
this.SetSequenceReads(sequenceReads.ToList());
this.CreateGraph();
ContigGraph graph = new ContigGraph();
this.UnDangleGraph();
// Build contig.
this.ContigBuilder = new SimplePathContigBuilder();
this.RemoveRedundancy();
IEnumerable<ISequence> contigs = this.BuildContigs();
IList<ISequence> sortedContigs = SortContigsData(contigs.ToList());
ReadContigMapper mapper = new ReadContigMapper();
ReadContigMap maps = mapper.Map(sortedContigs, sequenceReads, this.KmerLength);
// Find map paired reads.
CloneLibrary.Instance.AddLibrary(libraray, float.Parse(mean, null), float.Parse(stdDeviation, null));
MatePairMapper mapPairedReads = new MatePairMapper();
ContigMatePairs pairedReads = mapPairedReads.MapContigToMatePairs(sequenceReads, maps);
// Filter contigs based on the orientation.
OrientationBasedMatePairFilter filter = new OrientationBasedMatePairFilter();
ContigMatePairs contigpairedReads = filter.FilterPairedReads(pairedReads, 0);
DistanceCalculator dist = new DistanceCalculator(contigpairedReads);
dist.CalculateDistance();
graph.BuildContigGraph(contigs.ToList(), this.KmerLength);
// Validate ScaffoldPath using BFS.
TracePath trace = new TracePath();
IList<ScaffoldPath> paths = trace.FindPaths(graph, contigpairedReads, Int32.Parse(kmerLength, null),
Int32.Parse(expectedDepth, null));
ScaffoldPath scaffold = paths.First();
foreach (KeyValuePair<Node, Edge> kvp in scaffold)
{
ISequence seq = graph.GetNodeSequence(kvp.Key);
string sequence = seq.ConvertToString();
string reversedSequence = seq.GetReverseComplementedSequence().ConvertToString();
Assert.IsTrue(expectedScaffoldNodes.Contains(sequence)
|| expectedScaffoldNodes.Contains(reversedSequence),
"Failed to find " + sequence + ", or " + reversedSequence);
}
ApplicationLog.WriteLine("PADENA P1 : FindPaths() validation for Padena step6:step6 completed successfully");
}
示例3: ValidatePadenaAssembledSeqs
/// <summary>
/// Validate Parallel Denovo Assembly Assembled sequences.
/// </summary>
/// <param name="nodeName">XML node used to validate different test scenarios</param>
internal void ValidatePadenaAssembledSeqs(string nodeName)
{
// Get values from XML node.
string filePath = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.FilePathNode);
string kmerLength = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.KmerLengthNode);
string daglingThreshold = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.DanglingLinkThresholdNode);
string redundantThreshold = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.RedundantThreshold);
string libraray = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.LibraryName);
string stdDeviation = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.StdDeviation);
string mean = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.Mean);
string assembledSequences = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.SequencePathNode);
string assembledSeqCount = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.AssembledSeqCountNode);
string[] updatedAssembledSeqs = assembledSequences.Split(',');
// Get the input reads and build kmers
IEnumerable<ISequence> sequenceReads = null;
FastAParser parser = new FastAParser();
parser.Open(filePath);
sequenceReads = parser.Parse().ToList();
parser.Close ();
// Create a ParallelDeNovoAssembler instance.
ParallelDeNovoAssembler denovoObj = null;
try
{
denovoObj = new ParallelDeNovoAssembler();
denovoObj.KmerLength = Int32.Parse(kmerLength, (IFormatProvider)null);
denovoObj.DanglingLinksThreshold = Int32.Parse(daglingThreshold, (IFormatProvider)null);
denovoObj.RedundantPathLengthThreshold = Int32.Parse(redundantThreshold, (IFormatProvider)null);
CloneLibrary.Instance.AddLibrary(libraray, float.Parse(mean, (IFormatProvider)null),
float.Parse(stdDeviation, (IFormatProvider)null));
byte[] symbols = sequenceReads.ElementAt(0).Alphabet.GetSymbolValueMap();
IDeNovoAssembly assembly =
denovoObj.Assemble(sequenceReads.Select(a => new Sequence(Alphabets.DNA, a.Select(b => symbols[b]).ToArray()) { ID = a.ID }), true);
IList<ISequence> assembledSequenceList = assembly.AssembledSequences.ToList();
// Validate assembled sequences.
Assert.AreEqual(assembledSeqCount, assembledSequenceList.Count.ToString((IFormatProvider)null));
for (int i = 0; i < assembledSequenceList.Count; i++)
{
Assert.IsTrue(assembledSequences.Contains(
new string(assembledSequenceList[i].Select(a => (char)a).ToArray()))
|| updatedAssembledSeqs.Contains(
new string(assembledSequenceList[i].GetReverseComplementedSequence().Select(a => (char)a).ToArray())));
}
}
finally
{
if (denovoObj != null)
denovoObj.Dispose();
}
ApplicationLog.WriteLine("Padena P1 : Assemble() validation for Padena step6:step7 completed successfully");
}
示例4: AddLibraryInformation
/// <summary>
/// Validate Add library information in existing libraries.
/// </summary>
/// <param name="nodeName">xml node name used for different testcases</param>
/// <param name="IsLibraryInfo">Is library info?</param>
internal void AddLibraryInformation(string nodeName, bool IsLibraryInfo)
{
string filePath = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.FilePathNode);
string expectedPairedReadsCount = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.PairedReadsCountNode);
string[] backwardReadsNode = utilityObj.xmlUtil.GetTextValues(nodeName,
Constants.BackwardReadsNode);
string[] forwardReadsNode = utilityObj.xmlUtil.GetTextValues(nodeName,
Constants.ForwardReadsNode);
string expectedLibraray = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.LibraryName);
string expectedStdDeviation = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.StdDeviation);
string mean = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.Mean);
IList<ISequence> sequenceReads = new List<ISequence>();
IList<MatePair> pairedreads = new List<MatePair>();
// Get the input reads
IEnumerable<ISequence> sequences = null;
FastAParser parser = new FastAParser();
parser.Open(filePath);
sequences = parser.Parse().ToList();
parser.Close ();
foreach (ISequence seq in sequences)
{
sequenceReads.Add(seq);
}
// Add a new library infomration.
if (IsLibraryInfo)
{
CloneLibraryInformation libraryInfo =
new CloneLibraryInformation();
libraryInfo.LibraryName = expectedLibraray;
libraryInfo.MeanLengthOfInsert = float.Parse(mean, (IFormatProvider)null);
libraryInfo.StandardDeviationOfInsert = float.Parse(expectedStdDeviation, (IFormatProvider)null);
CloneLibrary.Instance.AddLibrary(libraryInfo);
}
else
{
CloneLibrary.Instance.AddLibrary(expectedLibraray,
float.Parse(mean, (IFormatProvider)null), float.Parse(expectedStdDeviation, (IFormatProvider)null));
}
// Convert reads to map paired reads.
MatePairMapper pair = new MatePairMapper();
pairedreads = pair.Map(sequenceReads);
// Validate Map paired reads.
Assert.AreEqual(expectedPairedReadsCount, pairedreads.Count.ToString((IFormatProvider)null));
for (int index = 0; index < pairedreads.Count; index++)
{
Assert.IsTrue(forwardReadsNode.Contains(new string(pairedreads[index].GetForwardRead(sequenceReads).Select(a => (char)a).ToArray())));
Assert.IsTrue(backwardReadsNode.Contains(new string(pairedreads[index].GetReverseRead(sequenceReads).Select(a => (char)a).ToArray())));
Assert.AreEqual(expectedStdDeviation,
pairedreads[index].StandardDeviationOfLibrary.ToString((IFormatProvider)null));
Assert.AreEqual(expectedLibraray, pairedreads[index].Library.ToString((IFormatProvider)null));
Assert.AreEqual(mean, pairedreads[index].MeanLengthOfLibrary.ToString((IFormatProvider)null));
}
ApplicationLog.WriteLine(@"Padena P1 : Map paired reads has been verified successfully");
}
示例5: ValidateFilterPaired
/// <summary>
/// Validate Filter contig nodes.
/// </summary>
/// <param name="nodeName">xml node name used for a differnt testcase.</param>
/// <param name="isFirstContig">Is First Contig?</param>
internal void ValidateFilterPaired(string nodeName, bool isFirstContig)
{
string filePath = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.FilePathNode);
string kmerLength = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.KmerLengthNode);
string daglingThreshold = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.DanglingLinkThresholdNode);
string redundantThreshold = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.RedundantThreshold);
string expectedContigPairedReadsCount = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.ContigPairedReadsCount);
string forwardReadStartPos = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.ForwardReadStartPos);
string reverseReadStartPos = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.ReverseReadStartPos);
string reverseComplementStartPos = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.RerverseReadReverseCompPos);
string[] expectedForwardReadStartPos = forwardReadStartPos.Split(',');
string[] expectedReverseReadStartPos = reverseReadStartPos.Split(',');
string[] expectedReverseComplementStartPos = reverseComplementStartPos.Split(',');
// Get the input reads and build kmers
IEnumerable<ISequence> sequenceReads = null;
FastAParser parser = new FastAParser();
parser.Open(filePath);
sequenceReads = parser.Parse().ToList();
parser.Close ();
// Build kmers from step1,graph in step2
// Remove the dangling links from graph in step3
// Remove bubbles form the graph in step4
// Pass the graph and build contigs
// Validate contig reads
this.KmerLength = Int32.Parse(kmerLength, (IFormatProvider)null);
this.DanglingLinksThreshold = Int32.Parse(daglingThreshold, (IFormatProvider)null);
this.DanglingLinksPurger = new DanglingLinksPurger(Int32.Parse(daglingThreshold, (IFormatProvider)null));
this.RedundantPathsPurger =
new RedundantPathsPurger(Int32.Parse(redundantThreshold, (IFormatProvider)null));
this.RedundantPathLengthThreshold = Int32.Parse(redundantThreshold, (IFormatProvider)null);
this.SequenceReads.Clear();
this.SetSequenceReads(sequenceReads.ToList());
this.CreateGraph();
this.UnDangleGraph();
// Build contig.
this.ContigBuilder = new SimplePathContigBuilder();
this.RemoveRedundancy();
IEnumerable<ISequence> contigs = this.BuildContigs();
IList<ISequence> sortedContigs = SortContigsData(contigs.ToList());
ReadContigMapper mapper = new ReadContigMapper();
ReadContigMap maps = mapper.Map(
sortedContigs, sequenceReads, this.KmerLength);
// Find map paired reads.
MatePairMapper mapPairedReads = new MatePairMapper();
ContigMatePairs pairedReads = mapPairedReads.MapContigToMatePairs(sequenceReads, maps);
// Filter contigs based on the orientation.
OrientationBasedMatePairFilter filter = new OrientationBasedMatePairFilter();
ContigMatePairs contigpairedReads = filter.FilterPairedReads(pairedReads, 0);
Assert.AreEqual(expectedContigPairedReadsCount,
contigpairedReads.Values.Count.ToString((IFormatProvider)null));
Dictionary<ISequence, IList<ValidMatePair>> map = null;
IList<ValidMatePair> valid = null;
ISequence firstSeq = sortedContigs[0];
ISequence secondSeq = sortedContigs[1];
// Validate Contig paired reads after filtering contig sequences.
if (isFirstContig)
{
map = contigpairedReads[firstSeq];
valid = SortPairedReads(map[secondSeq], sequenceReads);
}
else
{
map = contigpairedReads[secondSeq];
valid = SortPairedReads(map[firstSeq], sequenceReads);
}
for (int index = 0; index < valid.Count; index++)
{
Assert.IsTrue((expectedForwardReadStartPos[index] ==
valid[index].ForwardReadStartPosition[0].ToString((IFormatProvider)null)
|| (expectedForwardReadStartPos[index] ==
valid[index].ForwardReadStartPosition[1].ToString((IFormatProvider)null))));
if (valid[index].ReverseReadReverseComplementStartPosition.Count > 1)
{
Assert.IsTrue((expectedReverseReadStartPos[index] ==
//.........这里部分代码省略.........
示例6: ValidateRedundantPathPurgerCtor
/// <summary>
/// Creates RedundantPathPurger instance by passing pathlength and count. Detect
/// redundant error nodes and remove these nodes from the graph. Validate the graph.
/// </summary>
/// <param name="nodeName">xml node name used for different testcases</param>
/// <param name="isMicroOrganism">Is micro organism</param>
internal void ValidateRedundantPathPurgerCtor(string nodeName, bool isMicroOrganism)
{
string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
string kmerLength = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.KmerLengthNode);
string expectedNodesCount = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.ExpectedNodesCountAfterDangling);
// Get the input reads and build kmers
IEnumerable<ISequence> sequenceReads = null;
FastAParser parser = new FastAParser();
parser.Open(filePath);
sequenceReads = parser.Parse().ToList();
parser.Close ();
// Build kmers from step1,graph in step2
// Remove the dangling links from graph in step3
// Validate the graph
this.KmerLength = int.Parse(kmerLength, (IFormatProvider)null);
this.SequenceReads.Clear();
this.SetSequenceReads(sequenceReads.ToList());
this.CreateGraph();
DeBruijnGraph graph = this.Graph;
this.DanglingLinksPurger = new DanglingLinksPurger(this.KmerLength);
this.UnDangleGraph();
// Create RedundantPathPurger instance, detect redundant nodes and remove error nodes
RedundantPathsPurger redundantPathPurger =
new RedundantPathsPurger(int.Parse(kmerLength, (IFormatProvider)null) + 1);
DeBruijnPathList redundantnodelist = redundantPathPurger.DetectErroneousNodes(graph);
redundantPathPurger.RemoveErroneousNodes(graph, redundantnodelist);
if (isMicroOrganism)
Assert.AreEqual(expectedNodesCount, graph.GetNodes().Count());
else
ValidateGraph(graph, nodeName);
ApplicationLog.WriteLine(@"Padena P1 :RedundantPathsPurger ctor and methods validation for Padena step4 completed successfully");
}
示例7: ValidateSimpleContigBuilderBuild
/// <summary>
/// Validate the SimpleContigBuilder Build() method using step 4 graph
/// </summary>
/// <param name="nodeName">xml node name used for different testcases</param>
/// <param name="isChromosomeRC">Is Chromosome RC?</param>
internal void ValidateSimpleContigBuilderBuild(string nodeName, bool isChromosomeRC)
{
string filePath = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.FilePathNode);
string kmerLength = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.KmerLengthNode);
string expectedContigsString = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.ContigsNode);
string[] expectedContigs = expectedContigsString.Split(',');
string expectedContigsCount = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.ContigsCount);
// Get the input reads and build kmers
IEnumerable<ISequence> sequenceReads = null;
FastAParser parser = new FastAParser();
parser.Open(filePath);
sequenceReads = parser.Parse().ToList();
parser.Close ();
// Build kmers from step1,graph in step2
// Remove the dangling links from graph in step3
// Remove bubbles from graph in step4
this.KmerLength = int.Parse(kmerLength, (IFormatProvider)null);
this.SequenceReads.Clear();
this.SetSequenceReads(sequenceReads.ToList());
this.CreateGraph();
DeBruijnGraph graph = this.Graph;
this.UnDangleGraph();
this.RemoveRedundancy();
// Validate the SimpleContigBuilder.Build() by passing graph
SimplePathContigBuilder builder = new SimplePathContigBuilder();
IList<ISequence> contigs = builder.Build(graph).ToList();
if (isChromosomeRC)
{
Assert.AreEqual(expectedContigsCount,
contigs.Count.ToString((IFormatProvider)null));
}
else
{
// Validate the contigs
for (int index = 0; index < contigs.Count; index++)
{
Assert.IsTrue(expectedContigs.Contains(new string(contigs[index].Select(a => (char)a).ToArray())));
}
}
ApplicationLog.WriteLine(@"Padena P1 :SimpleContigBuilder.BuildContigs() validation for Padena step5 completed successfully");
}
示例8: ValidatePadenaBuildKmers
/// <summary>
/// Validate ParallelDeNovothis step1 Build kmers
/// </summary>
/// <param name="nodeName">xml node for test data</param>
/// <param name="isSmallSize">Is file small size?</param>
internal void ValidatePadenaBuildKmers(string nodeName, bool isSmallSize)
{
// Read all the input sequences from xml config file
string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
string kmerLength = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.KmerLengthNode);
string expectedKmersCount = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedKmersCount);
// Set kmerLength
this.KmerLength = int.Parse(kmerLength, (IFormatProvider)null);
IEnumerable<ISequence> sequenceReads = null;
FastAParser parser = new FastAParser();
parser.Open(filePath);
sequenceReads = parser.Parse().ToList();
parser.Close ();
// Set all the input reads and execute build kmers
this.SequenceReads.Clear();
this.SetSequenceReads(sequenceReads.ToList());
IEnumerable<KmersOfSequence> lstKmers =
(new SequenceToKmerBuilder()).Build(this.SequenceReads, this.KmerLength);
if (isSmallSize)
{
Assert.AreEqual(expectedKmersCount, lstKmers.Count().ToString((IFormatProvider)null));
}
else
{
ValidateKmersList(new List<KmersOfSequence>(lstKmers), sequenceReads.ToList(), nodeName);
}
ApplicationLog.WriteLine(@"Padena P1 : Validation of Build with all input reads using ParallelDeNovothis sequence completed successfully");
}
示例9: ValidatePadenaBuildGraph
/// <summary>
/// Validate graph generated using ParallelDeNovothis.CreateGraph() with kmers
/// </summary>
/// <param name="nodeName">xml node name used for different testcases</param>
/// <param name="isLargeSizeReads">Is large size reads?</param>
internal void ValidatePadenaBuildGraph(string nodeName, bool isLargeSizeReads)
{
string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
string kmerLength = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.KmerLengthNode);
string expectedGraphsNodeCount = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.GraphNodesCountNode);
// Get the input reads and build kmers
FastAParser parser = new FastAParser();
parser.Open(filePath);
IEnumerable<ISequence> sequenceReads = parser.Parse().ToList();
parser.Close ();
this.KmerLength = int.Parse(kmerLength, null);
this.SequenceReads.Clear();
this.SetSequenceReads(sequenceReads.ToList());
this.CreateGraph();
DeBruijnGraph graph = this.Graph;
ApplicationLog.WriteLine("Padena P1 : Step1,2 Completed Successfully");
if (isLargeSizeReads)
Assert.AreEqual(Int32.Parse(expectedGraphsNodeCount, null), graph.GetNodes().Count());
else
ValidateGraph(graph, nodeName);
ApplicationLog.WriteLine(@"Padena P1 : ParallelDeNovothis CreateGraph() validation for Padena step2 completed successfully");
}
示例10: ValidateKmerBuilderBuild
/// <summary>
/// Validate SequenceRangeToKmerBuilder Build() method which build kmers
/// </summary>
/// <param name="nodeName">xml node name for test data</param>
internal void ValidateKmerBuilderBuild(string nodeName)
{
string filePath = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.FilePathNode);
string kmerLength = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.KmerLengthNode);
// Get the input reads
IEnumerable<ISequence> sequenceReads = null;
FastAParser parser = new FastAParser ();
parser.Open( filePath.Replace("\\", System.IO.Path.DirectorySeparatorChar.ToString()));
sequenceReads = parser.Parse().ToList();
parser.Close ();
// Pass all the input reads and kmerLength to generate kmers
SequenceToKmerBuilder builder = new SequenceToKmerBuilder();
IEnumerable<KmersOfSequence> lstKmers = builder.Build(sequenceReads,
int.Parse(kmerLength, (IFormatProvider)null));
// Validate kmers list
ValidateKmersList(new List<KmersOfSequence>(lstKmers),
new List<ISequence>(sequenceReads), nodeName);
ApplicationLog.WriteLine(
@"Padena BVT : Validation of Build with all input reads
sequence completed successfully");
}
示例11: ValidateKmerBuilderBuildWithSequence
/// <summary>
/// Validate SequenceRangeToKmerBuilder Build() which build kmers
/// using one base sequence
/// </summary>
/// <param name="nodeName">xml node name used for different testcases</param>
internal void ValidateKmerBuilderBuildWithSequence(string nodeName)
{
string filePath = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.FilePathNode);
string kmerLength = utilityObj.xmlUtil.GetTextValue(
nodeName, Constants.KmerLengthNode);
// Get the input reads
IEnumerable<ISequence> sequenceReads = null;
FastAParser parser = new FastAParser ();
parser.Open (filePath);
sequenceReads = parser.Parse().ToList();
parser.Close ();
// Pass each input read and kmerLength
// Add all the generated kmers to kmer list
SequenceToKmerBuilder builder = new SequenceToKmerBuilder();
IList<KmersOfSequence> lstKmers = new List<KmersOfSequence>();
foreach (ISequence sequence in sequenceReads)
{
lstKmers.Add(builder.Build(sequence, int.Parse(kmerLength, (IFormatProvider)null)));
}
// Validate all the kmers
ValidateKmersList(lstKmers, sequenceReads.ToList(), nodeName);
ApplicationLog.WriteLine(
@"Padena BVT : Validation of Build with each input read sequence
completed successfully");
}
示例12: ValidateDe2AssemblerBuildKmers
/// <summary>
/// Validate ParallelDeNovoAssembler step1 Build kmers
/// </summary>
/// <param name="nodeName">xml node for test data</param>
internal void ValidateDe2AssemblerBuildKmers(string nodeName)
{
// Read all the input sequences from xml config file
string filePath = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.FilePathNode);
string kmerLength = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.KmerLengthNode);
// set kmerLength
this.KmerLength = int.Parse(kmerLength, (IFormatProvider)null);
IEnumerable<ISequence> sequenceReads = null;
FastAParser parser = new FastAParser ();
parser.Open( filePath.Replace("\\", System.IO.Path.DirectorySeparatorChar.ToString()));
sequenceReads = parser.Parse().ToList();
parser.Close ();
this.SequenceReads.Clear(); // set all the input reads and execute build kmers
this.SetSequenceReads(sequenceReads.ToList());
IEnumerable<KmersOfSequence> lstKmers =
(new SequenceToKmerBuilder()).Build(this.SequenceReads,
this.KmerLength);
ValidateKmersList(new List<KmersOfSequence>(lstKmers),
new List<ISequence>(sequenceReads), nodeName);
ApplicationLog.WriteLine(
@"Padena BVT : Validation of Build with all input reads using
ParallelDeNovoAssembler sequence completed successfully");
}
示例13: ValidateReadContigMap
public void ValidateReadContigMap()
{
// Read all the input sequences from xml config file
string filePath = utilityObj.xmlUtil.GetTextValue(Constants.SmallChromosomeReadsNode,
Constants.FilePathNode);
IEnumerable<ISequence> sequenceReads = null;
FastAParser parser = new FastAParser ();
parser.Open( filePath.Replace("\\", System.IO.Path.DirectorySeparatorChar.ToString()));
sequenceReads = parser.Parse().ToList();
parser.Close ();
ReadContigMap map = new ReadContigMap(sequenceReads);
Assert.IsNotNull(map);
for (int i = 0; i < 10; i++)
{
Assert.IsTrue(map.ContainsKey(sequenceReads.ElementAt(0).ID));
}
}
示例14: ValidatePadenaAssembledSeqs
/// <summary>
/// Validate Parallel Denovo Assembly Assembled sequences.
/// </summary>
/// <param name="nodeName">XML node used to validate different test scenarios</param>
/// <param name="isScaffold"></param>
/// <param name="enableLowerContigRemoval"></param>
/// <param name="allowErosion"></param>
internal void ValidatePadenaAssembledSeqs(string nodeName,
bool isScaffold, bool enableLowerContigRemoval, bool allowErosion)
{
// Get values from XML node.
string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
string kmerLength = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.KmerLengthNode);
string daglingThreshold = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.DanglingLinkThresholdNode);
string redundantThreshold = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.RedundantThreshold);
string library = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.LibraryName);
string stdDeviation = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.StdDeviation);
string mean = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.Mean);
string erosionThreshold = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ErosionNode);
string lowCCThreshold = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.LowCoverageContigNode);
string expectedSequences = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SequencePathNode);
// Get the input reads and build kmers
FastAParser parser = new FastAParser();
parser.Open( filePath.Replace("\\", System.IO.Path.DirectorySeparatorChar.ToString()));
IEnumerable<ISequence> sequenceReads = parser.Parse().ToList();
parser.Close ();
// Create a ParallelDeNovoAssembler instance.
ParallelDeNovoAssembler assembler = null;
try
{
assembler = new ParallelDeNovoAssembler
{
KmerLength = Int32.Parse(kmerLength, null),
DanglingLinksThreshold = Int32.Parse(daglingThreshold, null),
RedundantPathLengthThreshold = Int32.Parse(redundantThreshold, null)
};
if (enableLowerContigRemoval)
{
assembler.AllowLowCoverageContigRemoval = enableLowerContigRemoval;
assembler.ContigCoverageThreshold = double.Parse(lowCCThreshold, null);
}
if (allowErosion)
{
assembler.AllowErosion = true;
assembler.ErosionThreshold = Int32.Parse(erosionThreshold, null);
}
CloneLibrary.Instance.AddLibrary(library, float.Parse(mean, null),
float.Parse(stdDeviation, null));
IDeNovoAssembly assembly = assembler.Assemble(sequenceReads.ToList(), isScaffold);
IList<ISequence> assembledSequenceList = assembly.AssembledSequences.ToList();
HashSet<string> expected = new HashSet<string>(expectedSequences.Split(',').Select(s => s.Trim()));
AlignmentHelpers.CompareSequenceLists(expected, assembledSequenceList);
ApplicationLog.WriteLine("Padena BVT : Assemble() validation for Padena step6:step7 completed successfully");
}
finally
{
if (assembler != null)
assembler.Dispose();
}
}
示例15: ValidateDeBruijnNodeCtor
/// <summary>
/// Validate the DeBruijnNode ctor by passing the kmer and validating
/// the node object.
/// </summary>
/// <param name="nodeName">xml node name used for different testcases</param>
internal void ValidateDeBruijnNodeCtor(string nodeName)
{
string filePath = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.FilePathNode);
string kmerLength = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.KmerLengthNode);
string nodeExtensionsCount = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.NodeExtensionsCountNode);
string kmersCount = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.KmersCountNode);
string leftNodeExtensionCount = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.LeftNodeExtensionsCountNode);
string rightNodeExtensionCount = utilityObj.xmlUtil.GetTextValue(nodeName,
Constants.RightNodeExtensionsCountNode);
// Get the input reads and build kmers
IEnumerable<ISequence> sequenceReads = null;
FastAParser parser = new FastAParser();
parser.Open(filePath);
sequenceReads = parser.Parse().ToList();
parser.Close ();
// Build the kmers using this
this.KmerLength = int.Parse(kmerLength, (IFormatProvider)null);
this.SequenceReads.Clear();
this.SetSequenceReads(sequenceReads.ToList());
IList<KmersOfSequence> lstKmers = new List<KmersOfSequence>(
(new SequenceToKmerBuilder()).Build(this.SequenceReads, this.KmerLength));
// Validate the node creation
// Create node and add left node.
ISequence seq = this.SequenceReads.First();
KmerData32 kmerData = new KmerData32();
kmerData.SetKmerData(seq, lstKmers[0].Kmers.First().Positions[0], this.KmerLength);
DeBruijnNode node = new DeBruijnNode(kmerData, 1);
kmerData = new KmerData32();
kmerData.SetKmerData(seq, lstKmers[1].Kmers.First().Positions[0], this.KmerLength);
DeBruijnNode leftnode = new DeBruijnNode(kmerData, 1);
DeBruijnNode rightnode = new DeBruijnNode(kmerData, 1);
node.SetExtensionNode(false, true, leftnode);
node.SetExtensionNode(true, true, rightnode);
// Validate DeBruijnNode class properties.
Assert.AreEqual(nodeExtensionsCount, node.ExtensionsCount.ToString((IFormatProvider)null));
Assert.AreEqual(kmersCount, node.KmerCount.ToString((IFormatProvider)null));
Assert.AreEqual(leftNodeExtensionCount, node.LeftExtensionNodesCount.ToString((IFormatProvider)null));
Assert.AreEqual(rightNodeExtensionCount, node.RightExtensionNodesCount.ToString((IFormatProvider)null));
Assert.AreEqual(leftNodeExtensionCount, node.LeftExtensionNodesCount.ToString((IFormatProvider)null));
Assert.AreEqual(rightNodeExtensionCount, node.RightExtensionNodesCount.ToString((IFormatProvider)null));
ApplicationLog.WriteLine("Padena P1 : DeBruijnNode ctor() validation for Padena step2 completed successfully");
}