Skip to content

Commit

Permalink
Merge pull request #19 from ggabernet/dev
Browse files Browse the repository at this point in the history
multi input tsv
  • Loading branch information
ggabernet authored Dec 5, 2021
2 parents 102d258 + 9f91997 commit 76f22e5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
20 changes: 10 additions & 10 deletions bin/check_samplesheet_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def check_samplesheet(file_in, file_out):
"""
This function checks that the samplesheet follows the following structure:
gem,fastq_id,fastqs,feature_types
gem1,sc5p_v2_hs_PBMC_10k_5gex,/sfs/7/workspace/ws/qeaga01-GEX_TCR_BCR_FB-0/data/sc5p_v2_hs_PBMC_10k_5gex_5fb_fastqs/sc5p_v2_hs_PBMC_10k_5gex_fastqs,gex
gem1,sc5p_v2_hs_PBMC_10k_5fb,/sfs/7/workspace/ws/qeaga01-GEX_TCR_BCR_FB-0/data/sc5p_v2_hs_PBMC_10k_5gex_5fb_fastqs/sc5p_v2_hs_PBMC_10k_5fb_fastqs,fb
gem1,sc5p_v2_hs_PBMC_10k_b,/sfs/7/workspace/ws/qeaga01-GEX_TCR_BCR_FB-0/data/sc5p_v2_hs_PBMC_10k_b_fastqs,vdj_b
gem1,sc5p_v2_hs_PBMC_10k_t,/sfs/7/workspace/ws/qeaga01-GEX_TCR_BCR_FB-0/data/sc5p_v2_hs_PBMC_10k_t_fastqs,vdj_t
gem fastq_id fastqs feature_types
gem1 sc5p_v2_hs_PBMC_10k_5gex /sfs/7/workspace/ws/qeaga01-GEX_TCR_BCR_FB-0/data/sc5p_v2_hs_PBMC_10k_5gex_5fb_fastqs/sc5p_v2_hs_PBMC_10k_5gex_fastqs gex
gem1 sc5p_v2_hs_PBMC_10k_5fb /sfs/7/workspace/ws/qeaga01-GEX_TCR_BCR_FB-0/data/sc5p_v2_hs_PBMC_10k_5gex_5fb_fastqs/sc5p_v2_hs_PBMC_10k_5fb_fastqs fb
gem1 sc5p_v2_hs_PBMC_10k_b /sfs/7/workspace/ws/qeaga01-GEX_TCR_BCR_FB-0/data/sc5p_v2_hs_PBMC_10k_b_fastqs vdj_b
gem1 sc5p_v2_hs_PBMC_10k_t /sfs/7/workspace/ws/qeaga01-GEX_TCR_BCR_FB-0/data/sc5p_v2_hs_PBMC_10k_t_fastqs vdj_t
"""

featuretype_list = list()
Expand All @@ -54,14 +54,14 @@ def check_samplesheet(file_in, file_out):
MIN_COLS = 4
# TODO nf-core: Update the column names for the input samplesheet
HEADER = ["gem", "fastq_id", "fastqs", "feature_types"]
header = [x.strip('"') for x in fin.readline().strip().split(",")]
header = [x.strip('"') for x in fin.readline().strip().split("\t")]
if header[: len(HEADER)] != HEADER:
print("ERROR: Please check samplesheet header -> {} != {}".format(",".join(header), ",".join(HEADER)))
print("ERROR: Please check samplesheet header -> {} != {}".format("\t".join(header), "\t".join(HEADER)))
sys.exit(1)

## Check sample entries
for line in fin:
lspl = [x.strip().strip('"') for x in line.strip().split(",")]
lspl = [x.strip().strip('"') for x in line.strip().split("\t")]

# Check valid number of columns per row
if len(lspl) < len(HEADER):
Expand Down Expand Up @@ -115,8 +115,8 @@ def check_samplesheet(file_in, file_out):
exist.append("false")

with open(file_out, "w") as fout:
fout.write(",".join(ftypes)+"\n")
fout.write(",".join(exist)+"\n")
fout.write("\t".join(ftypes)+"\n")
fout.write("\t".join(exist)+"\n")


def main(args=None):
Expand Down
8 changes: 7 additions & 1 deletion bin/generate_multi_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
args = parser.parse_args()

# Read and transform arguments to list
print(args.samples)
samples = args.samples.strip('[').strip(']').replace(" ","")
print(samples)
samples_list = samples.split(',')
print(samples_list)
samples_list = [ x.replace("|",",") for x in samples_list]
feature_types = args.feature_types.strip('[').strip(']').replace(" ","")
feature_type_list = feature_types.split(',')
print(feature_type_list)
Expand Down Expand Up @@ -51,7 +54,10 @@
f.write("[libraries]\n")
f.write("fastq_id,fastqs,feature_types\n")
for (sample,dir,ft) in zip(samples_list,sample_dirs_list,feature_type_list):
f.write("{0},{1},{2}\n".format(sample,dir,dict_ft[ft]))
if "," in sample:
f.write("\"{0}\",{1},{2}\n".format(sample,dir,dict_ft[ft]))
else:
f.write("{0},{1},{2}\n".format(sample,dir,dict_ft[ft]))



Expand Down
2 changes: 1 addition & 1 deletion subworkflows/local/input_multi_check.nf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ workflow INPUT_MULTI_CHECK {
main:
SAMPLESHEET_MULTI_CHECK ( samplesheet )

SAMPLESHEET_MULTI_CHECK.out.samplesheet.splitCsv( header:true )
SAMPLESHEET_MULTI_CHECK.out.samplesheet.splitCsv( header:true, sep: '\t' )
.map { get_samplesheet_paths(it) }
.set { fastqs }

Expand Down

0 comments on commit 76f22e5

Please sign in to comment.