88using MzLibUtil ;
99using NUnit . Framework ;
1010using ThermoRawFileParser ;
11+ using ThermoRawFileParser . Writer ;
1112using ThermoRawFileParser . Writer . MzML ;
1213using UsefulProteomicsDatabases ;
1314
@@ -16,6 +17,97 @@ namespace ThermoRawFileParserTest
1617 [ TestFixture ]
1718 public class WriterTests
1819 {
20+ [ Test ]
21+ public void TestExtensionsNull ( )
22+ {
23+ // Get temp path for writing the test files
24+ var tempFilePath = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) ) ;
25+ Directory . CreateDirectory ( tempFilePath ) ;
26+
27+ var testRawFile = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , @"Data/small.RAW" ) ;
28+ var parseInput = new ParseInput ( ) ;
29+ parseInput . RawFilePath = testRawFile ;
30+ parseInput . OutputDirectory = tempFilePath ;
31+
32+ //empty filename
33+ parseInput . OutputFormat = OutputFormat . MGF ;
34+ RawFileParser . Parse ( parseInput ) ;
35+ Assert . IsTrue ( File . Exists ( Path . Combine ( tempFilePath , "small.mgf" ) ) ) ;
36+
37+ parseInput . OutputFormat = OutputFormat . MzML ;
38+ RawFileParser . Parse ( parseInput ) ;
39+ Assert . IsTrue ( File . Exists ( Path . Combine ( tempFilePath , "small.mzML" ) ) ) ;
40+ File . Delete ( Path . Combine ( tempFilePath , "small.mzML" ) ) ;
41+
42+ parseInput . OutputFormat = OutputFormat . IndexMzML ;
43+ RawFileParser . Parse ( parseInput ) ;
44+ Assert . IsTrue ( File . Exists ( Path . Combine ( tempFilePath , "small.mzML" ) ) ) ;
45+
46+ parseInput . Gzip = true ;
47+ RawFileParser . Parse ( parseInput ) ;
48+ Assert . IsTrue ( File . Exists ( Path . Combine ( tempFilePath , "small.mzML.gz" ) ) ) ;
49+ File . Delete ( Path . Combine ( tempFilePath , "small.mzML.gz" ) ) ;
50+
51+ parseInput . OutputFormat = OutputFormat . MGF ;
52+ RawFileParser . Parse ( parseInput ) ;
53+ Assert . IsTrue ( File . Exists ( Path . Combine ( tempFilePath , "small.mgf.gz" ) ) ) ;
54+
55+ parseInput . OutputFormat = OutputFormat . MzML ;
56+ RawFileParser . Parse ( parseInput ) ;
57+ Assert . IsTrue ( File . Exists ( Path . Combine ( tempFilePath , "small.mzML.gz" ) ) ) ;
58+
59+ Directory . Delete ( tempFilePath , true ) ;
60+ }
61+
62+ [ Test ]
63+ public void TestExtensionsFull ( )
64+ {
65+ // Get temp path for writing the test files
66+ var tempFilePath = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) ) ;
67+ Directory . CreateDirectory ( tempFilePath ) ;
68+
69+ var testRawFile = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , @"Data/small.RAW" ) ;
70+ var parseInput = new ParseInput ( ) ;
71+ parseInput . RawFilePath = testRawFile ;
72+
73+ List < OutputFormat > formats = new List < OutputFormat > ( ) ;
74+ string userInput ;
75+ string expectedOutput ;
76+
77+ foreach ( string line in File . ReadLines ( Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , @"Data/ExtensionTest.tsv" ) ) . Skip ( 1 ) )
78+ {
79+ string [ ] words = line . Split ( '\t ' ) ;
80+
81+ switch ( words [ 0 ] . ToLower ( ) )
82+ {
83+ case "mgf" : formats = new List < OutputFormat > { OutputFormat . MGF } ; break ;
84+ case "mzml" : formats = new List < OutputFormat > { OutputFormat . MzML , OutputFormat . IndexMzML } ; break ;
85+ }
86+
87+ switch ( words [ 1 ] . ToLower ( ) )
88+ {
89+ case "true" : parseInput . Gzip = true ; break ;
90+ default : parseInput . Gzip = false ; break ;
91+ }
92+
93+ userInput = words [ 2 ] ;
94+ expectedOutput = words [ 3 ] ;
95+
96+ parseInput . OutputFile = Path . Combine ( tempFilePath , userInput ) ;
97+
98+ foreach ( var format in formats )
99+ {
100+ parseInput . OutputFormat = format ;
101+ RawFileParser . Parse ( parseInput ) ;
102+ Assert . IsTrue ( File . Exists ( Path . Combine ( tempFilePath , expectedOutput ) ) ) ;
103+ File . Delete ( Path . Combine ( tempFilePath , expectedOutput ) ) ;
104+ }
105+
106+ }
107+
108+ Directory . Delete ( tempFilePath , true ) ;
109+ }
110+
19111 [ Test ]
20112 public void TestMgf ( )
21113 {
0 commit comments