Skip to content

Commit bc6fb7a

Browse files
committed
feat: adds -n, --nb-models option
This option allows to choose the number of target models generated by MODELLER
1 parent fd97c62 commit bc6fb7a

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

asmc/modeling.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
## Functions ##
1010
###############
1111

12-
def modeling(aln, outdir):
12+
def modeling(aln, outdir, n):
1313
"""Build model
1414
1515
Args:
1616
aln (str): String containing the path to the alignment and the reference name
17-
outdir (pathlib.Path): Path to the output directory
17+
outdir (pathlib.Path): Path to the output directory
18+
n (int): number of target models generated by MODELLER
1819
1920
Returns:
2021
(int): 0
@@ -35,7 +36,7 @@ def modeling(aln, outdir):
3536
automodel.assess.GA341))
3637

3738
a.starting_model = 1
38-
a.ending_model = 2
39+
a.ending_model = n
3940
a.make()
4041

4142
model_name = ""
@@ -63,7 +64,9 @@ def modeling(aln, outdir):
6364
" ref name(s), e.g: /home/data/target.ali+refA+refB+refC")
6465
parser.add_argument("-o", "--outdir", type=str, metavar="", default="./",
6566
help="output directory [default: ./]")
67+
parser.add_argument("-n", "--nb-models", type=int, default=2, metavar="",
68+
help="number of target models generated by MODELLER")
6669

6770
args = parser.parse_args()
6871

69-
modeling(args.ali, Path(args.outdir))
72+
modeling(args.ali, Path(args.outdir), args.nb_models)

run_asmc.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,14 @@ def run_build_ali(ref, seq, pocket, outdir, pid, log):
149149

150150
return ret
151151

152-
def modeling(job_file, outdir, threads):
152+
def modeling(job_file, outdir, threads, n):
153153
"""Prepares data and execute in parallel the run_modeling function
154154
155155
Args:
156156
job (pathlib.Path): Path of file containing the list of inputs
157157
outdir (pathlib.Path): Path to the output directory
158158
threads (int): Number of parallel jobs
159+
n (int): number of target models generated by MODELLER
159160
160161
Returns:
161162
ret (subprocess.CompletedProcess): The completed process
@@ -176,7 +177,7 @@ def modeling(job_file, outdir, threads):
176177
job_list = []
177178
with open(job_file, "r") as f:
178179
for line in f:
179-
job_list.append(f"python3 {src_path} -a {line.strip()} -o {model_dir}")
180+
job_list.append(f"python3 {src_path} -a {line.strip()} -o {model_dir} -n {n}")
180181

181182
with multiprocessing.Pool(processes=threads) as pool:
182183
ret = set(pool.map(run_modeling, job_list))
@@ -387,6 +388,8 @@ def run_usalign(job, usalign, log):
387388
help="percent identity cutoff between target and "
388389
"reference to build a model of the target, only "
389390
"used with -s, --seqs [default: 30.0]")
391+
targts_opt.add_argument("-n", "--nb-models", type=int, default=2, metavar="",
392+
help="number of target models generated by MODELLER")
390393
dbscan_opt = parser.add_argument_group("Clustering options")
391394
dbscan_opt.add_argument("-e", "--eps", type=str, metavar="", default="auto",
392395
help="maximum distance between two samples for them"
@@ -545,7 +548,7 @@ def run_usalign(job, usalign, log):
545548
sys.exit(1)
546549
else:
547550
start_model = datetime.datetime.now()
548-
ret_model = modeling(job_file, outdir, args.threads)
551+
ret_model = modeling(job_file, outdir, args.threads, args.nb_models)
549552
logging.info("modeling duration: "
550553
f"{datetime.datetime.now() - start_model}")
551554

0 commit comments

Comments
 (0)