-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8be99e4
commit 389066a
Showing
6 changed files
with
426 additions
and
12 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from dna_hash import DNAHash, tokenizers | ||
|
||
from Bio import SeqIO | ||
|
||
import matplotlib.pyplot as plt | ||
|
||
hash_table = DNAHash(max_false_positive_rate=0.001) | ||
|
||
tokenizer = tokenizers.Canonical(tokenizers.Kmer(6)) | ||
|
||
with open('covid-19-virus.fasta', 'r') as file: | ||
for record in SeqIO.parse(file, 'fasta'): | ||
for token in tokenizer.tokenize(str(record.seq)): | ||
hash_table.increment(token) | ||
|
||
counts, bins = hash_table.histogram(20) | ||
|
||
plt.stairs(counts, bins) | ||
plt.title('Histogram of SARS-CoV-2 Genome') | ||
plt.xlabel('Counts') | ||
plt.ylabel('Frequency') | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from dna_hash import DNAHash, tokenizers | ||
|
||
from Bio import SeqIO | ||
|
||
hash_table = DNAHash(max_false_positive_rate=0.001) | ||
|
||
tokenizer = tokenizers.Canonical(tokenizers.Kmer(6)) | ||
|
||
with open('covid-19-virus.fasta', 'r') as file: | ||
for record in SeqIO.parse(file, 'fasta'): | ||
for token in tokenizer.tokenize(str(record.seq)): | ||
hash_table.increment(token) | ||
|
||
for sequence, count in hash_table.top(25): | ||
print(f'{sequence}: {count}') | ||
|
||
print(f'Total sequences: {hash_table.num_sequences}') | ||
print(f'# of unique sequences: {hash_table.num_unique_sequences}') | ||
print(f'# of singletons: {hash_table.num_singletons}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters