Skip to content

Commit

Permalink
adding additional documentation to the code
Browse files Browse the repository at this point in the history
  • Loading branch information
proost committed Dec 1, 2017
1 parent 6c92b29 commit 2500f22
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 3 additions & 1 deletion conekt/models/blast_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
class BlastDB:
@staticmethod
def create_db():
# Raise an error if BLAST is not enabled
"""
Creates a blast database using the settings specified in the app's configuration
"""
assert current_app.config['BLAST_ENABLED']

TEMP_DIR = tempfile.mkdtemp()
Expand Down
12 changes: 11 additions & 1 deletion conekt/models/clades.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,18 @@ def add_clade(name, species, tree):

@staticmethod
def add_clades_from_json(data):
"""
Adds a clade from a dict with clade details
:param data: dict with clade details
"""
for c, data in data.items():
Clade.add_clade(c, data['species'], data['tree'])

@staticmethod
def update_clades():
"""
Loop over all families and determine what clade they belong too
Loop over all families and determine what clade they belong too. Results are stored in the database
"""
clades = Clade.query.all()
families = GeneFamily.query.all()
Expand Down Expand Up @@ -119,6 +124,11 @@ def update_clades_interpro():

@property
def newick_tree_species(self):
"""
Returns a Newick tree with the species present in the current clade.
:return: Newick tree (string) with species for the current clade
"""
species = {s.code: s.name for s in Species.query.all()}

tree = newick.loads(self.newick_tree)[0]
Expand Down
14 changes: 14 additions & 0 deletions conekt/models/gene_families.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ def sequence_stats(sequence_ids):

@staticmethod
def sequence_stats_subquery(sequences):
"""
Same as sequence_stats but takes a BaseQuery returning sequences as input (to avoid multiple times querying
sequences by ID)
:param sequences: BaseQuery returning sequences
:return: dict with for each InterPro domain linked with any of the input sequences stats
"""
subquery = sequences.subquery()

data = SequenceFamilyAssociation.query.join(subquery, SequenceFamilyAssociation.sequence_id == subquery.c.id).all()
Expand Down Expand Up @@ -286,6 +293,13 @@ def family_stats(self):

@staticmethod
def __add_families(families, family_members):
"""
Adds gene families to the database and assigs genes to their designated family
:param families:
:param family_members:
:return:
"""
for i, f in enumerate(families):
db.session.add(f)

Expand Down

0 comments on commit 2500f22

Please sign in to comment.