Skip to content

Commit

Permalink
Address Sphinx build warnings about docstring formatting
Browse files Browse the repository at this point in the history
Corrects docstring indentation and converts tabular data in docstrings to rST
tables. Also, updates descriptions of method parameters to NumPy format in the
associated methods.

With this commit there are no more Sphinx warnings except for one about the
RTD's theme.
  • Loading branch information
huddlej committed May 24, 2019
1 parent 022980e commit 067a31f
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 43 deletions.
1 change: 1 addition & 0 deletions augur/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def convert_tree_to_json_structure(node, metadata, div=0, nextflu_schema=False,
converts the Biopython tree structure to a dictionary that can
be written to file as a json. This is called recursively.
Creates the strain property & divergence on each node
input
node -- node for which top level dict is produced.
div -- cumulative divergence (root = 0)
Expand Down
66 changes: 39 additions & 27 deletions augur/sequence_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,40 +98,52 @@ def mutation_struct():
def read_in_features(drm_file):
'''
Reads in and stores position, alt base/AA, feature, gene,
and 'display name' (optional) of mutations such
and 'display name' (optional) of mutations such
as drug-resistance mutations
Format to map by both nucleotide and AA sites:
----------------------------------------------
GENE SITE ALT DISPLAY_NAME FEATURE
gyrB 461 N Fluoroquinolones
nuc 1472358 T rrs: C513T Streptomycin
nuc 1673425 T fabG1: C-15T Isoniazid Ethionamide
ethA 175 T Ethionamide
==== ======= === ============ =====================
GENE SITE ALT DISPLAY_NAME FEATURE
==== ======= === ============ =====================
gyrB 461 N Fluoroquinolones
nuc 1472358 T rrs: C513T Streptomycin
nuc 1673425 T fabG1: C-15T Isoniazid Ethionamide
ethA 175 T Ethionamide
==== ======= === ============ =====================
Format to map by AA site:
-------------------------
GENE SITE ALT FEATURE
gyrB 461 N Fluoroquinolones
gyrB 499 D Fluoroquinolones
rpoB 170 F Rifampicin
rpoB 359 A Rifampicin
==== ==== === ================
GENE SITE ALT FEATURE
==== ==== === ================
gyrB 461 N Fluoroquinolones
gyrB 499 D Fluoroquinolones
rpoB 170 F Rifampicin
rpoB 359 A Rifampicin
==== ==== === ================
Format to map by nucleotide site:
-----------------------------------
SITE ALT DISPLAY_NAME FEATURE
6505 T D461N Fluoroquinolones
6505 C D461N Fluoroquinolones
760314 T V170F Rifampicin
760882 C V359A Rifampicin
or to map by nucleotide site and display mutations:
---------------------------------------------------
SITE ALT FEATURE
====== === ============ ================
SITE ALT DISPLAY_NAME FEATURE
====== === ============ ================
6505 T D461N Fluoroquinolones
6505 C D461N Fluoroquinolones
760314 T V170F Rifampicin
760882 C V359A Rifampicin
====== === ============ ================
Or to map by nucleotide site and display mutations:
====== === ================
SITE ALT FEATURE
====== === ================
6505 T Fluoroquinolones
6505 C Fluoroquinolones
760314 T Rifampicin
760882 C Rifampicin
760314 T Rifampicin
760882 C Rifampicin
====== === ================
Parameters
----------
Expand Down Expand Up @@ -235,8 +247,8 @@ def annotate_strains(all_features, all_sequences):
def attach_features(annotations, label, count):
'''
'Attaches' features to nodes and lists the corresponding mutations
as values, that is
>>>
as values, that is:
{nodename:{"Resistance 1":"mut1,mut2", "Resistance 2":"mut1"}}
Parameters
Expand Down
50 changes: 34 additions & 16 deletions augur/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,21 @@ def safe_translate(sequence, report_exceptions=False):

def translate_feature(aln, feature):
'''
translates a subsequence of input nucleotide sequences
input:
aln -- dictionary of sequences indexed by node name
feature -- Biopython sequence feature
returns:
dictionary of translated sequences indexed by node name
Translates a subsequence of input nucleotide sequences.
Parameters
----------
aln : dict
sequences indexed by node name
feature : Bio.Seq.Seq
BioPython sequence feature
Returns
-------
dict :
translated sequences indexed by node name
'''
translations = {}
for sname, seq in aln.items():
Expand All @@ -96,16 +105,25 @@ def translate_feature(aln, feature):


def translate_vcf_feature(sequences, ref, feature):
'''
translates a subsequence of input nucleotide sequences
input:
sequences -- TreeTime format dictionary from VCF-input of sequences
indexed by node name
ref -- reference alignment the VCF was mapped to
feature -- Biopython sequence feature
returns:
dictionary giving the translated reference gene, positions of AA differences,
and AA differences indexed by node name
'''Translates a subsequence of input nucleotide sequences.
Parameters
----------
sequences : dict
TreeTime format dictionary from VCF-input of sequences indexed by node name
ref :
reference alignment the VCF was mapped to
feature : Bio.Seq.Seq
BioPython sequence feature
Returns
-------
dict :
translated reference gene, positions of AA differences, and AA
differences indexed by node name
'''
def str_reverse_comp(str_seq):
#gets reverse-compliment of a string and returns it as a string
Expand Down

0 comments on commit 067a31f

Please sign in to comment.