comparison env/lib/python3.7/site-packages/planemo/conda_recipes.py @ 0:26e78fe6e8c4 draft

"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author shellac
date Sat, 02 May 2020 07:14:21 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:26e78fe6e8c4
1 """Planemo specific utilities for dealing with conda recipe generation.
2 """
3
4 from __future__ import absolute_import
5
6 import os
7
8 from planemo import git
9 from planemo.bioconda_scripts import bioconductor_skeleton
10 from planemo.io import info
11
12 # Bioconda helper functions
13
14
15 def clone_bioconda_repo(path):
16 """Clone bioconda repository in given path."""
17 bioconda_repo = "git@github.com:bioconda/bioconda-recipes.git"
18 git.clone(None, bioconda_repo, path)
19 return "git clone of bioconda repo worked"
20
21
22 def write_bioconda_recipe(package_name, clone, update, bioconda_dir_path=None):
23 """Make a bioconda recipe given the package name.
24
25 clone: y/N , clone the whole bioconda repository and create recipe inside
26 repository.
27
28 update: The update feature differs from the one in bioconda, as it
29 updates the specific package, as opposed to the every package in the
30 biocoda repository.
31 """
32 # set bioconda path
33 if bioconda_dir_path is None:
34 bioconda_recipe_path = os.path.join(os.path.expanduser("~"), "bioconda-recipes")
35 else:
36 bioconda_recipe_path = os.path.join(bioconda_dir_path, "bioconda-recipes")
37
38 # Clone
39 if clone and (not os.path.exists(bioconda_recipe_path)):
40 clone_bioconda_repo(bioconda_recipe_path)
41 info("bioconda-recipes cloned and writing to %s" % bioconda_dir_path)
42 else:
43 info("Bioconda repository not cloned or already exists")
44
45 # Check if package_name is in recipes
46 presence = any(package_name in r for r, d, f in os.walk(bioconda_recipe_path))
47 if presence:
48 info("Package already exists in bioconda")
49 if update:
50 info("Package will be updated")
51 recipe_dir = os.path.join(bioconda_recipe_path, "recipes")
52 bioconductor_skeleton.write_recipe(package_name, recipe_dir, True)
53 elif not presence:
54 info("Package found in bioconda recipes")
55 recipe_dir = os.path.join(bioconda_recipe_path, "recipes")
56 bioconductor_skeleton.write_recipe(package_name, recipe_dir, True)
57 return
58
59
60 __all__ = (
61 "clone_bioconda_repo",
62 "write_bioconda_recipe",
63 )