Relative frequencies of the nucleotides in Fasta files
I have 2 fasta files (File A, File B) each one contains sequence, How can I report the relative frequencies of the nucleotides in set A and set B with python?
Thanks in advance
• 558 views
Hi check the link in the comments and read the biopython documentation. Until then, try this:
#!/usr/bin/env python from Bio import SeqIO for fasta_path in ['/path/to/fasta1', '/path/to/fasta2']: count_nucletides = dict([(i,0) for i in "ACTG"]) for record in SeqIO.parse(fasta_path, 'fasta'): for nucleotide in count_nucletides: count_nucletides[nucleotide] += record.seq.count(nucleotide) print(fasta_path) print('n'.join(['{}: {}'.format(i,count_nucletides[i]) for i in count_nucletides]))
Traffic: 1852 users visited in the last hour
Read more here: Source link