Created
November 20, 2019 16:43
-
-
Save gideonite/87e99a346ff5c400ce81c80eff5dc2d0 to your computer and use it in GitHub Desktop.
for Philip
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/python_ | |
import sys,os | |
def main(): | |
basedir = "/cluster/work/grlab/projects/projects2018-germlinesqtl/PM_transQTL_analysis/ensembl-vep" | |
filename = "mergedQTL_v3_VEP_output.vep.txt" | |
fullpath = os.path.join(basedir, filename) | |
full_delimiter = "\t" | |
extra_col_delimiter = ";" | |
with open(fullpath, 'r') as file: | |
for line in file.readlines(): | |
line = line.strip() | |
parts = line.split(full_delimiter) | |
if line[0] == "#": | |
# header line | |
extra_col = parts.index("Extra") | |
else: | |
# body lines | |
val = parts[extra_col] | |
extra_col_parts = val.split(extra_col_delimiter) | |
new_col = parts[:extra_col] + parts[extra_col+1:] + extra_col_parts | |
print("\t".join(new_col)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment