Skip to content

Commit 3b3ab40

Browse files
committed
#122 Adding bootstrap.py and buildout with instructions in README
1 parent a0e3d8c commit 3b3ab40

File tree

3 files changed

+247
-21
lines changed

3 files changed

+247
-21
lines changed

README.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,23 @@
55
</object>
66

77
![master branch build Status](https://www.bcgsc.ca/bamboo/plugins/servlet/wittified/build-status/MAV-TEST)
8-
*(master)*
9-
8+
*(master)*
109

1110
![develop branch build status](https://www.bcgsc.ca/bamboo/plugins/servlet/wittified/build-status/MAV-TEST0)
12-
*(develop)*
11+
*(develop)*
1312

1413
# About
1514

1615
[MAVIS](http://mavis.bcgsc.ca) is python command-line tool for the post-processing of structural variant calls.
1716
The general [MAVIS](http://mavis.bcgsc.ca) pipeline consists of six main stages
18-
17+
1918
- convert
2019
- [cluster](http://mavis.bcgsc.ca/docs/latest/mavis.cluster.html#mavis-cluster)
2120
- [validate](http://mavis.bcgsc.ca/docs/latest/mavis.validate.html#mavis-validate)
2221
- [annotate](http://mavis.bcgsc.ca/docs/latest/mavis.annotate.html#mavis-annotate)
2322
- [pairing](http://mavis.bcgsc.ca/docs/latest/mavis.pairing.html#mavis-pairing)
2423
- [summary](http://mavis.bcgsc.ca/docs/latest/mavis.summary.html#mavis-summary)
2524

26-
2725
## Getting Help
2826

2927
All steps in the MAVIS pipeline are called following the main mavis entry point. The usage menu can be viewed
@@ -39,74 +37,83 @@ Common problems and questions are addressed on the [wiki](https://github.com/bcg
3937
If you have a question or issue that is not answered there (or already a github issue) please submit
4038
a github issue to our [github page](https://github.com/bcgsc/mavis/issues) or contact us by email at [[email protected]](mailto:[email protected])
4139

42-
4340
## Install Instructions
4441

45-
4642
There are 3 major steps to setting up and installing [MAVIS](http://mavis.bcgsc.ca).
4743

48-
4944
### 1. Install Aligner
5045

5146
In addition to the python package dependencies, [MAVIS](http://mavis.bcgsc.ca) also requires an aligner to be installed.
5247
Currently the only aligners supported are [blat](http://mavis.bcgsc.ca/docs/latest/glossary.html#term-blat) and [bwa mem](http://mavis.bcgsc.ca/docs/latest/glossary.html#term-bwa).
5348
For MAVIS to run successfully the aligner must be installed and accessible on the path.
5449
If you have a non-standard install you may find it useful to edit the PATH environment variable. For example
5550

56-
```
51+
``` bash
5752
export PATH=/path/to/directory/containing/blat/binary:$PATH
5853
```
5954

6055
[blat](http://mavis.bcgsc.ca/docs/latest/glossary.html#term-blat) is the default aligner. To configure MAVIS to use [bwa mem](http://mavis.bcgsc.ca/docs/latest/glossary.html#term-bwa) as a default instead, use the
6156
[MAVIS environment variables](http://mavis.bcgsc.ca/configuration.html#environment-variables). Make sure to specify BOTH of the variables below to change the default aligner.
6257

63-
64-
```
58+
``` bash
6559
export MAVIS_ALIGNER='bwa mem'
6660
export MAVIS_ALIGNER_REFERENCE=/path/to/mem/fasta/ref/file
6761
```
6862

6963
After these have been installed MAVIS itself can be installed through pip
7064

65+
#### 2. Install MAVIS
7166

72-
### 2. Install MAVIS
67+
##### Install using pip
7368

7469
The easiest way to install [MAVIS](http://mavis.bcgsc.ca) is through the python package manager, pip. If you do not have python3 installed it can be found [here](https://www.python.org/downloads)
7570

7671
Ensuring you have a recent version of pip and setuptools will improve the install experience. Older versions of pip and setuptools may have issues with obtaining some of the mavis python dependencies
7772

78-
```
73+
``` bash
7974
pip install --upgrade pip setuptools
8075
```
8176

8277
or (for Anaconda users)
8378

84-
```
79+
``` bash
8580
conda update pip setuptools
8681
```
8782

8883
If this is not a clean/new python install it may be useful to set up mavis in a [virtual python environment](https://docs.python.org/3/tutorial/venv.html)
8984

9085
Then install mavis itself
91-
```
86+
87+
``` bash
9288
pip install mavis
9389
```
9490

9591
This will install mavis and its python dependencies.
9692

97-
### 3. Build or Download Reference Files
93+
##### Install using Buildout
9894

99-
After [MAVIS](http://mavis.bcgsc.ca) is installed the [reference files](http://mavis.bcgsc.ca/docs/latest/mavis_input.html#reference-input-files) must be generated (or downloaded) before it can be run. A simple bash script to download the hg19 reference files and generate a MAVIS environment file is provided under mavis/tools for convenience.
95+
Alternatively you can use the [bootstrap/buildout](http://www.buildout.org/en/latest/) to install mavis into bin/mavis
10096

97+
``` bash
98+
git clone https://github.com/bcgsc/mavis.git
99+
cd mavis
100+
pip install zc.buildout
101+
python bootstrap.py
102+
bin/buildout
101103
```
104+
105+
This will install mavis and its python dependencies into eggs inside the cloned mavis directory which can be used by simply running bin/mavis
106+
107+
### 3. Build or Download Reference Files
108+
109+
After [MAVIS](http://mavis.bcgsc.ca) is installed the [reference files](http://mavis.bcgsc.ca/docs/latest/mavis_input.html#reference-input-files) must be generated (or downloaded) before it can be run. A simple bash script to download the hg19 reference files and generate a MAVIS environment file is provided under mavis/tools for convenience.
110+
111+
``` bash
102112
cd /path/to/where/you/want/to/put/the/files
103113
wget https://raw.githubusercontent.com/bcgsc/mavis/master/tools/get_hg19_reference_files.sh
104114
bash get_hg19_reference_files.sh
105115
source reference_inputs/hg19_env.sh
106116
```
107117

108-
Once the above 3 steps are complete [MAVIS](http://mavis.bcgsc.ca) is ready to be run.
118+
Once the above 3 steps are complete [MAVIS](http://mavis.bcgsc.ca) is ready to be run.
109119
See the MAVIS [tutorial](http://mavis.bcgsc.ca/docs/latest/pipeline.html#mavis-tutorial) to learn about running MAVIS.
110-
111-
112-

bootstrap.py

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
##############################################################################
2+
#
3+
# Copyright (c) 2006 Zope Foundation and Contributors.
4+
# All Rights Reserved.
5+
#
6+
# This software is subject to the provisions of the Zope Public License,
7+
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
8+
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9+
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10+
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11+
# FOR A PARTICULAR PURPOSE.
12+
#
13+
##############################################################################
14+
"""Bootstrap a buildout-based project
15+
16+
Simply run this script in a directory containing a buildout.cfg.
17+
The script accepts buildout command-line options, so you can
18+
use the -c option to specify an alternate configuration file.
19+
"""
20+
21+
from optparse import OptionParser
22+
import os
23+
import shutil
24+
import subprocess
25+
import sys
26+
import tempfile
27+
28+
import pkg_resources
29+
import setuptools
30+
31+
import zc.buildout.buildout
32+
33+
34+
__version__ = '2015-07-01'
35+
# See zc.buildout's changelog if this version is up to date.
36+
37+
tmpeggs = tempfile.mkdtemp(prefix='bootstrap-')
38+
39+
usage = '''\
40+
[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options]
41+
42+
Bootstraps a buildout-based project.
43+
44+
Simply run this script in a directory containing a buildout.cfg, using the
45+
Python that you want bin/buildout to use.
46+
47+
Note that by using --find-links to point to local resources, you can keep
48+
this script from going over the network.
49+
'''
50+
51+
parser = OptionParser(usage=usage)
52+
parser.add_option("--version",
53+
action="store_true", default=False,
54+
help=("Return bootstrap.py version."))
55+
parser.add_option("-t", "--accept-buildout-test-releases",
56+
dest='accept_buildout_test_releases',
57+
action="store_true", default=False,
58+
help=("Normally, if you do not specify a --buildout-version, "
59+
"the bootstrap script and buildout gets the newest "
60+
"*final* versions of zc.buildout and its recipes and "
61+
"extensions for you. If you use this flag, "
62+
"bootstrap and buildout will get the newest releases "
63+
"even if they are alphas or betas."))
64+
parser.add_option("-c", "--config-file",
65+
help=("Specify the path to the buildout configuration "
66+
"file to be used."))
67+
parser.add_option("-f", "--find-links",
68+
help=("Specify a URL to search for buildout releases"))
69+
parser.add_option("--allow-site-packages",
70+
action="store_true", default=False,
71+
help=("Let bootstrap.py use existing site packages"))
72+
parser.add_option("--buildout-version",
73+
help="Use a specific zc.buildout version")
74+
parser.add_option("--setuptools-version",
75+
help="Use a specific setuptools version")
76+
parser.add_option("--setuptools-to-dir",
77+
help=("Allow for re-use of existing directory of "
78+
"setuptools versions"))
79+
80+
options, args = parser.parse_args()
81+
if options.version:
82+
print("bootstrap.py version %s" % __version__)
83+
sys.exit(0)
84+
85+
86+
######################################################################
87+
# load/install setuptools
88+
89+
try:
90+
from urllib.request import urlopen
91+
except ImportError:
92+
from urllib2 import urlopen
93+
94+
ez = {}
95+
if os.path.exists('ez_setup.py'):
96+
exec(open('ez_setup.py').read(), ez)
97+
else:
98+
exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez)
99+
100+
if not options.allow_site_packages:
101+
# ez_setup imports site, which adds site packages
102+
# this will remove them from the path to ensure that incompatible versions
103+
# of setuptools are not in the path
104+
import site
105+
# inside a virtualenv, there is no 'getsitepackages'.
106+
# We can't remove these reliably
107+
if hasattr(site, 'getsitepackages'):
108+
for sitepackage_path in site.getsitepackages():
109+
# Strip all site-packages directories from sys.path that
110+
# are not sys.prefix; this is because on Windows
111+
# sys.prefix is a site-package directory.
112+
if sitepackage_path != sys.prefix:
113+
sys.path[:] = [x for x in sys.path
114+
if sitepackage_path not in x]
115+
116+
setup_args = dict(to_dir=tmpeggs, download_delay=0)
117+
118+
if options.setuptools_version is not None:
119+
setup_args['version'] = options.setuptools_version
120+
if options.setuptools_to_dir is not None:
121+
setup_args['to_dir'] = options.setuptools_to_dir
122+
123+
ez['use_setuptools'](**setup_args)
124+
125+
# This does not (always?) update the default working set. We will
126+
# do it.
127+
for path in sys.path:
128+
if path not in pkg_resources.working_set.entries:
129+
pkg_resources.working_set.add_entry(path)
130+
131+
######################################################################
132+
# Install buildout
133+
134+
ws = pkg_resources.working_set
135+
136+
setuptools_path = ws.find(
137+
pkg_resources.Requirement.parse('setuptools')).location
138+
139+
# Fix sys.path here as easy_install.pth added before PYTHONPATH
140+
cmd = [sys.executable, '-c',
141+
'import sys; sys.path[0:0] = [%r]; ' % setuptools_path +
142+
'from setuptools.command.easy_install import main; main()',
143+
'-mZqNxd', tmpeggs]
144+
145+
find_links = os.environ.get(
146+
'bootstrap-testing-find-links',
147+
options.find_links or
148+
('http://downloads.buildout.org/'
149+
if options.accept_buildout_test_releases else None)
150+
)
151+
if find_links:
152+
cmd.extend(['-f', find_links])
153+
154+
requirement = 'zc.buildout'
155+
version = options.buildout_version
156+
if version is None and not options.accept_buildout_test_releases:
157+
# Figure out the most recent final version of zc.buildout.
158+
import setuptools.package_index
159+
_final_parts = '*final-', '*final'
160+
161+
def _final_version(parsed_version):
162+
try:
163+
return not parsed_version.is_prerelease
164+
except AttributeError:
165+
# Older setuptools
166+
for part in parsed_version:
167+
if (part[:1] == '*') and (part not in _final_parts):
168+
return False
169+
return True
170+
171+
index = setuptools.package_index.PackageIndex(
172+
search_path=[setuptools_path])
173+
if find_links:
174+
index.add_find_links((find_links,))
175+
req = pkg_resources.Requirement.parse(requirement)
176+
if index.obtain(req) is not None:
177+
best = []
178+
bestv = None
179+
for dist in index[req.project_name]:
180+
distv = dist.parsed_version
181+
if _final_version(distv):
182+
if bestv is None or distv > bestv:
183+
best = [dist]
184+
bestv = distv
185+
elif distv == bestv:
186+
best.append(dist)
187+
if best:
188+
best.sort()
189+
version = best[-1].version
190+
if version:
191+
requirement = '=='.join((requirement, version))
192+
cmd.append(requirement)
193+
194+
if subprocess.call(cmd) != 0:
195+
raise Exception(
196+
"Failed to execute command:\n%s" % repr(cmd)[1:-1])
197+
198+
######################################################################
199+
# Import and run buildout
200+
201+
ws.add_entry(tmpeggs)
202+
ws.require(requirement)
203+
204+
if not [a for a in args if '=' not in a]:
205+
args.append('bootstrap')
206+
207+
# if -c was provided, we push it back into args for buildout' main function
208+
if options.config_file is not None:
209+
args[0:0] = ['-c', options.config_file]
210+
211+
zc.buildout.buildout.main(args)
212+
shutil.rmtree(tmpeggs)

buildout.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[buildout]
2+
develop = .
3+
parts = mavis
4+
5+
[mavis]
6+
recipe = zc.recipe.egg:scripts
7+
eggs = mavis

0 commit comments

Comments
 (0)