Tired of writing vcf_hg18_to_b36 over and over again when necessary. Added a -r flag to this script that does it.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4363 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
96cccafb0d
commit
37613810bf
|
|
@ -17,6 +17,7 @@ def main():
|
||||||
parser.add_option("", "--dry", dest="dry",
|
parser.add_option("", "--dry", dest="dry",
|
||||||
action='store_true', default=False,
|
action='store_true', default=False,
|
||||||
help="If provided, nothing actually gets run, just a dry run")
|
help="If provided, nothing actually gets run, just a dry run")
|
||||||
|
parser.add_option("-r","--reverse",dest="reverse",action="store_true",default=False,help="If set, will convert the hg18VCF to a b36VCF (thus reversing the functionality)")
|
||||||
|
|
||||||
(OPTIONS, args) = parser.parse_args()
|
(OPTIONS, args) = parser.parse_args()
|
||||||
if len(args) != 2:
|
if len(args) != 2:
|
||||||
|
|
@ -26,6 +27,7 @@ def main():
|
||||||
|
|
||||||
temp = open("tmp", 'w')
|
temp = open("tmp", 'w')
|
||||||
mitotemp = open("mtmp",'w')
|
mitotemp = open("mtmp",'w')
|
||||||
|
if not OPTIONS.reverse:
|
||||||
for line in open(b36vcf):
|
for line in open(b36vcf):
|
||||||
length = len(line)
|
length = len(line)
|
||||||
if length > 2 :
|
if length > 2 :
|
||||||
|
|
@ -42,6 +44,21 @@ def main():
|
||||||
temp.close()
|
temp.close()
|
||||||
mitotemp.close()
|
mitotemp.close()
|
||||||
os.system("cat mtmp tmp > "+hg18vcf+" ; rm mtmp ; rm tmp")
|
os.system("cat mtmp tmp > "+hg18vcf+" ; rm mtmp ; rm tmp")
|
||||||
|
else:
|
||||||
|
for line in open(hg18vcf):
|
||||||
|
if line.startswith("#") :
|
||||||
|
temp.write(line)
|
||||||
|
else:
|
||||||
|
spline = line.split("\t")
|
||||||
|
if ( spline[0] == "chrM" ):
|
||||||
|
spline[0] = "MT"
|
||||||
|
mitotemp.write("\t".join(spline))
|
||||||
|
else:
|
||||||
|
spline[0] = spline[0].split("chr")[1]
|
||||||
|
temp.write("\t".join(spline))
|
||||||
|
temp.close()
|
||||||
|
mitotemp.close()
|
||||||
|
os.system("cat tmp mtmp > "+b36vcf+" ; rm mtmp ; rm tmp")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue