Last active
August 29, 2015 14:22
-
-
Save ElDeveloper/dabccfb9024378262549 to your computer and use it in GitHub Desktop.
Convert nmds.py output to an emperor friendly format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from sys import argv | |
# USE AT YOUR OWN RISK | |
# first argument is file to convert, second argument is file to | |
# write the converted output to | |
with open(argv[1]) as f, open(argv[2], 'w') as g: | |
for line in f: | |
if line.startswith('samples'): | |
g.write(line.replace('samples', 'pc vector number')) | |
# inflate the values so emperor won't complain about them being | |
# too small | |
elif line.startswith('stress'): | |
x = line.split('\t') | |
g.write('eigvals\t%s\n' % '\t'.join(['1']*(len(x)-1))) | |
elif line.startswith('% variation explained'): | |
x = line.split('\t') | |
g.write('%% variation explained\t%s\n' % '\t'.join(['1']*(len(x)-1))) | |
else: | |
g.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment