Created
March 29, 2021 16:19
-
-
Save jasonsahl/b950e350fa67910bf5916dd2ecd460c3 to your computer and use it in GitHub Desktop.
transpose a BSR matrix
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 | |
import sys | |
from sys import argv | |
try: | |
out_matrix = open("transposed_matrix.matrix", "w") | |
reduced = [] | |
with open(argv[1]) as my_file: | |
for line in my_file: | |
newline=line.strip("\n") | |
fields = newline.split("\t") | |
reduced.append(fields) | |
test=map(list, zip(*reduced)) | |
for x in test: | |
out_matrix.write("\t".join(x)+"\n") | |
out_matrix.close() | |
except: | |
print("usage: script bsr_matrix.txt") | |
sys.exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment