ngoto-bio 1.2.9.9001
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +2046 -0
- data/README.rdoc +223 -0
- data/README_DEV.rdoc +285 -0
- data/Rakefile +70 -0
- data/bin/bioruby +44 -0
- data/bin/br_biofetch.rb +47 -0
- data/bin/br_bioflat.rb +293 -0
- data/bin/br_biogetseq.rb +45 -0
- data/bin/br_pmfetch.rb +421 -0
- data/bioruby.gemspec +463 -0
- data/bioruby.gemspec.erb +79 -0
- data/doc/Changes-0.7.rd +369 -0
- data/doc/Changes-1.3.rdoc +195 -0
- data/doc/KEGG_API.rd +1843 -0
- data/doc/KEGG_API.rd.ja +1834 -0
- data/doc/Tutorial.rd +1296 -0
- data/doc/Tutorial.rd.ja +2640 -0
- data/etc/bioinformatics/seqdatabase.ini +210 -0
- data/extconf.rb +2 -0
- data/lib/bio/alignment.rb +2518 -0
- data/lib/bio/appl/bl2seq/report.rb +334 -0
- data/lib/bio/appl/blast/ddbj.rb +142 -0
- data/lib/bio/appl/blast/format0.rb +1438 -0
- data/lib/bio/appl/blast/format8.rb +83 -0
- data/lib/bio/appl/blast/genomenet.rb +263 -0
- data/lib/bio/appl/blast/ncbioptions.rb +220 -0
- data/lib/bio/appl/blast/remote.rb +105 -0
- data/lib/bio/appl/blast/report.rb +767 -0
- data/lib/bio/appl/blast/rexml.rb +144 -0
- data/lib/bio/appl/blast/rpsblast.rb +277 -0
- data/lib/bio/appl/blast/wublast.rb +671 -0
- data/lib/bio/appl/blast/xmlparser.rb +236 -0
- data/lib/bio/appl/blast.rb +505 -0
- data/lib/bio/appl/blat/report.rb +530 -0
- data/lib/bio/appl/clustalw/report.rb +152 -0
- data/lib/bio/appl/clustalw.rb +219 -0
- data/lib/bio/appl/emboss.rb +203 -0
- data/lib/bio/appl/fasta/format10.rb +325 -0
- data/lib/bio/appl/fasta.rb +235 -0
- data/lib/bio/appl/gcg/msf.rb +212 -0
- data/lib/bio/appl/gcg/seq.rb +195 -0
- data/lib/bio/appl/genscan/report.rb +552 -0
- data/lib/bio/appl/hmmer/report.rb +683 -0
- data/lib/bio/appl/hmmer.rb +126 -0
- data/lib/bio/appl/iprscan/report.rb +374 -0
- data/lib/bio/appl/mafft/report.rb +226 -0
- data/lib/bio/appl/mafft.rb +259 -0
- data/lib/bio/appl/muscle.rb +52 -0
- data/lib/bio/appl/paml/baseml/report.rb +32 -0
- data/lib/bio/appl/paml/baseml.rb +95 -0
- data/lib/bio/appl/paml/codeml/rates.rb +67 -0
- data/lib/bio/appl/paml/codeml/report.rb +67 -0
- data/lib/bio/appl/paml/codeml.rb +242 -0
- data/lib/bio/appl/paml/common.rb +348 -0
- data/lib/bio/appl/paml/common_report.rb +38 -0
- data/lib/bio/appl/paml/yn00/report.rb +32 -0
- data/lib/bio/appl/paml/yn00.rb +103 -0
- data/lib/bio/appl/phylip/alignment.rb +129 -0
- data/lib/bio/appl/phylip/distance_matrix.rb +96 -0
- data/lib/bio/appl/probcons.rb +41 -0
- data/lib/bio/appl/psort/report.rb +457 -0
- data/lib/bio/appl/psort.rb +548 -0
- data/lib/bio/appl/pts1.rb +263 -0
- data/lib/bio/appl/sim4/report.rb +485 -0
- data/lib/bio/appl/sim4.rb +124 -0
- data/lib/bio/appl/sosui/report.rb +151 -0
- data/lib/bio/appl/spidey/report.rb +593 -0
- data/lib/bio/appl/targetp/report.rb +267 -0
- data/lib/bio/appl/tcoffee.rb +55 -0
- data/lib/bio/appl/tmhmm/report.rb +231 -0
- data/lib/bio/command.rb +593 -0
- data/lib/bio/compat/features.rb +157 -0
- data/lib/bio/compat/references.rb +128 -0
- data/lib/bio/data/aa.rb +349 -0
- data/lib/bio/data/codontable.rb +722 -0
- data/lib/bio/data/na.rb +223 -0
- data/lib/bio/db/aaindex.rb +357 -0
- data/lib/bio/db/biosql/biosql_to_biosequence.rb +67 -0
- data/lib/bio/db/biosql/sequence.rb +508 -0
- data/lib/bio/db/embl/common.rb +352 -0
- data/lib/bio/db/embl/embl.rb +500 -0
- data/lib/bio/db/embl/embl_to_biosequence.rb +85 -0
- data/lib/bio/db/embl/format_embl.rb +190 -0
- data/lib/bio/db/embl/sptr.rb +1283 -0
- data/lib/bio/db/embl/swissprot.rb +42 -0
- data/lib/bio/db/embl/trembl.rb +41 -0
- data/lib/bio/db/embl/uniprot.rb +42 -0
- data/lib/bio/db/fantom.rb +597 -0
- data/lib/bio/db/fasta/defline.rb +532 -0
- data/lib/bio/db/fasta/fasta_to_biosequence.rb +63 -0
- data/lib/bio/db/fasta/format_fasta.rb +97 -0
- data/lib/bio/db/fasta.rb +410 -0
- data/lib/bio/db/genbank/common.rb +307 -0
- data/lib/bio/db/genbank/ddbj.rb +22 -0
- data/lib/bio/db/genbank/format_genbank.rb +187 -0
- data/lib/bio/db/genbank/genbank.rb +250 -0
- data/lib/bio/db/genbank/genbank_to_biosequence.rb +86 -0
- data/lib/bio/db/genbank/genpept.rb +60 -0
- data/lib/bio/db/genbank/refseq.rb +18 -0
- data/lib/bio/db/gff.rb +1846 -0
- data/lib/bio/db/go.rb +481 -0
- data/lib/bio/db/kegg/brite.rb +41 -0
- data/lib/bio/db/kegg/compound.rb +131 -0
- data/lib/bio/db/kegg/drug.rb +98 -0
- data/lib/bio/db/kegg/enzyme.rb +148 -0
- data/lib/bio/db/kegg/expression.rb +155 -0
- data/lib/bio/db/kegg/genes.rb +263 -0
- data/lib/bio/db/kegg/genome.rb +241 -0
- data/lib/bio/db/kegg/glycan.rb +166 -0
- data/lib/bio/db/kegg/keggtab.rb +357 -0
- data/lib/bio/db/kegg/kgml.rb +256 -0
- data/lib/bio/db/kegg/orthology.rb +136 -0
- data/lib/bio/db/kegg/reaction.rb +82 -0
- data/lib/bio/db/kegg/taxonomy.rb +331 -0
- data/lib/bio/db/lasergene.rb +209 -0
- data/lib/bio/db/litdb.rb +107 -0
- data/lib/bio/db/medline.rb +326 -0
- data/lib/bio/db/nbrf.rb +191 -0
- data/lib/bio/db/newick.rb +658 -0
- data/lib/bio/db/nexus.rb +1854 -0
- data/lib/bio/db/pdb/atom.rb +77 -0
- data/lib/bio/db/pdb/chain.rb +210 -0
- data/lib/bio/db/pdb/chemicalcomponent.rb +224 -0
- data/lib/bio/db/pdb/model.rb +148 -0
- data/lib/bio/db/pdb/pdb.rb +1911 -0
- data/lib/bio/db/pdb/residue.rb +176 -0
- data/lib/bio/db/pdb/utils.rb +399 -0
- data/lib/bio/db/pdb.rb +29 -0
- data/lib/bio/db/prosite.rb +597 -0
- data/lib/bio/db/rebase.rb +456 -0
- data/lib/bio/db/soft.rb +404 -0
- data/lib/bio/db/transfac.rb +375 -0
- data/lib/bio/db.rb +329 -0
- data/lib/bio/feature.rb +139 -0
- data/lib/bio/io/biosql/biodatabase.rb +64 -0
- data/lib/bio/io/biosql/bioentry.rb +29 -0
- data/lib/bio/io/biosql/bioentry_dbxref.rb +11 -0
- data/lib/bio/io/biosql/bioentry_path.rb +12 -0
- data/lib/bio/io/biosql/bioentry_qualifier_value.rb +10 -0
- data/lib/bio/io/biosql/bioentry_reference.rb +10 -0
- data/lib/bio/io/biosql/bioentry_relationship.rb +10 -0
- data/lib/bio/io/biosql/biosequence.rb +11 -0
- data/lib/bio/io/biosql/comment.rb +7 -0
- data/lib/bio/io/biosql/config/database.yml +20 -0
- data/lib/bio/io/biosql/dbxref.rb +13 -0
- data/lib/bio/io/biosql/dbxref_qualifier_value.rb +12 -0
- data/lib/bio/io/biosql/location.rb +32 -0
- data/lib/bio/io/biosql/location_qualifier_value.rb +11 -0
- data/lib/bio/io/biosql/ontology.rb +10 -0
- data/lib/bio/io/biosql/reference.rb +9 -0
- data/lib/bio/io/biosql/seqfeature.rb +32 -0
- data/lib/bio/io/biosql/seqfeature_dbxref.rb +11 -0
- data/lib/bio/io/biosql/seqfeature_path.rb +11 -0
- data/lib/bio/io/biosql/seqfeature_qualifier_value.rb +20 -0
- data/lib/bio/io/biosql/seqfeature_relationship.rb +11 -0
- data/lib/bio/io/biosql/taxon.rb +12 -0
- data/lib/bio/io/biosql/taxon_name.rb +9 -0
- data/lib/bio/io/biosql/term.rb +27 -0
- data/lib/bio/io/biosql/term_dbxref.rb +11 -0
- data/lib/bio/io/biosql/term_path.rb +12 -0
- data/lib/bio/io/biosql/term_relationship.rb +13 -0
- data/lib/bio/io/biosql/term_relationship_term.rb +11 -0
- data/lib/bio/io/biosql/term_synonym.rb +10 -0
- data/lib/bio/io/das.rb +461 -0
- data/lib/bio/io/dbget.rb +194 -0
- data/lib/bio/io/ddbjxml.rb +638 -0
- data/lib/bio/io/ebisoap.rb +158 -0
- data/lib/bio/io/ensembl.rb +229 -0
- data/lib/bio/io/fastacmd.rb +163 -0
- data/lib/bio/io/fetch.rb +195 -0
- data/lib/bio/io/flatfile/autodetection.rb +545 -0
- data/lib/bio/io/flatfile/bdb.rb +253 -0
- data/lib/bio/io/flatfile/buffer.rb +237 -0
- data/lib/bio/io/flatfile/index.rb +1381 -0
- data/lib/bio/io/flatfile/indexer.rb +805 -0
- data/lib/bio/io/flatfile/splitter.rb +297 -0
- data/lib/bio/io/flatfile.rb +473 -0
- data/lib/bio/io/higet.rb +73 -0
- data/lib/bio/io/hinv.rb +442 -0
- data/lib/bio/io/keggapi.rb +805 -0
- data/lib/bio/io/ncbirest.rb +733 -0
- data/lib/bio/io/ncbisoap.rb +155 -0
- data/lib/bio/io/pubmed.rb +307 -0
- data/lib/bio/io/registry.rb +292 -0
- data/lib/bio/io/soapwsdl.rb +119 -0
- data/lib/bio/io/sql.rb +186 -0
- data/lib/bio/location.rb +867 -0
- data/lib/bio/map.rb +410 -0
- data/lib/bio/pathway.rb +960 -0
- data/lib/bio/reference.rb +602 -0
- data/lib/bio/sequence/aa.rb +125 -0
- data/lib/bio/sequence/adapter.rb +108 -0
- data/lib/bio/sequence/common.rb +310 -0
- data/lib/bio/sequence/compat.rb +123 -0
- data/lib/bio/sequence/dblink.rb +54 -0
- data/lib/bio/sequence/format.rb +358 -0
- data/lib/bio/sequence/format_raw.rb +23 -0
- data/lib/bio/sequence/generic.rb +24 -0
- data/lib/bio/sequence/na.rb +491 -0
- data/lib/bio/sequence.rb +456 -0
- data/lib/bio/shell/core.rb +578 -0
- data/lib/bio/shell/demo.rb +146 -0
- data/lib/bio/shell/interface.rb +218 -0
- data/lib/bio/shell/irb.rb +95 -0
- data/lib/bio/shell/object.rb +71 -0
- data/lib/bio/shell/plugin/blast.rb +42 -0
- data/lib/bio/shell/plugin/codon.rb +218 -0
- data/lib/bio/shell/plugin/das.rb +58 -0
- data/lib/bio/shell/plugin/emboss.rb +23 -0
- data/lib/bio/shell/plugin/entry.rb +105 -0
- data/lib/bio/shell/plugin/flatfile.rb +101 -0
- data/lib/bio/shell/plugin/keggapi.rb +181 -0
- data/lib/bio/shell/plugin/midi.rb +430 -0
- data/lib/bio/shell/plugin/obda.rb +45 -0
- data/lib/bio/shell/plugin/psort.rb +56 -0
- data/lib/bio/shell/plugin/seq.rb +247 -0
- data/lib/bio/shell/plugin/soap.rb +87 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/bioruby_generator.rb +29 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_classes.rhtml +4 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_log.rhtml +27 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_methods.rhtml +11 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_modules.rhtml +4 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_variables.rhtml +7 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-bg.gif +0 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-gem.png +0 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-link.gif +0 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.css +368 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.rhtml +47 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb +144 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_helper.rb +47 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/commands.rhtml +8 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/history.rhtml +10 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/index.rhtml +26 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/spinner.gif +0 -0
- data/lib/bio/shell/script.rb +25 -0
- data/lib/bio/shell/setup.rb +109 -0
- data/lib/bio/shell/web.rb +102 -0
- data/lib/bio/shell.rb +44 -0
- data/lib/bio/tree.rb +852 -0
- data/lib/bio/util/color_scheme/buried.rb +59 -0
- data/lib/bio/util/color_scheme/helix.rb +59 -0
- data/lib/bio/util/color_scheme/hydropathy.rb +64 -0
- data/lib/bio/util/color_scheme/nucleotide.rb +31 -0
- data/lib/bio/util/color_scheme/strand.rb +59 -0
- data/lib/bio/util/color_scheme/taylor.rb +50 -0
- data/lib/bio/util/color_scheme/turn.rb +59 -0
- data/lib/bio/util/color_scheme/zappo.rb +50 -0
- data/lib/bio/util/color_scheme.rb +191 -0
- data/lib/bio/util/contingency_table.rb +370 -0
- data/lib/bio/util/restriction_enzyme/analysis.rb +249 -0
- data/lib/bio/util/restriction_enzyme/analysis_basic.rb +217 -0
- data/lib/bio/util/restriction_enzyme/cut_symbol.rb +107 -0
- data/lib/bio/util/restriction_enzyme/double_stranded/aligned_strands.rb +130 -0
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb +103 -0
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb +38 -0
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations.rb +76 -0
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb +107 -0
- data/lib/bio/util/restriction_enzyme/double_stranded.rb +321 -0
- data/lib/bio/util/restriction_enzyme/enzymes.yaml +7061 -0
- data/lib/bio/util/restriction_enzyme/range/cut_range.rb +24 -0
- data/lib/bio/util/restriction_enzyme/range/cut_ranges.rb +47 -0
- data/lib/bio/util/restriction_enzyme/range/horizontal_cut_range.rb +67 -0
- data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +242 -0
- data/lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb +51 -0
- data/lib/bio/util/restriction_enzyme/range/sequence_range/fragments.rb +41 -0
- data/lib/bio/util/restriction_enzyme/range/sequence_range.rb +257 -0
- data/lib/bio/util/restriction_enzyme/range/vertical_cut_range.rb +77 -0
- data/lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb +135 -0
- data/lib/bio/util/restriction_enzyme/single_strand.rb +200 -0
- data/lib/bio/util/restriction_enzyme/single_strand_complement.rb +23 -0
- data/lib/bio/util/restriction_enzyme/string_formatting.rb +111 -0
- data/lib/bio/util/restriction_enzyme.rb +228 -0
- data/lib/bio/util/sirna.rb +288 -0
- data/lib/bio.rb +300 -0
- data/rdoc.zsh +8 -0
- data/sample/any2fasta.rb +59 -0
- data/sample/biofetch.rb +475 -0
- data/sample/color_scheme_na.rb +91 -0
- data/sample/dbget +37 -0
- data/sample/demo_sequence.rb +158 -0
- data/sample/enzymes.rb +78 -0
- data/sample/fasta2tab.rb +99 -0
- data/sample/fastagrep.rb +72 -0
- data/sample/fastasort.rb +54 -0
- data/sample/fsplit.rb +51 -0
- data/sample/gb2fasta.rb +30 -0
- data/sample/gb2tab.rb +325 -0
- data/sample/gbtab2mysql.rb +161 -0
- data/sample/genes2nuc.rb +33 -0
- data/sample/genes2pep.rb +33 -0
- data/sample/genes2tab.rb +81 -0
- data/sample/genome2rb.rb +29 -0
- data/sample/genome2tab.rb +76 -0
- data/sample/goslim.rb +303 -0
- data/sample/gt2fasta.rb +47 -0
- data/sample/na2aa.rb +34 -0
- data/sample/pmfetch.rb +42 -0
- data/sample/pmsearch.rb +42 -0
- data/sample/psortplot_html.rb +214 -0
- data/sample/ssearch2tab.rb +96 -0
- data/sample/tdiary.rb +158 -0
- data/sample/tfastx2tab.rb +100 -0
- data/sample/vs-genes.rb +212 -0
- data/setup.rb +1596 -0
- data/test/data/HMMER/hmmpfam.out +64 -0
- data/test/data/HMMER/hmmsearch.out +88 -0
- data/test/data/SOSUI/sample.report +11 -0
- data/test/data/TMHMM/sample.report +21 -0
- data/test/data/aaindex/DAYM780301 +30 -0
- data/test/data/aaindex/PRAM900102 +20 -0
- data/test/data/bl2seq/cd8a_cd8b_blastp.bl2seq +53 -0
- data/test/data/bl2seq/cd8a_p53_e-5blastp.bl2seq +37 -0
- data/test/data/blast/2.2.15.blastp.m7 +876 -0
- data/test/data/blast/b0002.faa +15 -0
- data/test/data/blast/b0002.faa.m0 +128 -0
- data/test/data/blast/b0002.faa.m7 +65 -0
- data/test/data/blast/b0002.faa.m8 +1 -0
- data/test/data/blast/blastp-multi.m7 +188 -0
- data/test/data/command/echoarg2.bat +1 -0
- data/test/data/embl/AB090716.embl +65 -0
- data/test/data/embl/AB090716.embl.rel89 +63 -0
- data/test/data/fasta/example1.txt +75 -0
- data/test/data/fasta/example2.txt +21 -0
- data/test/data/genscan/sample.report +63 -0
- data/test/data/iprscan/merged.raw +32 -0
- data/test/data/iprscan/merged.txt +74 -0
- data/test/data/paml/codeml/control_file.txt +30 -0
- data/test/data/paml/codeml/output.txt +78 -0
- data/test/data/paml/codeml/rates +217 -0
- data/test/data/prosite/prosite.dat +2233 -0
- data/test/data/refseq/nm_126355.entret +64 -0
- data/test/data/rpsblast/misc.rpsblast +193 -0
- data/test/data/soft/GDS100_partial.soft +92 -0
- data/test/data/soft/GSE3457_family_partial.soft +874 -0
- data/test/data/uniprot/p53_human.uniprot +1456 -0
- data/test/functional/bio/appl/test_pts1.rb +115 -0
- data/test/functional/bio/io/test_ensembl.rb +229 -0
- data/test/functional/bio/io/test_soapwsdl.rb +52 -0
- data/test/functional/bio/sequence/test_output_embl.rb +51 -0
- data/test/functional/bio/test_command.rb +301 -0
- data/test/runner.rb +23 -0
- data/test/unit/bio/appl/bl2seq/test_report.rb +134 -0
- data/test/unit/bio/appl/blast/test_ncbioptions.rb +112 -0
- data/test/unit/bio/appl/blast/test_report.rb +1135 -0
- data/test/unit/bio/appl/blast/test_rpsblast.rb +398 -0
- data/test/unit/bio/appl/genscan/test_report.rb +182 -0
- data/test/unit/bio/appl/hmmer/test_report.rb +342 -0
- data/test/unit/bio/appl/iprscan/test_report.rb +338 -0
- data/test/unit/bio/appl/mafft/test_report.rb +63 -0
- data/test/unit/bio/appl/paml/codeml/test_rates.rb +45 -0
- data/test/unit/bio/appl/paml/codeml/test_report.rb +45 -0
- data/test/unit/bio/appl/paml/test_codeml.rb +174 -0
- data/test/unit/bio/appl/sosui/test_report.rb +81 -0
- data/test/unit/bio/appl/targetp/test_report.rb +146 -0
- data/test/unit/bio/appl/test_blast.rb +277 -0
- data/test/unit/bio/appl/test_fasta.rb +130 -0
- data/test/unit/bio/appl/test_pts1.rb +77 -0
- data/test/unit/bio/appl/tmhmm/test_report.rb +126 -0
- data/test/unit/bio/data/test_aa.rb +90 -0
- data/test/unit/bio/data/test_codontable.rb +107 -0
- data/test/unit/bio/data/test_na.rb +80 -0
- data/test/unit/bio/db/embl/test_common.rb +117 -0
- data/test/unit/bio/db/embl/test_embl.rb +214 -0
- data/test/unit/bio/db/embl/test_embl_rel89.rb +219 -0
- data/test/unit/bio/db/embl/test_embl_to_bioseq.rb +203 -0
- data/test/unit/bio/db/embl/test_sptr.rb +1812 -0
- data/test/unit/bio/db/embl/test_uniprot.rb +31 -0
- data/test/unit/bio/db/kegg/test_genes.rb +45 -0
- data/test/unit/bio/db/pdb/test_pdb.rb +152 -0
- data/test/unit/bio/db/test_aaindex.rb +197 -0
- data/test/unit/bio/db/test_fasta.rb +250 -0
- data/test/unit/bio/db/test_gff.rb +1190 -0
- data/test/unit/bio/db/test_lasergene.rb +95 -0
- data/test/unit/bio/db/test_medline.rb +127 -0
- data/test/unit/bio/db/test_newick.rb +293 -0
- data/test/unit/bio/db/test_nexus.rb +364 -0
- data/test/unit/bio/db/test_prosite.rb +1437 -0
- data/test/unit/bio/db/test_rebase.rb +101 -0
- data/test/unit/bio/db/test_soft.rb +138 -0
- data/test/unit/bio/io/flatfile/test_autodetection.rb +375 -0
- data/test/unit/bio/io/flatfile/test_buffer.rb +251 -0
- data/test/unit/bio/io/flatfile/test_splitter.rb +369 -0
- data/test/unit/bio/io/test_ddbjxml.rb +80 -0
- data/test/unit/bio/io/test_ensembl.rb +109 -0
- data/test/unit/bio/io/test_fastacmd.rb +42 -0
- data/test/unit/bio/io/test_flatfile.rb +488 -0
- data/test/unit/bio/io/test_soapwsdl.rb +32 -0
- data/test/unit/bio/sequence/test_aa.rb +103 -0
- data/test/unit/bio/sequence/test_common.rb +373 -0
- data/test/unit/bio/sequence/test_compat.rb +69 -0
- data/test/unit/bio/sequence/test_dblink.rb +58 -0
- data/test/unit/bio/sequence/test_na.rb +330 -0
- data/test/unit/bio/shell/plugin/test_seq.rb +185 -0
- data/test/unit/bio/test_alignment.rb +1025 -0
- data/test/unit/bio/test_command.rb +349 -0
- data/test/unit/bio/test_db.rb +96 -0
- data/test/unit/bio/test_feature.rb +144 -0
- data/test/unit/bio/test_location.rb +599 -0
- data/test/unit/bio/test_map.rb +230 -0
- data/test/unit/bio/test_pathway.rb +499 -0
- data/test/unit/bio/test_reference.rb +252 -0
- data/test/unit/bio/test_sequence.rb +329 -0
- data/test/unit/bio/test_shell.rb +18 -0
- data/test/unit/bio/test_tree.rb +593 -0
- data/test/unit/bio/util/restriction_enzyme/analysis/test_calculated_cuts.rb +299 -0
- data/test/unit/bio/util/restriction_enzyme/analysis/test_cut_ranges.rb +103 -0
- data/test/unit/bio/util/restriction_enzyme/analysis/test_sequence_range.rb +240 -0
- data/test/unit/bio/util/restriction_enzyme/double_stranded/test_aligned_strands.rb +101 -0
- data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair.rb +75 -0
- data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +73 -0
- data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations.rb +53 -0
- data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +104 -0
- data/test/unit/bio/util/restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +83 -0
- data/test/unit/bio/util/restriction_enzyme/test_analysis.rb +246 -0
- data/test/unit/bio/util/restriction_enzyme/test_cut_symbol.rb +44 -0
- data/test/unit/bio/util/restriction_enzyme/test_double_stranded.rb +115 -0
- data/test/unit/bio/util/restriction_enzyme/test_single_strand.rb +147 -0
- data/test/unit/bio/util/restriction_enzyme/test_single_strand_complement.rb +147 -0
- data/test/unit/bio/util/restriction_enzyme/test_string_formatting.rb +60 -0
- data/test/unit/bio/util/test_color_scheme.rb +33 -0
- data/test/unit/bio/util/test_contingency_table.rb +94 -0
- data/test/unit/bio/util/test_restriction_enzyme.rb +42 -0
- data/test/unit/bio/util/test_sirna.rb +245 -0
- metadata +484 -0
@@ -0,0 +1,257 @@
|
|
1
|
+
#
|
2
|
+
# bio/util/restriction_enzyme/range/sequence_range.rb - A defined range over a nucleotide sequence
|
3
|
+
#
|
4
|
+
# Author:: Trevor Wennblom <mailto:trevor@corevx.com>
|
5
|
+
# Copyright:: Copyright (c) 2005-2007 Midwinter Laboratories, LLC (http://midwinterlabs.com)
|
6
|
+
# License:: The Ruby License
|
7
|
+
#
|
8
|
+
# $Id: sequence_range.rb,v 1.9 2007/07/16 19:28:48 k Exp $
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'bio/util/restriction_enzyme'
|
12
|
+
|
13
|
+
module Bio
|
14
|
+
class RestrictionEnzyme
|
15
|
+
class Range
|
16
|
+
|
17
|
+
autoload :CutRange, 'bio/util/restriction_enzyme/range/cut_range'
|
18
|
+
autoload :CutRanges, 'bio/util/restriction_enzyme/range/cut_ranges'
|
19
|
+
autoload :HorizontalCutRange, 'bio/util/restriction_enzyme/range/horizontal_cut_range'
|
20
|
+
autoload :VerticalCutRange, 'bio/util/restriction_enzyme/range/vertical_cut_range'
|
21
|
+
|
22
|
+
# A defined range over a nucleotide sequence.
|
23
|
+
#
|
24
|
+
# This class accomadates having cuts defined on a sequence and returning the
|
25
|
+
# fragments made by those cuts.
|
26
|
+
class SequenceRange
|
27
|
+
|
28
|
+
autoload :Fragment, 'bio/util/restriction_enzyme/range/sequence_range/fragment'
|
29
|
+
autoload :Fragments, 'bio/util/restriction_enzyme/range/sequence_range/fragments'
|
30
|
+
autoload :CalculatedCuts, 'bio/util/restriction_enzyme/range/sequence_range/calculated_cuts'
|
31
|
+
|
32
|
+
# Left-most index of primary strand
|
33
|
+
attr_reader :p_left
|
34
|
+
|
35
|
+
# Right-most index of primary strand
|
36
|
+
attr_reader :p_right
|
37
|
+
|
38
|
+
# Left-most index of complementary strand
|
39
|
+
attr_reader :c_left
|
40
|
+
|
41
|
+
# Right-most index of complementary strand
|
42
|
+
attr_reader :c_right
|
43
|
+
|
44
|
+
# Left-most index of DNA sequence
|
45
|
+
attr_reader :left
|
46
|
+
|
47
|
+
# Right-most index of DNA sequence
|
48
|
+
attr_reader :right
|
49
|
+
|
50
|
+
# Size of DNA sequence
|
51
|
+
attr_reader :size
|
52
|
+
|
53
|
+
# CutRanges in this SequenceRange
|
54
|
+
attr_reader :cut_ranges
|
55
|
+
|
56
|
+
def initialize( p_left = nil, p_right = nil, c_left = nil, c_right = nil )
|
57
|
+
raise ArgumentError if p_left == nil and c_left == nil
|
58
|
+
raise ArgumentError if p_right == nil and c_right == nil
|
59
|
+
(raise ArgumentError unless p_left <= p_right) unless p_left == nil or p_right == nil
|
60
|
+
(raise ArgumentError unless c_left <= c_right) unless c_left == nil or c_right == nil
|
61
|
+
|
62
|
+
@p_left, @p_right, @c_left, @c_right = p_left, p_right, c_left, c_right
|
63
|
+
@left = [p_left, c_left].compact.sort.first
|
64
|
+
@right = [p_right, c_right].compact.sort.last
|
65
|
+
@size = (@right - @left) + 1 unless @left == nil or @right == nil
|
66
|
+
@cut_ranges = CutRanges.new
|
67
|
+
@__fragments_current = false
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
# If the first object is HorizontalCutRange or VerticalCutRange, that is
|
72
|
+
# added to the SequenceRange. Otherwise this method
|
73
|
+
# builds a VerticalCutRange object and adds it to the SequenceRange.
|
74
|
+
#
|
75
|
+
# Note:
|
76
|
+
# Cut occurs immediately after the index supplied.
|
77
|
+
# For example, a cut at '0' would mean a cut occurs between bases 0 and 1.
|
78
|
+
#
|
79
|
+
# ---
|
80
|
+
# *Arguments*
|
81
|
+
# * +p_cut_left+: (_optional_) Left-most cut on the primary strand *or* a CutRange object. +nil+ to skip
|
82
|
+
# * +p_cut_right+: (_optional_) Right-most cut on the primary strand. +nil+ to skip
|
83
|
+
# * +c_cut_left+: (_optional_) Left-most cut on the complementary strand. +nil+ to skip
|
84
|
+
# * +c_cut_right+: (_optional_) Right-most cut on the complementary strand. +nil+ to skip
|
85
|
+
# *Returns*:: nothing
|
86
|
+
def add_cut_range( p_cut_left=nil, p_cut_right=nil, c_cut_left=nil, c_cut_right=nil )
|
87
|
+
@__fragments_current = false
|
88
|
+
if p_cut_left.kind_of? CutRange # shortcut
|
89
|
+
@cut_ranges << p_cut_left
|
90
|
+
else
|
91
|
+
[p_cut_left, p_cut_right, c_cut_left, c_cut_right].each { |n| (raise IndexError unless n >= @left and n <= @right) unless n == nil }
|
92
|
+
@cut_ranges << VerticalCutRange.new( p_cut_left, p_cut_right, c_cut_left, c_cut_right )
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# Add a series of CutRange objects (HorizontalCutRange or VerticalCutRange).
|
97
|
+
#
|
98
|
+
# ---
|
99
|
+
# *Arguments*
|
100
|
+
# * +cut_ranges+: A series of CutRange objects
|
101
|
+
# *Returns*:: nothing
|
102
|
+
def add_cut_ranges(*cut_ranges)
|
103
|
+
cut_ranges.flatten.each do |cut_range|
|
104
|
+
raise TypeError, "Not of type CutRange" unless cut_range.kind_of? CutRange
|
105
|
+
self.add_cut_range( cut_range )
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Builds a HorizontalCutRange object and adds it to the SequenceRange.
|
110
|
+
#
|
111
|
+
# ---
|
112
|
+
# *Arguments*
|
113
|
+
# * +left+: Left-most cut
|
114
|
+
# * +right+: (_optional_) Right side - by default this equals the left side, default is recommended.
|
115
|
+
# *Returns*:: nothing
|
116
|
+
def add_horizontal_cut_range( left, right=left )
|
117
|
+
@__fragments_current = false
|
118
|
+
@cut_ranges << HorizontalCutRange.new( left, right )
|
119
|
+
end
|
120
|
+
|
121
|
+
# A Bio::RestrictionEnzyme::Range::SequenceRange::Bin holds an +Array+ of
|
122
|
+
# indexes for the primary and complement strands (+p+ and +c+ accessors).
|
123
|
+
#
|
124
|
+
# Example hash with Bin values:
|
125
|
+
# {0=>#<struct Bio::RestrictionEnzyme::Range::SequenceRange::Bin c=[0, 1], p=[0]>,
|
126
|
+
# 2=>#<struct Bio::RestrictionEnzyme::Range::SequenceRange::Bin c=[], p=[1, 2]>,
|
127
|
+
# 3=>#<struct Bio::RestrictionEnzyme::Range::SequenceRange::Bin c=[2, 3], p=[]>,
|
128
|
+
# 4=>#<struct Bio::RestrictionEnzyme::Range::SequenceRange::Bin c=[4, 5], p=[3, 4, 5]>}
|
129
|
+
#
|
130
|
+
# Note that the bin cannot be easily stored as a range since there may be
|
131
|
+
# nucleotides excised in the middle of a range.
|
132
|
+
#
|
133
|
+
# TODO: Perhaps store the bins as one-or-many ranges since missing
|
134
|
+
# nucleotides due to enzyme cutting is a special case.
|
135
|
+
Bin = Struct.new(:c, :p)
|
136
|
+
|
137
|
+
# Calculates the fragments over this sequence range as defined after using
|
138
|
+
# the methods add_cut_range, add_cut_ranges, and/or add_horizontal_cut_range
|
139
|
+
#
|
140
|
+
# Example return value:
|
141
|
+
# [#<Bio::RestrictionEnzyme::Range::SequenceRange::Fragment:0x277bdc
|
142
|
+
# @complement_bin=[0, 1],
|
143
|
+
# @primary_bin=[0]>,
|
144
|
+
# #<Bio::RestrictionEnzyme::Range::SequenceRange::Fragment:0x277bc8
|
145
|
+
# @complement_bin=[],
|
146
|
+
# @primary_bin=[1, 2]>,
|
147
|
+
# #<Bio::RestrictionEnzyme::Range::SequenceRange::Fragment:0x277bb4
|
148
|
+
# @complement_bin=[2, 3],
|
149
|
+
# @primary_bin=[]>,
|
150
|
+
# #<Bio::RestrictionEnzyme::Range::SequenceRange::Fragment:0x277ba0
|
151
|
+
# @complement_bin=[4, 5],
|
152
|
+
# @primary_bin=[3, 4, 5]>]
|
153
|
+
#
|
154
|
+
# ---
|
155
|
+
# *Arguments*
|
156
|
+
# * _none_
|
157
|
+
# *Returns*:: Bio::RestrictionEnzyme::Range::SequenceRange::Fragments
|
158
|
+
def fragments
|
159
|
+
return @__fragments if @__fragments_current == true
|
160
|
+
@__fragments_current = true
|
161
|
+
|
162
|
+
num_txt = '0123456789'
|
163
|
+
num_txt_repeat = (num_txt * ( @size / num_txt.size.to_f ).ceil)[0..@size-1]
|
164
|
+
fragments = Fragments.new(num_txt_repeat, num_txt_repeat)
|
165
|
+
|
166
|
+
cc = Bio::RestrictionEnzyme::Range::SequenceRange::CalculatedCuts.new(@size)
|
167
|
+
cc.add_cuts_from_cut_ranges(@cut_ranges)
|
168
|
+
cc.remove_incomplete_cuts
|
169
|
+
|
170
|
+
create_bins(cc).sort.each { |k, bin| fragments << Fragment.new( bin.p, bin.c ) }
|
171
|
+
@__fragments = fragments
|
172
|
+
return fragments
|
173
|
+
end
|
174
|
+
|
175
|
+
#########
|
176
|
+
protected
|
177
|
+
#########
|
178
|
+
|
179
|
+
# Example:
|
180
|
+
# cc = Bio::RestrictionEnzyme::Range::SequenceRange::CalculatedCuts.new(@size)
|
181
|
+
# cc.add_cuts_from_cut_ranges(@cut_ranges)
|
182
|
+
# cc.remove_incomplete_cuts
|
183
|
+
# bins = create_bins(cc)
|
184
|
+
#
|
185
|
+
# Example return value:
|
186
|
+
# {0=>#<struct Bio::RestrictionEnzyme::Range::SequenceRange::Bin c=[0, 1], p=[0]>,
|
187
|
+
# 2=>#<struct Bio::RestrictionEnzyme::Range::SequenceRange::Bin c=[], p=[1, 2]>,
|
188
|
+
# 3=>#<struct Bio::RestrictionEnzyme::Range::SequenceRange::Bin c=[2, 3], p=[]>,
|
189
|
+
# 4=>#<struct Bio::RestrictionEnzyme::Range::SequenceRange::Bin c=[4, 5], p=[3, 4, 5]>}
|
190
|
+
#
|
191
|
+
# ---
|
192
|
+
# *Arguments*
|
193
|
+
# * +cc+: Bio::RestrictionEnzyme::Range::SequenceRange::CalculatedCuts
|
194
|
+
# *Returns*:: +Hash+ Keys are unique, values are Bio::RestrictionEnzyme::Range::SequenceRange::Bin objects filled with indexes of the sequence locations they represent.
|
195
|
+
def create_bins(cc)
|
196
|
+
p_cut = cc.vc_primary
|
197
|
+
c_cut = cc.vc_complement
|
198
|
+
h_cut = cc.hc_between_strands
|
199
|
+
|
200
|
+
if @circular
|
201
|
+
# NOTE
|
202
|
+
# if it's circular we should start at the beginning of a cut for orientation
|
203
|
+
# scan for it, hack off the first set of hcuts and move them to the back
|
204
|
+
|
205
|
+
unique_id = 0
|
206
|
+
else
|
207
|
+
p_cut.unshift(-1) unless p_cut.include?(-1)
|
208
|
+
c_cut.unshift(-1) unless c_cut.include?(-1)
|
209
|
+
unique_id = -1
|
210
|
+
end
|
211
|
+
|
212
|
+
p_bin_id = c_bin_id = unique_id
|
213
|
+
bins = {}
|
214
|
+
setup_new_bin(bins, unique_id)
|
215
|
+
|
216
|
+
-1.upto(@size-1) do |idx| # NOTE - circular, for the future - should '-1' be replace with 'unique_id'?
|
217
|
+
|
218
|
+
# if bin_ids are out of sync but the strands are attached
|
219
|
+
if (p_bin_id != c_bin_id) and !h_cut.include?(idx)
|
220
|
+
min_id, max_id = [p_bin_id, c_bin_id].sort
|
221
|
+
bins.delete(max_id)
|
222
|
+
p_bin_id = c_bin_id = min_id
|
223
|
+
end
|
224
|
+
|
225
|
+
bins[ p_bin_id ].p << idx
|
226
|
+
bins[ c_bin_id ].c << idx
|
227
|
+
|
228
|
+
if p_cut.include? idx
|
229
|
+
p_bin_id = (unique_id += 1)
|
230
|
+
setup_new_bin(bins, p_bin_id)
|
231
|
+
end
|
232
|
+
|
233
|
+
if c_cut.include? idx # repetition
|
234
|
+
c_bin_id = (unique_id += 1) # repetition
|
235
|
+
setup_new_bin(bins, c_bin_id) # repetition
|
236
|
+
end # repetition
|
237
|
+
|
238
|
+
end
|
239
|
+
|
240
|
+
# Bin "-1" is an easy way to indicate the start of a strand just in case
|
241
|
+
# there is a horizontal cut at position 0
|
242
|
+
bins.delete(-1) unless @circular
|
243
|
+
bins
|
244
|
+
end
|
245
|
+
|
246
|
+
# Modifies bins in place by creating a new element with key bin_id and
|
247
|
+
# initializing the bin.
|
248
|
+
def setup_new_bin(bins, bin_id)
|
249
|
+
bins[ bin_id ] = Bin.new
|
250
|
+
bins[ bin_id ].p = []
|
251
|
+
bins[ bin_id ].c = []
|
252
|
+
end
|
253
|
+
|
254
|
+
end # SequenceRange
|
255
|
+
end # Range
|
256
|
+
end # RestrictionEnzyme
|
257
|
+
end # Bio
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#
|
2
|
+
# bio/util/restriction_enzyme/range/vertical_cut_range.rb -
|
3
|
+
#
|
4
|
+
# Author:: Trevor Wennblom <mailto:trevor@corevx.com>
|
5
|
+
# Copyright:: Copyright (c) 2005-2007 Midwinter Laboratories, LLC (http://midwinterlabs.com)
|
6
|
+
# License:: The Ruby License
|
7
|
+
#
|
8
|
+
# $Id: vertical_cut_range.rb,v 1.5 2007/07/16 19:28:48 k Exp $
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'bio/util/restriction_enzyme'
|
12
|
+
|
13
|
+
module Bio
|
14
|
+
class RestrictionEnzyme
|
15
|
+
class Range
|
16
|
+
|
17
|
+
# FIXME docs are kind of out of date. Change this to VerticalAndHorizontalCutRange
|
18
|
+
class VerticalCutRange < CutRange
|
19
|
+
attr_reader :p_cut_left, :p_cut_right
|
20
|
+
attr_reader :c_cut_left, :c_cut_right
|
21
|
+
attr_reader :min, :max
|
22
|
+
attr_reader :range
|
23
|
+
|
24
|
+
# VerticalCutRange provides an extremely raw, yet precise, method of
|
25
|
+
# defining the location of cuts on primary and complementary sequences.
|
26
|
+
#
|
27
|
+
# Many VerticalCutRange objects are used with HorizontalCutRange objects
|
28
|
+
# to be contained in CutRanges to define the cut pattern that a
|
29
|
+
# specific enzyme may make.
|
30
|
+
#
|
31
|
+
# VerticalCutRange takes up to four possible cuts, two on the primary
|
32
|
+
# strand and two on the complementary strand. In typical usage
|
33
|
+
# you will want to make a single cut on the primary strand and a single
|
34
|
+
# cut on the complementary strand.
|
35
|
+
#
|
36
|
+
# However, you can construct it with whatever cuts you desire to accomadate
|
37
|
+
# the most eccentric of imaginary restriction enzymes.
|
38
|
+
#
|
39
|
+
# ---
|
40
|
+
# *Arguments*
|
41
|
+
# * +p_cut_left+: (_optional_) Left-most cut on the primary strand. +nil+ to skip
|
42
|
+
# * +p_cut_right+: (_optional_) Right-most cut on the primary strand. +nil+ to skip
|
43
|
+
# * +c_cut_left+: (_optional_) Left-most cut on the complementary strand. +nil+ to skip
|
44
|
+
# * +c_cut_right+: (_optional_) Right-most cut on the complementary strand. +nil+ to skip
|
45
|
+
# *Returns*:: nothing
|
46
|
+
def initialize( p_cut_left=nil, p_cut_right=nil, c_cut_left=nil, c_cut_right=nil )
|
47
|
+
@p_cut_left = p_cut_left
|
48
|
+
@p_cut_right = p_cut_right
|
49
|
+
@c_cut_left = c_cut_left
|
50
|
+
@c_cut_right = c_cut_right
|
51
|
+
|
52
|
+
a = [@p_cut_left, @c_cut_left, @p_cut_right, @c_cut_right]
|
53
|
+
a.delete(nil)
|
54
|
+
a.sort!
|
55
|
+
@min = a.first
|
56
|
+
@max = a.last
|
57
|
+
|
58
|
+
@range = nil
|
59
|
+
@range = (@min..@max) unless @min == nil or @max == nil
|
60
|
+
return
|
61
|
+
end
|
62
|
+
|
63
|
+
# Check if a location falls within the minimum or maximum values of this
|
64
|
+
# range.
|
65
|
+
#
|
66
|
+
# ---
|
67
|
+
# *Arguments*
|
68
|
+
# * +i+: Location to check if it is included in the range
|
69
|
+
# *Returns*:: +true+ _or_ +false+
|
70
|
+
def include?(i)
|
71
|
+
return false if @range == nil
|
72
|
+
@range.include?(i)
|
73
|
+
end
|
74
|
+
end # VerticalCutRange
|
75
|
+
end # Range
|
76
|
+
end # RestrictionEnzyme
|
77
|
+
end # Bio
|
@@ -0,0 +1,135 @@
|
|
1
|
+
#
|
2
|
+
# bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb - The cut locations, in enzyme notation
|
3
|
+
#
|
4
|
+
# Author:: Trevor Wennblom <mailto:trevor@corevx.com>
|
5
|
+
# Copyright:: Copyright (c) 2005-2007 Midwinter Laboratories, LLC (http://midwinterlabs.com)
|
6
|
+
# License:: The Ruby License
|
7
|
+
#
|
8
|
+
# $Id: cut_locations_in_enzyme_notation.rb,v 1.7 2007/07/16 19:28:48 k Exp $
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'bio/util/restriction_enzyme'
|
12
|
+
|
13
|
+
module Bio
|
14
|
+
class RestrictionEnzyme
|
15
|
+
class SingleStrand
|
16
|
+
|
17
|
+
# Stores the cut location in thier enzyme index notation
|
18
|
+
#
|
19
|
+
# May be initialized with a series of cuts or an enzyme pattern marked
|
20
|
+
# with cut symbols.
|
21
|
+
#
|
22
|
+
# Enzyme index notation:: 1.._n_, value before 1 is -1
|
23
|
+
#
|
24
|
+
# example:: [-3][-2][-1][1][2][3][4][5]
|
25
|
+
#
|
26
|
+
# Negative values are used to indicate when a cut may occur at a specified
|
27
|
+
# distance before the sequence begins. This would be padded with 'n'
|
28
|
+
# nucleotides to represent wildcards.
|
29
|
+
#
|
30
|
+
# Notes:
|
31
|
+
# * <code>0</code> is invalid as it does not refer to any index
|
32
|
+
# * +nil+ is not allowed here as it has no meaning
|
33
|
+
# * +nil+ values are kept track of in DoubleStranded::CutLocations as they
|
34
|
+
# need a reference point on the correlating strand. In
|
35
|
+
# DoubleStranded::CutLocations +nil+ represents no cut or a partial
|
36
|
+
# digestion.
|
37
|
+
#
|
38
|
+
class CutLocationsInEnzymeNotation < Array
|
39
|
+
include CutSymbol
|
40
|
+
extend CutSymbol
|
41
|
+
|
42
|
+
# First cut, in enzyme-index notation
|
43
|
+
attr_reader :min
|
44
|
+
|
45
|
+
# Last cut, in enzyme-index notation
|
46
|
+
attr_reader :max
|
47
|
+
|
48
|
+
# Constructor for CutLocationsInEnzymeNotation
|
49
|
+
#
|
50
|
+
# ---
|
51
|
+
# *Arguments*
|
52
|
+
# * +a+: Locations of cuts represented as a string with cuts or an array of values
|
53
|
+
# Examples:
|
54
|
+
# * n^ng^arraxt^n
|
55
|
+
# * 2
|
56
|
+
# * -1, 5
|
57
|
+
# * [-1, 5]
|
58
|
+
# *Returns*:: nothing
|
59
|
+
def initialize(*a)
|
60
|
+
a.flatten! # in case an array was passed as an argument
|
61
|
+
|
62
|
+
if a.size == 1 and a[0].kind_of? String and a[0] =~ re_cut_symbol
|
63
|
+
# Initialize with a cut symbol pattern such as 'n^ng^arraxt^n'
|
64
|
+
s = a[0]
|
65
|
+
a = []
|
66
|
+
i = -( s.tr(cut_symbol, '') =~ %r{[^n]} ) # First character that's not 'n'
|
67
|
+
s.each_byte { |c| (a << i; next) if c.chr == cut_symbol; i += 1 }
|
68
|
+
a.collect! { |n| n <= 0 ? n-1 : n } # 0 is not a valid enzyme index, decrement from 0 and all negative
|
69
|
+
else
|
70
|
+
a.collect! { |n| n.to_i } # Cut locations are always integers
|
71
|
+
end
|
72
|
+
|
73
|
+
validate_cut_locations( a )
|
74
|
+
super(a)
|
75
|
+
self.sort!
|
76
|
+
@min = self.first
|
77
|
+
@max = self.last
|
78
|
+
self.freeze
|
79
|
+
end
|
80
|
+
|
81
|
+
# Transform the cut locations from enzyme index notation to 0-based index
|
82
|
+
# notation.
|
83
|
+
#
|
84
|
+
# input -> output
|
85
|
+
# [ 1, 2, 3 ] -> [ 0, 1, 2 ]
|
86
|
+
# [ 1, 3, 5 ] -> [ 0, 2, 4 ]
|
87
|
+
# [ -1, 1, 2 ] -> [ 0, 1, 2 ]
|
88
|
+
# [ -2, 1, 3 ] -> [ 0, 2, 4 ]
|
89
|
+
#
|
90
|
+
# ---
|
91
|
+
# *Arguments*
|
92
|
+
# * _none_
|
93
|
+
# *Returns*:: +Array+ of cuts in 0-based index notation
|
94
|
+
def to_array_index
|
95
|
+
return [] if @min == nil
|
96
|
+
if @min < 0
|
97
|
+
calc = lambda do |n|
|
98
|
+
n -= 1 unless n < 0
|
99
|
+
n + @min.abs
|
100
|
+
end
|
101
|
+
else
|
102
|
+
calc = lambda { |n| n - 1 }
|
103
|
+
end
|
104
|
+
self.collect(&calc)
|
105
|
+
end
|
106
|
+
|
107
|
+
#########
|
108
|
+
protected
|
109
|
+
#########
|
110
|
+
|
111
|
+
def validate_cut_locations( input_cut_locations )
|
112
|
+
unless input_cut_locations == input_cut_locations.uniq
|
113
|
+
err = "The cut locations supplied contain duplicate values. Redundant / undefined meaning.\n"
|
114
|
+
err += "cuts: #{input_cut_locations.inspect}\n"
|
115
|
+
err += "unique: #{input_cut_locations.uniq.inspect}"
|
116
|
+
raise ArgumentError, err
|
117
|
+
end
|
118
|
+
|
119
|
+
if input_cut_locations.include?(nil)
|
120
|
+
err = "The cut locations supplied contained a nil. nil has no index for enzyme notation, alternative meaning is 'no cut'.\n"
|
121
|
+
err += "cuts: #{input_cut_locations.inspect}"
|
122
|
+
raise ArgumentError, err
|
123
|
+
end
|
124
|
+
|
125
|
+
if input_cut_locations.include?(0)
|
126
|
+
err = "The cut locations supplied contained a '0'. '0' has no index for enzyme notation, alternative meaning is 'no cut'.\n"
|
127
|
+
err += "cuts: #{input_cut_locations.inspect}"
|
128
|
+
raise ArgumentError, err
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
end # CutLocationsInEnzymeNotation
|
133
|
+
end # SingleStrand
|
134
|
+
end # RestrictionEnzyme
|
135
|
+
end # Bio
|
@@ -0,0 +1,200 @@
|
|
1
|
+
#
|
2
|
+
# bio/util/restriction_enzyme/single_strand.rb - Single strand of a restriction enzyme sequence
|
3
|
+
#
|
4
|
+
# Author:: Trevor Wennblom <mailto:trevor@corevx.com>
|
5
|
+
# Copyright:: Copyright (c) 2005-2007 Midwinter Laboratories, LLC (http://midwinterlabs.com)
|
6
|
+
# License:: The Ruby License
|
7
|
+
#
|
8
|
+
# $Id:$
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'bio/util/restriction_enzyme'
|
12
|
+
require 'bio/sequence'
|
13
|
+
|
14
|
+
module Bio
|
15
|
+
class RestrictionEnzyme
|
16
|
+
|
17
|
+
# A single strand of restriction enzyme sequence pattern with a 5' to 3'
|
18
|
+
# orientation.
|
19
|
+
#
|
20
|
+
# DoubleStranded puts the SingleStrand and SingleStrandComplement together to
|
21
|
+
# create the sequence pattern with cuts on both strands.
|
22
|
+
#
|
23
|
+
class SingleStrand < Bio::Sequence::NA
|
24
|
+
|
25
|
+
autoload :CutLocationsInEnzymeNotation, 'bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation'
|
26
|
+
|
27
|
+
include CutSymbol
|
28
|
+
include StringFormatting
|
29
|
+
|
30
|
+
# The cut locations in enzyme notation. Contains a
|
31
|
+
# CutLocationsInEnzymeNotation object set when the SingleStrand
|
32
|
+
# object is initialized.
|
33
|
+
attr_reader :cut_locations_in_enzyme_notation
|
34
|
+
|
35
|
+
# The cut locations transformed from enzyme index notation to 0-based
|
36
|
+
# array index notation. Contains an Array.
|
37
|
+
attr_reader :cut_locations
|
38
|
+
|
39
|
+
# Orientation of the strand, 5' to 3'
|
40
|
+
def orientation; [5,3]; end
|
41
|
+
|
42
|
+
# Constructor for a Bio::RestrictionEnzyme::StingleStrand object.
|
43
|
+
#
|
44
|
+
# A single strand of restriction enzyme sequence pattern with a 5' to 3' orientation.
|
45
|
+
#
|
46
|
+
# ---
|
47
|
+
# *Arguments*
|
48
|
+
# * +sequence+: (_required_) The enzyme sequence.
|
49
|
+
# * +c+: (_optional_) Cut locations in enzyme notation.
|
50
|
+
# See Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation
|
51
|
+
#
|
52
|
+
# *Constraints*
|
53
|
+
# * +sequence+ cannot contain immediately adjacent cut symbols (ex. atg^^c).
|
54
|
+
# * +c+ is in enzyme index notation and therefore cannot contain a 0.
|
55
|
+
# * If +c+ is omitted, +sequence+ must contain a cut symbol.
|
56
|
+
# * You cannot provide both a sequence with cut symbols and provide cut locations - ambiguous.
|
57
|
+
#
|
58
|
+
# +sequence+ must be a kind of:
|
59
|
+
# * String
|
60
|
+
# * Bio::Sequence::NA
|
61
|
+
# * Bio::RestrictionEnzyme::SingleStrand
|
62
|
+
#
|
63
|
+
# +c+ must be a kind of:
|
64
|
+
# * Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation
|
65
|
+
# * Integer, one or more
|
66
|
+
# * Array
|
67
|
+
#
|
68
|
+
# *Returns*:: nothing
|
69
|
+
def initialize( sequence, *c )
|
70
|
+
c.flatten! # if an array was supplied as an argument
|
71
|
+
validate_args(sequence, c)
|
72
|
+
sequence.downcase!
|
73
|
+
|
74
|
+
if sequence =~ re_cut_symbol
|
75
|
+
@cut_locations_in_enzyme_notation = CutLocationsInEnzymeNotation.new( strip_padding(sequence) )
|
76
|
+
else
|
77
|
+
@cut_locations_in_enzyme_notation = CutLocationsInEnzymeNotation.new( c )
|
78
|
+
end
|
79
|
+
|
80
|
+
@stripped = Bio::Sequence::NA.new( strip_cuts_and_padding( sequence ) )
|
81
|
+
super( pattern )
|
82
|
+
@cut_locations = @cut_locations_in_enzyme_notation.to_array_index
|
83
|
+
return
|
84
|
+
end
|
85
|
+
|
86
|
+
# Returns true if this enzyme is palindromic with its reverse complement.
|
87
|
+
# Does not report if the +cut_locations+ are palindromic or not.
|
88
|
+
#
|
89
|
+
# Examples:
|
90
|
+
# * This would be palindromic:
|
91
|
+
# 5' - ATGCAT - 3'
|
92
|
+
# TACGTA
|
93
|
+
#
|
94
|
+
# * This would not be palindromic:
|
95
|
+
# 5' - ATGCGTA - 3'
|
96
|
+
# TACGCAT
|
97
|
+
#
|
98
|
+
# ---
|
99
|
+
# *Arguments*
|
100
|
+
# * _none_
|
101
|
+
# *Returns*:: +true+ _or_ +false+
|
102
|
+
def palindromic?
|
103
|
+
@stripped.reverse_complement == @stripped
|
104
|
+
end
|
105
|
+
|
106
|
+
# Sequence pattern with no cut symbols and no 'n' padding.
|
107
|
+
# * <code>SingleStrand.new('garraxt', [-2, 1, 7]).stripped # => "garraxt"</code>
|
108
|
+
attr_reader :stripped
|
109
|
+
|
110
|
+
# The sequence with 'n' padding and cut symbols.
|
111
|
+
# * <code>SingleStrand.new('garraxt', [-2, 1, 7]).with_cut_symbols # => "n^ng^arraxt^n"</code>
|
112
|
+
#
|
113
|
+
# ---
|
114
|
+
# *Arguments*
|
115
|
+
# * _none_
|
116
|
+
# *Returns*:: The sequence with 'n' padding and cut symbols.
|
117
|
+
def with_cut_symbols
|
118
|
+
s = pattern
|
119
|
+
@cut_locations_in_enzyme_notation.to_array_index.sort.reverse.each { |c| s.insert(c+1, cut_symbol) }
|
120
|
+
s
|
121
|
+
end
|
122
|
+
|
123
|
+
# The sequence with 'n' padding on the left and right for cuts larger than the sequence.
|
124
|
+
# * <code>SingleStrand.new('garraxt', [-2, 1, 7]).pattern # => "nngarraxtn"</code>
|
125
|
+
#
|
126
|
+
# ---
|
127
|
+
# *Arguments*
|
128
|
+
# * _none_
|
129
|
+
# *Returns*:: The sequence with 'n' padding on the left and right for cuts larger than the sequence.
|
130
|
+
def pattern
|
131
|
+
return stripped if @cut_locations_in_enzyme_notation.min == nil
|
132
|
+
left = (@cut_locations_in_enzyme_notation.min < 0 ? 'n' * @cut_locations_in_enzyme_notation.min.abs : '')
|
133
|
+
|
134
|
+
# Add one more 'n' if a cut is at the last position
|
135
|
+
right = ( (@cut_locations_in_enzyme_notation.max >= @stripped.length) ? ('n' * (@cut_locations_in_enzyme_notation.max - @stripped.length + 1)) : '')
|
136
|
+
[left, stripped, right].join('')
|
137
|
+
end
|
138
|
+
|
139
|
+
# The sequence with 'n' pads, cut symbols, and spacing for alignment.
|
140
|
+
# * <code>SingleStrand.new('garraxt', [-2, 1, 7]).with_spaces # => "n^n g^a r r a x t^n"</code>
|
141
|
+
#
|
142
|
+
# ---
|
143
|
+
# *Arguments*
|
144
|
+
# * _none_
|
145
|
+
# *Returns*:: The sequence with 'n' pads, cut symbols, and spacing for alignment.
|
146
|
+
def with_spaces
|
147
|
+
add_spacing( with_cut_symbols )
|
148
|
+
end
|
149
|
+
|
150
|
+
#########
|
151
|
+
protected
|
152
|
+
#########
|
153
|
+
|
154
|
+
def validate_args( input_pattern, input_cut_locations )
|
155
|
+
unless input_pattern.kind_of?(String)
|
156
|
+
err = "input_pattern is not a String, Bio::Sequence::NA, or Bio::RestrictionEnzyme::SingleStrand object\n"
|
157
|
+
err += "pattern: #{input_pattern}\n"
|
158
|
+
err += "class: #{input_pattern.class}"
|
159
|
+
raise ArgumentError, err
|
160
|
+
end
|
161
|
+
|
162
|
+
if ( input_pattern =~ re_cut_symbol ) and !input_cut_locations.empty?
|
163
|
+
err = "Cut symbol found in sequence, but cut locations were also supplied. Ambiguous.\n"
|
164
|
+
err += "pattern: #{input_pattern}\n"
|
165
|
+
err += "symbol: #{cut_symbol}\n"
|
166
|
+
err += "locations: #{input_cut_locations.inspect}"
|
167
|
+
raise ArgumentError, err
|
168
|
+
end
|
169
|
+
|
170
|
+
input_pattern.each_byte do |c|
|
171
|
+
c = c.chr.downcase
|
172
|
+
unless Bio::NucleicAcid::NAMES.has_key?(c) or c == 'x' or c == 'X' or c == cut_symbol
|
173
|
+
err = "Invalid character in pattern.\n"
|
174
|
+
err += "Not a nucleotide or representation of possible nucleotides. See Bio::NucleicAcid::NAMES for more information.\n"
|
175
|
+
err += "char: #{c}\n"
|
176
|
+
err += "input_pattern: #{input_pattern}"
|
177
|
+
raise ArgumentError, err
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# Tadayoshi Funaba's method as discussed in Programming Ruby 2ed, p390
|
183
|
+
def self.once(*ids)
|
184
|
+
for id in ids
|
185
|
+
module_eval <<-"end;"
|
186
|
+
alias_method :__#{id.__id__}__, :#{id.to_s}
|
187
|
+
private :__#{id.__id__}__
|
188
|
+
def #{id.to_s}(*args, &block)
|
189
|
+
(@__#{id.__id__}__ ||= [__#{id.__id__}__(*args, &block)])[0]
|
190
|
+
end
|
191
|
+
end;
|
192
|
+
end
|
193
|
+
end
|
194
|
+
private_class_method :once
|
195
|
+
|
196
|
+
once :pattern, :with_cut_symbols, :with_spaces, :to_re
|
197
|
+
|
198
|
+
end # SingleStrand
|
199
|
+
end # RestrictionEnzyme
|
200
|
+
end # Bio
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# bio/util/restriction_enzyme/single_strand_complement.rb - Single strand restriction enzyme sequence in complement orientation
|
3
|
+
#
|
4
|
+
# Author:: Trevor Wennblom <mailto:trevor@corevx.com>
|
5
|
+
# Copyright:: Copyright (c) 2005-2007 Midwinter Laboratories, LLC (http://midwinterlabs.com)
|
6
|
+
# License:: The Ruby License
|
7
|
+
#
|
8
|
+
# $Id: single_strand_complement.rb,v 1.5 2007/07/16 19:28:48 k Exp $
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'bio/util/restriction_enzyme'
|
12
|
+
|
13
|
+
module Bio
|
14
|
+
class RestrictionEnzyme
|
15
|
+
|
16
|
+
# A single strand of restriction enzyme sequence pattern with a 3' to 5' orientation.
|
17
|
+
#
|
18
|
+
class SingleStrandComplement < SingleStrand
|
19
|
+
# Orientation of the strand, 3' to 5'
|
20
|
+
def orientation; [3, 5]; end
|
21
|
+
end # SingleStrandComplement
|
22
|
+
end # RestrictionEnzyme
|
23
|
+
end # Bio
|