wwood-bioruby 1.2.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +205 -0
- data/README_DEV.rdoc +285 -0
- data/VERSION.yml +4 -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/lib/bio.rb +306 -0
- data/lib/bio/alignment.rb +2518 -0
- data/lib/bio/appl/bl2seq/report.rb +334 -0
- data/lib/bio/appl/blast.rb +505 -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 +635 -0
- data/lib/bio/appl/blast/xmlparser.rb +236 -0
- data/lib/bio/appl/blat/report.rb +530 -0
- data/lib/bio/appl/clustalw.rb +219 -0
- data/lib/bio/appl/clustalw/report.rb +152 -0
- data/lib/bio/appl/emboss.rb +203 -0
- data/lib/bio/appl/fasta.rb +235 -0
- data/lib/bio/appl/fasta/format10.rb +325 -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.rb +126 -0
- data/lib/bio/appl/hmmer/report.rb +683 -0
- data/lib/bio/appl/iprscan/report.rb +374 -0
- data/lib/bio/appl/mafft.rb +259 -0
- data/lib/bio/appl/mafft/report.rb +226 -0
- data/lib/bio/appl/muscle.rb +52 -0
- data/lib/bio/appl/paml/baseml.rb +95 -0
- data/lib/bio/appl/paml/baseml/report.rb +32 -0
- data/lib/bio/appl/paml/codeml.rb +242 -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/common.rb +348 -0
- data/lib/bio/appl/paml/common_report.rb +38 -0
- data/lib/bio/appl/paml/yn00.rb +103 -0
- data/lib/bio/appl/paml/yn00/report.rb +32 -0
- data/lib/bio/appl/phylip/alignment.rb +133 -0
- data/lib/bio/appl/phylip/distance_matrix.rb +96 -0
- data/lib/bio/appl/probcons.rb +41 -0
- data/lib/bio/appl/psort.rb +548 -0
- data/lib/bio/appl/psort/report.rb +542 -0
- data/lib/bio/appl/pts1.rb +263 -0
- data/lib/bio/appl/sim4.rb +124 -0
- data/lib/bio/appl/sim4/report.rb +485 -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 +353 -0
- data/lib/bio/data/codontable.rb +722 -0
- data/lib/bio/data/na.rb +223 -0
- data/lib/bio/db.rb +329 -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.rb +410 -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/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.rb +29 -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/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/url.rb +42 -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.rb +482 -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/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.rb +456 -0
- data/lib/bio/sequence/aa.rb +152 -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/shell.rb +44 -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/tree.rb +852 -0
- data/lib/bio/util/color_scheme.rb +191 -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/contingency_table.rb +370 -0
- data/lib/bio/util/restriction_enzyme.rb +228 -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.rb +321 -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/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.rb +257 -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/vertical_cut_range.rb +77 -0
- data/lib/bio/util/restriction_enzyme/single_strand.rb +200 -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_complement.rb +23 -0
- data/lib/bio/util/restriction_enzyme/string_formatting.rb +111 -0
- data/lib/bio/util/sirna.rb +288 -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 +14 -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_psort.rb +57 -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/db/test_url.rb +36 -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 +505 -0
- data/test/unit/bio/io/test_soapwsdl.rb +32 -0
- data/test/unit/bio/sequence/test_aa.rb +115 -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 +543 -0
data/lib/bio/location.rb
ADDED
@@ -0,0 +1,867 @@
|
|
1
|
+
#
|
2
|
+
# = bio/location.rb - Locations/Location class (GenBank location format)
|
3
|
+
#
|
4
|
+
# Copyright:: Copyright (C) 2001, 2005 Toshiaki Katayama <k@bioruby.org>
|
5
|
+
# 2006 Jan Aerts <jan.aerts@bbsrc.ac.uk>
|
6
|
+
# 2008 Naohisa Goto <ng@bioruby.org>
|
7
|
+
# License:: The Ruby License
|
8
|
+
#
|
9
|
+
# $Id:$
|
10
|
+
#
|
11
|
+
|
12
|
+
module Bio
|
13
|
+
|
14
|
+
# == Description
|
15
|
+
#
|
16
|
+
# The Bio::Location class describes the position of a genomic locus.
|
17
|
+
# Typically, Bio::Location objects are created automatically when the
|
18
|
+
# user creates a Bio::Locations object, instead of initialized directly.
|
19
|
+
#
|
20
|
+
# == Usage
|
21
|
+
#
|
22
|
+
# location = Bio::Location.new('500..550')
|
23
|
+
# puts "start=" + location.from.to_s + ";end=" + location.to.to_s
|
24
|
+
#
|
25
|
+
# #, or better: through Bio::Locations
|
26
|
+
# locations = Bio::Locations.new('500..550')
|
27
|
+
# locations.each do |location|
|
28
|
+
# puts "start=" + location.from.to_s + ";end=" + location.to.to_s
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
class Location
|
32
|
+
|
33
|
+
include Comparable
|
34
|
+
|
35
|
+
# Parses a'location' segment, which can be 'ID:' + ('n' or 'n..m' or 'n^m'
|
36
|
+
# or "seq") with '<' or '>', and returns a Bio::Location object.
|
37
|
+
#
|
38
|
+
# location = Bio::Location.new('500..550')
|
39
|
+
#
|
40
|
+
# ---
|
41
|
+
# *Arguments*:
|
42
|
+
# * (required) _str_: GenBank style position string (see Bio::Locations
|
43
|
+
# documentation)
|
44
|
+
# *Returns*:: the Bio::Location object
|
45
|
+
def initialize(location = nil)
|
46
|
+
|
47
|
+
if location
|
48
|
+
if location =~ /:/ # (G) ID:location
|
49
|
+
xref_id, location = location.split(':')
|
50
|
+
end
|
51
|
+
if location =~ /</ # (I) <,>
|
52
|
+
lt = true
|
53
|
+
end
|
54
|
+
if location =~ />/
|
55
|
+
gt = true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# s : start base, e : end base => from, to
|
60
|
+
case location
|
61
|
+
when /^[<>]?(\d+)$/ # (A, I) n
|
62
|
+
s = e = $1.to_i
|
63
|
+
when /^[<>]?(\d+)\.\.[<>]?(\d+)$/ # (B, I) n..m
|
64
|
+
s = $1.to_i
|
65
|
+
e = $2.to_i
|
66
|
+
if e - s < 0
|
67
|
+
# raise "Error: invalid range : #{location}"
|
68
|
+
$stderr.puts "[Warning] invalid range : #{location}" if $DEBUG
|
69
|
+
end
|
70
|
+
when /^[<>]?(\d+)\^[<>]?(\d+)$/ # (C, I) n^m
|
71
|
+
s = $1.to_i
|
72
|
+
e = $2.to_i
|
73
|
+
carat = true
|
74
|
+
if e - s != 1 or e != 1 # assert n^n+1 or n^1
|
75
|
+
# raise "Error: invalid range : #{location}"
|
76
|
+
$stderr.puts "[Warning] invalid range : #{location}" if $DEBUG
|
77
|
+
end
|
78
|
+
when /^"?([ATGCatgc]+)"?$/ # (H) literal sequence
|
79
|
+
sequence = $1.downcase
|
80
|
+
s = e = nil
|
81
|
+
when nil
|
82
|
+
;
|
83
|
+
else
|
84
|
+
raise "Error: unknown location format : #{location}"
|
85
|
+
end
|
86
|
+
|
87
|
+
@from = s # start position of the location
|
88
|
+
@to = e # end position of the location
|
89
|
+
@strand = 1 # strand direction of the location
|
90
|
+
# forward => 1 or complement => -1
|
91
|
+
@sequence = sequence # literal sequence of the location
|
92
|
+
@lt = lt # true if the position contains '<'
|
93
|
+
@gt = gt # true if the position contains '>'
|
94
|
+
@xref_id = xref_id # link to the external entry as GenBank ID
|
95
|
+
@carat = carat # true if the location indicates the site
|
96
|
+
# between two adjoining nucleotides
|
97
|
+
end
|
98
|
+
|
99
|
+
# (Integer) start position of the location
|
100
|
+
attr_accessor :from
|
101
|
+
# (Integer) end position of the location
|
102
|
+
attr_accessor :to
|
103
|
+
|
104
|
+
# (Integer) strand direction of the location
|
105
|
+
# (forward => 1 or complement => -1)
|
106
|
+
attr_accessor :strand
|
107
|
+
|
108
|
+
# (String) literal sequence of the location
|
109
|
+
attr_accessor :sequence
|
110
|
+
|
111
|
+
# (true, false or nil) true if the position contains '<'
|
112
|
+
attr_accessor :lt
|
113
|
+
|
114
|
+
# (true, false or nil) true if the position contains '>'
|
115
|
+
attr_accessor :gt
|
116
|
+
|
117
|
+
# (String) link to the external entry as GenBank ID
|
118
|
+
attr_accessor :xref_id
|
119
|
+
|
120
|
+
# (true, false or nil) true if the location indicates the site
|
121
|
+
# between two adjoining nucleotides
|
122
|
+
attr_accessor :carat
|
123
|
+
|
124
|
+
# Complements the sequence location (i.e. alternates the strand).
|
125
|
+
# Note that it is destructive method (i.e. modifies itself),
|
126
|
+
# but it does not modify the "sequence" attribute.
|
127
|
+
# ---
|
128
|
+
# *Returns*:: the Bio::Location object
|
129
|
+
def complement
|
130
|
+
@strand *= -1
|
131
|
+
self # return Location object
|
132
|
+
end
|
133
|
+
|
134
|
+
# Replaces the sequence of the location.
|
135
|
+
# ---
|
136
|
+
# *Arguments*:
|
137
|
+
# * (required) _sequence_: sequence to be used to replace the sequence
|
138
|
+
# at the location
|
139
|
+
# *Returns*:: the Bio::Location object
|
140
|
+
def replace(sequence)
|
141
|
+
@sequence = sequence.downcase
|
142
|
+
self # return Location object
|
143
|
+
end
|
144
|
+
|
145
|
+
# Returns the range (from..to) of the location as a Range object.
|
146
|
+
def range
|
147
|
+
@from..@to
|
148
|
+
end
|
149
|
+
|
150
|
+
# Check where a Bio::Location object is located compared to another
|
151
|
+
# Bio::Location object (mainly to facilitate the use of Comparable).
|
152
|
+
# A location A is upstream of location B if the start position of
|
153
|
+
# location A is smaller than the start position of location B. If
|
154
|
+
# they're the same, the end positions are checked.
|
155
|
+
# ---
|
156
|
+
# *Arguments*:
|
157
|
+
# * (required) _other location_: a Bio::Location object
|
158
|
+
# *Returns*::
|
159
|
+
# * 1 if self < other location
|
160
|
+
# * -1 if self > other location
|
161
|
+
# * 0 if both location are the same
|
162
|
+
# * nil if the argument is not a Bio::Location object
|
163
|
+
def <=>(other)
|
164
|
+
if ! other.kind_of?(Bio::Location)
|
165
|
+
return nil
|
166
|
+
end
|
167
|
+
|
168
|
+
if @from.to_f < other.from.to_f
|
169
|
+
return -1
|
170
|
+
elsif @from.to_f > other.from.to_f
|
171
|
+
return 1
|
172
|
+
end
|
173
|
+
|
174
|
+
if @to.to_f < other.to.to_f
|
175
|
+
return -1
|
176
|
+
elsif @to.to_f > other.to.to_f
|
177
|
+
return 1
|
178
|
+
end
|
179
|
+
return 0
|
180
|
+
end
|
181
|
+
|
182
|
+
end # Location
|
183
|
+
|
184
|
+
# == Description
|
185
|
+
#
|
186
|
+
# The Bio::Locations class is a container for Bio::Location objects:
|
187
|
+
# creating a Bio::Locations object (based on a GenBank style position string)
|
188
|
+
# will spawn an array of Bio::Location objects.
|
189
|
+
#
|
190
|
+
# == Usage
|
191
|
+
#
|
192
|
+
# locations = Bio::Locations.new('join(complement(500..550), 600..625)')
|
193
|
+
# locations.each do |loc|
|
194
|
+
# puts "class = " + loc.class.to_s
|
195
|
+
# puts "range = #{loc.from}..#{loc.to} (strand = #{loc.strand})"
|
196
|
+
# end
|
197
|
+
# # Output would be:
|
198
|
+
# # class = Bio::Location
|
199
|
+
# # range = 500..550 (strand = -1)
|
200
|
+
# # class = Bio::Location
|
201
|
+
# # range = 600..625 (strand = 1)
|
202
|
+
#
|
203
|
+
# # For the following three location strings, print the span and range
|
204
|
+
# ['one-of(898,900)..983',
|
205
|
+
# 'one-of(5971..6308,5971..6309)',
|
206
|
+
# '8050..one-of(10731,10758,10905,11242)'].each do |loc|
|
207
|
+
# location = Bio::Locations.new(loc)
|
208
|
+
# puts location.span
|
209
|
+
# puts location.range
|
210
|
+
# end
|
211
|
+
#
|
212
|
+
# === GenBank location descriptor classification
|
213
|
+
#
|
214
|
+
# ==== Definition of the position notation of the GenBank location format
|
215
|
+
#
|
216
|
+
# According to the GenBank manual 'gbrel.txt', position notations were
|
217
|
+
# classified into 10 patterns - (A) to (J).
|
218
|
+
#
|
219
|
+
# 3.4.12.2 Feature Location
|
220
|
+
#
|
221
|
+
# The second column of the feature descriptor line designates the
|
222
|
+
# location of the feature in the sequence. The location descriptor
|
223
|
+
# begins at position 22. Several conventions are used to indicate
|
224
|
+
# sequence location.
|
225
|
+
#
|
226
|
+
# Base numbers in location descriptors refer to numbering in the entry,
|
227
|
+
# which is not necessarily the same as the numbering scheme used in the
|
228
|
+
# published report. The first base in the presented sequence is numbered
|
229
|
+
# base 1. Sequences are presented in the 5 to 3 direction.
|
230
|
+
#
|
231
|
+
# Location descriptors can be one of the following:
|
232
|
+
#
|
233
|
+
# (A) 1. A single base;
|
234
|
+
#
|
235
|
+
# (B) 2. A contiguous span of bases;
|
236
|
+
#
|
237
|
+
# (C) 3. A site between two bases;
|
238
|
+
#
|
239
|
+
# (D) 4. A single base chosen from a range of bases;
|
240
|
+
#
|
241
|
+
# (E) 5. A single base chosen from among two or more specified bases;
|
242
|
+
#
|
243
|
+
# (F) 6. A joining of sequence spans;
|
244
|
+
#
|
245
|
+
# (G) 7. A reference to an entry other than the one to which the feature
|
246
|
+
# belongs (i.e., a remote entry), followed by a location descriptor
|
247
|
+
# referring to the remote sequence;
|
248
|
+
#
|
249
|
+
# (H) 8. A literal sequence (a string of bases enclosed in quotation marks).
|
250
|
+
#
|
251
|
+
# ==== Description commented with pattern IDs.
|
252
|
+
#
|
253
|
+
# (C) A site between two residues, such as an endonuclease cleavage site, is
|
254
|
+
# indicated by listing the two bases separated by a carat (e.g., 23^24).
|
255
|
+
#
|
256
|
+
# (D) A single residue chosen from a range of residues is indicated by the
|
257
|
+
# number of the first and last bases in the range separated by a single
|
258
|
+
# period (e.g., 23.79). The symbols < and > indicate that the end point
|
259
|
+
# (I) of the range is beyond the specified base number.
|
260
|
+
#
|
261
|
+
# (B) A contiguous span of bases is indicated by the number of the first and
|
262
|
+
# last bases in the range separated by two periods (e.g., 23..79). The
|
263
|
+
# (I) symbols < and > indicate that the end point of the range is beyond the
|
264
|
+
# specified base number. Starting and ending positions can be indicated
|
265
|
+
# by base number or by one of the operators described below.
|
266
|
+
#
|
267
|
+
# Operators are prefixes that specify what must be done to the indicated
|
268
|
+
# sequence to locate the feature. The following are the operators
|
269
|
+
# available, along with their most common format and a description.
|
270
|
+
#
|
271
|
+
# (J) complement (location): The feature is complementary to the location
|
272
|
+
# indicated. Complementary strands are read 5 to 3.
|
273
|
+
#
|
274
|
+
# (F) join (location, location, .. location): The indicated elements should
|
275
|
+
# be placed end to end to form one contiguous sequence.
|
276
|
+
#
|
277
|
+
# (F) order (location, location, .. location): The elements are found in the
|
278
|
+
# specified order in the 5 to 3 direction, but nothing is implied about
|
279
|
+
# the rationality of joining them.
|
280
|
+
#
|
281
|
+
# (F) group (location, location, .. location): The elements are related and
|
282
|
+
# should be grouped together, but no order is implied.
|
283
|
+
#
|
284
|
+
# (E) one-of (location, location, .. location): The element can be any one,
|
285
|
+
# but only one, of the items listed.
|
286
|
+
#
|
287
|
+
# === Reduction strategy of the position notations
|
288
|
+
#
|
289
|
+
# * (A) Location n
|
290
|
+
# * (B) Location n..m
|
291
|
+
# * (C) Location n^m
|
292
|
+
# * (D) (n.m) => Location n
|
293
|
+
# * (E)
|
294
|
+
# * one-of(n,m,..) => Location n
|
295
|
+
# * one-of(n..m,..) => Location n..m
|
296
|
+
# * (F)
|
297
|
+
# * order(loc,loc,..) => join(loc, loc,..)
|
298
|
+
# * group(loc,loc,..) => join(loc, loc,..)
|
299
|
+
# * join(loc,loc,..) => Sequence
|
300
|
+
# * (G) ID:loc => Location with ID
|
301
|
+
# * (H) "atgc" => Location only with Sequence
|
302
|
+
# * (I)
|
303
|
+
# * <n => Location n with lt flag
|
304
|
+
# * >n => Location n with gt flag
|
305
|
+
# * <n..m => Location n..m with lt flag
|
306
|
+
# * n..>m => Location n..m with gt flag
|
307
|
+
# * <n..>m => Location n..m with lt, gt flag
|
308
|
+
# * (J) complement(loc) => Sequence
|
309
|
+
# * (K) replace(loc, str) => Location with replacement Sequence
|
310
|
+
#
|
311
|
+
class Locations
|
312
|
+
|
313
|
+
include Enumerable
|
314
|
+
|
315
|
+
# Parses a GenBank style position string and returns a Bio::Locations
|
316
|
+
# object, which contains a list of Bio::Location objects.
|
317
|
+
#
|
318
|
+
# locations = Bio::Locations.new('join(complement(500..550), 600..625)')
|
319
|
+
#
|
320
|
+
# ---
|
321
|
+
# *Arguments*:
|
322
|
+
# * (required) _str_: GenBank style position string
|
323
|
+
# *Returns*:: Bio::Locations object
|
324
|
+
def initialize(position)
|
325
|
+
@operator = nil
|
326
|
+
if position.is_a? Array
|
327
|
+
@locations = position
|
328
|
+
else
|
329
|
+
position = gbl_cleanup(position) # preprocessing
|
330
|
+
@locations = gbl_pos2loc(position) # create an Array of Bio::Location objects
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
# (Array) An Array of Bio::Location objects
|
335
|
+
attr_accessor :locations
|
336
|
+
|
337
|
+
# (Symbol or nil) Operator.
|
338
|
+
# nil (means :join), :order, or :group (obsolete).
|
339
|
+
attr_accessor :operator
|
340
|
+
|
341
|
+
# Evaluate equality of Bio::Locations object.
|
342
|
+
def equals?(other)
|
343
|
+
if ! other.kind_of?(Bio::Locations)
|
344
|
+
return nil
|
345
|
+
end
|
346
|
+
if self.sort == other.sort
|
347
|
+
return true
|
348
|
+
else
|
349
|
+
return false
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
# Iterates on each Bio::Location object.
|
354
|
+
def each
|
355
|
+
@locations.each do |x|
|
356
|
+
yield(x)
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
# Returns nth Bio::Location object.
|
361
|
+
def [](n)
|
362
|
+
@locations[n]
|
363
|
+
end
|
364
|
+
|
365
|
+
# Returns first Bio::Location object.
|
366
|
+
def first
|
367
|
+
@locations.first
|
368
|
+
end
|
369
|
+
|
370
|
+
# Returns last Bio::Location object.
|
371
|
+
def last
|
372
|
+
@locations.last
|
373
|
+
end
|
374
|
+
|
375
|
+
# Returns an Array containing overall min and max position [min, max]
|
376
|
+
# of this Bio::Locations object.
|
377
|
+
def span
|
378
|
+
span_min = @locations.min { |a,b| a.from <=> b.from }
|
379
|
+
span_max = @locations.max { |a,b| a.to <=> b.to }
|
380
|
+
return span_min.from, span_max.to
|
381
|
+
end
|
382
|
+
|
383
|
+
# Similar to span, but returns a Range object min..max
|
384
|
+
def range
|
385
|
+
min, max = span
|
386
|
+
min..max
|
387
|
+
end
|
388
|
+
|
389
|
+
# Returns a length of the spliced RNA.
|
390
|
+
def length
|
391
|
+
len = 0
|
392
|
+
@locations.each do |x|
|
393
|
+
if x.sequence
|
394
|
+
len += x.sequence.size
|
395
|
+
else
|
396
|
+
len += (x.to - x.from + 1)
|
397
|
+
end
|
398
|
+
end
|
399
|
+
len
|
400
|
+
end
|
401
|
+
alias size length
|
402
|
+
|
403
|
+
# Converts absolute position in the whole of the DNA sequence to relative
|
404
|
+
# position in the locus.
|
405
|
+
#
|
406
|
+
# This method can for example be used to relate positions in a DNA-sequence
|
407
|
+
# with those in RNA. In this use, the optional ':aa'-flag returns the
|
408
|
+
# position of the associated amino-acid rather than the nucleotide.
|
409
|
+
#
|
410
|
+
# loc = Bio::Locations.new('complement(12838..13533)')
|
411
|
+
# puts loc.relative(13524) # => 10
|
412
|
+
# puts loc.relative(13506, :aa) # => 3
|
413
|
+
#
|
414
|
+
# ---
|
415
|
+
# *Arguments*:
|
416
|
+
# * (required) _position_: nucleotide position within whole of the sequence
|
417
|
+
# * _:aa_: flag that lets method return position in aminoacid coordinates
|
418
|
+
# *Returns*:: position within the location
|
419
|
+
def relative(n, type = nil)
|
420
|
+
case type
|
421
|
+
when :location
|
422
|
+
;
|
423
|
+
when :aa
|
424
|
+
if n = abs2rel(n)
|
425
|
+
(n - 1) / 3 + 1
|
426
|
+
else
|
427
|
+
nil
|
428
|
+
end
|
429
|
+
else
|
430
|
+
abs2rel(n)
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
# Converts relative position in the locus to position in the whole of the
|
435
|
+
# DNA sequence.
|
436
|
+
#
|
437
|
+
# This method can for example be used to relate positions in a DNA-sequence
|
438
|
+
# with those in RNA. In this use, the optional ':aa'-flag returns the
|
439
|
+
# position of the associated amino-acid rather than the nucleotide.
|
440
|
+
#
|
441
|
+
# loc = Bio::Locations.new('complement(12838..13533)')
|
442
|
+
# puts loc.absolute(10) # => 13524
|
443
|
+
# puts loc.absolute(10, :aa) # => 13506
|
444
|
+
#
|
445
|
+
# ---
|
446
|
+
# *Arguments*:
|
447
|
+
# * (required) _position_: nucleotide position within locus
|
448
|
+
# * _:aa_: flag to be used if _position_ is a aminoacid position rather than
|
449
|
+
# a nucleotide position
|
450
|
+
# *Returns*:: position within the whole of the sequence
|
451
|
+
def absolute(n, type = nil)
|
452
|
+
case type
|
453
|
+
when :location
|
454
|
+
;
|
455
|
+
when :aa
|
456
|
+
n = (n - 1) * 3 + 1
|
457
|
+
rel2abs(n)
|
458
|
+
else
|
459
|
+
rel2abs(n)
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
|
464
|
+
# String representation.
|
465
|
+
#
|
466
|
+
# Note: In some cases, it fails to detect whether
|
467
|
+
# "complement(join(...))" or "join(complement(..))", and whether
|
468
|
+
# "complement(order(...))" or "order(complement(..))".
|
469
|
+
#
|
470
|
+
# ---
|
471
|
+
# *Returns*:: String
|
472
|
+
def to_s
|
473
|
+
return '' if @locations.empty?
|
474
|
+
complement_join = false
|
475
|
+
locs = @locations
|
476
|
+
if locs.size >= 2 and locs.inject(true) do |flag, loc|
|
477
|
+
# check if each location is complement
|
478
|
+
(flag && (loc.strand == -1) && !loc.xref_id)
|
479
|
+
end and locs.inject(locs[0].from) do |pos, loc|
|
480
|
+
if pos then
|
481
|
+
(pos >= loc.from) ? loc.from : false
|
482
|
+
else
|
483
|
+
false
|
484
|
+
end
|
485
|
+
end then
|
486
|
+
locs = locs.reverse
|
487
|
+
complement_join = true
|
488
|
+
end
|
489
|
+
locs = locs.collect do |loc|
|
490
|
+
lt = loc.lt ? '<' : ''
|
491
|
+
gt = loc.gt ? '>' : ''
|
492
|
+
str = if loc.from == loc.to then
|
493
|
+
"#{lt}#{gt}#{loc.from.to_i}"
|
494
|
+
elsif loc.carat then
|
495
|
+
"#{lt}#{loc.from.to_i}^#{gt}#{loc.to.to_i}"
|
496
|
+
else
|
497
|
+
"#{lt}#{loc.from.to_i}..#{gt}#{loc.to.to_i}"
|
498
|
+
end
|
499
|
+
if loc.xref_id and !loc.xref_id.empty? then
|
500
|
+
str = "#{loc.xref_id}:#{str}"
|
501
|
+
end
|
502
|
+
if loc.strand == -1 and !complement_join then
|
503
|
+
str = "complement(#{str})"
|
504
|
+
end
|
505
|
+
if loc.sequence then
|
506
|
+
str = "replace(#{str},\"#{loc.sequence}\")"
|
507
|
+
end
|
508
|
+
str
|
509
|
+
end
|
510
|
+
if locs.size >= 2 then
|
511
|
+
op = (self.operator || 'join').to_s
|
512
|
+
result = "#{op}(#{locs.join(',')})"
|
513
|
+
else
|
514
|
+
result = locs[0]
|
515
|
+
end
|
516
|
+
if complement_join then
|
517
|
+
result = "complement(#{result})"
|
518
|
+
end
|
519
|
+
result
|
520
|
+
end
|
521
|
+
|
522
|
+
private
|
523
|
+
|
524
|
+
|
525
|
+
# Preprocessing to clean up the position notation.
|
526
|
+
def gbl_cleanup(position)
|
527
|
+
# sometimes position contains white spaces...
|
528
|
+
position = position.gsub(/\s+/, '')
|
529
|
+
|
530
|
+
# select one base # (D) n.m
|
531
|
+
# .. n m :
|
532
|
+
# <match> $1 ( $2 $3 not )
|
533
|
+
position.gsub!(/(\.{2})?\(?([<>\d]+)\.([<>\d]+)(?!:)\)?/) do |match|
|
534
|
+
if $1
|
535
|
+
$1 + $3 # ..(n.m) => ..m
|
536
|
+
else
|
537
|
+
$2 # (?n.m)? => n
|
538
|
+
end
|
539
|
+
end
|
540
|
+
|
541
|
+
# select the 1st location # (E) one-of()
|
542
|
+
# <match> .. one-of ($2 ,$3 )
|
543
|
+
position.gsub!(/(\.{2})?one-of\(([^,]+),([^)]+)\)/) do |match|
|
544
|
+
if $1
|
545
|
+
$1 + $3.gsub(/.*,(.*)/, '\1') # ..one-of(n,m) => ..m
|
546
|
+
else
|
547
|
+
$2 # one-of(n,m) => n
|
548
|
+
end
|
549
|
+
end
|
550
|
+
|
551
|
+
## substitute order(), group() by join() # (F) group(), order()
|
552
|
+
#position.gsub!(/(order|group)/, 'join')
|
553
|
+
|
554
|
+
return position
|
555
|
+
end
|
556
|
+
|
557
|
+
|
558
|
+
# Parse position notation and create Location objects.
|
559
|
+
def gbl_pos2loc(position)
|
560
|
+
ary = []
|
561
|
+
|
562
|
+
case position
|
563
|
+
|
564
|
+
when /^(join|order|group)\((.*)\)$/ # (F) join()
|
565
|
+
if $1 != "join" then
|
566
|
+
@operator = $1.intern
|
567
|
+
end
|
568
|
+
position = $2
|
569
|
+
|
570
|
+
join_list = [] # sub positions to join
|
571
|
+
bracket = [] # position with bracket
|
572
|
+
s_count = 0 # stack counter
|
573
|
+
|
574
|
+
position.split(',').each do |sub_pos|
|
575
|
+
case sub_pos
|
576
|
+
when /\(.*\)/
|
577
|
+
join_list << sub_pos
|
578
|
+
when /\(/
|
579
|
+
s_count += 1
|
580
|
+
bracket << sub_pos
|
581
|
+
when /\)/
|
582
|
+
s_count -= 1
|
583
|
+
bracket << sub_pos
|
584
|
+
if s_count == 0
|
585
|
+
join_list << bracket.join(',')
|
586
|
+
end
|
587
|
+
else
|
588
|
+
if s_count == 0
|
589
|
+
join_list << sub_pos
|
590
|
+
else
|
591
|
+
bracket << sub_pos
|
592
|
+
end
|
593
|
+
end
|
594
|
+
end
|
595
|
+
|
596
|
+
join_list.each do |position|
|
597
|
+
ary << gbl_pos2loc(position)
|
598
|
+
end
|
599
|
+
|
600
|
+
when /^complement\((.*)\)$/ # (J) complement()
|
601
|
+
position = $1
|
602
|
+
gbl_pos2loc(position).reverse_each do |location|
|
603
|
+
ary << location.complement
|
604
|
+
end
|
605
|
+
|
606
|
+
when /^replace\(([^,]+),"?([^"]*)"?\)/ # (K) replace()
|
607
|
+
position = $1
|
608
|
+
sequence = $2
|
609
|
+
ary << gbl_pos2loc(position).first.replace(sequence)
|
610
|
+
|
611
|
+
else # (A, B, C, G, H, I)
|
612
|
+
ary << Location.new(position)
|
613
|
+
|
614
|
+
end
|
615
|
+
|
616
|
+
return ary.flatten
|
617
|
+
end
|
618
|
+
|
619
|
+
|
620
|
+
# Convert the relative position to the absolute position
|
621
|
+
def rel2abs(n)
|
622
|
+
return nil unless n > 0 # out of range
|
623
|
+
|
624
|
+
cursor = 0
|
625
|
+
@locations.each do |x|
|
626
|
+
if x.sequence
|
627
|
+
len = x.sequence.size
|
628
|
+
else
|
629
|
+
len = x.to - x.from + 1
|
630
|
+
end
|
631
|
+
if n > cursor + len
|
632
|
+
cursor += len
|
633
|
+
else
|
634
|
+
if x.strand < 0
|
635
|
+
return x.to - (n - cursor - 1)
|
636
|
+
else
|
637
|
+
return x.from + (n - cursor - 1)
|
638
|
+
end
|
639
|
+
end
|
640
|
+
end
|
641
|
+
return nil # out of range
|
642
|
+
end
|
643
|
+
|
644
|
+
# Convert the absolute position to the relative position
|
645
|
+
def abs2rel(n)
|
646
|
+
return nil unless n > 0 # out of range
|
647
|
+
|
648
|
+
cursor = 0
|
649
|
+
@locations.each do |x|
|
650
|
+
if x.sequence
|
651
|
+
len = x.sequence.size
|
652
|
+
else
|
653
|
+
len = x.to - x.from + 1
|
654
|
+
end
|
655
|
+
if n < x.from or n > x.to then
|
656
|
+
cursor += len
|
657
|
+
else
|
658
|
+
if x.strand < 0 then
|
659
|
+
return x.to - (n - cursor - 1)
|
660
|
+
else
|
661
|
+
return n + cursor + 1 - x.from
|
662
|
+
end
|
663
|
+
end
|
664
|
+
end
|
665
|
+
return nil # out of range
|
666
|
+
end
|
667
|
+
|
668
|
+
end # Locations
|
669
|
+
|
670
|
+
end # Bio
|
671
|
+
|
672
|
+
|
673
|
+
|
674
|
+
# === GenBank location examples
|
675
|
+
#
|
676
|
+
# (C) n^m
|
677
|
+
#
|
678
|
+
# * [AB015179] 754^755
|
679
|
+
# * [AF179299] complement(53^54)
|
680
|
+
# * [CELXOL1ES] replace(4480^4481,"")
|
681
|
+
# * [ECOUW87] replace(4792^4793,"a")
|
682
|
+
# * [APLPCII] replace(1905^1906,"acaaagacaccgccctacgcc")
|
683
|
+
#
|
684
|
+
# (D) (n.m)
|
685
|
+
#
|
686
|
+
# * [HACSODA] 157..(800.806)
|
687
|
+
# * [HALSODB] (67.68)..(699.703)
|
688
|
+
# * [AP001918] (45934.45974)..46135
|
689
|
+
# * [BACSPOJ] <180..(731.761)
|
690
|
+
# * [BBU17998] (88.89)..>1122
|
691
|
+
# * [ECHTGA] complement((1700.1708)..(1715.1721))
|
692
|
+
# * [ECPAP17] complement(<22..(255.275))
|
693
|
+
# * [LPATOVGNS] complement((64.74)..1525)
|
694
|
+
# * [PIP404CG] join((8298.8300)..10206,1..855)
|
695
|
+
# * [BOVMHDQBY4] join(M30006.1:(392.467)..575,M30005.1:415..681,M30004.1:129..410,M30004.1:907..1017,521..534)
|
696
|
+
# * [HUMMIC2A] replace((651.655)..(651.655),"")
|
697
|
+
# * [HUMSOD102] order(L44135.1:(454.445)..>538,<1..181)
|
698
|
+
#
|
699
|
+
# (E) one-of
|
700
|
+
#
|
701
|
+
# * [ECU17136] one-of(898,900)..983
|
702
|
+
# * [CELCYT1A] one-of(5971..6308,5971..6309)
|
703
|
+
# * [DMU17742] 8050..one-of(10731,10758,10905,11242)
|
704
|
+
# * [PFU27807] one-of(623,627,632)..one-of(628,633,637)
|
705
|
+
# * [BTBAINH1] one-of(845,953,963,1078,1104)..1354
|
706
|
+
# * [ATU39449] join(one-of(969..1094,970..1094,995..1094,1018..1094),1518..1587,1726..2119,2220..2833,2945..3215)
|
707
|
+
#
|
708
|
+
# (F) join, order, group
|
709
|
+
#
|
710
|
+
# * [AB037374S2] join(AB037374.1:1..177,1..807)
|
711
|
+
# * [AP000001] join(complement(1..61),complement(AP000007.1:252907..253505))
|
712
|
+
# * [ASNOS11] join(AF130124.1:<2563..2964,AF130125.1:21..157,AF130126.1:12..174,AF130127.1:21..112,AF130128.1:21..162,AF130128.1:281..595,AF130128.1:661..842,AF130128.1:916..1030,AF130129.1:21..115,AF130130.1:21..165,AF130131.1:21..125,AF130132.1:21..428,AF130132.1:492..746,AF130133.1:21..168,AF130133.1:232..401,AF130133.1:475..906,AF130133.1:970..1107,AF130133.1:1176..1367,21..>128)
|
713
|
+
#
|
714
|
+
# * [AARPOB2] order(AF194507.1:<1..510,1..>871)
|
715
|
+
# * [AF006691] order(912..1918,20410..21416)
|
716
|
+
# * [AF024666] order(complement(18919..19224),complement(13965..14892))
|
717
|
+
# * [AF264948] order(27066..27076,27089..27099,27283..27314,27330..27352)
|
718
|
+
# * [D63363] order(3..26,complement(964..987))
|
719
|
+
# * [ECOCURLI2] order(complement(1009..>1260),complement(AF081827.1:<1..177))
|
720
|
+
# * [S72388S2] order(join(S72388.1:757..911,S72388.1:609..1542),1..>139)
|
721
|
+
# * [HEYRRE07] order(complement(1..38),complement(M82666.1:1..140),complement(M82665.1:1..176),complement(M82664.1:1..215),complement(M82663.1:1..185),complement(M82662.1:1..49),complement(M82661.1:1..133))
|
722
|
+
# * [COL11A1G34] order(AF101079.1:558..1307,AF101080.1:1..749,AF101081.1:1..898,AF101082.1:1..486,AF101083.1:1..942,AF101084.1:1..1734,AF101085.1:1..2385,AF101086.1:1..1813,AF101087.1:1..2287,AF101088.1:1..1073,AF101089.1:1..989,AF101090.1:1..5017,AF101091.1:1..3401,AF101092.1:1..1225,AF101093.1:1..1072,AF101094.1:1..989,AF101095.1:1..1669,AF101096.1:1..918,AF101097.1:1..1114,AF101098.1:1..1074,AF101099.1:1..1709,AF101100.1:1..986,AF101101.1:1..1934,AF101102.1:1..1699,AF101103.1:1..940,AF101104.1:1..2330,AF101105.1:1..4467,AF101106.1:1..1876,AF101107.1:1..2465,AF101108.1:1..1150,AF101109.1:1..1170,AF101110.1:1..1158,AF101111.1:1..1193,1..611)
|
723
|
+
#
|
724
|
+
# group() are found in the COMMENT field only (in GenBank 122.0)
|
725
|
+
#
|
726
|
+
# gbpat2.seq: FT repeat_region group(598..606,611..619)
|
727
|
+
# gbpat2.seq: FT repeat_region group(8..16,1457..1464).
|
728
|
+
# gbpat2.seq: FT variation group(t1,t2)
|
729
|
+
# gbpat2.seq: FT variation group(t1,t3)
|
730
|
+
# gbpat2.seq: FT variation group(t1,t2,t3)
|
731
|
+
# gbpat2.seq: FT repeat_region group(11..202,203..394)
|
732
|
+
# gbpri9.seq:COMMENT Residues reported = 'group(1..2145);'.
|
733
|
+
#
|
734
|
+
# (G) ID:location
|
735
|
+
#
|
736
|
+
# * [AARPOB2] order(AF194507.1:<1..510,1..>871)
|
737
|
+
# * [AF178221S4] join(AF178221.1:<1..60,AF178222.1:1..63,AF178223.1:1..42,1..>90)
|
738
|
+
# * [BOVMHDQBY4] join(M30006.1:(392.467)..575,M30005.1:415..681,M30004.1:129..410,M30004.1:907..1017,521..534)
|
739
|
+
# * [HUMSOD102] order(L44135.1:(454.445)..>538,<1..181)
|
740
|
+
# * [SL16SRRN1] order(<1..>267,X67092.1:<1..>249,X67093.1:<1..>233)
|
741
|
+
#
|
742
|
+
# (I) <, >
|
743
|
+
#
|
744
|
+
# * [A5U48871] <1..>318
|
745
|
+
# * [AA23SRRNP] <1..388
|
746
|
+
# * [AA23SRRNP] 503..>1010
|
747
|
+
# * [AAM5961] complement(<1..229)
|
748
|
+
# * [AAM5961] complement(5231..>5598)
|
749
|
+
# * [AF043934] join(<1,60..99,161..241,302..370,436..594,676..887,993..1141,1209..1329,1387..1559,1626..1646,1708..>1843)
|
750
|
+
# * [BACSPOJ] <180..(731.761)
|
751
|
+
# * [BBU17998] (88.89)..>1122
|
752
|
+
# * [AARPOB2] order(AF194507.1:<1..510,1..>871)
|
753
|
+
# * [SL16SRRN1] order(<1..>267,X67092.1:<1..>249,X67093.1:<1..>233)
|
754
|
+
#
|
755
|
+
# (J) complement
|
756
|
+
#
|
757
|
+
# * [AF179299] complement(53^54) <= hoge insertion site etc.
|
758
|
+
# * [AP000001] join(complement(1..61),complement(AP000007.1:252907..253505))
|
759
|
+
# * [AF209868S2] order(complement(1..>308),complement(AF209868.1:75..336))
|
760
|
+
# * [AP000001] join(complement(1..61),complement(AP000007.1:252907..253505))
|
761
|
+
# * [CPPLCG] complement(<1..(1093.1098))
|
762
|
+
# * [D63363] order(3..26,complement(964..987))
|
763
|
+
# * [ECHTGA] complement((1700.1708)..(1715.1721))
|
764
|
+
# * [ECOUXW] order(complement(1658..1663),complement(1636..1641))
|
765
|
+
# * [LPATOVGNS] complement((64.74)..1525)
|
766
|
+
# * [AF129075] complement(join(71606..71829,75327..75446,76039..76203,76282..76353,76914..77029,77114..77201,77276..77342,78138..78316,79755..79892,81501..81562,81676..81856,82341..82490,84208..84287,85032..85122,88316..88403))
|
767
|
+
# * [ZFDYST2] join(AF137145.1:<1..18,complement(<1..99))
|
768
|
+
#
|
769
|
+
# (K) replace
|
770
|
+
#
|
771
|
+
# * [CSU27710] replace(64,"A")
|
772
|
+
# * [CELXOL1ES] replace(5256,"t")
|
773
|
+
# * [ANICPC] replace(1..468,"")
|
774
|
+
# * [CSU27710] replace(67..68,"GC")
|
775
|
+
# * [CELXOL1ES] replace(4480^4481,"") <= ? only one case in GenBank 122.0
|
776
|
+
# * [ECOUW87] replace(4792^4793,"a")
|
777
|
+
# * [CEU34893] replace(1..22,"ggttttaacccagttactcaag")
|
778
|
+
# * [APLPCII] replace(1905^1906,"acaaagacaccgccctacgcc")
|
779
|
+
# * [MBDR3S1] replace(1400..>9281,"")
|
780
|
+
# * [HUMMHDPB1F] replace(complement(36..37),"ttc")
|
781
|
+
# * [HUMMIC2A] replace((651.655)..(651.655),"")
|
782
|
+
# * [LEIMDRPGP] replace(1..1554,"L01572")
|
783
|
+
# * [TRBND3] replace(376..395,"atttgtgtgtggtaatta")
|
784
|
+
# * [TRBND3] replace(376..395,"atttgtgtgggtaatttta")
|
785
|
+
# * [TRBND3] replace(376..395,"attttgttgttgttttgttttgaatta")
|
786
|
+
# * [TRBND3] replace(376..395,"atgtgtggtgaatta")
|
787
|
+
# * [TRBND3] replace(376..395,"atgtgtgtggtaatta")
|
788
|
+
# * [TRBND3] replace(376..395,"gatttgttgtggtaatttta")
|
789
|
+
# * [MSU09460] replace(193, <= replace(193, "t")
|
790
|
+
# * [HUMMAGE12X] replace(3002..3003, <= replace(3002..3003, "GC")
|
791
|
+
# * [ADR40FIB] replace(510..520, <= replace(510..520, "taatcctaccg")
|
792
|
+
# * [RATDYIIAAB] replace(1306..1443,"aagaacatccacggagtcagaactgggctcttcacgccggatttggcgttcgaggccattgtgaaaaagcaggcaatgcaccagcaagctcagttcctacccctgcgtggacctggttatccaggagctaatcagtacagttaggtggtcaagctgaaagagccctgtctgaaa")
|
793
|
+
#
|
794
|
+
|
795
|
+
if __FILE__ == $0
|
796
|
+
puts "Test new & span methods"
|
797
|
+
[
|
798
|
+
'450',
|
799
|
+
'500..600',
|
800
|
+
'join(500..550, 600..625)',
|
801
|
+
'complement(join(500..550, 600..625))',
|
802
|
+
'join(complement(500..550), 600..625)',
|
803
|
+
'754^755',
|
804
|
+
'complement(53^54)',
|
805
|
+
'replace(4792^4793,"a")',
|
806
|
+
'replace(1905^1906,"acaaagacaccgccctacgcc")',
|
807
|
+
'157..(800.806)',
|
808
|
+
'(67.68)..(699.703)',
|
809
|
+
'(45934.45974)..46135',
|
810
|
+
'<180..(731.761)',
|
811
|
+
'(88.89)..>1122',
|
812
|
+
'complement((1700.1708)..(1715.1721))',
|
813
|
+
'complement(<22..(255.275))',
|
814
|
+
'complement((64.74)..1525)',
|
815
|
+
'join((8298.8300)..10206,1..855)',
|
816
|
+
'replace((651.655)..(651.655),"")',
|
817
|
+
'one-of(898,900)..983',
|
818
|
+
'one-of(5971..6308,5971..6309)',
|
819
|
+
'8050..one-of(10731,10758,10905,11242)',
|
820
|
+
'one-of(623,627,632)..one-of(628,633,637)',
|
821
|
+
'one-of(845,953,963,1078,1104)..1354',
|
822
|
+
'join(2035..2050,complement(1775..1818),13..345,414..992,1232..1253,1024..1157)',
|
823
|
+
'join(complement(1..61),complement(AP000007.1:252907..253505))',
|
824
|
+
'complement(join(71606..71829,75327..75446,76039..76203))',
|
825
|
+
'order(3..26,complement(964..987))',
|
826
|
+
'order(L44135.1:(454.445)..>538,<1..181)',
|
827
|
+
'<200001..<318389',
|
828
|
+
].each do |pos|
|
829
|
+
p pos
|
830
|
+
# p Bio::Locations.new(pos)
|
831
|
+
# p Bio::Locations.new(pos).span
|
832
|
+
# p Bio::Locations.new(pos).range
|
833
|
+
Bio::Locations.new(pos).each do |location|
|
834
|
+
puts "class=" + location.class.to_s
|
835
|
+
puts "start=" + location.from.to_s + "\tend=" + location.to.to_s + "\tstrand=" + location.strand.to_s
|
836
|
+
end
|
837
|
+
|
838
|
+
end
|
839
|
+
|
840
|
+
puts "Test rel2abs/abs2rel method"
|
841
|
+
[
|
842
|
+
'6..15',
|
843
|
+
'join(6..10,16..30)',
|
844
|
+
'complement(join(6..10,16..30))',
|
845
|
+
'join(complement(6..10),complement(16..30))',
|
846
|
+
'join(6..10,complement(16..30))',
|
847
|
+
].each do |pos|
|
848
|
+
loc = Bio::Locations.new(pos)
|
849
|
+
p pos
|
850
|
+
# p loc
|
851
|
+
(1..21).each do |x|
|
852
|
+
print "absolute(#{x}) #=> ", y = loc.absolute(x), "\n"
|
853
|
+
print "relative(#{y}) #=> ", y ? loc.relative(y) : y, "\n"
|
854
|
+
print "absolute(#{x}, :aa) #=> ", y = loc.absolute(x, :aa), "\n"
|
855
|
+
print "relative(#{y}, :aa) #=> ", y ? loc.relative(y, :aa) : y, "\n"
|
856
|
+
end
|
857
|
+
end
|
858
|
+
|
859
|
+
pos = 'join(complement(6..10),complement(16..30))'
|
860
|
+
loc = Bio::Locations.new(pos)
|
861
|
+
print "pos : "; p pos
|
862
|
+
print "`- loc[1] : "; p loc[1]
|
863
|
+
print " `- range : "; p loc[1].range
|
864
|
+
|
865
|
+
puts Bio::Location.new('5').<=>(Bio::Location.new('3'))
|
866
|
+
end
|
867
|
+
|