Skip to content

Commit

Permalink
feat: adds -n, --nb-models option
Browse files Browse the repository at this point in the history
This option allows to choose the number of target models generated by MODELLER
  • Loading branch information
thomas-bailly committed Jul 8, 2024
1 parent fd97c62 commit bc6fb7a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
11 changes: 7 additions & 4 deletions asmc/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
## Functions ##
###############

def modeling(aln, outdir):
def modeling(aln, outdir, n):
"""Build model
Args:
aln (str): String containing the path to the alignment and the reference name
outdir (pathlib.Path): Path to the output directory
outdir (pathlib.Path): Path to the output directory
n (int): number of target models generated by MODELLER
Returns:
(int): 0
Expand All @@ -35,7 +36,7 @@ def modeling(aln, outdir):
automodel.assess.GA341))

a.starting_model = 1
a.ending_model = 2
a.ending_model = n
a.make()

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

args = parser.parse_args()

modeling(args.ali, Path(args.outdir))
modeling(args.ali, Path(args.outdir), args.nb_models)
9 changes: 6 additions & 3 deletions run_asmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,14 @@ def run_build_ali(ref, seq, pocket, outdir, pid, log):

return ret

def modeling(job_file, outdir, threads):
def modeling(job_file, outdir, threads, n):
"""Prepares data and execute in parallel the run_modeling function
Args:
job (pathlib.Path): Path of file containing the list of inputs
outdir (pathlib.Path): Path to the output directory
threads (int): Number of parallel jobs
n (int): number of target models generated by MODELLER
Returns:
ret (subprocess.CompletedProcess): The completed process
Expand All @@ -176,7 +177,7 @@ def modeling(job_file, outdir, threads):
job_list = []
with open(job_file, "r") as f:
for line in f:
job_list.append(f"python3 {src_path} -a {line.strip()} -o {model_dir}")
job_list.append(f"python3 {src_path} -a {line.strip()} -o {model_dir} -n {n}")

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

Expand Down

0 comments on commit bc6fb7a

Please sign in to comment.