Skip to content

Commit

Permalink
Merge pull request #163 from sunbeam-labs/dev
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
eclarke authored Jul 12, 2018
2 parents cc0c6ad + 7d3d23f commit 0399ae0
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 18 deletions.
27 changes: 17 additions & 10 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,27 @@ Pairs = ['1', '2'] if Cfg['all']['paired_end'] else ['1']

# Collect host (contaminant) genomes
sys.stderr.write("Collecting host/contaminant genomes... ")
HostGenomeFiles = [f for f in Cfg['qc']['host_fp'].glob('*.fasta')]
if not HostGenomeFiles:
sys.stderr.write(
"\n\nWARNING: No files detected in host genomes folder ({}). "
"If this is not intentional, make sure all files end in "
".fasta and the folder is specified correctly.\n\n".format(
Cfg['qc']['host_fp']
))
if Cfg['qc']['host_fp'] == Cfg['all']['root']:
HostGenomeFiles = []
else:
HostGenomeFiles = [f for f in Cfg['qc']['host_fp'].glob('*.fasta')]
if not HostGenomeFiles:
sys.stderr.write(
"\n\nWARNING: No files detected in host genomes folder ({}). "
"If this is not intentional, make sure all files end in "
".fasta and the folder is specified correctly.\n\n".format(
Cfg['qc']['host_fp']
))
HostGenomes = {Path(g.name).stem: read_seq_ids(Cfg['qc']['host_fp'] / g) for g in HostGenomeFiles}
sys.stderr.write("done.\n")

sys.stderr.write("Collecting target genomes... ")
GenomeFiles = [f for f in Cfg['mapping']['genomes_fp'].glob('*.fasta')]
GenomeSegments = {PurePath(g.name).stem: read_seq_ids(Cfg['mapping']['genomes_fp'] / g) for g in GenomeFiles}
if Cfg['mapping']['genomes_fp'] == Cfg['all']['root']:
GenomeFiles = []
GenomeSegments = {}
else:
GenomeFiles = [f for f in Cfg['mapping']['genomes_fp'].glob('*.fasta')]
GenomeSegments = {PurePath(g.name).stem: read_seq_ids(Cfg['mapping']['genomes_fp'] / g) for g in GenomeFiles}
sys.stderr.write("done.\n")

# ---- Change your workdir to output_fp
Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ runs some tests to make sure everything was installed correctly.
If you've never installed Conda before, you'll need to add it to your shell's
path. If you're running Bash (the most common terminal shell), the following
command will add it to your path: ``echo 'export
PATH=$PATH:$HOME/miniconda3/bin` > ~/.bashrc``
PATH=$PATH:$HOME/miniconda3/bin' > ~/.bashrc``

If you see "Tests failed", check out our :ref:`troubleshooting` section or file an issue
on our `GitHub <https://github.com/sunbeam-labs/sunbeam/issues>`_ page.
Expand Down
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ dependencies:
- snakemake=4.8.1
- ruamel.yaml
- biopython
- trimmomatic
- trimmomatic=0.36
- fastqc
- blast
- kraken=1.0
- kraken-biom
- vsearch
- jellyfish=1.1.11=1
- cutadapt
- bwa
- bwa>=0.7.17
- pysam
- pandas
- megahit
Expand Down
1 change: 1 addition & 0 deletions sunbeamlib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def check_config(cfg):
new_cfg = dict()
for section, values in cfg.items():
new_cfg[section] = validate_paths(values, root)
new_cfg['all']['root'] = root
return new_cfg


Expand Down
20 changes: 15 additions & 5 deletions sunbeamlib/scripts/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,26 @@ def main(argv=sys.argv):
args = parser.parse_args(argv)

# Create project folder if it doesn't exist
project_fp = args.project_fp.resolve()
project_fp_exists = False
project_fp = args.project_fp

try:
project_fp = args.project_fp.resolve()
project_fp_exists = project_fp.exists()
except FileNotFoundError:
pass

if not project_fp_exists:
sys.stderr.write(
"Creating project folder at {}...\n".format(args.project_fp))
project_fp.mkdir(parents=True, exist_ok=True)


# Check if files already exist
config_file = check_existing(project_fp/args.output, args.force)
samplelist_file = check_existing(project_fp/"samples.csv", args.force)

if not project_fp.exists():
sys.stderr.write(
"Creating project folder at {}...\n".format(args.project_fp))
project_fp.mkdir(parents=True, exist_ok=True)


# Create config file
cfg = config.new(
Expand Down
23 changes: 23 additions & 0 deletions tests/test_suite.bash
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,26 @@ function test_guess_with_index_files_present {
grep '{sample}_R{rp}.fastq.gz' out.txt
# rm -r $TEMPDIR/idx_files_present
}

# Fix for #153
# Empty strings for _fp entries in the config should result in the relevant
# files being ignored, even if they would normally match the pattern used.
function test_blank_fp_behavior {
# Move indexes to top-level
for file in $TEMPDIR/indexes/*; do
mv $file $TEMPDIR/indexes_${file##*/}
done
# Run sunbeam with a blank string for the mapping step's genomes path, and
# with fasta files lying around in the top-level directory.
sunbeam config modify --str 'mapping: {genomes_fp: ""}' \
$TEMPDIR/tmp_config.yml > $TEMPDIR/blank_fp_config.yml
sunbeam run --configfile $TEMPDIR/blank_fp_config.yml
# Move indexes back to original location
for file in $TEMPDIR/indexes_*; do
mv $file ${file/indexes_/indexes\//}
done
# These files should *not* exist, because we don't accept the top-level
# directory as a genomes_fp directory.
[ ! -f $TEMPDIR/sunbeam_output/mapping/indexes_human/coverage.csv ]
[ ! -f $TEMPDIR/sunbeam_output/mapping/indexes_phix174/coverage.csv ]
}

0 comments on commit 0399ae0

Please sign in to comment.