Skip to content

Commit

Permalink
A couple improvements to generalize when AA translation is absent.
Browse files Browse the repository at this point in the history
  • Loading branch information
trvrb committed Mar 25, 2015
1 parent 267c96c commit c183e4a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion augur/src/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def export_to_auspice(self, tree_fields = [], tree_pop_list = []):
print "Writing sequences"
elems = {}
for node in self.tree:
if hasattr(node,"clade"):
if hasattr(node, "clade") and hasattr(node, "aa_seq"):
elems[node.clade] = node.aa_seq
write_json(elems, self.auspice_sequences_fname, indent=None)

Expand Down
10 changes: 7 additions & 3 deletions augur/src/tree_refine.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ def remove_outgroup(self):
def collapse(self):
"""Collapse edges without mutations to polytomies"""
for edge in self.tree.postorder_edge_iter():
if edge.tail_node is not None:
if edge.is_internal() and edge.head_node.seq==edge.tail_node.seq:
edge.collapse()
if edge.tail_node is not None and edge.is_internal():
if hasattr(edge.head_node, 'seq') and hasattr(edge.tail_node, 'seq'):
if edge.head_node.seq==edge.tail_node.seq:
edge.collapse()
else:
if edge.length < 0.00001:
edge.collapse()

def reduce(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion augur/src/virus_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def unique_date(self):
v.num_date = numerical_date(v.date) + 1e-7*(ii+1)

def times_from_outgroup(self):
self.unique_date()
outgroup_date = self.sequence_lookup[self.outgroup['strain']].num_date
return np.array([x.num_date-outgroup_date for x in self.viruses if x.strain])

Expand Down Expand Up @@ -82,6 +81,7 @@ def clean_distances(self):

def clean_generic(self):
print "Number of viruses before cleaning:",len(self.viruses)
self.unique_date()
self.remove_insertions()
self.clean_ambiguous()
self.clean_distances()
Expand Down

0 comments on commit c183e4a

Please sign in to comment.