Skip to content

Commit 09d95cb

Browse files
committed
Adds an intial ALStructure wrapper
1 parent 078ba2c commit 09d95cb

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

structure_threader/structure_threader.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import wrappers.maverick_wrapper as mw
3535
import wrappers.faststructure_wrapper as fsw
3636
import wrappers.structure_wrapper as sw
37+
import wrappers.alstructure_wrapper as alsw
3738
import argparser
3839

3940
except ImportError:
@@ -43,6 +44,7 @@
4344
import structure_threader.wrappers.maverick_wrapper as mw
4445
import structure_threader.wrappers.faststructure_wrapper as fsw
4546
import structure_threader.wrappers.structure_wrapper as sw
47+
import structure_threader.wrappers.alstructure_wrapper as alsw
4648
import structure_threader.argparser as argparser
4749

4850
# Where are we?
@@ -85,10 +87,17 @@ def runprogram(wrapped_prog, iterations, arg):
8587
mav_params = mw.mav_params_parser(arg.params)
8688
cli, output_dir = mw.mav_cli_generator(arg, k_val, mav_params)
8789

90+
elif wrapped_prog == "alstructure": # Run ALStructure
91+
cli, output_file = alsw.alstr_cli_generator(arg, k_val)
92+
8893
else: # Run fastStructure
8994
cli, output_file = fsw.fs_cli_generator(k_val, arg)
9095

9196
logging.info("Running: " + " ".join(cli))
97+
if wrapped_prog == "alstructure":
98+
logging.info("If this is the first time running ALStructure it might "
99+
"take a while to install all the dependencies. Please "
100+
"be patient.")
92101
program = subprocess.Popen(cli,
93102
stdout=subprocess.PIPE,
94103
stderr=subprocess.PIPE)
@@ -277,6 +286,10 @@ def full_run(arg):
277286
wrapped_prog = "maverick"
278287
elif "-st" in sys.argv:
279288
wrapped_prog = "structure"
289+
elif "-als" in sys.argv:
290+
wrapped_prog = "alstructure"
291+
arg.threads = 1
292+
arg.notests = True
280293

281294
structure_threader(wrapped_prog, arg)
282295

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/python3
2+
3+
# Copyright 2019 Francisco Pina Martins <[email protected]>
4+
# This file is part of structure_threader.
5+
# structure_threader is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
9+
10+
# structure_threader is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
15+
# You should have received a copy of the GNU General Public License
16+
# along with structure_threader. If not, see <http://www.gnu.org/licenses/>.
17+
18+
import os
19+
import logging
20+
21+
22+
try:
23+
import colorer.colorer as colorer
24+
except ImportError:
25+
import structure_threader.colorer.colorer as colorer
26+
27+
28+
def alstr_cli_generator(arg, k_val):
29+
"""
30+
Generates and returns command line for running ALStructure.
31+
"""
32+
output_file = os.path.join(arg.outpath, "alstr_K" + str(k_val))
33+
if arg.infile.endswith((".bed", ".fam", ".bim")):
34+
infile = arg.infile[:-4]
35+
36+
cli = ["Rscript", arg.external_prog, infile, str(k_val), output_file]
37+
38+
return cli, output_file

0 commit comments

Comments
 (0)