Skip to content

Commit

Permalink
issues with nones on ftp_user
Browse files Browse the repository at this point in the history
jorgeboucas committed Feb 6, 2024
2 parents 5b644c0 + a859225 commit 51eaca7
Showing 2 changed files with 490 additions and 106 deletions.
119 changes: 64 additions & 55 deletions routes/apps/crispr.py
Original file line number Diff line number Diff line change
@@ -179,11 +179,10 @@ def generate_submission_file(samplenames, \
mle_matrices,\
ONLY_COUNT ):
@cache.memoize(60*60*2) # 2 hours
def _generate_submission_file(
samplenames, \
samples, \
library, \
email, \
def _generate_submission_file(samplenames,\
samples,\
library,\
email,\
group,\
experiment_name,\
folder,\
@@ -207,17 +206,16 @@ def _generate_submission_file(
BAGEL_NONESSENTIAL,\
mageckflute_organism,\
nontargeting_tag,\
magecku_fdr, \
magecku_fdr,\
magecku_threshold_control_groups,\
magecku_threshold_treatment_groups, \
use_neg_ctrl, \
magecku_threshold_treatment_groups,\
use_neg_ctrl,\
using_master_library,\
acer_master_library,\
facs,\
ctrl_guides,\
mle_matrices,\
ONLY_COUNT
):
ONLY_COUNT):
samplenames_df=make_df_from_rows(samplenames)
samples_df=make_df_from_rows(samples)
library_df=make_df_from_rows(library)
@@ -302,7 +300,7 @@ def _generate_submission_file(
ONLY_COUNT
]
}, index=list(range(37)))

df_=df_.to_json()

filename=make_submission_file(".crispr.xlsx")
@@ -354,71 +352,79 @@ def _generate_submission_file(
"project_title":experiment_name,
"image_folder":"/nexus/posix0/MAGE-flaski/service/images/" ,
"project_folder" : os.path.join(run_data,project_folder),
"reference_file": os.path.join(code, filename),
"raw_fastq": os.path.join(raw_data, folder),
"renamed_fastq": os.path.join(run_data,"raw_renamed"),
"fastqc_raw_data" : os.path.join(run_data,"raw_renamed"),
"cutadapt_raw_data" : os.path.join(run_data,"raw_renamed"),
"reference_file": os.path.join(code,project_folder, "scripts.flaski", filename),
"raw_fastq": os.path.join(raw_data),
"renamed_fastq": os.path.join(run_data,project_folder,"raw_renamed"),
"fastqc_raw_data" : os.path.join(run_data,project_folder,"raw_renamed"),
"cutadapt_raw_data" : os.path.join(run_data,project_folder,"raw_renamed"),
"sgRNA_size" : sgRNA_size,
"SSC_sgRNA_size" : SSC_sgRNA_size,
"upstreamseq" : upstreamseq,
"library" : os.path.join(run_data,"library.csv"),
"input_count" : os.path.join(run_data,"cutadapt_output"),
"library" : os.path.join(run_data,project_folder,"library.csv"),
"input_count" : os.path.join(run_data,project_folder,"cutadapt_output"),
"output_count" : "mageck_output/count",
"mageck_counts_type":"mageck",
"samples_tsv": os.path.join(run_data,"samples.tsv"),
"samples_tsv": os.path.join(run_data,project_folder,"samples.tsv"),
"output_test":"mageck_output/test",
"mageck_test_remove_zero": mageck_test_remove_zero,
"mageck_test_remove_zero_threshold": mageck_test_remove_zero_threshold ,
"cnv_file": cnv_file,
"cnv_line": cnv_line,
"output_mle": "mageck_output/mle",
"efficiency_matrix": f"/SSC0.1/matrix/{efficiency_matrix}",
"mle_matrices": os.path.join(raw_data, folder),
"library_xlsx": os.path.join(run_data, "library.xlsx"),
"mle_matrices": os.path.join(raw_data),
"library_xlsx": os.path.join(run_data, project_folder,"library.xlsx"),
"gmt_file":gmt_file,
"output_pathway":"mageck_output/pathway",
"output_plot":"mageck_output/plot",
"output_vispr":"mageck_output/vispr",
"vispr_fastqc": os.path.join(run_data, "fastqc_output"),
"vispr_fastqc": os.path.join(run_data,project_folder,"fastqc_output"),
"vispr_species":species,
"vispr_assembly":assembly,
"output_flute":"mageck_output/flute",
"mageckflute_organism":mageckflute_organism,
"depmap":depmap,
"depmap_cell_line":depmap_cell_line,
"output_mageck_count" : os.path.join(run_data, "mageck_output/count"),
"output_mageck_count" : os.path.join(run_data,project_folder,"mageck_output/count"),
"output_magecku":"mageck_output/magecku",
"magecku_fdr":magecku_fdr,
"nontargeting_tag": nontargeting_tag ,
"magecku_threshold_control_groups":magecku_threshold_control_groups,
"magecku_threshold_treatment_groups":magecku_threshold_treatment_groups,
"output_bagel": os.path.join(run_data, "bagel_output"),
"output_bagel": os.path.join(run_data,project_folder,"bagel_output"),
"bagel_essential":BAGEL_ESSENTIAL,
"bagel_nonessential":BAGEL_NONESSENTIAL,
"output_drugz": os.path.join(run_data, "drugz_output"),
"output_acer":os.path.join(run_data, "acer_output"),
"output_drugz": os.path.join(run_data,project_folder,"drugz_output"),
"output_acer":os.path.join(run_data,project_folder,"acer_output"),
"use_neg_ctrl":use_neg_ctrl,
"using_master_library":using_master_library,
"acer_master_library":acer_master_library,
"md5sums":md5sums,\
"output_maude":os.path.join(run_data, "maude_output"),
"output_maude":os.path.join(run_data,project_folder,"maude_output"),
"facs":facs,
"ctrl_guides":ctrl_guides,
"mle_matrices":mle_matrices,
"skip_mle":skip_mle
}

if not use_neg_ctrl :
# if use_neg_ctrl == "F" :
if not use_neg_ctrl:
del(nf_["use_neg_ctrl"])
del(nf_["using_master_library"])
del(nf_["acer_master_library"])
del(nf_["output_acer"])
# del(nf_["output_acer"])

if not nontargeting_tag:
del(nf_["magecku_fdr"])
del(nf_["nontargeting_tag"])
del(nf_["magecku_threshold_control_groups"])
del(nf_["magecku_threshold_treatment_groups"])
del(nf_["output_magecku"])

if not facs :
del(nf_["output_maude"])
del(nf_["facs"])
del(nf_["ctrl_guides"])
# if not facs :
# # del(nf_["output_maude"])
# del(nf_["facs"])
# del(nf_["ctrl_guides"])

if skip_mle == "True" :
del(nf_["output_mle"])
@@ -436,8 +442,8 @@ def _generate_submission_file(
del(nf_["depmap"])
del(nf_["depmap_cell_line"])

if not depmap_cell_line :
del(nf_["depmap_cell_line"])
# if not depmap_cell_line :
# del(nf_["depmap_cell_line"])

if not magecku_fdr:
del(nf_["nontargeting_tag"])
@@ -481,10 +487,10 @@ def _generate_submission_file(
BAGEL_ESSENTIAL,\
BAGEL_NONESSENTIAL,\
mageckflute_organism ,\
nontargeting_tag ,\
magecku_fdr, \
magecku_threshold_control_groups,\
magecku_threshold_treatment_groups, \
nontargeting_tag,\
use_neg_ctrl, \
using_master_library,\
acer_master_library,\
@@ -933,8 +939,8 @@ def make_app_content(pathname):
dbc.Row(
[
dbc.Col( html.Label('MageckU nontargeting tag') ,md=3 , style={"textAlign":"right" }),
dbc.Col( dcc.Input(id='nontargeting_tag', value="Non-Targeting Control", type='text', style={ "width":"100%"} ) ,md=3 ),
dbc.Col( html.Label('[magecku] How the non targeting controls are labele'),md=3 ),
dbc.Col( dcc.Input(id='nontargeting_tag', placeholder="Non-Targeting Control", type='text', style={ "width":"100%"} ) ,md=3 ),
dbc.Col( html.Label('[magecku] How the non targeting controls are labelled'),md=3 ),
],
style={"margin-top":10}
),
@@ -1141,10 +1147,10 @@ def make_app_content(pathname):
"BAGEL_ESSENTIAL",\
"BAGEL_NONESSENTIAL",\
"mageckflute_organism",\
"nontargeting_tag",\
"magecku_fdr", \
"magecku_threshold_control_groups",\
"magecku_threshold_treatment_groups", \
"nontargeting_tag",\
"use_neg_ctrl", \
"using_master_library",\
"acer_master_library",\
@@ -1250,10 +1256,10 @@ def update_output(n_clicks, \
BAGEL_ESSENTIAL,\
BAGEL_NONESSENTIAL,\
mageckflute_organism,\
nontargeting_tag,\
magecku_fdr, \
magecku_threshold_control_groups,\
magecku_threshold_treatment_groups, \
nontargeting_tag,\
use_neg_ctrl, \
using_master_library,\
acer_master_library,\
@@ -1309,11 +1315,10 @@ def update_output(n_clicks, \
msg='''One or more samples in your list of control or treated samples does not match the sample names.'''
return header, msg, dash.no_update


subdic=generate_submission_file( samplenames, \
samples, \
library, \
email, \
subdic=generate_submission_file( samplenames,\
samples,\
library,\
email,\
group,\
experiment_name,\
folder,\
@@ -1336,18 +1341,18 @@ def update_output(n_clicks, \
BAGEL_ESSENTIAL,\
BAGEL_NONESSENTIAL,\
mageckflute_organism,\
magecku_fdr, \
magecku_threshold_control_groups,\
magecku_threshold_treatment_groups, \
nontargeting_tag,\
use_neg_ctrl, \
magecku_fdr,\
magecku_threshold_control_groups,\
magecku_threshold_treatment_groups,\
use_neg_ctrl,\
using_master_library,\
acer_master_library,\
facs,\
ctrl_guides,\
mle_matrices,\
ONLY_COUNT )

# samples=pd.read_json(subdic["samples"])
# metadata=pd.read_json(subdic["metadata"])

@@ -1398,7 +1403,7 @@ def update_output(n_clicks, \
def writeout(subdic=subdic, json_config=json_config, json_filename=json_filename, arguments=arguments,filename=filename ):
EXCout=pd.ExcelWriter(filename)
sampleNames[["Files","Name"]].to_excel(EXCout,"sampleNames",index=None)
samples[["Label","Pairness (paired or unpaired)", "List of control samples","List of treated samples","List of control sgRNAs", "List of control genes" ]].to_excel(EXCout,"samples",index=None)
samples[["Label","Pairness (paired or unpaired)", "List of control samples","List of treated samples","List of control sgRNAs", "List of control genes", "CNV line" ]].to_excel(EXCout,"samples",index=None)
library[["gene_ID","UID","seq","Annotation"]].to_excel(EXCout,"library",index=None)
arguments.to_excel(EXCout,"crispr",index=None)
EXCout.save()
@@ -1413,10 +1418,14 @@ def writeout(subdic=subdic, json_config=json_config, json_filename=json_filename
ftp_user=ftp_user["Value"].tolist()[0]
raw_folder=json_config[json_filename_]["raven"]["raw_fastq"]
raw_folder=os.path.join( raw_folder, ftp_user )
json_config[json_filename_]["raven"]["ftp"]=ftp_user
json_config[json_filename_]["studio"]["ftp"]=ftp_user
json_config[json_filename_]["raven"]["raw_fastq"]=raw_folder
json_config[json_filename_]["studio"]["raw_fastq"]=raw_folder
json_config[os.path.basename(json_filename)]["raven"]["ftp"]=ftp_user
json_config[os.path.basename(json_filename)]["studio"]["ftp"]=ftp_user
json_config[os.path.basename(json_filename)]["raven"]["raw_fastq"]=raw_folder
json_config[os.path.basename(json_filename)]["studio"]["raw_fastq"]=raw_folder

if mle_matrices:
json_config[os.path.basename(json_filename)]["raven"]["mle_matrices"]=os.path.join(raw_folder,mle_matrices)
json_config[os.path.basename(json_filename)]["studio"]["mle_matrices"]=os.path.join(raw_folder,mle_matrices)

if BAGEL_NONESSENTIAL != "/bagel/NEGv1.txt" :
json_config[os.path.basename(json_filename)]["raven"]["bagel_nonessential"]=os.path.join(raw_folder,BAGEL_NONESSENTIAL)
Loading

0 comments on commit 51eaca7

Please sign in to comment.