Exemplo n.º 1
0
def main():
	parser = OptionParser(usage=usage)
	(options, args) = parser.parse_args()

	list_of_autosomes = range(1,23)

	for autosome in list_of_autosomes: 
		
		# read tag SNP file 
		tag_snp_file = open("Results/tags_chr" + str(autosome) + ".txt")
		tag_snp_file.next() # discard header

		#print('Processing tag SNP file...')
		del_snp_pairs, snp_positions = [], []
		for line in tag_snp_file:
			del_snp_pairs.append(DeletionTAGSNPPair(line))
			snp_positions.append(del_snp_pairs[-1].snp_pos)
		#print('DONE processing tag SNP file...')
	
		# read VCF file
		#print('Processing VCF file...')
		snp_reader = SNPReader(1, max_major_af = .96)		
		snp_reader.readRawList(snp_positions)
		#print('DONE Processing VCF file...')
		
		# Postprocess every tag SNP-deletion pair
		for del_snp_pair in del_snp_pairs:
			for snp in snp_reader.snps:
				if del_snp_pair.snp_pos == snp.position: 
					del_snp_pair.addReferenceAlternativeAllele(snp.vcf_record.REF, snp.vcf_record.ALT[0])
			del_snp_pair.update()
			del_snp_pair.print()	
Exemplo n.º 2
0
def main():

	parser = OptionParser(usage=usage)
	parser.add_option("-a", action="store", dest="max_major_af", default=.96, type=float,
				  		help="Max. major allele frequency for a deletion and a snp to be considered. (Default = .96)")
	parser.add_option("-d", action="store", dest="distance_threshold", default=1000000, type=int,
				  		help="Max. distance between SNP and deletion for the pair to be considered. (Default = 10^6)")
	(options, args) = parser.parse_args()

	if (len(args)!=1):
		parser.print_help()
		return 1

	chromosome = int(args[0])

	deletion_reader = DeletionReader(max_major_af = options.max_major_af)
	# Read in the relevant data
	deletion_reader.read(chromosome)
	snp_reader = SNPReader(chromosome, max_major_af = options.max_major_af)		
	snp_reader.read()

	print('# of SNPs now: ', len(snp_reader.snps))

	# walk through all SNPs:
	for snp in snp_reader.snps:
		# walk through all deletions
		for deletion in deletion_reader.deletions: 
			distance_snp_deletion = deletion.minimumDistanceTo(snp.position)
			if distance_snp_deletion > options.distance_threshold:
				continue
			table = Table2x2(snp.haplotypes, deletion.haplotypes)
			# output relevant data:
			snp.store()
			deletion.store()
			print(distance_snp_deletion, '\t', end = '')
			table.store()
			print(table.R(), '\t', table.FishersExactTest())