Skip to content

Commit 07c651b

Browse files
committed
First stab at implementing PLINK format for fastStructure.
1 parent 5f220a2 commit 07c651b

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

structure_threader.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,23 @@ def runprogram(iterations):
5656
else: # Run fastStructure
5757
# Keeps correct directory separator across OS's
5858
output_file = os.path.join(outpath, "fS_run_K")
59-
from os import symlink
60-
try:
61-
symlink(infile, infile+".str")
62-
except OSError as err:
63-
if err.errno != 17:
64-
raise
59+
if infile.endswith((".bed", ".fam", ".bim")):
60+
file_format = "bed"
61+
infile = infile[:-4]
62+
else:
63+
file_format = "str" # Assume str format if plink is not specified
64+
if infile.endswith(".str") is False: # Do we need a symlink?
65+
from os import symlink
66+
try:
67+
symlink(infile, infile+".str")
68+
except OSError as err:
69+
if err.errno != 17:
70+
raise
71+
else:
72+
infile = infile[:-4]
6573

6674
cli = ["python2", arg.faststructure_bin, "-K", str(K), "--input",
67-
infile, "--output", output_file, "--format=str"]
75+
infile, "--output", output_file, "--format", file_format]
6876

6977
print("Running: " + " ".join(cli))
7078
program = subprocess.Popen(cli, bufsize=64, shell=False,

0 commit comments

Comments
 (0)