Micromeda / pygenprop

A python library for programmatic usage of EBI InterPro Genome Properties.
http://pygenprop.rtfd.io/
Apache License 2.0
9 stars 4 forks source link

Improve Usage Documentation #27

Closed SilasK closed 5 years ago

SilasK commented 5 years ago

@LeeBergstrand

Can you write some short example how to use this library? Is it intended only for your internal use?

LeeBergstrand commented 5 years ago

@SilasK You can use it now if you want.

I'm in the process of moving this into becoming a downloadable package on PyPI / Conda.

I'm currently working on bumping up our automated tests on this branch: https://github.com/Micromeda/pygenprop/tree/improve_test_coverage

Then the plan is to change the directory structure to look more like a proper python package and add a setup.py etc.

LeeBergstrand commented 5 years ago

@SilasK Here are a few usage examples I have been using for the end to end tests:

These two scripts are for parsing genome properties database files (https://github.com/Micromeda/genome-properties/blob/master/flatfiles/genomeProperties.txt) and genome properties assignment files (https://github.com/Micromeda/pygenprop/blob/develop/testing/test_constants/C_chlorochromatii_CaD3.txt) respectively.

LeeBergstrand commented 5 years ago

Work off develop for now

The gist of it until I can get up proper docs or a Jupyter notebook.

Property Tree:

https://github.com/Micromeda/pygenprop/blob/develop/modules/genome_properties_tree.py

with open(genome_property_flat_file_path) as genome_property_file:
        properties_tree = parse_genome_property_file(genome_property_file)

# Searchable by property ID
genome_property_56 = properties_tree['GP0056']

# Iterable
for property in properties_tree:
      print(property)

# Special short cut properties
root_genome_property = properties_tree.root
leaf_genome_properties = properties_tree.leafs

Logical Structure:

pygenprop structure

Property Assignments:

https://github.com/Micromeda/pygenprop/blob/develop/modules/genome_properties_results.py

assignments = []

 for path in assignment_file_paths:
        with open(path) as assignment_file:
            assignments.append(parse_genome_property_longform_file(assignment_file))

results = GenomePropertiesResults(*assignments, genome_properties_tree=properties_tree)

property_result_pandas_dataframe = results.property_results
step_result_pandas_dataframe = results.step_result

result_for_gp_56 = results.get_property_result('GP0056')
result_for_gp_56_step_1 = results.get_step_result('GP0056', 1)

For more of the API you'll have to read the code for now. Its pretty well documented.

https://github.com/Micromeda/pygenprop/tree/develop/modules

LeeBergstrand commented 5 years ago

@SilasK Hope that helps. Feel free to ask if there are any questions.

LeeBergstrand commented 5 years ago

@SilasK We just set up a release of pygenprop that is pip installable.

SilasK commented 5 years ago

Great!

LeeBergstrand commented 5 years ago

@SilasK Basic RTD is up (https://pygenprop.readthedocs.io/en/latest/) with function level docs (https://pygenprop.readthedocs.io/en/latest/py-modindex.html) Closed in https://github.com/Micromeda/pygenprop/pull/37