refgenie / refgenconf

A Python object for standardized reference genome assets.
http://refgenie.databio.org
BSD 2-Clause "Simplified" License
3 stars 6 forks source link

Listing recipe requirements from within python #91

Open nsheff opened 4 years ago

nsheff commented 4 years ago

I thought there might be a way to do this:

rgc.requirements("rCRSd", "bowtie2_index")

But it fails. This is because the recipes are not in the refgenconf package, so of course it can't provide a list of the requirements from the python interface. When recipes are made flexible, we should keep this in mind.

nsheff commented 3 years ago

@stolarczyk with flexible recipes, is there now a way to retrieve recipe requirements from RefGenConf?

stolarczyk commented 3 years ago

yes, there are 2 dedicated properties on Recipe objcts, so you can do this now:

In [9]: rgc = RefGenConf(filepath="r.yaml")

In [10]: bt2_idx_recipe = rgc.get_recipe("bowtie2_index")

In [11]: print(bt2_idx_recipe.requirements)
bowtie2_index recipe requirements:

params:
  - threads (Number of threads to use); default: 1
assets:
  - fasta (fasta asset for genome); default: fasta

In [12]: bt2_idx_recipe.requirements_table
Out[12]: 
                          bowtie2_index recipe requirements                           
┏━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┓
┃ Type   ┃ ID      ┃ Description              ┃ Default value ┃ Argument pattern     ┃
┡━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━┩
│ params │ threads │ Number of threads to use │ 1             │ --params threads=1   │
│ assets │ fasta   │ fasta asset for genome   │ fasta         │ --assets fasta=fasta │
└────────┴─────────┴──────────────────────────┴───────────────┴──────────────────────┘

There is no Recipe.requirements_dict though, which would be more elegant, but you can get it this way:

In [4]: bt2_idx_recipe.inputs
Out[4]: 
{'files': None,
 'params': {'threads': {'description': 'Number of threads to use',
   'default': 1}},
 'assets': {'fasta': {'asset_class': 'fasta',
   'description': 'fasta asset for genome',
   'default': 'fasta'}}}