-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a genbank parser to python through the C shared library. Most of this was written by AI, because it's pretty annoying to write, and is mostly just piping data. Amazingly, it seems to work. I also added a little benchmark showing that we have comparable performance to biopython - but I'm sure some of our other features will be even better in that regard. - Keoni
- Loading branch information
Showing
9 changed files
with
849 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import timeit | ||
import os | ||
from Bio import SeqIO | ||
from dnadesign.parsers import parse_genbank_from_c_file | ||
|
||
def benchmark_dnadesign(file_path, num_iterations=10): | ||
def parse_with_dnadesign(): | ||
records = parse_genbank_from_c_file(file_path) | ||
return records | ||
|
||
time_taken = timeit.timeit(parse_with_dnadesign, number=num_iterations) | ||
return time_taken / num_iterations | ||
|
||
def benchmark_biopython(file_path, num_iterations=10): | ||
def parse_with_biopython(): | ||
with open(file_path, "r") as handle: | ||
records = list(SeqIO.parse(handle, "genbank")) | ||
return records | ||
|
||
time_taken = timeit.timeit(parse_with_biopython, number=num_iterations) | ||
return time_taken / num_iterations | ||
|
||
def main(): | ||
current_dir = os.path.dirname(__file__) | ||
example_path = os.path.join(current_dir, '../lib/bio/genbank/data/bsub.gbk') | ||
|
||
print(f"Benchmarking GenBank parsing for file: {example_path}") | ||
print("Running 10 iterations for each parser...") | ||
|
||
dnadesign_time = benchmark_dnadesign(example_path) | ||
biopython_time = benchmark_biopython(example_path) | ||
|
||
print(f"\nResults:") | ||
print(f"DNA design average time: {dnadesign_time:.6f} seconds") | ||
print(f"BioPython average time: {biopython_time:.6f} seconds") | ||
|
||
speedup = biopython_time / dnadesign_time | ||
print(f"\nDNA design is {speedup:.2f}x faster than BioPython") | ||
|
||
if __name__ == "__main__": | ||
main() |
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
Oops, something went wrong.