@@ -114,26 +114,27 @@ unittest {
114114 assert (normalizeAlleleString(" TC" ) == " 01" );
115115}
116116
117- void checkDataLine (const char [] line) {
118- auto r = regex(r " ^\w+\s\d+\s\d+(\s[ACTG01\?,]+){0,1}$" );
119- enforce(match(line, r));
120- }
121-
122- unittest {
123- assertThrown(checkDataLine(" 1 20 5 AACC,AACA 2.44" ));
124- assertNotThrown(checkDataLine(" 1 20 5 AACC" ));
125- assertNotThrown(checkDataLine(" 4 5 2" ));
126- assertNotThrown(checkDataLine(" 1 10 5 ACC" ));
127- assertThrown(checkDataLine(" 1 20 5 AGGSSXX" ));
128- }
117+ // void checkDataLine(const char[] line) {
118+ // auto r = regex(r"^\w+\s\d+\s\d+(\s[ACTG01\?,]+){0,1}$");
119+ // enforce(match(line, r));
120+ // }
121+ //
122+ // unittest {
123+ // assertThrown(checkDataLine("1 20 5 AACC,AACA 2.44"));
124+ // assertNotThrown(checkDataLine("1 20 5 AACC"));
125+ // assertNotThrown(checkDataLine("4 5 2"));
126+ // assertNotThrown(checkDataLine("1 10 5 ACC"));
127+ // assertThrown(checkDataLine("1 20 5 AGGSSXX"));
128+ // }
129129
130130size_t getNrHaplotypesFromFile (string filename) {
131131 auto file = File (filename, " r" );
132132 scope (exit) file.close();
133133 auto line = file.readln();
134134 line = line.strip();
135- checkDataLine(line);
135+ // checkDataLine(line);
136136 auto fields = line.strip().split();
137+ enforce(fields.length > 2 , " illegal input file" );
137138 if (fields.length < 4 )
138139 return 2 ;
139140 else {
@@ -178,11 +179,17 @@ SegSite_t[] readSegSites(string filename, bool directedEmissions, size_t[] indic
178179
179180 auto f = File (filename, " r" );
180181 long lastPos = - 1 ;
182+ auto chrom = " " ;
181183 foreach (line; f.byLine()) {
182184 // checkDataLine(line.strip());
183185 auto fields = line.strip().split();
186+ if (chrom == " " )
187+ chrom = fields[0 ].idup;
188+ else
189+ enforce(chrom == fields[0 ], " chromosomes must all be the same within one file (sorry)" );
184190 auto pos = to! size_t (fields[1 ]);
185191 auto nrCalledSites = to! size_t (fields[2 ]);
192+ enforce(nrCalledSites > 0 , " nr of called sites (3rd column in input file) must be always > 0" );
186193 if (lastPos == - 1 ) {
187194 lastPos = pos - nrCalledSites;
188195 }
0 commit comments