PageRenderTime 56ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/Tests/Bio.TestAutomation/IO/BAM/BAMBvtTestCases.cs

#
C# | 1226 lines | 848 code | 111 blank | 267 comment | 23 complexity | 9cc2fe16e65b1f2d77cd1f125059027b MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, CPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. // *****************************************************************
  2. // Copyright (c) Microsoft. All rights reserved.
  3. // This code is licensed under the Apache License, Version 2.0.
  4. // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
  5. // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
  6. // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
  7. // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
  8. // *****************************************************************
  9. /****************************************************************************
  10. * BAMBvtTestCases.cs
  11. *
  12. * This file contains the BAM - Parsers and Formatters Bvt test cases.
  13. *
  14. ***************************************************************************/
  15. using System;
  16. using System.Linq;
  17. using System.Collections.Generic;
  18. using System.IO;
  19. using System.Text;
  20. using Bio.TestAutomation.Util;
  21. using Bio.Util.Logging;
  22. using Microsoft.VisualStudio.TestTools.UnitTesting;
  23. using Bio.IO.SAM;
  24. using Bio.IO.BAM;
  25. using Bio.IO.FastA;
  26. using Bio.IO;
  27. using System.Globalization;
  28. using Bio;
  29. namespace Bio.TestAutomation.IO.BAM
  30. {
  31. /// <summary>
  32. /// BAM Bvt parser and formatter Test case implementation.
  33. /// </summary>
  34. [TestClass]
  35. public class BAMBvtTestCases
  36. {
  37. #region Enums
  38. /// <summary>
  39. /// BAM Parser ctor parameters used for different test cases.
  40. /// </summary>
  41. enum BAMParserParameters
  42. {
  43. StreamReader,
  44. FileName,
  45. ParseRangeFileName,
  46. ParseRangeWithIndex,
  47. ParserWithEncoding,
  48. IndexFile,
  49. IndexStreamWriter,
  50. StreamWriter,
  51. ParseRangeUsingRefSeq,
  52. ParseRangeUsingRefSeqAndFlag,
  53. ParseRangeUsingRefSeqUsingIndex,
  54. ParseRangeUsingIndexesAndFlag,
  55. Default
  56. }
  57. /// <summary>
  58. /// PairedReadType method parameters
  59. /// </summary>
  60. enum GetPairedReadTypeParameters
  61. {
  62. PaireReadTypeUsingLibraryName,
  63. PaireReadTypeUsingCloneLibraryInfo,
  64. PaireReadTypeUsingMeanAndDeviation,
  65. PaireReadTypeUsingReadsAndLibraryInfo,
  66. PaireReadTypeUsingReadsAndLibrary,
  67. GetInsertLength,
  68. Default
  69. }
  70. /// <summary>
  71. /// Get Paired parameters
  72. /// </summary>
  73. enum GetPairedReadParameters
  74. {
  75. GetPairedReadWithParameters,
  76. GetPairedReadWithLibraryName,
  77. GetPairedReadWithCloneLibraryInfo,
  78. Default
  79. }
  80. #endregion Enums
  81. #region Global Variables
  82. Utility utilityObj = new Utility(@"TestUtils\SAMBAMTestData\SAMBAMTestsConfig.xml");
  83. #endregion Global Variables
  84. #region Constructor
  85. /// <summary>
  86. /// Static constructor to open log and make other settings needed for test
  87. /// </summary>
  88. static BAMBvtTestCases()
  89. {
  90. Trace.Set(Trace.SeqWarnings);
  91. if (!ApplicationLog.Ready)
  92. {
  93. ApplicationLog.Open("bio.automation.log");
  94. }
  95. }
  96. #endregion Constructor
  97. #region BAM Parser Test Cases
  98. /// <summary>
  99. /// Validate BAM Parse(Stream) by passing valid BAM file
  100. /// Input : Small size BAM file.
  101. /// Output : Validation of aligned sequence.
  102. /// </summary>
  103. [TestMethod]
  104. [Priority(0)]
  105. [TestCategory("Priority0")]
  106. public void ValidateBAMParserWithStreamReader()
  107. {
  108. ValidateBAMParser(Constants.SmallSizeBAMFileNode,
  109. BAMParserParameters.StreamReader, false);
  110. }
  111. /// <summary>
  112. /// Validate BAM Parse(filename) by passing valid BAM file
  113. /// Input : Small size BAM file.
  114. /// Output : Validation of aligned sequence.
  115. /// </summary>
  116. [TestMethod]
  117. [Priority(0)]
  118. [TestCategory("Priority0")]
  119. public void ValidateBAMParserWithFilePath()
  120. {
  121. ValidateBAMParser(Constants.SmallSizeBAMFileNode,
  122. BAMParserParameters.FileName, false);
  123. }
  124. /// <summary>
  125. /// Validate BAM ParseRange(filename,RefIndex) by passing valid BAM file
  126. /// Input : Small size BAM file.
  127. /// Output : Validation of aligned sequence.
  128. /// </summary>
  129. [TestMethod]
  130. [Priority(0)]
  131. [TestCategory("Priority0")]
  132. public void ValidateBAMParserRangeWithFilePath()
  133. {
  134. ValidateBAMParser(Constants.SmallSizeBAMFileNode,
  135. BAMParserParameters.ParseRangeFileName, false);
  136. }
  137. /// <summary>
  138. /// Validate BAM ParseRange(filename,refSeqName)
  139. /// by passing valid BAM file
  140. /// Input : Small size BAM file.
  141. /// Output : Validation of aligned sequence.
  142. /// </summary>
  143. [TestMethod]
  144. [Priority(0)]
  145. [TestCategory("Priority0")]
  146. public void ValidateBAMParseRangeUsingRefSeqName()
  147. {
  148. ValidateBAMParser(Constants.BAMFileWithSequenceRangeRefSeqsNode,
  149. BAMParserParameters.ParseRangeUsingRefSeq, false);
  150. }
  151. /// <summary>
  152. /// Validate BAM ParseRange(filename,refSeqName,flag)
  153. /// by passing valid BAM file
  154. /// Input : Small size BAM file.
  155. /// Output : Validation of aligned sequence.
  156. /// </summary>
  157. [TestMethod]
  158. [Priority(0)]
  159. [TestCategory("Priority0")]
  160. public void ValidateBAMParseRangeUsingRefSeqNameAndFlag()
  161. {
  162. ValidateBAMParser(Constants.BAMFileWithSequenceRangeRefSeqsNode,
  163. BAMParserParameters.ParseRangeUsingRefSeqAndFlag, false);
  164. }
  165. /// <summary>
  166. /// Validate BAM ParseRange(filename,refSeqName,Start,end)
  167. /// by passing valid BAM file
  168. /// Input : Small size BAM file.
  169. /// Output : Validation of aligned sequence.
  170. /// </summary>
  171. [TestMethod]
  172. [Priority(0)]
  173. [TestCategory("Priority0")]
  174. public void ValidateBAMParseRangeUsingStartAndEndIndex()
  175. {
  176. ValidateBAMParser(Constants.SeqRangeBAMFileNode,
  177. BAMParserParameters.ParseRangeUsingRefSeqUsingIndex, false);
  178. }
  179. /// <summary>
  180. /// Validate BAM ParseRange(filename,refSeqName,Start,end,bool)
  181. /// by passing valid BAM file
  182. /// Input : Small size BAM file.
  183. /// Output : Validation of aligned sequence.
  184. /// </summary>
  185. [TestMethod]
  186. [Priority(0)]
  187. [TestCategory("Priority0")]
  188. public void ValidateBAMParseRangeUsingStartAndEndIndexWithFlag()
  189. {
  190. ValidateBAMParser(Constants.SeqRangeBAMFileNode,
  191. BAMParserParameters.ParseRangeUsingIndexesAndFlag, false);
  192. }
  193. /// <summary>
  194. /// Validate BAM GetPairedRead(Mean,Deviation)
  195. /// by passing valid BAM file
  196. /// Input : Small size BAM file.
  197. /// Output : Validation of aligned sequence.
  198. /// </summary>
  199. [TestMethod]
  200. [Priority(0)]
  201. [TestCategory("Priority0")]
  202. public void ValidatePairedReadUsingMeanAndDeviation()
  203. {
  204. ValidatePairedReads(Constants.PairedReadForSmallFileNodeName,
  205. GetPairedReadParameters.GetPairedReadWithParameters);
  206. }
  207. /// <summary>
  208. /// Validate BAM GetPairedRead()
  209. /// by passing valid BAM file
  210. /// Input : Small size BAM file.
  211. /// Output : Validation of aligned sequence.
  212. /// </summary>
  213. [TestMethod]
  214. [Priority(0)]
  215. [TestCategory("Priority0")]
  216. public void ValidatePairedReads()
  217. {
  218. ValidatePairedReads(Constants.PairedReadForSmallFileNodeName,
  219. GetPairedReadParameters.Default);
  220. }
  221. /// <summary>
  222. /// Validate BAM GetPairedRead(libraryName)
  223. /// by passing valid BAM file
  224. /// Input : Small size BAM file.
  225. /// Output : Validation of aligned sequence.
  226. /// </summary>
  227. [TestMethod]
  228. [Priority(0)]
  229. [TestCategory("Priority0")]
  230. public void ValidatePairedReadUsingLibraryName()
  231. {
  232. ValidatePairedReads(Constants.PairedReadForSmallFileNodeName,
  233. GetPairedReadParameters.GetPairedReadWithLibraryName);
  234. }
  235. /// <summary>
  236. /// Validate BAM GetPairedRead(CloneLibraryInfo)
  237. /// by passing valid BAM file
  238. /// Input : Small size BAM file.
  239. /// Output : Validation of aligned sequence.
  240. /// </summary>
  241. [TestMethod]
  242. [Priority(0)]
  243. [TestCategory("Priority0")]
  244. public void ValidatePairedReadUsingCloneLibraryInfo()
  245. {
  246. ValidatePairedReads(Constants.PairedReadForSmallFileNodeName,
  247. GetPairedReadParameters.GetPairedReadWithCloneLibraryInfo);
  248. }
  249. /// <summary>
  250. /// Validate BAM GetPairedReadType(PairedRead,CloneLibraryInfo)
  251. /// by passing valid BAM file
  252. /// Input : Small size BAM file.
  253. /// Output : Validation of aligned sequence.
  254. /// </summary>
  255. [TestMethod]
  256. [Priority(0)]
  257. [TestCategory("Priority0")]
  258. public void ValidatePairedReadTypeUsingCloneLibraryInfo()
  259. {
  260. ValidatePairedReadTypes(Constants.PairedReadTypesNode,
  261. GetPairedReadTypeParameters.PaireReadTypeUsingCloneLibraryInfo);
  262. }
  263. /// <summary>
  264. /// Validate BAM GetPairedReadType(PairedRead,Library)
  265. /// by passing valid BAM file
  266. /// Input : Small size BAM file.
  267. /// Output : Validation of aligned sequence.
  268. /// </summary>
  269. [TestMethod]
  270. [Priority(0)]
  271. [TestCategory("Priority0")]
  272. public void ValidatePairedReadTypeUsingLibrary()
  273. {
  274. ValidatePairedReadTypes(Constants.PairedReadTypesNode,
  275. GetPairedReadTypeParameters.PaireReadTypeUsingLibraryName);
  276. }
  277. /// <summary>
  278. /// Validate BAM GetPairedReadType(PairedRead,Mean,Devn)
  279. /// by passing valid BAM file
  280. /// Input : Small size BAM file.
  281. /// Output : Validation of aligned sequence.
  282. /// </summary>
  283. [TestMethod]
  284. [Priority(0)]
  285. [TestCategory("Priority0")]
  286. public void ValidatePairedReadTypeUsingMeanAndDeviation()
  287. {
  288. ValidatePairedReadTypes(Constants.PairedReadTypesForMeanAndDeviationNode,
  289. GetPairedReadTypeParameters.PaireReadTypeUsingMeanAndDeviation);
  290. }
  291. /// <summary>
  292. /// Validate BAM GetPairedReadType(Read1,Read2,Library)
  293. /// by passing valid BAM file
  294. /// Input : Small size BAM file.
  295. /// Output : Validation of aligned sequence.
  296. /// </summary>
  297. [TestMethod]
  298. [Priority(0)]
  299. [TestCategory("Priority0")]
  300. public void ValidatePairedReadTypeUsingReadsAndLibrary()
  301. {
  302. ValidatePairedReadTypes(Constants.PairedReadTypesForLibraryInfoNode,
  303. GetPairedReadTypeParameters.PaireReadTypeUsingReadsAndLibrary);
  304. }
  305. /// <summary>
  306. /// Validate BAM GetPairedReadType(Read1,Read2,CloneLibraryInfo)
  307. /// by passing valid BAM file
  308. /// Input : Small size BAM file.
  309. /// Output : Validation of aligned sequence.
  310. /// </summary>
  311. [TestMethod]
  312. [Priority(0)]
  313. [TestCategory("Priority0")]
  314. public void ValidatePairedReadTypeUsingReadsAndCloneLibraryInfo()
  315. {
  316. ValidatePairedReadTypes(Constants.PairedReadTypesForLibraryInfoNode,
  317. GetPairedReadTypeParameters.PaireReadTypeUsingReadsAndLibraryInfo);
  318. }
  319. /// <summary>
  320. /// Validate BAM GetInsertLength(Read1,Read2)
  321. /// by passing valid BAM file
  322. /// Input : Small size BAM file.
  323. /// Output : Validation of aligned sequence.
  324. /// </summary>
  325. [TestMethod]
  326. [Priority(0)]
  327. [TestCategory("Priority0")]
  328. public void ValidateInsertLengthForPairedReads()
  329. {
  330. ValidatePairedReadTypes(Constants.PairedReadTypesForLibraryInfoNode,
  331. GetPairedReadTypeParameters.GetInsertLength);
  332. }
  333. /// <summary>
  334. /// Validates the GetInsertLength method with a bool value passed for validate
  335. /// Input : Small size BAM file.
  336. /// Output : Validation of aligned sequence.
  337. /// </summary>
  338. /// </summary>
  339. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "System.String.Split(System.Char[])"), TestMethod]
  340. [Priority(0)]
  341. [TestCategory("Priority0")]
  342. public void ValidateGetInsertLengthWithValidate()
  343. {
  344. // Get input and output values from xml node.
  345. string bamFilePath = utilityObj.xmlUtil.GetTextValue(Constants.PairedReadTypesForLibraryInfoNode,
  346. Constants.FilePathNode);
  347. string mean = utilityObj.xmlUtil.GetTextValue(
  348. Constants.PairedReadTypesForLibraryInfoNode, Constants.MeanNode);
  349. string deviation = utilityObj.xmlUtil.GetTextValue(
  350. Constants.PairedReadTypesForLibraryInfoNode, Constants.DeviationValueNode);
  351. string[] insertLength = utilityObj.xmlUtil.GetTextValue(
  352. Constants.PairedReadTypesForLibraryInfoNode, Constants.InsertLengthNode).Split(',');
  353. IList<PairedRead> pairedReads = null;
  354. using (BAMParser bamParser = new BAMParser())
  355. {
  356. SequenceAlignmentMap seqAlignmentMapObj = bamParser.Parse(bamFilePath);
  357. int i = 0;
  358. try
  359. {
  360. pairedReads = seqAlignmentMapObj.GetPairedReads(float.Parse(mean, (IFormatProvider)null),
  361. float.Parse(deviation, (IFormatProvider)null));
  362. foreach (PairedRead read in pairedReads)
  363. {
  364. //pass true for validate parameter
  365. int length = PairedRead.GetInsertLength(read.Read1, read.Read2, true);
  366. Assert.AreEqual(length.ToString((IFormatProvider)null), insertLength[i]);
  367. i++;
  368. }
  369. ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
  370. "BAM Parser BVT : Validated GetInsertLength Successfully"));
  371. }
  372. finally
  373. {
  374. bamParser.Dispose();
  375. }
  376. }
  377. }
  378. #endregion BAM Parser Test Cases
  379. #region BAM Formatter Test Cases
  380. /// <summary>
  381. /// Validate format(seqAlignment,bamFile,indexFile) by
  382. /// parsing formatting valid BAM file.
  383. /// Input : Small size BAM file and index file.
  384. /// Output : Validation of aligned sequence.
  385. /// </summary>
  386. [TestMethod]
  387. [Priority(0)]
  388. [TestCategory("Priority0")]
  389. public void ValidateBAMFormatterWithIndexFile()
  390. {
  391. ValidateBAMFormatter(Constants.SmallSizeBAMFileNode,
  392. BAMParserParameters.IndexFile);
  393. }
  394. /// <summary>
  395. /// Validate format(seqAlignment, Stream) by
  396. /// parsing formatting valid BAM file.
  397. /// Input : Small size BAM file.
  398. /// Output : Validation of aligned sequence.
  399. /// </summary>
  400. [TestMethod]
  401. [Priority(0)]
  402. [TestCategory("Priority0")]
  403. public void ValidateBAMFormatterWithStreamWriter()
  404. {
  405. ValidateBAMFormatter(Constants.SmallSizeBAMFileNode,
  406. BAMParserParameters.StreamWriter);
  407. }
  408. /// <summary>
  409. /// Validate format(seqAlignment, filename) by
  410. /// parsing formatting valid BAM file.
  411. /// Input : Small size BAM file.
  412. /// Output : Validation of aligned sequence.
  413. /// </summary>
  414. [TestMethod]
  415. [Priority(0)]
  416. [TestCategory("Priority0")]
  417. public void ValidateBAMFormatterWithFilename()
  418. {
  419. ValidateBAMFormatter(Constants.SmallSizeBAMFileNode,
  420. BAMParserParameters.FileName);
  421. }
  422. /// <summary>
  423. /// Validate create bam index file
  424. /// </summary>
  425. [TestMethod]
  426. [Priority(0)]
  427. [TestCategory("Priority0")]
  428. public void ValidateCreateBAMIndexFile()
  429. {
  430. string bamFilePath = utilityObj.xmlUtil.GetTextValue(Constants.MediumSizeBAMFileNode,
  431. Constants.FilePathNode);
  432. BAMFormatter.CreateBAMIndexFile(bamFilePath);
  433. }
  434. #endregion BAM Formatter Test Cases.
  435. #region BAM Sort Test Cases
  436. /// <summary>
  437. /// Validates BAM Sort on ReadNames
  438. /// </summary>
  439. [TestMethod]
  440. [Priority(0)]
  441. [TestCategory("Priority0")]
  442. public void ValidateSortByReadNames()
  443. {
  444. using (BAMParser parser = new BAMParser())
  445. {
  446. string bamFilePath = utilityObj.xmlUtil.GetTextValue(Constants.MediumSizeBAMFileNode,
  447. Constants.FilePathNode);
  448. SequenceAlignmentMap seqAlignment = parser.Parse(bamFilePath);
  449. this.ValidateSort(seqAlignment, BAMSortByFields.ReadNames);
  450. }
  451. }
  452. /// <summary>
  453. /// Validates BAM Sort by ChromosomeCoordinates
  454. /// </summary>
  455. [TestMethod]
  456. [Priority(0)]
  457. [TestCategory("Priority0")]
  458. public void ValidateSortByChromosomeCoordinates()
  459. {
  460. using (BAMParser parser = new BAMParser())
  461. {
  462. string bamFilePath = utilityObj.xmlUtil.GetTextValue(Constants.MediumSizeBAMFileNode,
  463. Constants.FilePathNode);
  464. Assert.IsNotNull(bamFilePath);
  465. SequenceAlignmentMap seqAlignment = parser.Parse(bamFilePath);
  466. this.ValidateSort(seqAlignment, BAMSortByFields.ChromosomeCoordinates);
  467. }
  468. }
  469. /// <summary>
  470. /// Validates BAM Sort by ChromosomeNameAndCoordinates
  471. /// </summary>
  472. [TestMethod]
  473. [Priority(0)]
  474. [TestCategory("Priority0")]
  475. public void ValidateSortByChromosomeNameAndCoordinates()
  476. {
  477. using (BAMParser parser = new BAMParser())
  478. {
  479. string bamFilePath = utilityObj.xmlUtil.GetTextValue(Constants.MediumSizeBAMFileNode,
  480. Constants.FilePathNode);
  481. Assert.IsNotNull(bamFilePath);
  482. SequenceAlignmentMap seqAlignment = parser.Parse(bamFilePath);
  483. this.ValidateSort(seqAlignment, BAMSortByFields.ChromosomeNameAndCoordinates);
  484. }
  485. }
  486. #endregion BAM Sort Test Cases
  487. #region SAM BAM InterConversion Test Cases
  488. /// <summary>
  489. /// Validate BAM to SAM file conversion.
  490. /// Input : BAM file.
  491. /// Output : SAM file.
  492. /// </summary>
  493. [TestMethod]
  494. [Priority(0)]
  495. [TestCategory("Priority0")]
  496. public void ValidateBAMToSAMConversion()
  497. {
  498. // Get values from xml config file.
  499. string expectedSamFilePath = utilityObj.xmlUtil.GetTextValue(Constants.BAMToSAMConversionNode,
  500. Constants.FilePathNode1);
  501. string bamFilePath = utilityObj.xmlUtil.GetTextValue(Constants.BAMToSAMConversionNode,
  502. Constants.FilePathNode);
  503. using (BAMParser bamParserObj = new BAMParser())
  504. {
  505. using (SAMParser samParserObj = new SAMParser())
  506. {
  507. SAMFormatter samFormatterObj = new SAMFormatter();
  508. SequenceAlignmentMap samSeqAlignment = null;
  509. SequenceAlignmentMap bamSeqAlignment = null;
  510. // Parse expected SAM file.
  511. SequenceAlignmentMap expextedSamAlignmentObj = samParserObj.Parse(
  512. expectedSamFilePath);
  513. // Parse a BAM file.
  514. bamSeqAlignment = bamParserObj.Parse(bamFilePath);
  515. // Format BAM sequenceAlignment object to SAM file.
  516. samFormatterObj.Format(bamSeqAlignment, Constants.SAMTempFileName);
  517. // Parse a formatted SAM file.
  518. samSeqAlignment = samParserObj.Parse(Constants.SAMTempFileName);
  519. // Validate converted SAM file with expected SAM file.
  520. Assert.IsTrue(CompareSequencedAlignmentHeader(samSeqAlignment, expextedSamAlignmentObj));
  521. // Validate SAM file aligned sequences.
  522. Assert.IsTrue(CompareAlignedSequences(samSeqAlignment, expextedSamAlignmentObj));
  523. }
  524. }
  525. // Log message to VSTest GUI.
  526. ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
  527. "BAM Parser BVT : Validated the BAM->SAM conversion successfully"));
  528. Console.WriteLine(string.Format((IFormatProvider)null,
  529. "BAM Parser BVT : Validated the BAM->SAM conversion successfully"));
  530. // Delete temporary file.
  531. File.Delete(Constants.SAMTempFileName);
  532. ApplicationLog.WriteLine("Deleted the temp file created.");
  533. }
  534. /// <summary>
  535. /// Validate SAM to BAM file conversion.
  536. /// Input : SAM file.
  537. /// Output : BAM file.
  538. /// </summary>
  539. [TestMethod]
  540. [Priority(0)]
  541. [TestCategory("Priority0")]
  542. public void ValidateSAMToBAMConversion()
  543. {
  544. // Get values from xml config file.
  545. string expectedBamFilePath = utilityObj.xmlUtil.GetTextValue(
  546. Constants.BAMToSAMConversionNode, Constants.FilePathNode);
  547. string samFilePath = utilityObj.xmlUtil.GetTextValue(
  548. Constants.BAMToSAMConversionNode, Constants.FilePathNode1);
  549. using (BAMParser bamParserObj = new BAMParser())
  550. {
  551. using (SAMParser samParserObj = new SAMParser())
  552. {
  553. BAMFormatter bamFormatterObj = new BAMFormatter();
  554. SequenceAlignmentMap samSeqAlignment = null;
  555. SequenceAlignmentMap bamSeqAlignment = null;
  556. // Parse expected BAM file.
  557. SequenceAlignmentMap expextedBamAlignmentObj = bamParserObj.Parse(
  558. expectedBamFilePath);
  559. // Parse a SAM file.
  560. samSeqAlignment = samParserObj.Parse(samFilePath);
  561. // Format SAM sequenceAlignment object to BAM file.
  562. bamFormatterObj.Format(samSeqAlignment, Constants.BAMTempFileName);
  563. // Parse a formatted BAM file.
  564. bamSeqAlignment = bamParserObj.Parse(Constants.BAMTempFileName);
  565. // Validate converted BAM file with expected BAM file.
  566. Assert.IsTrue(CompareSequencedAlignmentHeader(bamSeqAlignment, expextedBamAlignmentObj));
  567. // Validate BAM file aligned sequences.
  568. Assert.IsTrue(CompareAlignedSequences(bamSeqAlignment, expextedBamAlignmentObj));
  569. }
  570. }
  571. // Log message to VSTest GUI.
  572. ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
  573. "BAM Parser BVT : Validated the SAM->BAM conversion successfully"));
  574. Console.WriteLine(string.Format((IFormatProvider)null,
  575. "BAM Parser BVT : Validated the SAM->BAM conversion successfully"));
  576. // Delete temporary file.
  577. File.Delete(Constants.BAMTempFileName);
  578. ApplicationLog.WriteLine("Deleted the temp file created.");
  579. }
  580. #endregion SAM BAM InterConversion Test Cases
  581. #region Helper Methods
  582. /// <summary>
  583. /// calls the Sort() method in BAMSort and checks if a BAMSortedIndex is returned.
  584. /// </summary>
  585. /// <param name="seqAlignment">SequenceAlignmentMap to be sorted</param>
  586. /// <param name="sortType">The sort type to be used when sorting using BAMSort</param>
  587. void ValidateSort(SequenceAlignmentMap seqAlignment, BAMSortByFields sortType)
  588. {
  589. BAMSort sorter = new BAMSort(seqAlignment, sortType);
  590. IList<BAMSortedIndex> sortedIndex = sorter.Sort();
  591. Assert.IsNotNull(sortedIndex);
  592. Assert.IsTrue(IsSortedIndex(sortedIndex,sortType));
  593. }
  594. /// <summary>
  595. /// Checks if the BAMSorted Index is sorted
  596. /// </summary>
  597. /// <param name="sortedIndex">The BAMSortedIndex that needs to be checked for proper sorting</param>
  598. /// <param name="sortType">The sort type to be used when sorting using BAMSort</param>
  599. /// <returns>true if properly sorted</returns>
  600. bool IsSortedIndex(IList<BAMSortedIndex> sortedIndex, BAMSortByFields sortType)
  601. {
  602. bool isSorted = true;
  603. string matchFile1 = utilityObj.xmlUtil.GetTextValue(Constants.MediumSizeBAMFileNode,
  604. Constants.MediumSizeBAMSortOutputMatchReadNames);
  605. string matchFile2 = utilityObj.xmlUtil.GetTextValue(Constants.MediumSizeBAMFileNode,
  606. Constants.MediumSizeBAMSortOutputMatchChromosomeCoordinates);
  607. string matchFile3 = utilityObj.xmlUtil.GetTextValue(Constants.MediumSizeBAMFileNode,
  608. Constants.MediumSizeBAMSortOutputMatchChromosomeNameAndCoordinates);
  609. string temp = string.Empty;
  610. switch (sortType)
  611. {
  612. case BAMSortByFields.ReadNames:
  613. temp = File.ReadAllText(matchFile1);
  614. Assert.AreEqual(temp, getSortedOutput(sortedIndex));
  615. break;
  616. case BAMSortByFields.ChromosomeCoordinates:
  617. temp = File.ReadAllText(matchFile2);
  618. Assert.AreEqual(temp, getSortedOutput(sortedIndex));
  619. break;
  620. case BAMSortByFields.ChromosomeNameAndCoordinates:
  621. temp = File.ReadAllText(matchFile3);
  622. Assert.AreEqual(temp, getSortedOutput(sortedIndex));
  623. break;
  624. default:
  625. break;
  626. }
  627. return isSorted;
  628. }
  629. /// <summary>
  630. /// Gets the sorted outpur from the BAMSortedIndex
  631. /// </summary>
  632. /// <param name="sortedIndex">The BAMSortedIndex for which sortedindex values are required.</param>
  633. /// <returns>Sorted index values as a string</returns>
  634. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
  635. private string getSortedOutput(IList<BAMSortedIndex> sortedIndex)
  636. {
  637. using (BAMParser parser = new BAMParser())
  638. {
  639. BAMSortedIndex index = sortedIndex.ElementAt(0);
  640. IEnumerator<int> sortedIndexList = index.GetEnumerator();
  641. StringBuilder temp = new StringBuilder();
  642. temp.Append(sortedIndexList.Current.ToString((IFormatProvider)null));
  643. while (sortedIndexList.MoveNext())
  644. {
  645. temp.Append("|" + sortedIndexList.Current.ToString((IFormatProvider)null));
  646. }
  647. Assert.IsNotNull(temp);
  648. Assert.AreNotEqual(0, temp.Length);
  649. sortedIndexList.Dispose();
  650. return temp.ToString();
  651. }
  652. }
  653. /// <summary>
  654. /// Parse BAM and validate parsed aligned sequences and its properties.
  655. /// </summary>
  656. /// <param name="nodeName">Different xml nodes used for different test cases</param>
  657. /// <param name="BAMParserPam">BAM Parse method parameters</param>
  658. /// <param name="IsEncoding">True for BAMParser ctor with encoding.
  659. /// False otherwise </param>
  660. void ValidateBAMParser(string nodeName,
  661. BAMParserParameters BAMParserPam,
  662. bool IsReferenceIndex)
  663. {
  664. // Get input and output values from xml node.
  665. string bamFilePath = utilityObj.xmlUtil.GetTextValue(nodeName,
  666. Constants.FilePathNode);
  667. string expectedAlignedSeqFilePath = utilityObj.xmlUtil.GetTextValue(
  668. nodeName, Constants.ExpectedSequence);
  669. string refIndexValue = utilityObj.xmlUtil.GetTextValue(
  670. nodeName, Constants.RefIndexNode);
  671. string startIndexValue = utilityObj.xmlUtil.GetTextValue(
  672. nodeName, Constants.StartIndexNode);
  673. string endIndexValue = utilityObj.xmlUtil.GetTextValue(
  674. nodeName, Constants.EndIndexNode);
  675. string alignedSeqCount = utilityObj.xmlUtil.GetTextValue(
  676. nodeName, Constants.AlignedSeqCountNode);
  677. string refSeqName = utilityObj.xmlUtil.GetTextValue(
  678. nodeName, Constants.ChromosomeNameNode);
  679. SequenceAlignmentMap seqAlignment = null;
  680. BAMParser bamParser = null;
  681. try
  682. {
  683. bamParser = new BAMParser();
  684. // Parse a BAM file with different parameters.
  685. switch (BAMParserPam)
  686. {
  687. case BAMParserParameters.StreamReader:
  688. using (Stream stream = new FileStream(bamFilePath, FileMode.Open,
  689. FileAccess.Read))
  690. {
  691. seqAlignment = bamParser.Parse(stream);
  692. }
  693. break;
  694. case BAMParserParameters.FileName:
  695. seqAlignment = bamParser.Parse(bamFilePath);
  696. break;
  697. case BAMParserParameters.ParseRangeFileName:
  698. seqAlignment = bamParser.ParseRange(bamFilePath,
  699. Convert.ToInt32(refIndexValue, (IFormatProvider)null));
  700. break;
  701. case BAMParserParameters.ParseRangeWithIndex:
  702. seqAlignment = bamParser.ParseRange(bamFilePath,
  703. Convert.ToInt32(refIndexValue, (IFormatProvider)null),
  704. Convert.ToInt32(startIndexValue, (IFormatProvider)null),
  705. Convert.ToInt32(endIndexValue, (IFormatProvider)null));
  706. break;
  707. case BAMParserParameters.ParseRangeUsingRefSeq:
  708. seqAlignment = bamParser.ParseRange(bamFilePath, refSeqName);
  709. break;
  710. case BAMParserParameters.ParseRangeUsingRefSeqAndFlag:
  711. seqAlignment = bamParser.ParseRange(bamFilePath, refSeqName);
  712. break;
  713. case BAMParserParameters.ParseRangeUsingRefSeqUsingIndex:
  714. seqAlignment = bamParser.ParseRange(bamFilePath, refSeqName,
  715. Convert.ToInt32(startIndexValue, (IFormatProvider)null),
  716. Convert.ToInt32(endIndexValue, (IFormatProvider)null));
  717. break;
  718. case BAMParserParameters.ParseRangeUsingIndexesAndFlag:
  719. seqAlignment = bamParser.ParseRange(bamFilePath, refSeqName,
  720. Convert.ToInt32(startIndexValue, (IFormatProvider)null),
  721. Convert.ToInt32(endIndexValue, (IFormatProvider)null));
  722. break;
  723. }
  724. // Validate BAM Header record fileds.
  725. if (!IsReferenceIndex)
  726. {
  727. ValidateBAMHeaderRecords(nodeName, seqAlignment);
  728. }
  729. IList<SAMAlignedSequence> alignedSeqs = seqAlignment.QuerySequences;
  730. Assert.AreEqual(alignedSeqCount, alignedSeqs.Count.ToString((IFormatProvider)null));
  731. // Get expected sequences
  732. using (FastAParser parserObj = new FastAParser(expectedAlignedSeqFilePath))
  733. {
  734. IEnumerable<ISequence> expectedSequences = parserObj.Parse();
  735. IList<ISequence> expectedSequencesList = expectedSequences.ToList();
  736. // Validate aligned sequences from BAM file.
  737. for (int index = 0; index < alignedSeqs.Count; index++)
  738. {
  739. Assert.AreEqual(
  740. new string(expectedSequencesList[index].Select(a => (char)a).ToArray()),
  741. new string(alignedSeqs[index].QuerySequence.Select(a => (char)a).ToArray()));
  742. // Log to VSTest GUI.
  743. ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
  744. "BAM Parser BVT : Validated Aligned sequence :{0} successfully",
  745. alignedSeqs[index].QuerySequence.ToString()));
  746. Console.WriteLine(string.Format((IFormatProvider)null,
  747. "BAM Parser BVT : Validated the aligned sequence :{0} successfully",
  748. alignedSeqs[index].QuerySequence.ToString()));
  749. }
  750. }
  751. }
  752. finally
  753. {
  754. bamParser.Dispose();
  755. }
  756. }
  757. /// <summary>
  758. /// Validate BAM file Header fields.
  759. /// </summary>
  760. /// <param name="nodeName">XML nodename used for different test cases</param>
  761. /// <param name="seqAlignment">seqAlignment object</param>
  762. void ValidateBAMHeaderRecords(string nodeName,
  763. SequenceAlignmentMap seqAlignment)
  764. {
  765. string expectedHeaderTagValues = utilityObj.xmlUtil.GetTextValue(
  766. nodeName, Constants.RecordTagValuesNode);
  767. string expectedHeaderTagKeys = utilityObj.xmlUtil.GetTextValue(
  768. nodeName, Constants.RecordTagKeysNode);
  769. string expectedHeaderTypes = utilityObj.xmlUtil.GetTextValue(
  770. nodeName, Constants.HeaderTyepsNodes);
  771. string[] expectedHeaderTagsValues = expectedHeaderTagValues.Split(',');
  772. string[] expectedHeaderKeys = expectedHeaderTagKeys.Split(',');
  773. string[] expectedHeaders = expectedHeaderTypes.Split(',');
  774. SAMAlignmentHeader header = seqAlignment.Header;
  775. IList<SAMRecordField> recordFields = header.RecordFields;
  776. int tagKeysCount = 0;
  777. int tagValuesCount = 0;
  778. for (int index = 0; index < recordFields.Count; index++)
  779. {
  780. Assert.AreEqual(expectedHeaders[index].Replace("/", ""),
  781. recordFields[index].Typecode.ToString((IFormatProvider)null).Replace("/", ""));
  782. for (int tags = 0; tags < recordFields[index].Tags.Count; tags++)
  783. {
  784. Assert.AreEqual(expectedHeaderKeys[tagKeysCount].Replace("/", ""),
  785. recordFields[index].Tags[tags].Tag.ToString((IFormatProvider)null).Replace("/", ""));
  786. Assert.AreEqual(expectedHeaderTagsValues[tagValuesCount].Replace("/", ""),
  787. recordFields[index].Tags[tags].Value.ToString((IFormatProvider)null).Replace("/", "").Replace("\r", "").Replace("\n", ""));
  788. tagKeysCount++;
  789. tagValuesCount++;
  790. }
  791. }
  792. }
  793. /// <summary>
  794. /// Validate formatted BAM file.
  795. /// </summary>
  796. /// <param name="nodeName">Different xml nodes used for different test cases</param>
  797. /// <param name="BAMParserPam">BAM Format method parameters</param>
  798. void ValidateBAMFormatter(string nodeName,
  799. BAMParserParameters BAMParserPam)
  800. {
  801. // Get input and output values from xml node.
  802. string bamFilePath = utilityObj.xmlUtil.GetTextValue(nodeName,
  803. Constants.FilePathNode);
  804. string expectedAlignedSeqFilePath = utilityObj.xmlUtil.GetTextValue(
  805. nodeName, Constants.ExpectedSequence);
  806. string alignedSeqCount = utilityObj.xmlUtil.GetTextValue(
  807. nodeName, Constants.AlignedSeqCountNode);
  808. Stream stream = null;
  809. SequenceAlignmentMap seqAlignment = null;
  810. using (BAMParser bamParserObj = new BAMParser())
  811. {
  812. // Parse a BAM file.
  813. seqAlignment = bamParserObj.Parse(bamFilePath);
  814. // Create a BAM formatter object.
  815. BAMFormatter formatterObj = new BAMFormatter();
  816. // Write/Format aligned sequences to BAM file.
  817. switch (BAMParserPam)
  818. {
  819. case BAMParserParameters.StreamWriter:
  820. using (stream = new
  821. FileStream(Constants.BAMTempFileName,
  822. FileMode.Create, FileAccess.Write))
  823. {
  824. formatterObj.Format(seqAlignment, stream);
  825. }
  826. break;
  827. case BAMParserParameters.FileName:
  828. formatterObj.Format(seqAlignment, Constants.BAMTempFileName);
  829. break;
  830. case BAMParserParameters.IndexFile:
  831. formatterObj.Format(seqAlignment, Constants.BAMTempFileName,
  832. Constants.BAMTempIndexFile);
  833. File.Exists(Constants.BAMTempIndexFile);
  834. break;
  835. default:
  836. break;
  837. }
  838. // Parse formatted BAM file and validate aligned sequences.
  839. SequenceAlignmentMap expectedSeqAlignmentMap = bamParserObj.Parse(
  840. Constants.BAMTempFileName);
  841. // Validate Parsed BAM file Header record fileds.
  842. ValidateBAMHeaderRecords(nodeName, expectedSeqAlignmentMap);
  843. IList<SAMAlignedSequence> alignedSeqs = expectedSeqAlignmentMap.QuerySequences;
  844. Assert.AreEqual(alignedSeqCount, alignedSeqs.Count.ToString((IFormatProvider)null));
  845. // Get expected sequences
  846. using (FastAParser parserObj = new FastAParser(expectedAlignedSeqFilePath))
  847. {
  848. IEnumerable<ISequence> expectedSequences = parserObj.Parse();
  849. IList<ISequence> expectedSequencesList = expectedSequences.ToList();
  850. // Validate aligned sequences from BAM file.
  851. for (int index = 0; index < alignedSeqs.Count; index++)
  852. {
  853. Assert.AreEqual(
  854. new string(expectedSequencesList[index].Select(a => (char)a).ToArray()),
  855. new string(alignedSeqs[index].QuerySequence.Select(a => (char)a).ToArray()));
  856. // Log to VSTest GUI.
  857. ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
  858. "BAM Formatter BVT : Validated Aligned sequence :{0} successfully",
  859. alignedSeqs[index].QuerySequence.ToString()));
  860. Console.WriteLine(string.Format((IFormatProvider)null,
  861. "BAM Formatter BVT : Validated the aligned sequence :{0} successfully",
  862. alignedSeqs[index].QuerySequence.ToString()));
  863. }
  864. }
  865. }
  866. File.Delete(Constants.BAMTempFileName);
  867. File.Delete(Constants.BAMTempIndexFile);
  868. }
  869. /// <summary>
  870. /// Comapare Sequence Alignment Header fields
  871. /// </summary>
  872. /// <param name="actualAlignment">Actual sequence alignment object</param>
  873. /// <param name="expectedAlignment">Expected sequence alignment object</param>
  874. /// <returns></returns>
  875. private static bool CompareSequencedAlignmentHeader(SequenceAlignmentMap actualAlignment,
  876. SequenceAlignmentMap expectedAlignment)
  877. {
  878. SAMAlignmentHeader aheader = actualAlignment.Header;
  879. IList<SAMRecordField> arecordFields = aheader.RecordFields;
  880. SAMAlignmentHeader expectedheader = expectedAlignment.Header;
  881. IList<SAMRecordField> expectedrecordFields = expectedheader.RecordFields;
  882. int tagKeysCount = 0;
  883. int tagValuesCount = 0;
  884. for (int index = 0; index < expectedrecordFields.Count; index++)
  885. {
  886. if (0 != string.Compare(expectedrecordFields[index].Typecode.ToString((IFormatProvider)null),
  887. arecordFields[index].Typecode.ToString((IFormatProvider)null), StringComparison.CurrentCulture))
  888. {
  889. return false;
  890. }
  891. for (int tags = 0; tags < expectedrecordFields[index].Tags.Count; tags++)
  892. {
  893. if ((0 != string.Compare(expectedrecordFields[index].Tags[tags].Tag.ToString((IFormatProvider)null),
  894. arecordFields[index].Tags[tags].Tag.ToString((IFormatProvider)null), StringComparison.CurrentCulture))
  895. || (0 != string.Compare(expectedrecordFields[index].Tags[tags].Value.ToString((IFormatProvider)null),
  896. arecordFields[index].Tags[tags].Value.ToString((IFormatProvider)null), StringComparison.CurrentCulture)))
  897. {
  898. Console.WriteLine(string.Format((IFormatProvider)null,
  899. "BAM Parser BVT : Sequence alignment header does not match"));
  900. ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
  901. "BAM Parser BVT : Sequence alignment header does not match"));
  902. return false;
  903. }
  904. tagKeysCount++;
  905. tagValuesCount++;
  906. }
  907. }
  908. return true;
  909. }
  910. /// <summary>
  911. /// Compare BAM file aligned sequences.
  912. /// </summary>
  913. /// <param name="expectedAlignment">Expected sequence alignment object</param>
  914. /// <param name="actualAlignment">Actual sequence alignment object</param>
  915. /// <returns></returns>
  916. private static bool CompareAlignedSequences(SequenceAlignmentMap expectedAlignment,
  917. SequenceAlignmentMap actualAlignment)
  918. {
  919. IList<SAMAlignedSequence> actualAlignedSeqs = actualAlignment.QuerySequences;
  920. IList<SAMAlignedSequence> expectedAlignedSeqs = expectedAlignment.QuerySequences;
  921. for (int i = 0; i < expectedAlignedSeqs.Count; i++)
  922. {
  923. if (0 != string.Compare(new string(expectedAlignedSeqs.ElementAt(i).QuerySequence.Select(a => (char)a).ToArray()),
  924. new string(actualAlignedSeqs[i].QuerySequence.Select(a => (char)a).ToArray()),
  925. true, CultureInfo.CurrentCulture))
  926. {
  927. Console.WriteLine(string.Format((IFormatProvider)null,
  928. "BAM Parser BVT : Sequence alignment aligned seq does not match"));
  929. ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
  930. "BAM Parser BVT : Sequence alignment aligned seq does match"));
  931. return false;
  932. }
  933. }
  934. return true;
  935. }
  936. /// <summary>
  937. /// Validate GetPaired method
  938. /// </summary>
  939. /// <param name="nodeName">XML node name</param>
  940. /// <param name="pams">GetPairedReads method parameters</param>
  941. void ValidatePairedReads(string nodeName, GetPairedReadParameters pams)
  942. {
  943. // Get input and output values from xml node.
  944. string bamFilePath = utilityObj.xmlUtil.GetTextValue(nodeName,
  945. Constants.FilePathNode);
  946. string expectedAlignedSeqFilePath = utilityObj.xmlUtil.GetTextValue(
  947. nodeName, Constants.ExpectedSequence);
  948. string mean = utilityObj.xmlUtil.GetTextValue(
  949. nodeName, Constants.MeanNode);
  950. string deviation = utilityObj.xmlUtil.GetTextValue(
  951. nodeName, Constants.DeviationValueNode);
  952. string library = utilityObj.xmlUtil.GetTextValue(
  953. nodeName, Constants.LibraryNameNode);
  954. string pairedReadsCount = utilityObj.xmlUtil.GetTextValue(
  955. nodeName, Constants.PairedReadsNode);
  956. string[] insertLength = utilityObj.xmlUtil.GetTextValue(
  957. nodeName, Constants.InsertLengthNode).Split(',');
  958. string[] pairedReadType = utilityObj.xmlUtil.GetTextValue(
  959. nodeName, Constants.PairedReadTypeNode).Split(',');
  960. SequenceAlignmentMap seqAlignment = null;
  961. IList<PairedRead> pairedReads = null;
  962. BAMParser bamParser = new BAMParser();
  963. FastAParser parserObj = new FastAParser(expectedAlignedSeqFilePath);
  964. try
  965. {
  966. seqAlignment = bamParser.Parse(bamFilePath);
  967. IEnumerable<ISequence> expectedSequences = parserObj.Parse();
  968. switch (pams)
  969. {
  970. case GetPairedReadParameters.GetPairedReadWithParameters:
  971. pairedReads = seqAlignment.GetPairedReads(float.Parse(mean, (IFormatProvider)null),
  972. float.Parse(deviation, (IFormatProvider)null));
  973. break;
  974. case GetPairedReadParameters.GetPairedReadWithLibraryName:
  975. pairedReads = seqAlignment.GetPairedReads(library);
  976. break;
  977. case GetPairedReadParameters.GetPairedReadWithCloneLibraryInfo:
  978. CloneLibraryInformation libraryInfo =
  979. CloneLibrary.Instance.GetLibraryInformation(library);
  980. pairedReads = seqAlignment.GetPairedReads(libraryInfo);
  981. break;
  982. case GetPairedReadParameters.Default:
  983. pairedReads = seqAlignment.GetPairedReads();
  984. break;
  985. }
  986. Assert.AreEqual(pairedReadsCount, pairedReads.Count.ToString((IFormatProvider)null));
  987. int i = 0;
  988. foreach (PairedRead read in pairedReads)
  989. {
  990. Assert.AreEqual(insertLength[i], read.InsertLength.ToString((IFormatProvider)null));
  991. Assert.AreEqual(pairedReadType[i], read.PairedType.ToString());
  992. foreach (SAMAlignedSequence seq in read.Reads)
  993. {
  994. Assert.AreEqual(new string(expectedSequences.ElementAt(i).Select(a => (char)a).ToArray()),
  995. new string(seq.QuerySequence.Select(a => (char)a).ToArray()));
  996. // Log to VSTest GUI.
  997. ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
  998. "BAM Parser BVT : Validated Paired read :{0} successfully",
  999. seq.QuerySequence.ToString()));
  1000. }
  1001. i++;
  1002. }
  1003. }
  1004. finally
  1005. {
  1006. bamParser.Dispose();
  1007. }
  1008. }
  1009. /// <summary>
  1010. /// Validate different paired read types
  1011. /// </summary>
  1012. /// <param name="nodeName">XML node name</param>
  1013. /// <param name="pams">GetPairedReadTypes method parameters</param>
  1014. void ValidatePairedReadTypes(string nodeName, GetPairedReadTypeParameters pams)
  1015. {
  1016. // Get input and output values from xml node.
  1017. string bamFilePath = utilityObj.xmlUtil.GetTextValue(nodeName,
  1018. Constants.FilePathNode);
  1019. string mean = utilityObj.xmlUtil.GetTextValue(
  1020. nodeName, Constants.MeanNode);
  1021. string deviation = utilityObj.xmlUtil.GetTextValue(
  1022. nodeName, Constants.DeviationValueNode);
  1023. string library = utilityObj.xmlUtil.GetTextValue(
  1024. nodeName, Constants.LibraryNameNode);

Large files files are truncated, but you can click here to view the full file