Beispiel #1
0
        /// <summary>
        /// Gets the paired reads.
        /// </summary>
        /// <param name="libraryInfo">Library information.</param>
        /// <returns>List of paired read.</returns>
        public IList <PairedRead> GetPairedReads(CloneLibraryInformation libraryInfo)
        {
            if (libraryInfo == null)
            {
                throw new ArgumentNullException("libraryInfo");
            }

            return(GetPairedReads(libraryInfo.MeanLengthOfInsert, libraryInfo.StandardDeviationOfInsert));
        }
Beispiel #2
0
        /// <summary>
        /// Override Equals method
        /// </summary>
        /// <param name="obj">Input Object</param>
        /// <returns>Result of comparison</returns>
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            CloneLibraryInformation info = (CloneLibraryInformation)obj;

            return((LibraryName == info.LibraryName) && (MeanLengthOfInsert == info.MeanLengthOfInsert) &&
                   (StandardDeviationOfInsert == info.StandardDeviationOfInsert));
        }
        public void ValidateLibraryName()
        {            
            CloneLibraryInformation cloneLibrary = new CloneLibraryInformation();
            
            string libraryName = this.utilityObj.xmlUtil.GetTextValue(
                                 Constants.CloneLibraryInformationNode, Constants.LibraryNameNode);

            cloneLibrary.LibraryName = libraryName;
            Assert.AreEqual(libraryName, cloneLibrary.LibraryName);

            ApplicationLog.WriteLine(string.Concat("CloneLibraryInformation BVT: Validation of Public property: Library Name",
                                    cloneLibrary.LibraryName, " completed successfully."));
        }
        /// <summary>
        /// Gets the paired reads type.
        /// </summary>
        /// <param name="pairedRead">Paired read.</param>
        /// <param name="libraryInfo">Library information.</param>
        /// <param name="useInsertLengthOfReads">
        /// If this flag is set to true then insert length will be calculated from read1 and read2,
        /// else InsertLength in spcified paired read will be used.
        /// </param>
        public static PairedReadType GetPairedReadType(PairedRead pairedRead, CloneLibraryInformation libraryInfo, bool useInsertLengthOfReads)
        {
            if (pairedRead == null)
            {
                throw new ArgumentNullException("pairedRead");
            }

            if (libraryInfo == null)
            {
                throw new ArgumentNullException("libraryInfo");
            }

            return(GetPairedReadType(pairedRead, libraryInfo.MeanLengthOfInsert, libraryInfo.StandardDeviationOfInsert, useInsertLengthOfReads));
        }
        public void ValidateInEqualityOfTwoClones()
        {
            CloneLibraryInformation cloneLibrary1 = new CloneLibraryInformation();
            CloneLibraryInformation cloneLibrary2 = new CloneLibraryInformation();

            string libraryName = this.utilityObj.xmlUtil.GetTextValue(
                                 Constants.CloneLibraryInformationNode, Constants.LibraryNameNode);
            cloneLibrary1.LibraryName = libraryName;
            cloneLibrary2.LibraryName = libraryName + "newValue";
            Assert.IsFalse(cloneLibrary1.Equals(cloneLibrary2));

            ApplicationLog.WriteLine(string.Concat("CloneLibraryInformation BVT: Validation of Overridden method: Not Equals",
                                    cloneLibrary2.LibraryName, " completed successfully."));

        }
        /// <summary>
        /// Gets the paired reads type.
        /// </summary>
        /// <param name="read1">First aligned sequence.</param>
        /// <param name="read2">Second aligned sequence.</param>
        /// <param name="libraryName">library name.</param>
        public static PairedReadType GetPairedReadType(SAMAlignedSequence read1, SAMAlignedSequence read2, string libraryName)
        {
            if (string.IsNullOrEmpty(libraryName))
            {
                throw new ArgumentNullException("libraryName");
            }

            CloneLibraryInformation libraryInfo = CloneLibrary.Instance.GetLibraryInformation(libraryName);

            if (libraryInfo == null)
            {
                throw new ArgumentOutOfRangeException("libraryName");
            }

            return(GetPairedReadType(read1, read2, libraryInfo));
        }
Beispiel #7
0
 /// <summary>
 /// Selection change event of library combo.
 /// </summary>
 /// <param name="sender">Sender object.</param>
 /// <param name="e">Selection Chnaged EventArgs.</param>
 private void OnLibraryNames_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!e.AddedItems[0].ToString().Equals("Add New Library"))
     {
         CloneLibraryInformation information = CloneLibrary.Instance.GetLibraryInformation(e.AddedItems[0].ToString());
         this.txtLibraryMean.Text = information.MeanLengthOfInsert.ToString();
         this.txtLibraryName.Text = information.LibraryName.ToString();
         this.txtLibraryStandardDeviation.Text = information.StandardDeviationOfInsert.ToString();
     }
     else
     {
         this.txtLibraryMean.Text = string.Empty;
         this.txtLibraryName.Text = string.Empty;
         this.txtLibraryStandardDeviation.Text = string.Empty;
     }
 }
Beispiel #8
0
        /// <summary>
        /// Gets the paired reads.
        /// </summary>
        /// <param name="libraryName">Name of the library present in CloneLibrary.</param>
        /// <returns>List of paired read.</returns>
        public IList <PairedRead> GetPairedReads(string libraryName)
        {
            if (string.IsNullOrEmpty(libraryName))
            {
                throw new ArgumentNullException("libraryName");
            }

            CloneLibraryInformation libraryInfo = CloneLibrary.Instance.GetLibraryInformation(libraryName);

            if (libraryInfo == null)
            {
                throw new ArgumentOutOfRangeException("libraryName");
            }

            return(GetPairedReads(libraryInfo));
        }
        /// <summary>
        /// Gets the paired reads type.
        /// </summary>
        /// <param name="pairedRead">Paired read.</param>
        /// <param name="libraryName">library name.</param>
        /// <param name="useInsertLengthOfReads">
        /// If this flag is set to true then insert length will be calculated from read1 and read2,
        /// else InsertLength in spcified paired read will be used.
        /// </param>
        public static PairedReadType GetPairedReadType(PairedRead pairedRead, string libraryName, bool useInsertLengthOfReads)
        {
            if (pairedRead == null)
            {
                throw new ArgumentNullException("pairedRead");
            }

            if (string.IsNullOrEmpty(libraryName))
            {
                throw new ArgumentNullException("libraryName");
            }

            CloneLibraryInformation libraryInfo = CloneLibrary.Instance.GetLibraryInformation(libraryName);

            if (libraryInfo == null)
            {
                throw new ArgumentOutOfRangeException("libraryName");
            }

            return(GetPairedReadType(pairedRead, libraryInfo, useInsertLengthOfReads));
        }
Beispiel #10
0
        /// <summary>
        /// Resolve repeats between two sets of deltas coming from paired reads
        /// </summary>
        /// <param name="curReadDeltas">Deltas from a read</param>
        /// <param name="mateDeltas">Deltas from mate pair</param>
        /// <returns>Selected delta out of all given deltas</returns>
        private static List <DeltaAlignment> ResolveRepeatUsingMatePair(List <DeltaAlignment> curReadDeltas, List <DeltaAlignment> mateDeltas, string libraryName)
        {
            // Check if all mate pairs are completly aligned, else return null (cannot resolve)
            if (mateDeltas.Any(a =>
            {
                return(a.SecondSequenceEnd != a.QuerySequence.Count - 1);
            }))
            {
                return(null);
            }

            // Get clone library information
            CloneLibraryInformation libraryInfo = CloneLibrary.Instance.GetLibraryInformation(libraryName);
            float mean         = libraryInfo.MeanLengthOfInsert;
            float stdDeviation = libraryInfo.StandardDeviationOfInsert;

            // Find delta with a matching distance.
            for (int indexFR = 0; indexFR < curReadDeltas.Count; indexFR++)
            {
                DeltaAlignment pair1 = curReadDeltas[indexFR];
                for (int indexRR = 0; indexRR < mateDeltas.Count; indexRR++)
                {
                    DeltaAlignment pair2    = mateDeltas[indexRR];
                    long           distance = Math.Abs(pair1.FirstSequenceStart - pair2.FirstSequenceEnd);

                    // Find delta with matching distance.
                    if (distance - mean <= stdDeviation)
                    {
                        List <DeltaAlignment> resolvedDeltas = new List <DeltaAlignment>(2);

                        resolvedDeltas.Add(pair1);
                        resolvedDeltas.Add(pair2);

                        return(resolvedDeltas);
                    }
                }
            }

            return(null);
        }
Beispiel #11
0
        /// <summary>
        /// Resolve repeats between two sets of deltas coming from paired reads
        /// </summary>
        /// <param name="curReadDeltas">Deltas from a read</param>
        /// <param name="mateDeltas">Deltas from mate pair</param>
        /// <returns>Selected delta out of all given deltas</returns>
        private static List <DeltaAlignment> ResolveRepeatUsingMatePair(IEnumerable <DeltaAlignment> curReadDeltas, IEnumerable <DeltaAlignment> mateDeltas)
        {
            // Check if all mate pairs are completly aligned, else return null (cannot resolve)
            if (mateDeltas.Any(a =>
            {
                return(a.SecondSequenceEnd != a.QuerySequence.Count - 1);
            }))
            {
                return(null);
            }

            // Get clone library information
            string libraryName = curReadDeltas.ElementAt(0).QuerySequence.ID.Split(':')[1];
            CloneLibraryInformation libraryInfo = CloneLibrary.Instance.GetLibraryInformation(libraryName);
            float mean         = libraryInfo.MeanLengthOfInsert;
            float stdDeviation = libraryInfo.StandardDeviationOfInsert;

            // Find delta with a matching distance.
            foreach (DeltaAlignment pair1 in curReadDeltas)
            {
                foreach (DeltaAlignment pair2 in mateDeltas)
                {
                    long distance = Math.Abs(pair1.FirstSequenceStart - pair2.FirstSequenceEnd);

                    // Find delta with matching distance.
                    if (distance - mean <= stdDeviation)
                    {
                        List <DeltaAlignment> resolvedDeltas = new List <DeltaAlignment>(2);

                        resolvedDeltas.Add(pair1);
                        resolvedDeltas.Add(pair2);

                        return(resolvedDeltas);
                    }
                }
            }

            return(null);
        }
 /// <summary>
 /// Gets the paired reads type.
 /// </summary>
 /// <param name="pairedRead">Paired read.</param>
 /// <param name="libraryInfo">Library information.</param>
 public static PairedReadType GetPairedReadType(PairedRead pairedRead, CloneLibraryInformation libraryInfo)
 {
     return(GetPairedReadType(pairedRead, libraryInfo, false));
 }
Beispiel #13
0
        /// <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;
            using (FastAParser parser = new FastAParser(filePath))
            {
                sequences = parser.Parse();

                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");
        }
Beispiel #14
0
 /// <summary>
 /// Gets the paired reads type.
 /// </summary>
 /// <param name="pairedRead">Paired read.</param>
 /// <param name="libraryInfo">Library information.</param>
 public static PairedReadType GetPairedReadType(PairedRead pairedRead, CloneLibraryInformation libraryInfo)
 {
     return GetPairedReadType(pairedRead, libraryInfo, false);
 }
Beispiel #15
0
        /// <summary>
        /// Gets the paired reads type.
        /// </summary>
        /// <param name="pairedRead">Paired read.</param>
        /// <param name="libraryInfo">Library information.</param>
        /// <param name="useInsertLengthOfReads">
        /// If this flag is set to true then insert length will be calculated from read1 and read2,
        /// else InsertLength in spcified paired read will be used.
        /// </param>
        public static PairedReadType GetPairedReadType(PairedRead pairedRead, CloneLibraryInformation libraryInfo, bool useInsertLengthOfReads)
        {
            if (pairedRead == null)
            {
                throw new ArgumentNullException("pairedRead");
            }

            if (libraryInfo == null)
            {
                throw new ArgumentNullException("libraryInfo");
            }

            return GetPairedReadType(pairedRead, libraryInfo.MeanLengthOfInsert, libraryInfo.StandardDeviationOfInsert, useInsertLengthOfReads);
        }
Beispiel #16
0
        /// <summary>
        /// Gets the paired reads type.
        /// </summary>
        /// <param name="read1">First aligned sequence.</param>
        /// <param name="read2">Second aligned sequence.</param>
        /// <param name="libraryInfo">Library information.</param>
        public static PairedReadType GetPairedReadType(SAMAlignedSequence read1, SAMAlignedSequence read2, CloneLibraryInformation libraryInfo)
        {
            if (libraryInfo == null)
            {
                throw new ArgumentNullException("libraryInfo");
            }

            return GetPairedReadType(read1, read2, libraryInfo.MeanLengthOfInsert, libraryInfo.StandardDeviationOfInsert);
        }
Beispiel #17
0
        /// <summary>
        /// Validate GetPaired method
        /// </summary>
        /// <param name="nodeName">XML node name</param>
        /// <param name="pams">GetPairedReads method parameters</param>
        void ValidatePairedReads(string nodeName, GetPairedReadParameters pams)
        {
            // Get input and output values from xml node.
            string bamFilePath = utilityObj.xmlUtil.GetTextValue(nodeName,
                                                                 Constants.FilePathNode);
            string expectedAlignedSeqFilePath = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpectedSequence);
            string mean = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.MeanNode);
            string deviation = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.DeviationValueNode);
            string library = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.LibraryNameNode);
            string pairedReadsCount = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.PairedReadsNode);

            string[] insertLength = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.InsertLengthNode).Split(',');
            string[] pairedReadType = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.PairedReadTypeNode).Split(',');

            SequenceAlignmentMap seqAlignment = null;
            IList <PairedRead>   pairedReads  = null;
            BAMParser            bamParser    = new BAMParser();
            FastAParser          parserObj    = new FastAParser(expectedAlignedSeqFilePath);

            try
            {
                seqAlignment = bamParser.Parse(bamFilePath);
                IEnumerable <ISequence> expectedSequences = parserObj.Parse();

                switch (pams)
                {
                case GetPairedReadParameters.GetPairedReadWithParameters:
                    pairedReads = seqAlignment.GetPairedReads(float.Parse(mean, (IFormatProvider)null),
                                                              float.Parse(deviation, (IFormatProvider)null));
                    break;

                case GetPairedReadParameters.GetPairedReadWithLibraryName:
                    pairedReads = seqAlignment.GetPairedReads(library);
                    break;

                case GetPairedReadParameters.GetPairedReadWithCloneLibraryInfo:
                    CloneLibraryInformation libraryInfo =
                        CloneLibrary.Instance.GetLibraryInformation(library);
                    pairedReads = seqAlignment.GetPairedReads(libraryInfo);
                    break;

                case GetPairedReadParameters.Default:
                    pairedReads = seqAlignment.GetPairedReads();
                    break;
                }

                Assert.AreEqual(pairedReadsCount, pairedReads.Count.ToString((IFormatProvider)null));

                int i = 0;
                foreach (PairedRead read in pairedReads)
                {
                    Assert.AreEqual(insertLength[i], read.InsertLength.ToString((IFormatProvider)null));
                    Assert.AreEqual(pairedReadType[i], read.PairedType.ToString());

                    foreach (SAMAlignedSequence seq in read.Reads)
                    {
                        Assert.AreEqual(new string(expectedSequences.ElementAt(i).Select(a => (char)a).ToArray()),
                                        new string(seq.QuerySequence.Select(a => (char)a).ToArray()));

                        // Log to NUNIT GUI.
                        ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                               "BAM Parser BVT : Validated Paired read :{0} successfully",
                                                               seq.QuerySequence.ToString()));
                    }
                    i++;
                }
            }

            finally
            {
                bamParser.Dispose();
            }
        }
Beispiel #18
0
        /// <summary>
        /// Gets the paired reads.
        /// </summary>
        /// <param name="libraryInfo">Library information.</param>
        /// <returns>List of paired read.</returns>
        public IList<PairedRead> GetPairedReads(CloneLibraryInformation libraryInfo)
        {
            if (libraryInfo == null)
            {
                throw new ArgumentNullException("libraryInfo");
            }

            return GetPairedReads(libraryInfo.MeanLengthOfInsert, libraryInfo.StandardDeviationOfInsert);
        }
        /// <summary>
        /// Gets the paired reads type.
        /// </summary>
        /// <param name="read1">First aligned sequence.</param>
        /// <param name="read2">Second aligned sequence.</param>
        /// <param name="libraryInfo">Library information.</param>
        public static PairedReadType GetPairedReadType(SAMAlignedSequence read1, SAMAlignedSequence read2, CloneLibraryInformation libraryInfo)
        {
            if (libraryInfo == null)
            {
                throw new ArgumentNullException("libraryInfo");
            }

            return(GetPairedReadType(read1, read2, libraryInfo.MeanLengthOfInsert, libraryInfo.StandardDeviationOfInsert));
        }
Beispiel #20
0
        /// <summary>
        /// Validate ParallelDenovoAssembler class properties.
        /// </summary>
        /// <param name="nodeName">xml node name used for different testcases</param>
        internal void ParallelDenovoAssemblyProperties(string nodeName)
        {
            // Get values from XML node.
            string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
            string kmerLength = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.KmerLengthNode);
            string library = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.LibraryName);
            string StdDeviation = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.StdDeviation);
            string mean = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.Mean);

            // Get the input reads and build kmers
            IEnumerable<ISequence> sequenceReads = null;
            using (FastAParser parser = new FastAParser(filePath))
            {
                sequenceReads = parser.Parse();

                // 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 the contigs
                this.KmerLength = int.Parse(kmerLength, (IFormatProvider)null);
                this.SequenceReads.Clear();

                this.SetSequenceReads(sequenceReads.ToList());
                this.CreateGraph();
                this.UnDangleGraph();
                this.RedundantPathsPurger =
                    new RedundantPathsPurger(int.Parse(kmerLength, (IFormatProvider)null) + 1);
                this.RemoveRedundancy();
                this.ContigBuilder = new SimplePathContigBuilder();

                // Build contigs
                IEnumerable<ISequence> contigs = this.BuildContigs();

                CloneLibraryInformation cloneLibInfoObj = new CloneLibraryInformation();
                cloneLibInfoObj.LibraryName = library;
                cloneLibInfoObj.MeanLengthOfInsert = float.Parse(mean, (IFormatProvider)null);
                cloneLibInfoObj.StandardDeviationOfInsert = float.Parse(StdDeviation, (IFormatProvider)null);

                // Build scaffolds.
                CloneLibrary.Instance.AddLibrary(library, float.Parse(mean, (IFormatProvider)null),
                float.Parse(StdDeviation, (IFormatProvider)null));

                IEnumerable<ISequence> scaffolds = BuildScaffolds(contigs.ToList());
                PadenaAssembly denovoAssembly = new PadenaAssembly();

                denovoAssembly.AddContigs(contigs);
                denovoAssembly.AddScaffolds(scaffolds);

                Assert.AreEqual(denovoAssembly.ContigSequences.Count(),
                    contigs.Count());
                Assert.AreEqual(denovoAssembly.Scaffolds.Count(), scaffolds.Count());
                Assert.IsNull(denovoAssembly.Documentation);

                // Validates the Clone Library for the existing clone
                CloneLibraryInformation actualObj = CloneLibrary.Instance.GetLibraryInformation(library);
                Assert.IsTrue(actualObj.Equals(cloneLibInfoObj));

                ApplicationLog.WriteLine("CloneLibraryInformation Equals() is successfully validated");
            }

            // Validate ParallelDenovoAssembler properties.
            ApplicationLog.WriteLine(
                @"Padena BVT : Validated ParallelDenovo Assembly properties");
        }