File tree 1 file changed +14
-0
lines changed
packages/nextclade/src/io
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,14 @@ pub fn read_one_fasta(filepath: impl AsRef<Path>) -> Result<FastaRecord, Report>
145
145
let mut reader = FastaReader :: from_path ( filepath) ?;
146
146
let mut record = FastaRecord :: default ( ) ;
147
147
reader. read ( & mut record) ?;
148
+ if record. is_empty ( ) {
149
+ return make_error ! ( "Expected exactly one FASTA record, but found none" )
150
+ . wrap_err_with ( || format ! ( "When reading file {filepath:?}" ) ) ;
151
+ }
152
+ if record. seq . is_empty ( ) {
153
+ return make_error ! ( "Sequence is empty, but a non-empty sequence was expected" )
154
+ . wrap_err_with ( || format ! ( "When reading file {filepath:?}" ) ) ;
155
+ }
148
156
Ok ( record)
149
157
}
150
158
@@ -168,6 +176,12 @@ pub fn read_one_fasta_str(contents: impl AsRef<str>) -> Result<FastaRecord, Repo
168
176
let mut reader = FastaReader :: from_str ( & contents) ?;
169
177
let mut record = FastaRecord :: default ( ) ;
170
178
reader. read ( & mut record) ?;
179
+ if record. is_empty ( ) {
180
+ return make_error ! ( "Expected exactly one FASTA record, but found none" ) ;
181
+ }
182
+ if record. seq . is_empty ( ) {
183
+ return make_error ! ( "Sequence is empty, but a non-empty sequence was expected" ) ;
184
+ }
171
185
Ok ( record)
172
186
}
173
187
You can’t perform that action at this time.
0 commit comments