Читать книгу Algorithms in Bioinformatics - Paul A. Gagniuc - Страница 60

Additional algorithm 2.2 Note that the source code is in context and works with copy/paste.

Оглавление

<script> // DNA to meters var a = 'Ambystoma mexicanum|32396Mb' + 'Pinus lambertiana|27603Mb' + 'Sequoia sempervirens|26537Mb' + 'Minicystis rosea|16Mb' + 'Sorangium cellulosum So0157-2|14.78Mb' + 'Escherichia coli|4.9Mb' + 'Encephalitozoon intestinalis|2.3Mb' + 'Ostreococcus tauri|12.6Mb' + 'Homo sapiens|3100Mb'; var t = a.split('Mb'); for (var u=0; u<t.length-1; u ++) { var r = t[u].split('|'); document.write(r[0] + ' (' + r[1] + ' Mb) = '); document.write(f(r[1]) + ' meters<br>'); } function f(Mb){return (0.34 * 1000000 * Mb)/1000000000;} </script> Output: Ambystoma mexicanum (32396 Mb) = 11.01464 meters Pinus lambertiana (27603 Mb) = 9.38502 meters Sequoia sempervirens (26537 Mb) = 9.02258 meters Minicystis rosea (16 Mb) = 0.00544 meters Sorangium cellulosum So0157-2 (14.78 Mb) = 0.0050252 meters Escherichia coli (4.9 Mb) = 0.0016660000000000002 meters Encephalitozoon intestinalis (2.3 Mb) = 0.0007819999999999999 meters Ostreococcus tauri (12.6 Mb) = 0.004284 meters Homo sapiens (3100 Mb) = 1.054 meters

To call function f repeatedly, a parsing-based method is used. Above, variable a contains a series of records. The structure of these records is based on two delimiters, namely: “|” and “Mb.” Delimiter “|” separates the species name ( r[0] ) from the size of the genome ( r[1] ), while the “Mb” delimiter separates the records from each other ( t[u] ). Please note that 0.001 m equals 1 mm. For instance, the output of Additional algorithm 2.2 shows that Escherichia coli contains a genome of ∼1.6 mm in length (0.0016 m), or that E. intestinalis contains a genome of 0.78 mm in length (0.00078 m).

Algorithms in Bioinformatics

Подняться наверх