Browse Source

Only load the parsers if necessary.

Check if Biopython already knows about our formats (which will be
the case starting from Biopython 1.75) before loading the parsers.

Emit a warning if the parsers are already available in Biopython
so that the user will know she no longer needs to load our module.
master
Damien Goutte-Gattat 2 years ago
parent
commit
55e1605684
  1. 33
      incenp/bio/seqio/__init__.py

33
incenp/bio/seqio/__init__.py

@ -27,28 +27,25 @@ formats in Biopython's SeqIO.
from Bio import SeqIO
from . import SnapGeneIO
from . import XdnaIO
from . import GckIO
if not 'xdna' in SeqIO._FormatToIterator:
SeqIO._FormatToIterator['xdna'] = XdnaIO.XdnaIterator
if not 'gck' in SeqIO._FormatToIterator:
if not 'xdna' in SeqIO._FormatToWriter:
SeqIO._FormatToWriter['xdna'] = XdnaIO.XdnaWriter
from . import GckIO
from . import SnapGeneIO
from . import XdnaIO
if not 'xdna' in SeqIO._BinaryFormats:
SeqIO._BinaryFormats.append('xdna')
SeqIO._FormatToIterator['gck'] = GckIO.GckIterator
SeqIO._BinaryFormats.append('gck')
if not 'snapgene' in SeqIO._FormatToIterator:
SeqIO._FormatToIterator['snapgene'] = SnapGeneIO.SnapGeneIterator
if not 'snapgene' in SeqIO._BinaryFormats:
SeqIO._BinaryFormats.append('snapgene')
if not 'gck' in SeqIO._FormatToIterator:
SeqIO._FormatToIterator['gck'] = GckIO.GckIterator
SeqIO._FormatToIterator['xdna'] = XdnaIO.XdnaIterator
SeqIO._FormatToWriter['xdna'] = XdnaIO.XdnaWriter
SeqIO._BinaryFormats.append('xdna')
if not 'gck' in SeqIO._BinaryFormats:
SeqIO._BinaryFormats.append('gck')
else:
import warnings
warnings.warn("Your Biopython installation already has support for the "
"Gck, SnapGene, and Xdna formats. You no longer need to "
"load the incenp.bio.seqio module",
DeprecationWarning)
Loading…
Cancel
Save