-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess_sequences_species_file_v2.py
54 lines (43 loc) · 2.01 KB
/
process_sequences_species_file_v2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from cgr_by_chrom_v3 import generate_images
from process_folders_species import process_files
import os
import argparse
# Initialize argument parser
parser = argparse.ArgumentParser(description='Process specified input file for CGR generation.')
parser.add_argument('--input_file', type=str, help='Path to the input .fa file')
parser.add_argument('--out_folder', type=str, help='Path to the output folder')
parser.add_argument('--size', type=int, default=512, help='Size of the output image')
parser.add_argument('--norm', type=str, default='no_norm', choices=['robust_scaler', 'no_norm'], help='Normalization option')
# Parse the arguments
args = parser.parse_args()
# Assign the arguments to variables
input_file = args.input_file
out_folder = args.out_folder
size = args.size
norm = args.norm
# Other code logic stays the same
print(input_file)
# Check by chrom
filename = os.path.basename(input_file)
prefix = filename.split(".")[0]
#prefix = prefix.split("_")[0]
chr_num = filename.split(".")[1]
chr_num = "chr" + chr_num
# Set folder path
folder_path = os.path.join(out_folder, prefix, chr_num, "")
os.makedirs(folder_path, exist_ok=True)
# CGR
print(f"Processing '{filename}':")
print(folder_path)
# Determine the scaler
robust_scaler = True if norm == 'robust_scaler' else False
# # Generate images
# if robust_scaler:
# generate_images(input_file, size=size, int_matrix=False, output_folder=folder_path, affix=("_" + chr_num), show_plot=False, robust_scaler=True)
# else:
# generate_images(input_file, size=size, int_matrix=False, output_folder=folder_path, affix=("_" + chr_num), show_plot=False, no_norm=True)
# Generate images
if robust_scaler:
generate_images(input_file, size=size, int_matrix=False, output_folder=folder_path, affix=("_" + chr_num), show_plot=False, robust_scaler=True, sequence_names_file="./chr2_list.txt")
else:
generate_images(input_file, size=size, int_matrix=False, output_folder=folder_path, affix=("_" + chr_num), show_plot=False, no_norm=True, sequence_names_file="./chr2_list.txt")