Skip to content

Commit

Permalink
ENH: predict_traits passes, removed extraneous serializations
Browse files Browse the repository at this point in the history
  • Loading branch information
wasade committed Mar 7, 2015
1 parent 6f1061a commit daafc0d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
9 changes: 2 additions & 7 deletions picrust/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,8 @@ def convert_precalc_to_biom(precalc_in, ids_to_load=None,transpose=True,md_prefi
type='Gene table')


def convert_biom_to_precalc(biom_in):
"""Converts a biom file into a PICRUSt precalculated tab-delimited file """
if type(biom_in) in (str, unicode):
biom_table = parse_table(biom_in)
else:
biom_table = load_table(biom_in)

def convert_biom_to_precalc(biom_table):
"""Converts a biom table into a PICRUSt precalculated tab-delimited file """
col_ids = biom_table.ids(axis='observation')
row_ids = biom_table.ids()

Expand Down
8 changes: 4 additions & 4 deletions scripts/predict_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def main():
#convert to precalc (tab-delimited) format

out_fh = open(opts.output_trait_table, 'w')
out_fh.write(convert_biom_to_precalc(biom_predictions.to_json('picrust')))
out_fh.write(convert_biom_to_precalc(biom_predictions))
out_fh.close()

#Write out variance information to file
Expand Down Expand Up @@ -404,7 +404,7 @@ def main():
write_biom_table(biom_prediction_variances, variance_outfile)
else:
open(variance_outfile,'w').write(\
convert_biom_to_precalc(biom_prediction_variances.to_json('picrust')))
convert_biom_to_precalc(biom_prediction_variances))


if confidence_intervals:
Expand All @@ -427,7 +427,7 @@ def main():
write_biom_table(biom_prediction_upper_CI, upper_CI_outfile)
else:
open(upper_CI_outfile,'w').write(\
convert_biom_to_precalc(biom_prediction_upper_CI.to_json('picrust')))
convert_biom_to_precalc(biom_prediction_upper_CI))

biom_prediction_lower_CI=biom_table_from_predictions({k:v['lower_CI'] for k,v in confidence_intervals.iteritems()},table_headers,\
observation_metadata=None,\
Expand All @@ -444,7 +444,7 @@ def main():
write_biom_table(biom_prediction_lower_CI, lower_CI_outfile)
else:
open(lower_CI_outfile,'w').write(\
convert_biom_to_precalc(biom_prediction_lower_CI.to_json('picrust')))
convert_biom_to_precalc(biom_prediction_lower_CI))


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_convert_precalc_to_biom_value_error(self):
def test_convert_biom_to_precalc(self):
""" convert_biom_to_precalc as expected with valid input """

result = convert_biom_to_precalc(precalc_in_biom)
result = convert_biom_to_precalc(parse_biom_table(precalc_in_biom))
self.assertEqual(result,precalc_in_tab)

def test_biom_meta_to_string(self):
Expand Down

0 comments on commit daafc0d

Please sign in to comment.