Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test 11 and 14 fails (and fixes) #120

Open
zeqianli opened this issue Aug 18, 2021 · 0 comments
Open

Test 11 and 14 fails (and fixes) #120

zeqianli opened this issue Aug 18, 2021 · 0 comments

Comments

@zeqianli
Copy link

Python version: 3.8.5
MIDAS: 1.3.2

Test 11:

'Traceback (most recent call last):\n File "/home/zeqianli/Documents/Kuehn/Software/MIDAS/scripts/snp_diversity.py", line 370, in <module>\n check_args(args)\n File "/home/zeqianli/Documents/Kuehn/Software/MIDAS/scripts/snp_diversity.py", line 180, in check_args\n if args[\'rand_reads\'] > args[\'site_depth\'] and not args[\'replace_reads\']:\nTypeError: \'>\' not supported between instances of \'NoneType\' and \'int\'\n'

In scripts/snp_diversity.py, 'rand_reads' is not assigned a default value, so '>' fails when --rand_reads is not used. I guess this becomes an issue because argparse changed how to assign default values for int type when the default argument is not specified?

Fix: scripts/snp_diversity.py, line 180:
if args['rand_reads'] and args['rand_reads'] > args['site_depth'] and not args['replace_reads']: # add the first condition

Test 14:

'Traceback (most recent call last):\n File "/home/zeqianli/Documents/Kuehn/Software/MIDAS/scripts/query_by_compound.py", line 28023, in <module>\n species = fetch_species(compound, samples)\n File "/home/zeqianli/Documents/Kuehn/Software/MIDAS/scripts/query_by_compound.py", line 27953, in fetch_species\n species[species_id].genes = fetch_genes(compound, species_id, args[\'db\'])\n File "/home/zeqianli/Documents/Kuehn/Software/MIDAS/scripts/query_by_compound.py", line 27894, in fetch_genes\n for r in csv.DictReader(gzip.open(path,mode=\'r\'), delimiter=\'\\t\'): # ZL\n File "/home/zeqianli/miniconda3/lib/python3.8/csv.py", line 110, in __next__\n self.fieldnames\n File "/home/zeqianli/miniconda3/lib/python3.8/csv.py", line 97, in fieldnames\n self._fieldnames = next(self.reader)\n_csv.Error: iterator should return strings, not bytes (did you open the file in text mode?)\n'

In scripts/query_by_compound.py, fetch_genes() and write_output(), gzip.open(path) now by default open files in binary mode. csv.DictReader requires it opening in text mode.

Fix: In scripts/query_by_compound.py, line 27894 and line 27966:
for r in csv.DictReader(gzip.open(path,mode='rt'), delimiter='\t'): # open in text mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant