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,217 @@
|
|
1
|
+
#
|
2
|
+
# bio/util/restriction_enzyme/analysis_basic.rb - Does the work of fragmenting the DNA from the enzymes
|
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: analysis_basic.rb,v 1.16 2007/07/16 19:28:48 k Exp $
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'set' # for method create_enzyme_actions
|
12
|
+
require 'bio/util/restriction_enzyme'
|
13
|
+
|
14
|
+
module Bio
|
15
|
+
class RestrictionEnzyme
|
16
|
+
|
17
|
+
class Analysis
|
18
|
+
|
19
|
+
# See cut_without_permutations instance method
|
20
|
+
def self.cut_without_permutations( sequence, *args )
|
21
|
+
self.new.cut_without_permutations( sequence, *args )
|
22
|
+
end
|
23
|
+
|
24
|
+
# See main documentation for Bio::RestrictionEnzyme
|
25
|
+
#
|
26
|
+
# Bio::RestrictionEnzyme.cut is preferred over this!
|
27
|
+
#
|
28
|
+
# USE AT YOUR OWN RISK
|
29
|
+
#
|
30
|
+
# This is a simpler version of method +cut+. +cut+ takes into account
|
31
|
+
# permutations of cut variations based on competitiveness of enzymes for an
|
32
|
+
# enzyme cutsite or enzyme bindsite on a sequence. This does not take into
|
33
|
+
# account those possibilities and is therefore faster, but less likely to be
|
34
|
+
# accurate.
|
35
|
+
#
|
36
|
+
# This code is mainly included as an academic example
|
37
|
+
# without having to wade through the extra layer of complexity added by the
|
38
|
+
# permutations.
|
39
|
+
#
|
40
|
+
# Example:
|
41
|
+
#
|
42
|
+
# FIXME add output
|
43
|
+
#
|
44
|
+
# Bio::RestrictionEnzyme::Analysis.cut_without_permutations('gaattc', 'EcoRI')
|
45
|
+
#
|
46
|
+
# _same as:_
|
47
|
+
#
|
48
|
+
# Bio::RestrictionEnzyme::Analysis.cut_without_permutations('gaattc', 'g^aattc')
|
49
|
+
# ---
|
50
|
+
# *Arguments*
|
51
|
+
# * +sequence+: +String+ kind of object that will be used as a nucleic acid sequence.
|
52
|
+
# * +args+: Series of enzyme names, enzymes sequences with cut marks, or RestrictionEnzyme objects.
|
53
|
+
# *Returns*:: Bio::RestrictionEnzyme::Fragments object populated with Bio::RestrictionEnzyme::Fragment objects. (Note: unrelated to Bio::RestrictionEnzyme::Range::SequenceRange::Fragments)
|
54
|
+
def cut_without_permutations( sequence, *args )
|
55
|
+
return fragments_for_display( {} ) if !sequence.kind_of?(String) or sequence.empty?
|
56
|
+
sequence = Bio::Sequence::NA.new( sequence )
|
57
|
+
|
58
|
+
# create_enzyme_actions returns two seperate array elements, they're not
|
59
|
+
# needed separated here so we put them into one array
|
60
|
+
enzyme_actions = create_enzyme_actions( sequence, *args ).flatten
|
61
|
+
return fragments_for_display( {} ) if enzyme_actions.empty?
|
62
|
+
|
63
|
+
# Primary and complement strands are both measured from '0' to 'sequence.size-1' here
|
64
|
+
sequence_range = Bio::RestrictionEnzyme::Range::SequenceRange.new( 0, 0, sequence.size-1, sequence.size-1 )
|
65
|
+
|
66
|
+
# Add the cuts to the sequence_range from each enzyme_action
|
67
|
+
enzyme_actions.each do |enzyme_action|
|
68
|
+
enzyme_action.cut_ranges.each do |cut_range|
|
69
|
+
sequence_range.add_cut_range(cut_range)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Fill in the source sequence for sequence_range so it knows what bases
|
74
|
+
# to use
|
75
|
+
sequence_range.fragments.primary = sequence
|
76
|
+
sequence_range.fragments.complement = sequence.forward_complement
|
77
|
+
|
78
|
+
# Format the fragments for the user
|
79
|
+
fragments_for_display( {0 => sequence_range} )
|
80
|
+
end
|
81
|
+
|
82
|
+
#########
|
83
|
+
protected
|
84
|
+
#########
|
85
|
+
|
86
|
+
# Take the fragments from SequenceRange objects generated from add_cut_range
|
87
|
+
# and return unique results as a Bio::RestrictionEnzyme::Analysis::Fragment object.
|
88
|
+
#
|
89
|
+
# ---
|
90
|
+
# *Arguments*
|
91
|
+
# * +hsh+: +Hash+ Keys are a permutation ID, if any. Values are SequenceRange objects that have cuts applied.
|
92
|
+
# *Returns*:: Bio::RestrictionEnzyme::Analysis::Fragments object populated with Bio::RestrictionEnzyme::Analysis::Fragment objects.
|
93
|
+
def fragments_for_display( hsh, view_ranges=false )
|
94
|
+
ary = Fragments.new
|
95
|
+
return ary unless hsh
|
96
|
+
|
97
|
+
hsh.each do |permutation_id, sequence_range|
|
98
|
+
sequence_range.fragments.for_display.each do |fragment|
|
99
|
+
if view_ranges
|
100
|
+
ary << Bio::RestrictionEnzyme::Fragment.new(fragment.primary, fragment.complement, fragment.p_left, fragment.p_right, fragment.c_left, fragment.c_right)
|
101
|
+
else
|
102
|
+
ary << Bio::RestrictionEnzyme::Fragment.new(fragment.primary, fragment.complement)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
ary.uniq! unless view_ranges
|
108
|
+
|
109
|
+
ary
|
110
|
+
end
|
111
|
+
|
112
|
+
# Creates an array of EnzymeActions based on the DNA sequence and supplied enzymes.
|
113
|
+
#
|
114
|
+
# ---
|
115
|
+
# *Arguments*
|
116
|
+
# * +sequence+: The string of DNA to match the enzyme recognition sites against
|
117
|
+
# * +args+:: The enzymes to use.
|
118
|
+
# *Returns*:: +Array+ with the first element being an array of EnzymeAction objects that +sometimes_cut+, and are subject to competition. The second is an array of EnzymeAction objects that +always_cut+ and are not subject to competition.
|
119
|
+
def create_enzyme_actions( sequence, *args )
|
120
|
+
all_enzyme_actions = []
|
121
|
+
|
122
|
+
args.each do |enzyme|
|
123
|
+
enzyme = Bio::RestrictionEnzyme.new(enzyme) unless enzyme.class == Bio::RestrictionEnzyme::DoubleStranded
|
124
|
+
|
125
|
+
# make sure pattern is the proper size
|
126
|
+
# for more info see the internal documentation of
|
127
|
+
# Bio::RestrictionEnzyme::DoubleStranded.create_action_at
|
128
|
+
pattern = Bio::Sequence::NA.new(
|
129
|
+
Bio::RestrictionEnzyme::DoubleStranded::AlignedStrands.align(
|
130
|
+
enzyme.primary, enzyme.complement
|
131
|
+
).primary
|
132
|
+
).to_re
|
133
|
+
|
134
|
+
find_match_locations( sequence, pattern ).each do |offset|
|
135
|
+
all_enzyme_actions << enzyme.create_action_at( offset )
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# FIXME VerticalCutRange should really be called VerticalAndHorizontalCutRange
|
140
|
+
|
141
|
+
# * all_enzyme_actions is now full of EnzymeActions at specific locations across
|
142
|
+
# the sequence.
|
143
|
+
# * all_enzyme_actions will now be examined to see if any EnzymeActions may
|
144
|
+
# conflict with one another, and if they do they'll be made note of in
|
145
|
+
# indicies_of_sometimes_cut. They will then be remove FIXME
|
146
|
+
# * a conflict occurs if another enzyme's bind site is compromised do due
|
147
|
+
# to another enzyme's cut. Enzyme's bind sites may overlap and not be
|
148
|
+
# competitive, however neither bind site may be part of the other
|
149
|
+
# enzyme's cut or else they do become competitive.
|
150
|
+
#
|
151
|
+
# Take current EnzymeAction's entire bind site and compare it to all other
|
152
|
+
# EzymeAction's cut ranges. Only look for vertical cuts as boundaries
|
153
|
+
# since trailing horizontal cuts would have no influence on the bind site.
|
154
|
+
#
|
155
|
+
# If example Enzyme A makes this cut pattern (cut range 2..5):
|
156
|
+
#
|
157
|
+
# 0 1 2|3 4 5 6 7
|
158
|
+
# +-----+
|
159
|
+
# 0 1 2 3 4 5|6 7
|
160
|
+
#
|
161
|
+
# Then the bind site (and EnzymeAction range) for Enzyme B would need it's
|
162
|
+
# right side to be at index 2 or less, or it's left side to be 6 or greater.
|
163
|
+
|
164
|
+
competition_indexes = Set.new
|
165
|
+
|
166
|
+
all_enzyme_actions[0..-2].each_with_index do |current_enzyme_action, i|
|
167
|
+
next if competition_indexes.include? i
|
168
|
+
next if current_enzyme_action.cut_ranges.empty? # no cuts, some enzymes are like this (ex. CjuI)
|
169
|
+
|
170
|
+
all_enzyme_actions[i+1..-1].each_with_index do |comparison_enzyme_action, j|
|
171
|
+
j += (i + 1)
|
172
|
+
next if competition_indexes.include? j
|
173
|
+
next if comparison_enzyme_action.cut_ranges.empty? # no cuts
|
174
|
+
|
175
|
+
if (current_enzyme_action.right <= comparison_enzyme_action.cut_ranges.min_vertical) or
|
176
|
+
(current_enzyme_action.left > comparison_enzyme_action.cut_ranges.max_vertical)
|
177
|
+
# no conflict
|
178
|
+
else
|
179
|
+
competition_indexes += [i, j] # merge both indexes into the flat set
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
sometimes_cut = all_enzyme_actions.values_at( *competition_indexes )
|
185
|
+
always_cut = all_enzyme_actions
|
186
|
+
always_cut.delete_if {|x| sometimes_cut.include? x }
|
187
|
+
|
188
|
+
[sometimes_cut, always_cut]
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns an +Array+ of the match indicies of a +RegExp+ to a string.
|
192
|
+
#
|
193
|
+
# Example:
|
194
|
+
#
|
195
|
+
# find_match_locations('abccdefeg', /[ce]/) # => [2,3,5,7]
|
196
|
+
#
|
197
|
+
# ---
|
198
|
+
# *Arguments*
|
199
|
+
# * +string+: The string to scan
|
200
|
+
# * +re+: A RegExp to use
|
201
|
+
# *Returns*:: +Array+ with indicies of match locations
|
202
|
+
def find_match_locations( string, re )
|
203
|
+
md = string.match( re )
|
204
|
+
locations = []
|
205
|
+
counter = 0
|
206
|
+
while md
|
207
|
+
# save the match index relative to the original string
|
208
|
+
locations << (counter += md.begin(0))
|
209
|
+
# find the next match
|
210
|
+
md = string[ (counter += 1)..-1 ].match( re )
|
211
|
+
end
|
212
|
+
locations
|
213
|
+
end
|
214
|
+
|
215
|
+
end # Analysis
|
216
|
+
end # RestrictionEnzyme
|
217
|
+
end # Bio
|
@@ -0,0 +1,107 @@
|
|
1
|
+
#
|
2
|
+
# bio/util/restriction_enzyme/cut_symbol.rb - Defines the symbol used to mark a cut in an 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: cut_symbol.rb,v 1.6 2007/07/16 19:28:48 k Exp $
|
9
|
+
#
|
10
|
+
|
11
|
+
module Bio
|
12
|
+
class RestrictionEnzyme
|
13
|
+
|
14
|
+
# = Usage
|
15
|
+
#
|
16
|
+
# #require 'bio/util/restriction_enzyme/cut_symbol'
|
17
|
+
# require 'cut_symbol'
|
18
|
+
# include Bio::RestrictionEnzyme::CutSymbol
|
19
|
+
#
|
20
|
+
# cut_symbol # => "^"
|
21
|
+
# set_cut_symbol('|') # => "|"
|
22
|
+
# cut_symbol # => "|"
|
23
|
+
# escaped_cut_symbol # => "\\|"
|
24
|
+
# re_cut_symbol # => /\|/
|
25
|
+
# set_cut_symbol('^') # => "^"
|
26
|
+
# "abc^de" =~ re_cut_symbol # => 3
|
27
|
+
# "abc^de" =~ re_cut_symbol_adjacent # => nil
|
28
|
+
# "abc^^de" =~ re_cut_symbol_adjacent # => 3
|
29
|
+
# "a^bc^^de" =~ re_cut_symbol_adjacent # => 4
|
30
|
+
# "a^bc^de" =~ re_cut_symbol_adjacent # => nil
|
31
|
+
#
|
32
|
+
module CutSymbol
|
33
|
+
|
34
|
+
# Set the token to be used as the cut symbol in a restriction enzyme sequece
|
35
|
+
#
|
36
|
+
# Starts as +^+ character
|
37
|
+
#
|
38
|
+
# ---
|
39
|
+
# *Arguments*
|
40
|
+
# * +glyph+: The single character to be used as the cut symbol in an enzyme sequence
|
41
|
+
# *Returns*:: +glyph+
|
42
|
+
def set_cut_symbol(glyph)
|
43
|
+
CutSymbol__.cut_symbol = glyph
|
44
|
+
end
|
45
|
+
|
46
|
+
# Get the token that's used as the cut symbol in a restriction enzyme sequece
|
47
|
+
#
|
48
|
+
# ---
|
49
|
+
# *Arguments*
|
50
|
+
# * _none_
|
51
|
+
# *Returns*:: +glyph+
|
52
|
+
def cut_symbol; CutSymbol__.cut_symbol; end
|
53
|
+
|
54
|
+
# Get the token that's used as the cut symbol in a restriction enzyme sequece with
|
55
|
+
# a back-slash preceding it.
|
56
|
+
#
|
57
|
+
# ---
|
58
|
+
# *Arguments*
|
59
|
+
# * _none_
|
60
|
+
# *Returns*:: +\glyph+
|
61
|
+
def escaped_cut_symbol; CutSymbol__.escaped_cut_symbol; end
|
62
|
+
|
63
|
+
# Used to check if multiple cut symbols are next to each other.
|
64
|
+
#
|
65
|
+
# ---
|
66
|
+
# *Arguments*
|
67
|
+
# * _none_
|
68
|
+
# *Returns*:: +RegExp+
|
69
|
+
def re_cut_symbol_adjacent
|
70
|
+
%r"#{escaped_cut_symbol}{2}"
|
71
|
+
end
|
72
|
+
|
73
|
+
# A Regexp of the cut_symbol.
|
74
|
+
#
|
75
|
+
# ---
|
76
|
+
# *Arguments*
|
77
|
+
# * _none_
|
78
|
+
# *Returns*:: +RegExp+
|
79
|
+
def re_cut_symbol
|
80
|
+
%r"#{escaped_cut_symbol}"
|
81
|
+
end
|
82
|
+
|
83
|
+
#########
|
84
|
+
#protected # NOTE this is a Module, can't hide CutSymbol__
|
85
|
+
#########
|
86
|
+
|
87
|
+
require 'singleton'
|
88
|
+
|
89
|
+
# Class to keep state
|
90
|
+
class CutSymbol__
|
91
|
+
include Singleton
|
92
|
+
|
93
|
+
@cut_symbol = '^'
|
94
|
+
|
95
|
+
def self.cut_symbol; @cut_symbol; end
|
96
|
+
|
97
|
+
def self.cut_symbol=(glyph);
|
98
|
+
raise ArgumentError if glyph.size != 1
|
99
|
+
@cut_symbol = glyph
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.escaped_cut_symbol; "\\" + self.cut_symbol; end
|
103
|
+
end
|
104
|
+
|
105
|
+
end # CutSymbol
|
106
|
+
end # RestrictionEnzyme
|
107
|
+
end # Bio
|
@@ -0,0 +1,130 @@
|
|
1
|
+
#
|
2
|
+
# bio/util/restriction_enzyme/double_stranded/aligned_strands.rb - Align two SingleStrand objects
|
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: aligned_strands.rb,v 1.6 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 DoubleStranded
|
16
|
+
|
17
|
+
# Align two SingleStrand objects and return a Result
|
18
|
+
# object with +primary+ and +complement+ accessors.
|
19
|
+
#
|
20
|
+
class AlignedStrands
|
21
|
+
extend CutSymbol
|
22
|
+
extend StringFormatting
|
23
|
+
|
24
|
+
# The object returned for alignments
|
25
|
+
Result = Struct.new(:primary, :complement)
|
26
|
+
|
27
|
+
# Pad and align two String objects without cut symbols.
|
28
|
+
#
|
29
|
+
# This will look for the sub-sequence without left and right 'n' padding
|
30
|
+
# and re-apply 'n' padding to both strings on both sides equal to the
|
31
|
+
# maximum previous padding on that side.
|
32
|
+
#
|
33
|
+
# The sub-sequences stripped of left and right 'n' padding must be of equal
|
34
|
+
# length.
|
35
|
+
#
|
36
|
+
# Example:
|
37
|
+
# AlignedStrands.align('nngattacannnnn', 'nnnnnctaatgtnn') # =>
|
38
|
+
# <struct Bio::RestrictionEnzyme::DoubleStranded::AlignedStrands::Result
|
39
|
+
# primary="nnnnngattacannnnn",
|
40
|
+
# complement="nnnnnctaatgtnnnnn">
|
41
|
+
#
|
42
|
+
# ---
|
43
|
+
# *Arguments*
|
44
|
+
# * +a+: Primary strand
|
45
|
+
# * +b+: Complementary strand
|
46
|
+
# *Returns*:: +Result+ object with equal padding on both strings
|
47
|
+
def self.align(a, b)
|
48
|
+
a = a.to_s
|
49
|
+
b = b.to_s
|
50
|
+
validate_input( strip_padding(a), strip_padding(b) )
|
51
|
+
left = [left_padding(a), left_padding(b)].sort.last
|
52
|
+
right = [right_padding(a), right_padding(b)].sort.last
|
53
|
+
|
54
|
+
p = left + strip_padding(a) + right
|
55
|
+
c = left + strip_padding(b) + right
|
56
|
+
Result.new(p,c)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Pad and align two String objects with cut symbols.
|
60
|
+
#
|
61
|
+
# Example:
|
62
|
+
# AlignedStrands.with_cuts('nngattacannnnn', 'nnnnnctaatgtnn', [0, 10, 12], [0, 2, 12]) # =>
|
63
|
+
# <struct Bio::RestrictionEnzyme::DoubleStranded::AlignedStrands::Result
|
64
|
+
# primary="n n n n^n g a t t a c a n n^n n^n",
|
65
|
+
# complement="n^n n^n n c t a a t g t n^n n n n">
|
66
|
+
#
|
67
|
+
# Notes:
|
68
|
+
# * To make room for the cut symbols each nucleotide is spaced out.
|
69
|
+
# * This is meant to be able to handle multiple cuts and completely
|
70
|
+
# unrelated cutsites on the two strands, therefore no biological
|
71
|
+
# algorithm assumptions (shortcuts) are made.
|
72
|
+
#
|
73
|
+
# The sequences stripped of left and right 'n' padding must be of equal
|
74
|
+
# length.
|
75
|
+
#
|
76
|
+
# ---
|
77
|
+
# *Arguments*
|
78
|
+
# * +a+: Primary sequence
|
79
|
+
# * +b+: Complementary sequence
|
80
|
+
# * +a_cuts+: Primary strand cut locations in 0-based index notation
|
81
|
+
# * +b_cuts+: Complementary strand cut locations in 0-based index notation
|
82
|
+
# *Returns*:: +Result+ object with equal padding on both strings and spacing between bases
|
83
|
+
def self.align_with_cuts(a,b,a_cuts,b_cuts)
|
84
|
+
a = a.to_s
|
85
|
+
b = b.to_s
|
86
|
+
validate_input( strip_padding(a), strip_padding(b) )
|
87
|
+
|
88
|
+
a_left, a_right = left_padding(a), right_padding(a)
|
89
|
+
b_left, b_right = left_padding(b), right_padding(b)
|
90
|
+
|
91
|
+
left_diff = a_left.length - b_left.length
|
92
|
+
right_diff = a_right.length - b_right.length
|
93
|
+
|
94
|
+
(right_diff > 0) ? (b_right += 'n' * right_diff) : (a_right += 'n' * right_diff.abs)
|
95
|
+
|
96
|
+
a_adjust = b_adjust = 0
|
97
|
+
|
98
|
+
if left_diff > 0
|
99
|
+
b_left += 'n' * left_diff
|
100
|
+
b_adjust = left_diff
|
101
|
+
else
|
102
|
+
a_left += 'n' * left_diff.abs
|
103
|
+
a_adjust = left_diff.abs
|
104
|
+
end
|
105
|
+
|
106
|
+
a = a_left + strip_padding(a) + a_right
|
107
|
+
b = b_left + strip_padding(b) + b_right
|
108
|
+
|
109
|
+
a_cuts.sort.reverse.each { |c| a.insert(c+1+a_adjust, cut_symbol) }
|
110
|
+
b_cuts.sort.reverse.each { |c| b.insert(c+1+b_adjust, cut_symbol) }
|
111
|
+
|
112
|
+
Result.new( add_spacing(a), add_spacing(b) )
|
113
|
+
end
|
114
|
+
|
115
|
+
#########
|
116
|
+
protected
|
117
|
+
#########
|
118
|
+
|
119
|
+
def self.validate_input(a,b)
|
120
|
+
unless a.size == b.size
|
121
|
+
err = "Result sequences are not the same size. Does not align sequences with differing lengths after strip_padding.\n"
|
122
|
+
err += "#{a.size}, #{a.inspect}\n"
|
123
|
+
err += "#{b.size}, #{b.inspect}"
|
124
|
+
raise ArgumentError, err
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end # AlignedStrands
|
128
|
+
end # DoubleStranded
|
129
|
+
end # RestrictionEnzyme
|
130
|
+
end # Bio
|
@@ -0,0 +1,103 @@
|
|
1
|
+
#
|
2
|
+
# bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb - Stores a cut location pair in 0-based index 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_location_pair.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 DoubleStranded
|
16
|
+
|
17
|
+
# Stores a single cut location pair in 0-based index notation for use with
|
18
|
+
# DoubleStranded enzyme sequences.
|
19
|
+
#
|
20
|
+
class CutLocationPair < Array
|
21
|
+
# Location of the cut on the primary strand.
|
22
|
+
# Corresponds - or 'pairs' - to the complement cut.
|
23
|
+
# A value of +nil+ is an explicit representation of 'no cut'.
|
24
|
+
attr_reader :primary
|
25
|
+
|
26
|
+
# Location of the cut on the complementary strand.
|
27
|
+
# Corresponds - or 'pairs' - to the primary cut.
|
28
|
+
# A value of +nil+ is an explicit representation of 'no cut'.
|
29
|
+
attr_reader :complement
|
30
|
+
|
31
|
+
# CutLocationPair constructor.
|
32
|
+
#
|
33
|
+
# Stores a single cut location pair in 0-based index notation for use with
|
34
|
+
# DoubleStranded enzyme sequences.
|
35
|
+
#
|
36
|
+
# Example:
|
37
|
+
# clp = CutLocationPair.new(3,2)
|
38
|
+
# clp.primary # 3
|
39
|
+
# clp.complement # 2
|
40
|
+
#
|
41
|
+
# ---
|
42
|
+
# *Arguments*
|
43
|
+
# * +pair+: May be two values represented as an Array, a Range, or a
|
44
|
+
# combination of Integer and nil values. The first value
|
45
|
+
# represents a cut on the primary strand, the second represents
|
46
|
+
# a cut on the complement strand.
|
47
|
+
# *Returns*:: nothing
|
48
|
+
def initialize( *pair )
|
49
|
+
a = b = nil
|
50
|
+
|
51
|
+
if pair[0].kind_of? Array
|
52
|
+
a,b = init_with_array( pair[0] )
|
53
|
+
|
54
|
+
# no idea why this barfs without the second half during test/runner.rb
|
55
|
+
# are there two Range objects running around?
|
56
|
+
elsif pair[0].kind_of? Range or (pair[0].class.to_s == 'Range')
|
57
|
+
#elsif pair[0].kind_of? Range
|
58
|
+
a,b = init_with_array( [pair[0].first, pair[0].last] )
|
59
|
+
|
60
|
+
elsif pair[0].kind_of? Integer or pair[0].kind_of? NilClass
|
61
|
+
a,b = init_with_array( [pair[0], pair[1]] )
|
62
|
+
|
63
|
+
else
|
64
|
+
raise ArgumentError, "#{pair[0].class} is an invalid class type to initalize CutLocationPair."
|
65
|
+
end
|
66
|
+
|
67
|
+
super( [a,b] )
|
68
|
+
@primary = a
|
69
|
+
@complement = b
|
70
|
+
return
|
71
|
+
end
|
72
|
+
|
73
|
+
#########
|
74
|
+
protected
|
75
|
+
#########
|
76
|
+
|
77
|
+
def init_with_array( ary )
|
78
|
+
validate_1(ary)
|
79
|
+
a = ary.shift
|
80
|
+
ary.empty? ? b = nil : b = ary.shift
|
81
|
+
validate_2(a,b)
|
82
|
+
[a,b]
|
83
|
+
end
|
84
|
+
|
85
|
+
def validate_1( ary )
|
86
|
+
unless ary.size == 1 or ary.size == 2
|
87
|
+
raise ArgumentError, "Must be one or two elements."
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def validate_2( a, b )
|
92
|
+
if (a != nil and a < 0) or (b != nil and b < 0)
|
93
|
+
raise ArgumentError, "0-based index notation only. Negative values are illegal."
|
94
|
+
end
|
95
|
+
|
96
|
+
if a == nil and b == nil
|
97
|
+
raise ArgumentError, "Neither strand has a cut. Ambiguous."
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end # CutLocationPair
|
101
|
+
end # DoubleStranded
|
102
|
+
end # RestrictionEnzyme
|
103
|
+
end # Bio
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#
|
2
|
+
# bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb - Inherits from DoubleStranded::CutLocationPair
|
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_location_pair_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 DoubleStranded
|
16
|
+
|
17
|
+
# Inherits from DoubleStranded::CutLocationPair , stores the cut location pair in
|
18
|
+
# enzyme notation instead of 0-based.
|
19
|
+
#
|
20
|
+
class CutLocationPairInEnzymeNotation < CutLocationPair
|
21
|
+
|
22
|
+
#########
|
23
|
+
protected
|
24
|
+
#########
|
25
|
+
|
26
|
+
def validate_2( a, b )
|
27
|
+
if (a == 0) or (b == 0)
|
28
|
+
raise ArgumentError, "Enzyme index notation only. 0 values are illegal."
|
29
|
+
end
|
30
|
+
|
31
|
+
if a == nil and b == nil
|
32
|
+
raise ArgumentError, "Neither strand has a cut. Ambiguous."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end # CutLocationPair
|
36
|
+
end # DoubleStranded
|
37
|
+
end # RestrictionEnzyme
|
38
|
+
end # Bio
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#
|
2
|
+
# bio/util/restriction_enzyme/double_stranded/cut_locations.rb - Contains an Array of CutLocationPair objects
|
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.rb,v 1.6 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 DoubleStranded
|
16
|
+
|
17
|
+
# Contains an +Array+ of CutLocationPair objects.
|
18
|
+
#
|
19
|
+
class CutLocations < Array
|
20
|
+
|
21
|
+
# CutLocations constructor.
|
22
|
+
#
|
23
|
+
# Contains an +Array+ of CutLocationPair objects.
|
24
|
+
#
|
25
|
+
# Example:
|
26
|
+
# clp1 = CutLocationPair.new(3,2)
|
27
|
+
# clp2 = CutLocationPair.new(7,9)
|
28
|
+
# pairs = CutLocations.new(clp1, clp2)
|
29
|
+
#
|
30
|
+
# ---
|
31
|
+
# *Arguments*
|
32
|
+
# * +args+: Any number of +CutLocationPair+ objects
|
33
|
+
# *Returns*:: nothing
|
34
|
+
def initialize(*args)
|
35
|
+
validate_args(args)
|
36
|
+
super(args)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns an +Array+ of locations of cuts on the primary strand
|
40
|
+
#
|
41
|
+
# ---
|
42
|
+
# *Arguments*
|
43
|
+
# * _none_
|
44
|
+
# *Returns*:: +Array+ of locations of cuts on the primary strand
|
45
|
+
def primary
|
46
|
+
self.collect {|a| a[0]}
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns an +Array+ of locations of cuts on the complementary strand
|
50
|
+
#
|
51
|
+
# ---
|
52
|
+
# *Arguments*
|
53
|
+
# * _none_
|
54
|
+
# *Returns*:: +Array+ of locations of cuts on the complementary strand
|
55
|
+
def complement
|
56
|
+
self.collect {|a| a[1]}
|
57
|
+
end
|
58
|
+
|
59
|
+
#########
|
60
|
+
protected
|
61
|
+
#########
|
62
|
+
|
63
|
+
def validate_args(args)
|
64
|
+
args.each do |a|
|
65
|
+
unless a.class == Bio::RestrictionEnzyme::DoubleStranded::CutLocationPair
|
66
|
+
err = "Not a CutLocationPair\n"
|
67
|
+
err += "class: #{a.class}\n"
|
68
|
+
err += "inspect: #{a.inspect}"
|
69
|
+
raise ArgumentError, err
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end # CutLocations
|
74
|
+
end # DoubleStranded
|
75
|
+
end # RestrictionEnzyme
|
76
|
+
end # Bio
|