Skip to content

Commit

Permalink
Merge pull request #18 from cdanielmachado/development
Browse files Browse the repository at this point in the history
merge development branch
  • Loading branch information
cdanielmachado committed May 28, 2018
2 parents 3b871f9 + 48dc0dc commit 7404718
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion carveme/reconstruction/carving.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def carve_model(model, reaction_scores, outputfile=None, flavor=None, inplace=Tr
r_id = row['reaction']
if r_id in model.reactions:
try:
gpr = parse_gpr_rule(row['GPR'])
gpr = parse_gpr_rule(row['GPR'], prefix='G_')
model.set_gpr_association(r_id, gpr, add_genes=True)
except:
print 'Failed to parse:', row['GPR']
Expand Down
10 changes: 6 additions & 4 deletions carveme/reconstruction/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ def merge_subunits(genes):
str: boolean rule
"""
if any(genes.isnull()):
genes = genes.dropna()

if len(genes) == 0:
return None
else:
protein = ' and '.join(sorted(genes))
Expand All @@ -23,8 +25,7 @@ def merge_subunits(genes):

def merge_subunit_scores(scores):
""" Merge scores of all genes in a protein complex.
Calculates the minimum score among all subunits.
If any subunit is missing (NaN) the result is NaN.
Calculates the mean score among all subunits.
Args:
scores: individual gene scores
Expand All @@ -33,7 +34,8 @@ def merge_subunit_scores(scores):
float: merged score
"""
return scores.min(skipna=False)

return scores.fillna(0).mean()


def merge_proteins(proteins):
Expand Down
2 changes: 2 additions & 0 deletions scripts/carve
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ def main(inputfile, input_type='protein', outputfile=None, diamond_args=None, un
init_env=init_env,
debug_output=debug_output)
else:
if verbose:
print 'Building an ensemble of', ensemble_size, 'models'
build_ensemble(universe_model, scores, ensemble_size, outputfile, flavor, init_env=init_env)

if gapfill and model is not None:
Expand Down

0 comments on commit 7404718

Please sign in to comment.