You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Review empty file behaviour for SeqIO parsers #1838
In some sequence formats (e.g. FASTA, FASTQ, GenBank, EMBL, Swiss) an empty file is a legitimate corner case meaning no sequences. In order formats (e.g. SFF, XML) an empty file is invalid as a minimal header is expected.
This issue is to review all the SeqIO file formats and their behaviour when asked to parse an empty file - and document on this issue what they currently do.
They should either return no sequences, or raise a clear exception indicating an invalid empty file. We may want to standardise the wording of the exception and ensure this is always the same exception class, e.g. ValueError.
See discussion on #1835 which touches on this, and white listing some of the parsers in the tests. Those test would ideally validate the exception follows any agreed convention.
I've tried to document the results that are printed out when SeqIO encounters an empty file in each of the formats mentioned in the documentation. I've uploaded the test script and the results here.
Most formats do not print anything (25/31). cif-atom and cif-seqres give Unknown format 'cif-atom' and Unknown format 'cif-seqres' errors. pdb-atom raises an exception the message for which is simply 0. sff and sff-trim raise more meaningful Empty file errors. Finally, uniport-xml raises a no element found: line 1, column 0 error.
This is my first attempt at contributing to Biopython, so if you could help me get started with what comes next, that'll be really great.
It sounds like a pull request for cif-atom and cif-seqres, and/or a pull request for uniprot-xml, would be a good idea. Rather than the current message I think these should return ValueError("Empty file") like SFF?
For pdb-atom, I'm not sure if return no records is sensible, or again, the Empty File message is better.
$ touch empty.ext
$ python empty.py
fasta: 0 records
fasta-2line: 0 records
gb: 0 records
genbank: 0 records
genbank-cds: 0 records
embl: 0 records
embl-cds: 0 records
imgt: 0 records
ig: 0 records
swiss: 0 records
pdb-atom: Empty file.
pdb-seqres: 0 records
cif-seqres: 0 records
cif-atom: Empty file.
phd: 0 records
ace: 0 records
tab: 0 records
pir: 0 records
fastq: 0 records
fastq-sanger: 0 records
fastq-solexa: 0 records
fastq-illumina: 0 records
qual: 0 records
sff: Empty file.
sff-trim: Empty file.
uniprot-xml: Empty file.
seqxml: 0 records
abi: 0 records
abi-trim: 0 records
There is unfortunately an inconsistency in pdb-atom vs pdb-seqres, and cif-seqres and cif-atom - they should all give ValueError("Empty file.") - do you want to add that @DevangThakkar?
Also, as ABI format is binary, I think abi and abi-trim ought to give the empty file exception too? What do you think @bow?
Activity
DevangThakkar commentedon Nov 9, 2018
I've tried to document the results that are printed out when SeqIO encounters an empty file in each of the formats mentioned in the documentation. I've uploaded the test script and the results here.
Most formats do not print anything (25/31). cif-atom and cif-seqres give
Unknown format 'cif-atom'andUnknown format 'cif-seqres'errors. pdb-atom raises an exception the message for which is simply 0. sff and sff-trim raise more meaningfulEmpty fileerrors. Finally, uniport-xml raises ano element found: line 1, column 0error.This is my first attempt at contributing to Biopython, so if you could help me get started with what comes next, that'll be really great.
peterjc commentedon Nov 9, 2018
It sounds like a pull request for cif-atom and cif-seqres, and/or a pull request for uniprot-xml, would be a good idea. Rather than the current message I think these should return
ValueError("Empty file")like SFF?For pdb-atom, I'm not sure if return no records is sensible, or again, the Empty File message is better.
peterjc commentedon Aug 30, 2019
Current results, using this
empty.pyscript:Gives:
There is unfortunately an inconsistency in
pdb-atomvspdb-seqres, andcif-seqresandcif-atom- they should all giveValueError("Empty file.")- do you want to add that @DevangThakkar?Also, as ABI format is binary, I think
abiandabi-trimought to give the empty file exception too? What do you think @bow?DevangThakkar commentedon Sep 3, 2019
Sure, I'll get to it in a bit today. Do we do that for abi as well?
peterjc commentedon Sep 3, 2019
Probably for ABI too, subject to approval by @bow
Caiofcas commentedon Apr 6, 2021
Is there Still something to do in this Issue? Would love to help, but it seems that it should be closed.
peterjc commentedon Apr 6, 2021
Running that test script again now,
I think that all looks fine, so yes - we can close this. Thank you @Caiofcas for taking a look.