Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ########################################################################
- #This script is used to convert BWA-generated .sam files to the IGB .gr
- #file format.
- ########################################################################
- import re
- import string
- import sys
- from math import *
- from Bio import SeqIO
- import numpy as np
- from array import array
- #set the constant for the start and end of the genome -- adjust this for different genome
- #for subtilis genome, this is from version 3 file
- GENOME_START_POS = 1
- GENOME_END_POS = 4215606
- geno = array('I')
- for x in range(GENOME_END_POS-1):
- geno.append(0)
- with open(sys.argv[1]) as f:
- for line in f:
- if not line.startswith('@'):
- read = line.split()
- pos = int(read[3])
- for i in range(pos+1,pos+51):
- #print pos
- geno[i] = geno[i]+1
- outfile=open(sys.argv[2],'w')
- x=0
- percent = 0
- part = GENOME_END_POS / 20
- for i in geno:
- x+=1
- outfile.write(str(x)+' '+str(i)+'\n')
- if (x % part == 0):
- percent+=5
- print str(percent)+"%"
- outfile.close()
- print 'done'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement