Skip to content

Commit e71e716

Browse files
committed
Improved function structuring.
1 parent 3301716 commit e71e716

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

structure_threader/structure_threader.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,7 @@ def structure_threader(wrapped_prog, arg):
123123
if wrapped_prog != "structure":
124124
arg.replicates = [1]
125125
else:
126-
os.chdir(os.path.dirname(arg.infile))
127-
if arg.params is not None:
128-
mainparams = arg.params
129-
extraparams = os.path.join(os.path.dirname(arg.params),
130-
"extraparams")
131-
if os.path.isfile(extraparams) is False:
132-
logging.warning("No 'extraparams' file was found. An empty one "
133-
"was created, but it is highly recommended "
134-
"that you fill one out.")
135-
touch = open(extraparams, 'w')
136-
touch.close()
137-
arg.params = ["-m", mainparams, "-e", extraparams]
126+
sw.str_param_checker(arg)
138127

139128
jobs = list(itertools.product(arg.k_list, arg.replicates))[::-1]
140129

structure_threader/wrappers/structure_wrapper.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
# along with structure_threader. If not, see <http://www.gnu.org/licenses/>.
1717

1818
import os
19+
import logging
20+
21+
try:
22+
import colorer.colorer as colorer
23+
except ImportError:
24+
import structure_threader.colorer.colorer as colorer
1925

2026

2127
def str_cli_generator(arg, k_val, rep_num):
@@ -30,3 +36,21 @@ def str_cli_generator(arg, k_val, rep_num):
3036
cli += arg.params
3137

3238
return cli, output_file
39+
40+
41+
def str_param_checker(arg):
42+
"""
43+
Handles the parameter files for STRUCTURE (or lack thereoff)
44+
"""
45+
os.chdir(os.path.dirname(arg.infile))
46+
if arg.params is not None:
47+
mainparams = arg.params
48+
extraparams = os.path.join(os.path.dirname(arg.params),
49+
"extraparams")
50+
if os.path.isfile(extraparams) is False:
51+
logging.warning("No 'extraparams' file was found. An empty one "
52+
"was created, but it is highly recommended "
53+
"that you fill one out.")
54+
touch = open(extraparams, 'w')
55+
touch.close()
56+
arg.params = ["-m", mainparams, "-e", extraparams]

0 commit comments

Comments
 (0)