Skip to content

Commit

Permalink
Merge pull request #51 from microbiomix/main
Browse files Browse the repository at this point in the history
Safely handling sample names as strings in yamls; Other bug fixes
  • Loading branch information
jszarvas authored Jul 5, 2024
2 parents 4d8ffc5 + 1d2edb6 commit 4177a7a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 38 deletions.
2 changes: 1 addition & 1 deletion scripts/plot_6_taxa_profile.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ profile_file = opt$table
profile_param = opt$profiler
out_dir = opt$outdir
metadata_file = opt$metadata
out_phyloseq = paste0(out_dir, '/', profile_param,'_phyloseq.rds')
out_phyloseq = paste0(out_dir, '/', profile_param,'.phyloseq.rds')

if (any(is.null(c(opt$table, opt$profiler, opt$metadata, opt$factor, opt$outdir)))) {
print_help(opt_parser)
Expand Down
2 changes: 1 addition & 1 deletion smk/QC_0.smk
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ PLOT_time:
# - I2
#
ILLUMINA:
$(for i in {ilmn_samples}; do echo "- $i"; done)
$(for i in {ilmn_samples}; do echo "- '$i'"; done)
___EOF___
echo {ilmn_samples} >& {log}
Expand Down
2 changes: 1 addition & 1 deletion smk/QC_1.smk
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ PLOT_time:
# - I2
#
ILLUMINA:
$(for i in {ilmn_samples}; do echo "- $i"; done)
$(for i in {ilmn_samples}; do echo "- '$i'"; done)
___EOF___
echo {ilmn_samples} >& {log}
Expand Down
58 changes: 26 additions & 32 deletions smk/QC_2.smk
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,19 @@ merged_illumina_samples = list()
##############################################

# Make list of illumina samples, if ILLUMINA in config
try:
# Make list of illumina samples, if ILLUMINA in config
if 'ILLUMINA' in config:
#print("Samples:")
for ilmn in config["ILLUMINA"]:
file_found = False
for loc in ['5-1-sortmerna', '4-hostfree', '3-minlength', '1-trimmed']:
location = "{}/{}/{}/{}".format(working_dir, omics, loc, ilmn)
if (path.exists(location) is True):
file_found = True
if file_found == True:
#print(ilmn)
ilmn_samples.append(ilmn)
else:
raise TypeError('ERROR in', config_path, ':', 'sample', ilmn, 'in ILLUMINA list does not exist. Please, complete', config_path)
except:
print('ERROR in ', config_path, ': ILLUMINA list of samples does not exist or has an incorrect format. Please, complete ', config_path)
if 'ILLUMINA' in config:
#print("Samples:")
for ilmn in config["ILLUMINA"]:
file_found = False
for loc in ['5-1-sortmerna', '4-hostfree', '3-minlength', '1-trimmed']:
location = "{}/{}/{}/{}".format(working_dir, omics, loc, ilmn)
if (path.exists(location) is True):
file_found = True
if file_found == True:
#print(ilmn)
ilmn_samples.append(ilmn)
else:
raise Exception(f"ERROR in {config_path}: ILLUMINA sample {ilmn} does not exist.")

##############################################
# Handle composite samples
Expand Down Expand Up @@ -162,10 +158,10 @@ else:
print('ERROR in ', config_path, ': TAXA_profiler variable is not correct. "TAXA_profiler" variable should be metaphlan, motus_rel or motus_raw, or combinations thereof.')

metaphlan_version = "4.0.6"
if metaphlan_version in config and config['metaphlan_version'] is not None:
if 'metaphlan_version' in config and config['metaphlan_version'] is not None:
metaphlan_version = config['metaphlan_version']
motus_version = "3.0.3"
if motus_version in config and config['motus_version'] is not None:
if 'motus_version' in config and config['motus_version'] is not None:
motus_version = config['motus_version']
motus_db_path = path.join(minto_dir, "data", "motus", motus_version, "db_mOTU")
if not path.exists(motus_db_path):
Expand Down Expand Up @@ -868,12 +864,11 @@ rule dummy_sourmash_clusters:

rule qc2_filter_config_yml_assembly:
input:
tax=expand("{wd}/{omics}/6-taxa_profile/{sample}/{sample}.{taxonomy}.tsv",
wd = working_dir,
omics = omics,
sample = ilmn_samples,
taxonomy = taxonomies_versioned),
table="{wd}/output/6-1-smash/{omics}.sourmash_clusters.tsv".format(wd = working_dir, omics = omics)
tax=lambda wildcards: expand("{wd}/output/6-taxa_profile/{omics}.{taxonomy}.tsv",
wd = wildcards.wd,
omics = wildcards.omics,
taxonomy = taxonomies_versioned),
table="{wd}/output/6-1-smash/{omics}.sourmash_clusters.tsv"
output:
config_file="{wd}/{omics}/assembly.yaml"
resources:
Expand Down Expand Up @@ -1031,7 +1026,7 @@ SAMTOOLS_sort_perthread_memgb: 10
# - I2
#
ILLUMINA:
$(for i in {ilmn_samples}; do echo "- $i"; done)
$(for i in {ilmn_samples}; do echo "- '$i'"; done)
###############################
# COASSEMBLY section:
Expand Down Expand Up @@ -1088,11 +1083,10 @@ fi

rule qc2_filter_config_yml_mapping:
input:
expand("{wd}/{omics}/6-taxa_profile/{sample}/{sample}.{taxonomy}.tsv",
wd = working_dir,
omics = omics,
sample = ilmn_samples,
taxonomy = taxonomies_versioned)
lambda wildcards: expand("{wd}/output/6-taxa_profile/{omics}.{taxonomy}.tsv",
wd = wildcards.wd,
omics = wildcards.omics,
taxonomy = taxonomies_versioned)
output:
config_file="{wd}/{omics}/mapping.yaml"
resources:
Expand Down Expand Up @@ -1180,7 +1174,7 @@ abundance_normalization: TPM,MG
# - I2
#
ILLUMINA:
$(for i in {ilmn_samples}; do echo "- $i"; done)
$(for i in {ilmn_samples}; do echo "- '$i'"; done)
___EOF___
echo {ilmn_samples} >& {log}
Expand Down
2 changes: 1 addition & 1 deletion smk/mags_generation.smk
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ rule gtdb_taxonomy_for_genome_collection:
log:
"{wd}/logs/{omics}/mags_generation_pipeline/taxonomy.gtdb.{db_version}.log"
params:
db_folder=lambda wildcards: "{minto_dir}/GTDB/{db_version}".format(minto_dir=minto_dir, db_version=wildcards.db_version)
db_folder=lambda wildcards: "{minto_dir}/data/GTDB/{db_version}".format(minto_dir=minto_dir, db_version=wildcards.db_version)
resources:
mem=70
threads:
Expand Down
4 changes: 2 additions & 2 deletions testing/run_IBD_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# Which MIntO version are we using?
# Use specific tag by "tags/<TAG>" or "main"
# E.g.
# MINTO_STABLE_VERSION="tags/2.0.0"
# MINTO_STABLE_VERSION="tags/2.1.0"
# Developers use 'main' but users should stick to stable versions.

MINTO_STABLE_VERSION="tags/2.0.0"
MINTO_STABLE_VERSION="tags/2.1.0"

function profile_command() {
local cmd=$1
Expand Down

0 comments on commit 4177a7a

Please sign in to comment.