PDX-Flamingo/codonpdx-python — pull request #2 by ptseng (2014-06-11 08:00:03+00:00)
Title: Exposed Fast C counter to python

The counter was written in C.
It was compiled to a shared library 'counterc.so'
The shared library was exposed to python using ctypes.
The C function returns a C struct which is eventually made into a Python dictionary.
main.py has been refactored to use the new counter.
bench.py is provided to test the counter's speed.

Here is some sample output.
```bash
gzip -cd complete.1.genomic.gbff.gz | python main.py -f genbank
[
{
"annotations": "{'comment': '\\nContig AARG01000015 was replaced by the complete pFN3 plasmid in\\nCP000710.', 'sequence_version': 1, 'source': 'Fusobacterium nucleatum subsp. polymorphum ATCC 10953', 'taxonomy': ['Bacteria', 'Fusobacteria', 'Fusobacteriales', 'Fusobacteriaceae', 'Fusobacterium'], 'keywords': ['WGS', 'RefSeq'], 'references': [Reference(title='Direct Submission', ...)], 'accessions': ['NZ_AARG01000001', 'NZ_AARG00000000'], 'data_file_division': 'BCT', 'date': '17-FEB-2009', 'organism': 'Fusobacterium nucleatum subsp. polymorphum ATCC 10953', 'gi': '110592360'}",
"codoncount": {
"AAA": 361,
"AAC": 52,
"AAG": 183,
"AAT": 258,
"ACA": 58,
"ACC": 13,
"ACG": 6,
"ACT": 67,
"AGA": 99,
"AGC": 35,
"AGG": 44,
"AGT": 84,
"ATA": 241,
"ATC": 39,
"ATG": 114,
"ATT": 204,
"CAA": 91,
"CAC": 15,
"CAG": 50,
"CAT": 43,
"CCA": 18,
"CCC": 5,
"CCG": 0,
"CCT": 20,
"CGA": 7,
"CGC": 1,
"CGG": 0,
"CGT": 3,
...
```

```bash
cat cow.seq | python bench.py
{'CTT': 578526, 'TAG': 385361, 'ACA': 570762, 'ACG': 59782, 'ATC': 382642, 'AAC': 422809, 'ATA': 646304, 'AGG': 458186, 'CCT': 455130, 'ACT': 463769, 'AGC': 365433, 'AAG': 577313, 'AGA': 627866, 'CAT': 531415, 'AAT': 770510, 'ATT': 773553, 'CTG': 521121, 'CTA': 383136, 'CTC': 432919, 'CAC': 387600, 'AAA': 1160703, 'CCG': 58156, 'AGT': 463957, 'CCA': 478747, 'CAA': 546849, 'CCC': 310692, 'TAT': 647698, 'GGT': 306196, 'TGT': 574118, 'CGA': 52125, 'CAG': 520075, 'TCT': 628490, 'GAT': 382211, 'CGG': 57943, 'TTT': 1169127, 'TGC': 381261, 'GGG': 310647, 'TGA': 556172, 'GGA': 403467, 'TGG': 479804, 'GGC': 285218, 'TAC': 338345, 'TTC': 572415, 'TCG': 52363, 'TTA': 653679, 'TTG': 551344, 'TCC': 402091, 'ACC': 306416, 'TAA': 650744, 'GCA': 380165, 'GTA': 339118, 'GCC': 284110, 'GTC': 251551, 'GCG': 50561, 'GTG': 389988, 'GAG': 434060, 'GTT': 426786, 'GCT': 365314, 'GAC': 249625, 'CGT': 59720, 'GAA': 571097, 'TCA': 557273, 'ATG': 531010, 'CGC': 50561}
Tokenize and Count in 594 ms
```