-
Notifications
You must be signed in to change notification settings - Fork 53
Description
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