Skip to content

Commit

Permalink
refactor config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
CChahrour committed Jan 26, 2024
1 parent 500acf1 commit 2ae051d
Showing 1 changed file with 32 additions and 71 deletions.
103 changes: 32 additions & 71 deletions seqnado/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def get_user_input(prompt, default=None, is_boolean=False, choices=None):
return user_input



def setup_configuration(assay, genome, template_data):
username = os.getenv('USER', 'unknown_user')
today = datetime.datetime.now().strftime('%Y-%m-%d')
Expand All @@ -40,79 +39,54 @@ def setup_configuration(assay, genome, template_data):

if genome == "other":
genome = get_user_input("What is your genome name?", default="other")
if assay in ["chip", "atac"]:
genome_dict = {
genome: {
"index": get_user_input("Path to Bowtie2 genome index:"),
"chromosome_sizes": get_user_input("Path to chromosome sizes file:"),
"gtf": get_user_input("Path to GTF file:"),
"blacklist": get_user_input("Path to blacklist bed file:")
}
genome_dict = {
genome: {
"index": get_user_input("Path to Bowtie2 genome index:") if assay in ["chip", "atac"] else get_user_input("Path to STAR v2.7.10b genome index:"),
"chromosome_sizes": get_user_input("Path to chromosome sizes file:"),
"gtf": get_user_input("Path to GTF file:"),
"blacklist": get_user_input("Path to blacklist bed file:")
}
elif assay == "rna":
genome_dict = {
genome: {
"index": get_user_input("Path to STAR v2.7.10b genome index:"),
"chromosome_sizes": get_user_input("Path to chromosome sizes file:"),
"gtf": get_user_input("Path to GTF file:"),
"blacklist": get_user_input("Path to blacklist bed file:")
}
}
else:
if genome in genome_values:
genome_dict[genome] = {
"index": genome_values[genome].get('bt2_index' if assay in ["chip", "atac"] else 'star_index', ''),
"chromosome_sizes": genome_values[genome].get('chromosome_sizes', ''),
"gtf": genome_values[genome].get('gtf', ''),
"blacklist": genome_values[genome].get('blacklist', '')
}

elif genome in genome_values:
if assay in ["chip", "atac"]:
genome_dict = {
genome: {
"index": genome_values[genome]['bt2_index'],
"chromosome_sizes": genome_values[genome]['chromosome_sizes'],
"gtf": genome_values[genome]['gtf'],
"blacklist": genome_values[genome]['blacklist']
}
}
elif assay == "rna":
genome_dict = {
genome: {
"index": genome_values[genome]['star_index'],
"chromosome_sizes": genome_values[genome]['chromosome_sizes'],
"gtf": genome_values[genome]['gtf'],
"blacklist": genome_values[genome]['blacklist']
}
}

genome_config = {
'genome': genome,
'indices': genome_dict[genome]['index'],
'chromosome_sizes': genome_dict[genome]['chromosome_sizes'],
'gtf': genome_dict[genome]['gtf'],
}
template_data.update(genome_config)

template_data['genome'] = genome
template_data['indices'] = genome_dict[genome]['index']
template_data['chromosome_sizes'] = genome_dict[genome]['chromosome_sizes']
template_data['gtf'] = genome_dict[genome]['gtf']

template_data['remove_blacklist'] = get_user_input("Do you want to remove blacklist regions? (yes/no)", default="yes", is_boolean=True)
if template_data['remove_blacklist']:
template_data['blacklist'] = genome_dict[genome]['blacklist']

if assay in ["chip", "atac"]:
template_data['remove_pcr_duplicates'] = get_user_input("Remove PCR duplicates? (yes/no)", default="yes", is_boolean=True)
elif assay == "rna":
template_data['remove_pcr_duplicates'] = get_user_input("Remove PCR duplicates? (yes/no)", default="no", is_boolean=True)

template_data['remove_pcr_duplicates'] = get_user_input("Remove PCR duplicates? (yes/no)", default= "yes" if assay in ["chip", "atac"] else "no", is_boolean=True)
if template_data['remove_pcr_duplicates']:
template_data['remove_pcr_duplicates_method'] = get_user_input("Remove PCR duplicates method:", default="picard", choices=["picard"])

else:
template_data['remove_pcr_duplicates_method'] = "False"

if assay == "atac":
template_data['shift_atac_reads'] = get_user_input("Shift ATAC-seq reads? (yes/no)", default="yes", is_boolean=True)
elif assay in ["chip", "rna"]:
template_data['shift_atac_reads'] = "False"
template_data['shift_atac_reads'] = get_user_input("Shift ATAC-seq reads? (yes/no)", default="yes", is_boolean=True) if assay == "atac" else "False"

if assay == "chip":
template_data['spikein'] = get_user_input("Do you have spikein? (yes/no)", default="no", is_boolean=True)
template_data['spikein'] = get_user_input("Do you have spikein? (yes/no)", default="no", is_boolean=True)
if template_data['spikein']:
template_data['normalisation_method'] = get_user_input("Normalisation method:", default="orlando", choices=["orlando", "with_input"])
template_data['reference_genome'] = get_user_input("Reference genome:", default="hg38")
template_data['spikein_genome'] = get_user_input("Spikein genome:", default="dm6")
template_data['fastq_screen_config'] = get_user_input("Path to fastqscreen config:", default="/ceph/project/milne_group/shared/seqnado_reference/fastqscreen_reference/fastq_screen.conf")
elif assay in ["atac", "rna"]:
template_data['normalisation_method'] = "False"

template_data['make_bigwigs'] = get_user_input("Do you want to make bigwigs? (yes/no)", default="no", is_boolean=True)
if template_data['make_bigwigs']:
Expand All @@ -123,29 +97,16 @@ def setup_configuration(assay, genome, template_data):
template_data['call_peaks'] = get_user_input("Do you want to call peaks? (yes/no)", default="no", is_boolean=True)
if template_data['call_peaks']:
template_data['peak_calling_method'] = get_user_input("Peak caller:", default="lanceotron", choices=["lanceotron", "macs", "homer"])

elif assay == "rna":
template_data['call_peaks'] = "False"

if assay == "rna":
template_data['run_deseq2'] = get_user_input("Run DESeq2? (yes/no)", default="no", is_boolean=True)
elif assay in ["chip", "atac"]:
template_data['run_deseq2'] = "False"
template_data['run_deseq2'] = get_user_input("Run DESeq2? (yes/no)", default="no", is_boolean=True) if assay == "rna" else "False"

template_data['make_ucsc_hub'] = get_user_input("Do you want to make a UCSC hub? (yes/no)", default="no", is_boolean=True)
if template_data['make_ucsc_hub']:
template_data['UCSC_hub_directory'] = get_user_input("UCSC hub directory:", default="/path/to/ucsc_hub/")
template_data['email'] = get_user_input("What is your email address?", default=f"{username}@example.com")
template_data['color_by'] = get_user_input("Color by (for UCSC hub):", default="samplename")
else :
template_data['UCSC_hub_directory'] = "."
template_data['email'] = f"{username}@example.com"
template_data['color_by'] = "samplename"

if assay in ["chip", "atac"]:
template_data['options'] = TOOL_OPTIONS
elif assay == "rna":
template_data['options'] = TOOL_OPTIONS_RNA

template_data['UCSC_hub_directory'] = get_user_input("UCSC hub directory:", default="/path/to/ucsc_hub/") if template_data['make_ucsc_hub'] else "."
template_data['email'] = get_user_input("What is your email address?", default=f"{username}@example.com") if template_data['make_ucsc_hub'] else f"{username}@example.com"
template_data['color_by'] = get_user_input("Color by (for UCSC hub):", default="samplename") if template_data['make_ucsc_hub'] else "samplename"

template_data['options'] = TOOL_OPTIONS_RNA if assay == "rna" else TOOL_OPTIONS_RNA


# Tool Specific Options
Expand Down

0 comments on commit 2ae051d

Please sign in to comment.