Skip to content

Commit

Permalink
Start updating BaseSpace version to include HCV reports for #412.
Browse files Browse the repository at this point in the history
  • Loading branch information
donkirkby committed Feb 5, 2018
1 parent 1ea6d4b commit 1804bfb
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 27 deletions.
18 changes: 8 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ RUN apt-get update -qq --fix-missing && apt-get install -qq -y \
libpython3.4-dev \
&& rm -rf /var/lib/apt/lists/*

## Python packages, plus trigger matplotlib to build its font cache
RUN pip install python-Levenshtein matplotlib requests reportlab pyyaml cutadapt==1.11 && \
ln -s /usr/local/bin/cutadapt /usr/local/bin/cutadapt-1.11 && \
python -c 'import matplotlib; matplotlib.use("Agg"); import matplotlib.pyplot'

## bowtie2
RUN wget -q -O bowtie2.zip https://github.com/BenLangmead/bowtie2/releases/download/v2.2.8/bowtie2-2.2.8-linux-x86_64.zip && \
unzip bowtie2.zip -d /opt/ && \
Expand All @@ -24,11 +19,14 @@ RUN wget -q -O bowtie2.zip https://github.com/BenLangmead/bowtie2/releases/downl
ENV PATH $PATH:/opt/bowtie2

## Gotoh
COPY micall/alignment /opt/alignment
WORKDIR /opt/alignment
RUN python setup.py install
WORKDIR /
RUN rm -r /opt/alignment && python -c 'import gotoh'
COPY micall/alignment /opt/micall/alignment
COPY requirements.txt requirements-basespace.txt /opt/micall/

## Python packages, plus trigger matplotlib to build its font cache
WORKDIR /opt
RUN pip install -r /opt/micall/requirements-basespace.txt && \
ln -s /usr/local/bin/cutadapt /usr/local/bin/cutadapt-1.11 && \
python -c 'import matplotlib; matplotlib.use("Agg"); import matplotlib.pyplot'

## MiCall
COPY micall_basespace.py version.txt /opt/micall/
Expand Down
32 changes: 23 additions & 9 deletions basespace/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,29 @@
"helpText": "A run does not have to be provided, however run quality information can only be produced if the selected samples were from the provided run"
},
{
"$type": "SampleChooser",
"size": 300,
"valueType": "Input",
"allowedPermissions": "read",
"label": "Sample",
"multiselect": true,
"required": true,
"id": "sample-ids",
"rules": "sample-reader"
"$type": "ResourceMatcher",
"required": true,
"id": "sample-ids",
"label": "Sample Pairs",
"buttonText": "Select Pairs",
"maxRows": 100,
"columns": [
{
"id": "main",
"label": "Main Samples",
"resourceType": "Sample",
"rules": null
},
{
"id": "midi",
"label": "NS5b-MIDI Samples",
"resourceType": "Sample",
"rules": null
}
],
"allowunpairedcells": true,
"rules": null,
"helpText": "MiCall expects Hepatitis C samples to come in two sections: the main section, and the NS5b-MIDI section (amino acids 336 to 560 in NS5b)."
},
{
"$type": "CheckBox",
Expand Down
5 changes: 3 additions & 2 deletions docker_build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from argparse import ArgumentParser
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
import os
from subprocess import check_call, CalledProcessError

Expand All @@ -8,7 +8,8 @@

def parse_args():
parser = ArgumentParser(
description="Build docker image from local source code or a tag.")
description="Build docker image from local source code or a tag.",
formatter_class=ArgumentDefaultsHelpFormatter)

parser.add_argument('-a',
'--agent_id',
Expand Down
2 changes: 1 addition & 1 deletion micall/core/prelim_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def prelim_map(fastq1,
ref_path = os.path.join(work_path, 'micall.fasta')
all_excluded_seeds = {project_config.G2P_SEED_NAME}
if excluded_seeds:
all_excluded_seeds |= excluded_seeds
all_excluded_seeds.update(excluded_seeds)
with open(ref_path, 'w') as ref:
projects.writeSeedFasta(ref, all_excluded_seeds)
reffile_template = os.path.join(work_path, 'reference')
Expand Down
17 changes: 12 additions & 5 deletions micall_basespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def parse_json(json_file):
args.read_length2 = run_content['SequencingStats']['NumCyclesRead2']
args.index_length1 = run_content['SequencingStats']['NumCyclesIndex1']
args.index_length2 = run_content['SequencingStats']['NumCyclesIndex2']
args.samples = sorted(arg_map['Input.sample-ids']['Items'],
args.samples = sorted(arg_map['Input.sample-ids.main']['Items'],
key=itemgetter('Name'))
args.project_id = arg_map['Input.project-id']['Content']['Id']
args.reports = arg_map['Input.reports']['Items']
Expand Down Expand Up @@ -334,7 +334,7 @@ def try_sample(sample_index, run_info, args, pssm):
"""
try:
process_sample(sample_index, run_info, args, pssm)
except:
except Exception:
message = 'Failed to process sample {}.'.format(sample_index+1)
logger.error(message, exc_info=True)
raise RuntimeError(message)
Expand Down Expand Up @@ -508,8 +508,14 @@ def process_sample(sample_index, run_info, args, pssm):
logger.info('Running hivdb (%d of %d).', sample_index+1, len(run_info.samples))
with open(os.path.join(sample_scratch_path, 'amino.csv')) as amino_csv, \
open(os.path.join(sample_scratch_path, 'resistance.csv'), 'w') as resistance_csv, \
open(os.path.join(sample_scratch_path, 'mutations.csv'), 'w') as mutations_csv:
hivdb(amino_csv, resistance_csv, mutations_csv, run_info.reports)
open(os.path.join(sample_scratch_path, 'mutations.csv'), 'w') as mutations_csv, \
open(os.path.join(sample_scratch_path, 'resistance_fail.csv'), 'w') as fail_csv:
hivdb(amino_csv,
amino_csv, # TODO: match with MIDI sample
resistance_csv,
mutations_csv,
fail_csv,
run_info.reports)

logger.info('Running resistance report (%d of %d).', sample_index+1, len(run_info.samples))
source_path = os.path.dirname(__file__)
Expand Down Expand Up @@ -715,7 +721,7 @@ def main():
try:
with open(json_path, 'r') as json_file:
run_json = parse_json(json_file)
except:
except IOError:
if os.path.exists(json_path):
# copy the input file to the output dir for postmortem analysis
logger.error("Error occurred while parsing '%s'" % json_path)
Expand Down Expand Up @@ -768,5 +774,6 @@ def main():
summarize_samples(args, run_json, run_summary)
logger.info('Done.')


if __name__ == '__main__':
main()
3 changes: 3 additions & 0 deletions requirements-basespace.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Requirements for running the micall_basespace.py script
-r requirements.txt
requests==2.13.0
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ micall/alignment
git+https://github.com/cfe-lab/pyvdrm.git@v0.3.1
numpy==1.12.0
matplotlib==2.0.0
cutadapt==1.11
python-Levenshtein==0.12.0
PyYAML==3.12
reportlab==3.4.0

0 comments on commit 1804bfb

Please sign in to comment.