Skip to content

Instantly share code, notes, and snippets.

@gideonite
Created November 20, 2019 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gideonite/87e99a346ff5c400ce81c80eff5dc2d0 to your computer and use it in GitHub Desktop.
Save gideonite/87e99a346ff5c400ce81c80eff5dc2d0 to your computer and use it in GitHub Desktop.
for Philip
#!/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