Skip to content

Commit

Permalink
Merge pull request #19 from pinellolab/thread_limit_removal
Browse files Browse the repository at this point in the history
Thread limit removal
  • Loading branch information
samuelecancellieri authored Jan 27, 2023
2 parents 14d25e3 + 2ea2e9a commit 1c96deb
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ guides/
*.pkl
*.txt
*.zip
PostProcess/dnaShape.pkl
2 changes: 2 additions & 0 deletions PostProcess/annotate_final_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
with open(inAnnotationFile, 'r') as annotations:
for line in annotations:
x = line.split('\t')
if 'vuoto.txt' in inAnnotationFile:
break
annotations_list = str(x[3]).strip()
if str(x[0]) in annotationDict.keys():
annotationDict[str(x[0])][int(x[1]):int(x[2])] = str(x[0])+'\t'+annotations_list
Expand Down
Binary file modified PostProcess/dnaShape.pkl
Binary file not shown.
12 changes: 6 additions & 6 deletions PostProcess/pool_post_analisi_indel.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
dict_folder = sys.argv[10]
final_res = sys.argv[11]
final_res_alt = sys.argv[12]
# ncpus=int(sys.argv[13])
ncpus = 4
ncpus=int(sys.argv[13])
# ncpus = 4


def start_analysis(f):
Expand All @@ -35,8 +35,8 @@ def start_analysis(f):
if 'vcf.gz' in f:
chrs.append(f)

t = 6
if ncpus < 6:
t = ncpus
with Pool(processes=t) as pool:
# t = 6
# if ncpus < 6:
# t = ncpus
with Pool(processes=ncpus) as pool:
pool.map(start_analysis, chrs)
8 changes: 4 additions & 4 deletions PostProcess/pool_post_analisi_snp.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def start_analysis(f):
if '.fa' in f and '.fai' not in f:
chrs.append(f)

t = 6
if ncpus < 6:
t = ncpus
with Pool(processes=t) as pool:
# t = 6
# if ncpus < 6:
# t = ncpus
with Pool(processes=ncpus) as pool:
pool.map(start_analysis, chrs)
21 changes: 11 additions & 10 deletions PostProcess/pool_search_indels.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
output_folder = sys.argv[10]
true_pam = sys.argv[11]
current_working_directory = sys.argv[12]
threads = int(sys.argv[13])


def search_indels(f):
global use_thread
# global use_thread
splitted = f.split('.')
for elem in splitted:
if "chr" in elem:
Expand All @@ -42,18 +43,18 @@ def search_indels(f):
if 'vcf.gz' == f[-6:]:
chrs.append(f)

cpus = len(os.sched_getaffinity(0))
if cpus - 3 < 10:
if cpus - 3 < 0:
t = 1
else:
t = cpus - 3
else:
t = 10
# cpus = len(os.sched_getaffinity(0))
# if cpus - 3 < 10:
# if cpus - 3 < 0:
# t = 1
# else:
# t = cpus - 3
# else:
# t = 10

os.chdir(output_folder)
# with Pool(processes=t) as pool:
with Pool(processes=t) as pool:
with Pool(processes=threads) as pool:
pool.map(search_indels, chrs)


Expand Down
2 changes: 2 additions & 0 deletions PostProcess/radar_chart_dict_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ def fillDict(guide, guideDict, motifDict):

# read all the annotations
for line in inAnnotationsFile:
if 'vuoto.txt' in sys.argv[4]: #se vuoto.txt usato come annotazione, skippa lettura
break
annotations_list = line.strip().split('\t')[3].split(',')
for annotation in annotations_list:
if '_personal' not in annotation:
Expand Down
2 changes: 1 addition & 1 deletion PostProcess/submit_job_automated_new_multiple_vcfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ while read vcf_f; do
cd $starting_dir
#commented to avoid indels search
#TODO REMOVE POOL SCRIPT FROM PROCESSING
./pool_search_indels.py "$ref_folder" "$vcf_folder" "$vcf_name" "$guide_file" "$pam_file" $bMax $mm $bDNA $bRNA "$output_folder" $true_pam "$current_working_directory/"
./pool_search_indels.py "$ref_folder" "$vcf_folder" "$vcf_name" "$guide_file" "$pam_file" $bMax $mm $bDNA $bRNA "$output_folder" $true_pam "$current_working_directory/" "$ncpus"
# mv "$output_folder/indels_${ref_name}+${vcf_name}_${pam_name}_${guide_name}_${mm}_${bDNA}_${bRNA}.targets.txt" "$output_folder/crispritz_targets"
awk '($3 !~ "n") {print $0}' "$output_folder/indels_${ref_name}+${vcf_name}_${pam_name}_${guide_name}_${mm}_${bDNA}_${bRNA}.targets.txt" >"$output_folder/indels_${ref_name}+${vcf_name}_${pam_name}_${guide_name}_${mm}_${bDNA}_${bRNA}.targets.txt.tmp"
mv "$output_folder/indels_${ref_name}+${vcf_name}_${pam_name}_${guide_name}_${mm}_${bDNA}_${bRNA}.targets.txt.tmp" "$output_folder/indels_${ref_name}+${vcf_name}_${pam_name}_${guide_name}_${mm}_${bDNA}_${bRNA}.targets.txt"
Expand Down

0 comments on commit 1c96deb

Please sign in to comment.