Skip to content

Commit

Permalink
fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nhoffman committed Dec 11, 2017
1 parent 940450a commit cb245b8
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -30,6 +30,7 @@ install:

script:
- python setup.py test
- check-manifest --ignore "tox.ini,test*,devtools*,docs*"
- check-manifest --ignore
"tox.ini,test*,devtools*,docs*,taxtastic/data,taxtastic/data/*"
- python setup.py check --metadata --restructuredtext --strict
- flake8 taxtastic
1 change: 1 addition & 0 deletions MANIFEST.in
Expand Up @@ -2,6 +2,7 @@ exclude docker docker/*
exclude singularity singularity/*
exclude dev dev/*
exclude README.txt readme.txt
include *.py
include *.in
include *.rst
include *.txt
Expand Down
17 changes: 9 additions & 8 deletions taxtastic/refpkg.py
Expand Up @@ -136,7 +136,7 @@ def transaction(f, self, *args, **kwargs):
r = f(self, *args, **kwargs)
self.commit_transaction()
return r
except:
except Exception:
self.contents = self.current_transaction['rollback']
self._sync_to_disk()
raise
Expand Down Expand Up @@ -675,9 +675,9 @@ def is_ill_formed(self):
for req_header in 'seqname', 'tax_id':
if req_header not in headers:
return "seq_info is missing {0}".format(req_header)
lens = [len(l) for l in lines]
if not(all([l == lens[0] and l > 1 for l in lens])):
return "seq_info is not valid CSV."
lengths = {len(line) for line in lines}
if len(lengths) > 1:
return "some lines in seq_info differ in field cout"
csv_names = {line[0] for line in lines[1:]}

with self.open_resource('aln_sto') as f:
Expand All @@ -693,7 +693,7 @@ def is_ill_formed(self):
case_sensitive_taxon_labels=True,
preserve_underscores=True)
tree_names = set(tree.taxon_namespace.labels())
except:
except Exception:
return 'tree file is not valid Newick.'

d = fasta_names.symmetric_difference(sto_names)
Expand All @@ -712,9 +712,10 @@ def is_ill_formed(self):
# Next make sure that taxonomy is valid CSV, phylo_model is valid JSON
with self.open_resource('taxonomy') as f:
lines = list(csv.reader(f))
lens = [len(l) for l in lines]
if not(all([l == lens[0] and l > 1 for l in lens])):
return "Taxonomy is invalid: not all lines had the same number of fields."
lengths = {len(line) for line in lines}
if len(lengths) > 1:
return ("Taxonomy is invalid: not all lines had "
"the same number of fields.")
# I don't try to check if the taxids match up to those
# mentioned in aln_fasta, since that would make taxtastic
# depend on RefsetInternalFasta in romperroom.
Expand Down
1 change: 0 additions & 1 deletion taxtastic/subcommands/create.py
Expand Up @@ -22,7 +22,6 @@
import logging
import shutil
import os
import sys

from taxtastic import refpkg, utils

Expand Down
4 changes: 2 additions & 2 deletions taxtastic/taxonomy.py
Expand Up @@ -688,8 +688,8 @@ def sibling_of(self, tax_id):
def is_ancestor_of(self, node, ancestor):
if node is None or ancestor is None:
return False
l = self.lineage(node)
return ancestor in list(l.values())
lineage = self.lineage(node)
return ancestor in list(lineage.values())

def rank(self, tax_id):
if tax_id is None:
Expand Down
10 changes: 5 additions & 5 deletions taxtastic/taxtable.py
Expand Up @@ -180,9 +180,9 @@ def lineage(self):
if not self.parent:
return [self]
else:
l = self.parent.lineage()
l.append(self)
return l
L = self.parent.lineage()
L.append(self)
return L

def __repr__(self):
return ("<TaxNode {0.tax_id}:{0.name} [rank={0.rank};"
Expand All @@ -208,8 +208,8 @@ def node_record(node):
'tax_name': node.name,
'parent_id': parent_id,
'rank': node.rank}
l = {i.rank: i.tax_id for i in node.lineage()}
d.update(l)
L = {i.rank: i.tax_id for i in node.lineage()}
d.update(L)
return d

header = ['tax_id', 'parent_id', 'rank', 'tax_name'] + ranks
Expand Down
2 changes: 1 addition & 1 deletion taxtastic/utils.py
Expand Up @@ -137,7 +137,7 @@ def parse_fasttree(fobj):
elif splut[0] == 'GTRRates':
data['subs_rates'] = dict(
list(zip(['ac', 'ag', 'at', 'cg', 'ct', 'gt'],
list(map(float, splut[1:])))))
list(map(float, splut[1:])))))
elif line.strip() == JTT_MODEL:
data['subs_model'] = 'JTT'
data['datatype'] = 'AA'
Expand Down

0 comments on commit cb245b8

Please sign in to comment.