annotate bioperl_compat.py @ 5:1c71c770bfd4 draft default tip

planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit cae3bd2f937dee563791707ffb4aab8fe5b7e13b
author brinkmanlab
date Wed, 27 Jul 2022 19:49:20 +0000
parents a5cb5e374399
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
869e206b3ca1 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit 2f8c5be3bf3117a8d3296a6b82655ff08edd2f34"
brinkmanlab
parents:
diff changeset
1 #!/usr/bin/env python
869e206b3ca1 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit 2f8c5be3bf3117a8d3296a6b82655ff08edd2f34"
brinkmanlab
parents:
diff changeset
2 import sys
869e206b3ca1 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit 2f8c5be3bf3117a8d3296a6b82655ff08edd2f34"
brinkmanlab
parents:
diff changeset
3 from biopython_convert import get_args, convert
4
a5cb5e374399 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit afc9f4ade42686dcf53a2615d90e1e9962cf1561"
brinkmanlab
parents: 0
diff changeset
4 from Bio.SeqIO.InsdcIO import _InsdcWriter, EmblWriter
a5cb5e374399 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit afc9f4ade42686dcf53a2615d90e1e9962cf1561"
brinkmanlab
parents: 0
diff changeset
5 import Bio
0
869e206b3ca1 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit 2f8c5be3bf3117a8d3296a6b82655ff08edd2f34"
brinkmanlab
parents:
diff changeset
6
869e206b3ca1 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit 2f8c5be3bf3117a8d3296a6b82655ff08edd2f34"
brinkmanlab
parents:
diff changeset
7 # Quote anticodon qualifiers
869e206b3ca1 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit 2f8c5be3bf3117a8d3296a6b82655ff08edd2f34"
brinkmanlab
parents:
diff changeset
8 _InsdcWriter.FTQUAL_NO_QUOTE = tuple(v for v in _InsdcWriter.FTQUAL_NO_QUOTE if v not in ['anticodon', 'transl_except'])
869e206b3ca1 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit 2f8c5be3bf3117a8d3296a6b82655ff08edd2f34"
brinkmanlab
parents:
diff changeset
9
4
a5cb5e374399 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit afc9f4ade42686dcf53a2615d90e1e9962cf1561"
brinkmanlab
parents: 0
diff changeset
10 if Bio.__version__ == "1.78":
a5cb5e374399 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit afc9f4ade42686dcf53a2615d90e1e9962cf1561"
brinkmanlab
parents: 0
diff changeset
11 # TODO monkeypatch until https://github.com/biopython/biopython/pull/3476
a5cb5e374399 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit afc9f4ade42686dcf53a2615d90e1e9962cf1561"
brinkmanlab
parents: 0
diff changeset
12 _write_the_first_lines_orig = EmblWriter._write_the_first_lines
a5cb5e374399 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit afc9f4ade42686dcf53a2615d90e1e9962cf1561"
brinkmanlab
parents: 0
diff changeset
13
a5cb5e374399 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit afc9f4ade42686dcf53a2615d90e1e9962cf1561"
brinkmanlab
parents: 0
diff changeset
14 def _write_the_first_lines(self, record):
a5cb5e374399 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit afc9f4ade42686dcf53a2615d90e1e9962cf1561"
brinkmanlab
parents: 0
diff changeset
15 orig_type = record.annotations.get("molecule_type")
a5cb5e374399 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit afc9f4ade42686dcf53a2615d90e1e9962cf1561"
brinkmanlab
parents: 0
diff changeset
16 record.annotations["molecule_type"] = orig_type.upper()
a5cb5e374399 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit afc9f4ade42686dcf53a2615d90e1e9962cf1561"
brinkmanlab
parents: 0
diff changeset
17 ret = _write_the_first_lines_orig(self, record)
a5cb5e374399 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit afc9f4ade42686dcf53a2615d90e1e9962cf1561"
brinkmanlab
parents: 0
diff changeset
18 record.annotations["molecule_type"] = orig_type
a5cb5e374399 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit afc9f4ade42686dcf53a2615d90e1e9962cf1561"
brinkmanlab
parents: 0
diff changeset
19 return ret
a5cb5e374399 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit afc9f4ade42686dcf53a2615d90e1e9962cf1561"
brinkmanlab
parents: 0
diff changeset
20
a5cb5e374399 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit afc9f4ade42686dcf53a2615d90e1e9962cf1561"
brinkmanlab
parents: 0
diff changeset
21 EmblWriter._write_the_first_lines = _write_the_first_lines
a5cb5e374399 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit afc9f4ade42686dcf53a2615d90e1e9962cf1561"
brinkmanlab
parents: 0
diff changeset
22
0
869e206b3ca1 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit 2f8c5be3bf3117a8d3296a6b82655ff08edd2f34"
brinkmanlab
parents:
diff changeset
23 if __name__ == '__main__':
869e206b3ca1 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit 2f8c5be3bf3117a8d3296a6b82655ff08edd2f34"
brinkmanlab
parents:
diff changeset
24 convert(*get_args(sys.argv[1:]))
869e206b3ca1 "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/biopython-convert commit 2f8c5be3bf3117a8d3296a6b82655ff08edd2f34"
brinkmanlab
parents:
diff changeset
25