From k at pub.open-bio.org Wed Sep 7 21:15:54 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 21:58:09 2005 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.44,1.45 Message-ID: <200509080115.j881FsdZ008944@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv8937/lib Modified Files: bio.rb Log Message: * require -> autoload (lost compatibility with Ruby 1.6 but runs at least 3 times faster by Ruby 1.8) Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** bio.rb 10 Aug 2005 12:56:37 -0000 1.44 --- bio.rb 8 Sep 2005 01:15:52 -0000 1.45 *************** *** 22,156 **** module Bio - BIORUBY_VERSION = [0, 6, 4].extend(Comparable) - end ! ### Basic data type modules ! ## Sequence ! require 'bio/sequence' ! ## Locations/Location ! require 'bio/location' ! ## Features/Feature ! require 'bio/feature' ! ## References/Reference ! require 'bio/reference' ! ## Pathway/Relation ! require 'bio/pathway' ! ## Alignment ! require 'bio/alignment' ! ### Constants ! require 'bio/data/na' ! require 'bio/data/aa' ! require 'bio/data/codontable' ! ### DB parsers ! require 'bio/db' ! ## GenBank/RefSeq/DDBJ ! require 'bio/db/genbank' ! ## EMBL/TrEMBL/Swiss-Prot/SPTR ! require 'bio/db/embl' ! ## KEGG ! require 'bio/db/kegg/genome' ! require 'bio/db/kegg/genes' ! require 'bio/db/kegg/enzyme' ! require 'bio/db/kegg/compound' ! require 'bio/db/kegg/glycan' ! require 'bio/db/kegg/reaction' ! require 'bio/db/kegg/brite' ! require 'bio/db/kegg/cell' ! require 'bio/db/kegg/microarray' ! require 'bio/db/kegg/keggtab' ! require 'bio/db/kegg/ko' - ## other formats ! require 'bio/db/fasta' ! require 'bio/db/gff' ! require 'bio/db/aaindex' ! require 'bio/db/transfac' ! require 'bio/db/prosite' ! require 'bio/db/litdb' ! require 'bio/db/medline' ! require 'bio/db/fantom' ! require 'bio/db/go' ! require 'bio/db/pdb' ! require 'bio/db/nbrf' ! ### IO interface modules ! require 'bio/io/registry' ! require 'bio/io/flatfile' ! require 'bio/io/flatfile/indexer' ! require 'bio/io/flatfile/index' ! require 'bio/io/flatfile/bdb' ! require 'bio/io/fastacmd' ! require 'bio/io/fetch' ! require 'bio/io/sql' - require 'bio/io/dbget' - require 'bio/io/keggapi' - require 'bio/io/pubmed' - require 'bio/io/das' - require 'bio/io/ddbjxml' - require 'bio/io/higet' - #require 'bio/io/esoap' - #require 'bio/io/brdb' ! ### Applications ! require 'bio/appl/fasta' ! require 'bio/appl/fasta/format10' ! require 'bio/appl/blast' ! require 'bio/appl/blast/report' ! require 'bio/appl/blast/format0' ! require 'bio/appl/blast/wublast' ! require 'bio/appl/blast/rexml' ! require 'bio/appl/blast/xmlparser' ! require 'bio/appl/blast/format8' ! require 'bio/appl/bl2seq/report' ! require 'bio/appl/hmmer' ! require 'bio/appl/hmmer/report' ! require 'bio/appl/emboss' ! require 'bio/appl/psort' ! require 'bio/appl/tmhmm/report' ! require 'bio/appl/targetp/report' ! require 'bio/appl/sosui/report' ! require 'bio/appl/genscan/report' ! require 'bio/appl/clustalw' ! require 'bio/appl/clustalw/report' ! require 'bio/appl/mafft' ! require 'bio/appl/mafft/report' ! require 'bio/appl/sim4' ! require 'bio/appl/sim4/report' ! require 'bio/appl/spidey/report' ! require 'bio/appl/blat/report' ! ### Utilities ! require 'bio/util/sirna' --- 22,234 ---- module Bio + BIORUBY_VERSION = [0, 7, 0].extend(Comparable) ! ### Basic data types ! ## Sequence ! autoload :Seq, 'bio/sequence' ! autoload :Sequence, 'bio/sequence' ! ## Locations/Location ! autoload :Location, 'bio/location' ! autoload :Locations, 'bio/location' ! ## Features/Feature ! autoload :Feature, 'bio/feature' ! autoload :Features, 'bio/feature' # to_gff ! ## References/Reference ! autoload :Reference, 'bio/reference' ! autoload :References, 'bio/reference' ! ## Pathway/Relation ! autoload :Pathway, 'bio/pathway' ! autoload :Relation, 'bio/pathway' ! ## Alignment ! autoload :Alignment, 'bio/alignment' ! ### Constants ! autoload :NucleicAcid, 'bio/data/na' ! autoload :AminoAcid, 'bio/data/aa' ! autoload :CodonTable, 'bio/data/codontable' ! ### DB parsers ! autoload :DB, 'bio/db' ! autoload :NCBIDB, 'bio/db' ! autoload :KEGGDB, 'bio/db' ! autoload :EMBLDB, 'bio/db' ! ## GenBank/RefSeq/DDBJ ! # module Bio ! # autoload :NCBIDB, 'bio/db' ! # class GenBank < NCBIDB ! # autoload :Common, 'bio/db/genbank/common' ! # include Bio::GenBank::Common ! # module Bio ! # autoload :NCBIDB, 'bio/db' ! # end ! # class Bio::GenBank < Bio::NCBIDB ! # autoload :Common, 'bio/db/genbank/common' ! # include Bio::GenBank::Common ! autoload :GenBank, 'bio/db/genbank/genbank' ! autoload :GenPept, 'bio/db/genbank/genpept' ! autoload :RefSeq, 'bio/db/genbank/refseq' ! autoload :DDBJ, 'bio/db/genbank/ddbj' ! ## EMBL/TrEMBL/Swiss-Prot/SPTR ! autoload :EMBL, 'bio/db/embl/embl' ! autoload :SPTR, 'bio/db/embl/sptr' ! autoload :TrEMBL, 'bio/db/embl/trembl' ! autoload :UniProt, 'bio/db/embl/uniprot' ! autoload :SwissProt, 'bio/db/embl/swissprot' ! ## KEGG + class KEGG + autoload :GENOME, 'bio/db/kegg/genome' + autoload :GENES, 'bio/db/kegg/genes' + autoload :ENZYME, 'bio/db/kegg/enzyme' + autoload :COMPOUND, 'bio/db/kegg/compound' + autoload :GLYCAN, 'bio/db/kegg/glycan' + autoload :REACTION, 'bio/db/kegg/reaction' + autoload :BRITE, 'bio/db/kegg/brite' + autoload :CELL, 'bio/db/kegg/cell' + autoload :Microarray, 'bio/db/kegg/microarray' + autoload :Microarrays, 'bio/db/kegg/microarray' + autoload :Keggtab, 'bio/db/kegg/keggtab' + autoload :KO, 'bio/db/kegg/ko' + end ! ## other formats ! autoload :FastaFormat, 'bio/db/fasta' ! autoload :FastaNumericFormat, 'bio/db/fasta' # change to FastaFormat::Numeric ? ! autoload :FastaDefline, 'bio/db/fasta' # change to FastaFormat::Defline ! autoload :GFF, 'bio/db/gff' ! autoload :GFF2, 'bio/db/gff' # change to GFF::GFF2, improve ! autoload :GFF3, 'bio/db/gff' # change to GFF::GFF3, improve ! autoload :AAindex, 'bio/db/aaindex' ! autoload :TRANSFAC, 'bio/db/transfac' ! autoload :TFMATRIX, 'bio/db/transfac' # change to TRANSFAC::MATRIX ! autoload :TFSITE, 'bio/db/transfac' # change to TRANSFAC::SITE ! autoload :TFFACTOR, 'bio/db/transfac' # change to TRANSFAC::FACTOR ! autoload :TFCELL, 'bio/db/transfac' # change to TRANSFAC::CELL ! autoload :TFCLASS, 'bio/db/transfac' # change to TRANSFAC::CLASS ! autoload :TFGENE, 'bio/db/transfac' # change to TRANSFAC::GENE ! autoload :PROSITE, 'bio/db/prosite' ! autoload :LITDB, 'bio/db/litdb' ! autoload :MEDLINE, 'bio/db/medline' ! autoload :FANTOM, 'bio/db/fantom' ! autoload :GO, 'bio/db/go' ! autoload :PDB, 'bio/db/pdb' ! autoload :NBRF, 'bio/db/nbrf' + ### IO interface modules ! autoload :Registry, 'bio/io/registry' ! autoload :Fetch, 'bio/io/fetch' ! autoload :SQL, 'bio/io/sql' ! autoload :FlatFile, 'bio/io/flatfile' ! autoload :FlatFileIndex, 'bio/io/flatfile/index' # chage to FlatFile::Index ? ! class FlatFileIndex ! autoload :Indexer, 'bio/io/flatfile/indexer' # require 'flatfile/index' ! autoload :BDBdefault, 'bio/io/flatfile/bdb' # require 'flatfile/index' ! end ! autoload :PubMed, 'bio/io/pubmed' ! autoload :DAS, 'bio/io/das' ! autoload :DBGET, 'bio/io/dbget' ! class Blast ! autoload :Fastacmd, 'bio/io/fastacmd' ! end ! class KEGG ! autoload :API, 'bio/io/keggapi' ! end + class DDBJ + autoload :XML, 'bio/io/ddbjxml' + end + + class HGC + autoload :HiGet, 'bio/io/higet' + end + + # autoload :ESOAP, 'bio/io/esoap' # NCBI::ESOAP ? + # autoload :BRDB, 'bio/io/brdb' # remove + + + ### Applications + + autoload :Fasta, 'bio/appl/fasta' + autoload :Report, 'bio/appl/fasta/format10' # improve format6 + + autoload :Blast, 'bio/appl/blast' + class Blast + autoload :Report, 'bio/appl/blast/report' + autoload :Default, 'bio/appl/blast/format0' + autoload :WU, 'bio/appl/blast/wublast' + autoload :Bl2seq, 'bio/appl/bl2seq/report' + end + + autoload :HMMER, 'bio/appl/hmmer' + class HMMER + autoload :Report, 'bio/appl/hmmer/report' + end + + # autoload :EMBOSS, 'bio/appl/emboss' # use bio/command, improve + + autoload :PSORT, 'bio/appl/psort' + class PSORT + autoload :PSORT1, 'bio/appl/psort' + autoload :PSORT2, 'bio/appl/psort' + end + + autoload :TMHMM, 'bio/appl/tmhmm/report' + autoload :TargetP, 'bio/appl/targetp/report' + autoload :SOSUI, 'bio/appl/sosui/report' + autoload :Genscan, 'bio/appl/genscan/report' + + autoload :ClustalW, 'bio/appl/clustalw' + class ClustalW + autoload :Report, 'bio/appl/clustalw/report' + end + + autoload :MAFFT, 'bio/appl/mafft' + class MAFFT + autoload :Report, 'bio/appl/mafft/report' + end + + autoload :Sim4, 'bio/appl/sim4' + class Sim4 + autoload :Report, 'bio/appl/sim4/report' + end + + autoload :Spidey, 'bio/appl/spidey/report' + autoload :Blat, 'bio/appl/blat/report' + + + ### Utilities + + autoload :SiRNA, 'bio/util/sirna' + + end From k at pub.open-bio.org Wed Sep 7 21:16:54 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 21:58:55 2005 Subject: [BioRuby-cvs] bioruby gemspec.rb,1.3,1.4 Message-ID: <200509080116.j881GsdZ008971@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv8967 Modified Files: gemspec.rb Log Message: * prepared for 0.7.0 * module name is changed from 'bioruby' to 'bio' Index: gemspec.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/gemspec.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gemspec.rb 10 Aug 2005 12:57:01 -0000 1.3 --- gemspec.rb 8 Sep 2005 01:16:52 -0000 1.4 *************** *** 3,8 **** spec = Gem::Specification.new do |s| ! s.name = 'bioruby' ! s.version = "0.6.4" s.author = "BioRuby project" s.email = "staff@bioruby.org" --- 3,8 ---- spec = Gem::Specification.new do |s| ! s.name = 'bio' ! s.version = "0.7.0" s.author = "BioRuby project" s.email = "staff@bioruby.org" From k at pub.open-bio.org Wed Sep 7 21:22:13 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:11:52 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/targetp report.rb,1.3,1.4 Message-ID: <200509080122.j881MDdZ009099@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/targetp In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/appl/targetp Modified Files: report.rb Log Message: * expanded tab at the line head Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/targetp/report.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** report.rb 26 Feb 2003 01:54:03 -0000 1.3 --- report.rb 8 Sep 2005 01:22:10 -0000 1.4 *************** *** 30,72 **** def initialize(str) ! @version = nil ! @query_sequences = nil ! @cleavage_site_prediction = nil ! @networks = nil ! @prediction = {} ! @cutoff = {} ! parse_entry(str) end attr_reader :version, :query_sequences, ! :cleavage_site_prediction, :networks, ! :prediction, :cutoff alias :pred :prediction def name ! @prediction['Name'] end alias :entry_id :name def query_len ! if @prediction['Len'] ! @prediction['Len'] ! else ! @prediction['Length'] ! end end alias :length :query_len def loc ! if @prediction['Loc'] ! @prediction['Loc'] # version 1.0 ! else ! @prediction['Loc.'] # version 1.1 ! end end def rc ! @prediction['RC'] end --- 30,72 ---- def initialize(str) ! @version = nil ! @query_sequences = nil ! @cleavage_site_prediction = nil ! @networks = nil ! @prediction = {} ! @cutoff = {} ! parse_entry(str) end attr_reader :version, :query_sequences, ! :cleavage_site_prediction, :networks, ! :prediction, :cutoff alias :pred :prediction def name ! @prediction['Name'] end alias :entry_id :name def query_len ! if @prediction['Len'] ! @prediction['Len'] ! else ! @prediction['Length'] ! end end alias :length :query_len def loc ! if @prediction['Loc'] ! @prediction['Loc'] # version 1.0 ! else ! @prediction['Loc.'] # version 1.1 ! end end def rc ! @prediction['RC'] end *************** *** 74,120 **** def parse_entry(str) ! labels = [] ! cutoff = [] ! values = [] ! str.split("\n").each {|line| ! case line ! when /targetp v(\d+.\d+)/,/T A R G E T P\s+(\d+.\d+)/ ! @version = $1 ! when /Number of (query|input) sequences:\s+(\d+)/ ! @query_sequences = $1.to_i ! when /Cleavage site predictions (\w.+)\./ ! @cleavage_site_prediction = $1 ! when /Using (\w+.+) networks/ ! @networks = $1 ! when /Name +Len/ ! labels = line.sub(/^\#\s*/,'').split(/\s+/) ! when /cutoff/ ! cutoff = line.split(/\s+/) ! cutoff.shift ! labels[2, 4].each_with_index {|loc, i| ! next if loc =~ /Loc/ ! @cutoff[loc] = cutoff[i].to_f ! } ! when /-----$/ ! when /^ +$/, '' ! else ! values = line.sub(/^\s*/,'').split(/\s+/) ! values.each_with_index {|val, i| ! label = labels[i] ! case label ! when 'RC', /Len/ ! val = val.to_i ! when 'SP','mTP','cTP','other' ! val = val.to_f ! end ! @prediction[label] = val ! } ! end ! } end --- 74,120 ---- def parse_entry(str) ! labels = [] ! cutoff = [] ! values = [] ! str.split("\n").each {|line| ! case line ! when /targetp v(\d+.\d+)/,/T A R G E T P\s+(\d+.\d+)/ ! @version = $1 ! when /Number of (query|input) sequences:\s+(\d+)/ ! @query_sequences = $1.to_i ! when /Cleavage site predictions (\w.+)\./ ! @cleavage_site_prediction = $1 ! when /Using (\w+.+) networks/ ! @networks = $1 ! when /Name +Len/ ! labels = line.sub(/^\#\s*/,'').split(/\s+/) ! when /cutoff/ ! cutoff = line.split(/\s+/) ! cutoff.shift ! labels[2, 4].each_with_index {|loc, i| ! next if loc =~ /Loc/ ! @cutoff[loc] = cutoff[i].to_f ! } ! when /-----$/ ! when /^ +$/, '' ! else ! values = line.sub(/^\s*/,'').split(/\s+/) ! values.each_with_index {|val, i| ! label = labels[i] ! case label ! when 'RC', /Len/ ! val = val.to_i ! when 'SP','mTP','cTP','other' ! val = val.to_f ! end ! @prediction[label] = val ! } ! end ! } end From k at pub.open-bio.org Wed Sep 7 21:22:14 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:12:04 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/util sirna.rb,1.3,1.4 Message-ID: <200509080122.j881MEdZ009144@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/util Modified Files: sirna.rb Log Message: * expanded tab at the line head Index: sirna.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/sirna.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sirna.rb 9 Aug 2005 05:40:44 -0000 1.3 --- sirna.rb 8 Sep 2005 01:22:12 -0000 1.4 *************** *** 75,82 **** target_stop = target_start + @target_size ! antisense_gc_percent = antisense.gc_percent ! next if antisense_gc_percent > @max_gc_percent ! next if antisense_gc_percent < @min_gc_percent ! case rule when 'uitei' --- 75,82 ---- target_stop = target_start + @target_size ! antisense_gc_percent = antisense.gc_percent ! next if antisense_gc_percent > @max_gc_percent ! next if antisense_gc_percent < @min_gc_percent ! case rule when 'uitei' *************** *** 86,93 **** else raise NotImplementedError ! end pair = Bio::SiRNA::Pair.new(target, sense, antisense, target_start, target_stop, rule, antisense_gc_percent) ! @pairs.push(pair) end return @pairs --- 86,93 ---- else raise NotImplementedError ! end pair = Bio::SiRNA::Pair.new(target, sense, antisense, target_start, target_stop, rule, antisense_gc_percent) ! @pairs.push(pair) end return @pairs *************** *** 98,108 **** def initialize(target, sense, antisense, start, stop, rule, gc_percent) ! @target = target ! @sense = sense ! @antisense = antisense ! @start = start ! @stop = stop ! @rule = rule ! @gc_percent = gc_percent end attr_accessor :target, :sense, :antisense, :start, :stop, :rule, :gc_percent --- 98,108 ---- def initialize(target, sense, antisense, start, stop, rule, gc_percent) ! @target = target ! @sense = sense ! @antisense = antisense ! @start = start ! @stop = stop ! @rule = rule ! @gc_percent = gc_percent end attr_accessor :target, :sense, :antisense, :start, :stop, :rule, :gc_percent *************** *** 110,121 **** # human readable report def report ! report = "### siRNA\n" ! report << 'Start: ' + @start.to_s + "\n" ! report << 'Stop: ' + @stop.to_s + "\n" ! report << 'Rule: ' + @rule.to_s + "\n" ! report << 'GC %: ' + @gc_percent.to_s + "\n" ! report << 'Target: ' + @target.upcase + "\n" ! report << 'Sense: ' + ' ' + @sense.upcase + "\n" ! report << 'Antisense: ' + @antisense.reverse.upcase + "\n" end --- 110,121 ---- # human readable report def report ! report = "### siRNA\n" ! report << 'Start: ' + @start.to_s + "\n" ! report << 'Stop: ' + @stop.to_s + "\n" ! report << 'Rule: ' + @rule.to_s + "\n" ! report << 'GC %: ' + @gc_percent.to_s + "\n" ! report << 'Target: ' + @target.upcase + "\n" ! report << 'Sense: ' + ' ' + @sense.upcase + "\n" ! report << 'Antisense: ' + @antisense.reverse.upcase + "\n" end *************** *** 138,143 **** case method when 'BLOCK-iT' ! block_it ! else raise NotImplementedError end --- 138,143 ---- case method when 'BLOCK-iT' ! block_it ! else raise NotImplementedError end *************** *** 165,173 **** if /^G/i =~ fwd @top_strand = top + fwd + loop_fwd + rev ! @bottom_strand = bot + fwd + loop_rev + rev ! else @top_strand = top + 'G' + fwd + loop_fwd + rev ! @bottom_strand = bot + fwd + loop_rev + rev + 'C' ! end end --- 165,173 ---- if /^G/i =~ fwd @top_strand = top + fwd + loop_fwd + rev ! @bottom_strand = bot + fwd + loop_rev + rev ! else @top_strand = top + 'G' + fwd + loop_fwd + rev ! @bottom_strand = bot + fwd + loop_rev + rev + 'C' ! end end From k at pub.open-bio.org Wed Sep 7 21:22:14 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:12:12 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/io/flatfile bdb.rb, 1.5, 1.6 index.rb, 1.9, 1.10 indexer.rb, 1.17, 1.18 Message-ID: <200509080122.j881MEdZ009140@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io/flatfile In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/io/flatfile Modified Files: bdb.rb index.rb indexer.rb Log Message: * expanded tab at the line head Index: bdb.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile/bdb.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** bdb.rb 28 Feb 2003 10:29:40 -0000 1.5 --- bdb.rb 8 Sep 2005 01:22:12 -0000 1.6 *************** *** 31,50 **** module BDBdefault def permission ! (0666 & (0777 ^ File.umask)) end module_function :permission def flag_read ! BDB::RDONLY end module_function :flag_read def flag_write ! (BDB::CREATE | BDB::TRUNCATE) end module_function :flag_write def flag_append ! 'r+' end module_function :flag_append --- 31,50 ---- module BDBdefault def permission ! (0666 & (0777 ^ File.umask)) end module_function :permission def flag_read ! BDB::RDONLY end module_function :flag_read def flag_write ! (BDB::CREATE | BDB::TRUNCATE) end module_function :flag_write def flag_append ! 'r+' end module_function :flag_append *************** *** 53,112 **** class BDBwrapper def initialize(name, filename, *arg) ! @dbname = name ! @file = nil ! @filename = filename ! #self.open(*arg) end def filename ! File.join(@dbname, @filename) end def open(flag = BDBdefault.flag_read, ! permission = BDBdefault.permission) ! unless @file then ! DEBUG.print "BDBwrapper: open #{filename}\n" ! @file = BDB::Btree.open(filename, nil, flag, permission) ! end ! true end def close ! if @file ! DEBUG.print "BDBwrapper: close #{filename}\n" ! @file.close ! @file = nil ! end ! nil end def [](arg) ! #self.open ! if @file then ! @file[arg] ! else ! nil ! end end def []=(key, val) ! #self.open ! @file[key.to_s] = val.to_s end def writeback_array(prefix, array, *arg) ! self.close ! self.open(*arg) ! array.each_with_index do |val, key| ! @file["#{prefix}#{key}"] = val.to_s ! end end def keys ! if @file then ! @file.keys ! else ! [] ! end end end #class BDBwrapper --- 53,112 ---- class BDBwrapper def initialize(name, filename, *arg) ! @dbname = name ! @file = nil ! @filename = filename ! #self.open(*arg) end def filename ! File.join(@dbname, @filename) end def open(flag = BDBdefault.flag_read, ! permission = BDBdefault.permission) ! unless @file then ! DEBUG.print "BDBwrapper: open #{filename}\n" ! @file = BDB::Btree.open(filename, nil, flag, permission) ! end ! true end def close ! if @file ! DEBUG.print "BDBwrapper: close #{filename}\n" ! @file.close ! @file = nil ! end ! nil end def [](arg) ! #self.open ! if @file then ! @file[arg] ! else ! nil ! end end def []=(key, val) ! #self.open ! @file[key.to_s] = val.to_s end def writeback_array(prefix, array, *arg) ! self.close ! self.open(*arg) ! array.each_with_index do |val, key| ! @file["#{prefix}#{key}"] = val.to_s ! end end def keys ! if @file then ! @file.keys ! else ! [] ! end end end #class BDBwrapper *************** *** 114,254 **** module BDB_1 class BDBMappingFile ! def self.open(*arg) ! self.new(*arg) ! end ! def initialize(filename, flag = BDBdefault.flag_read, ! permission = BDBdefault.permission) ! @filename = filename ! @flag = flag ! @permission = permission ! #@bdb = BDB::Btree.open(@filename, nil, @flag, @permission) ! end ! attr_reader :filename ! attr_accessor :flag, :permission ! def open ! unless @bdb then ! DEBUG.print "BDBMappingFile: open #{@filename}\n" ! @bdb = BDB::Btree.open(@filename, nil, @flag, @permission) ! true ! else ! nil ! end ! end ! def close ! if @bdb then ! DEBUG.print "BDBMappingFile: close #{@filename}\n" ! @bdb.close @bdb = nil ! end ! nil ! end ! def records ! @bdb.size ! end ! alias :size :records ! # methods for writing ! def add(key, val) ! open ! val = val.to_a.join("\t") ! s = @bdb[key] ! if s then ! s << "\t" ! s << val ! val = s ! end ! @bdb[key] = val ! #DEBUG.print "add: key=#{key.inspect}, val=#{val.inspect}\n" ! val ! end ! def add_exclusive(key, val) ! open ! val = val.to_a.join("\t") ! s = @bdb[key] ! if s then ! raise RuntimeError, "keys must be unique, but key #{key.inspect} already exists" ! end ! @bdb[key] = val ! #DEBUG.print "add_exclusive: key=#{key.inspect}, val=#{val.inspect}\n" ! val ! end ! def add_overwrite(key, val) ! open ! val = val.to_a.join("\t") ! s = @bdb[key] ! if s then ! DEBUG.print "Warining: overwrote unique id #{key.inspect}\n" ! end ! @bdb[key] = val ! #DEBUG.print "add_overwrite: key=#{key.inspect}, val=#{val.inspect}\n" ! val ! end ! def add_nr(key, val) ! open ! s = @bdb[key] ! if s then ! a = s.split("\t") ! else ! a = [] ! end ! a.concat val.to_a ! a.sort! ! a.uniq! ! str = a.join("\t") ! @bdb[key] = str ! #DEBUG.print "add_nr: key=#{key.inspect}, val=#{str.inspect}\n" ! str ! end ! ! # methods for searching ! def search(key) ! open ! s = @bdb[key] ! if s then ! a = s.split("\t") ! a ! else ! [] ! end ! end end #class BDBMappingFile class PrimaryNameSpace < Template::NameSpace ! def mapping(filename) ! BDBMappingFile.new(filename) ! end ! def filename ! File.join(dbname, "key_#{name}") ! end ! def search(key) ! r = super(key) ! unless r.empty? then ! [ r ] ! else ! r ! end ! end end #class PrimaryNameSpace class SecondaryNameSpace < Template::NameSpace ! def mapping(filename) ! BDBMappingFile.new(filename) ! end ! def filename ! File.join(dbname, "id_#{name}") ! end #class SecondaryNameSpaces ! def search(key) ! r = super(key) ! file.close ! r ! end end #class SecondaryNameSpace end #module BDB_1 --- 114,254 ---- module BDB_1 class BDBMappingFile ! def self.open(*arg) ! self.new(*arg) ! end ! def initialize(filename, flag = BDBdefault.flag_read, ! permission = BDBdefault.permission) ! @filename = filename ! @flag = flag ! @permission = permission ! #@bdb = BDB::Btree.open(@filename, nil, @flag, @permission) ! end ! attr_reader :filename ! attr_accessor :flag, :permission ! def open ! unless @bdb then ! DEBUG.print "BDBMappingFile: open #{@filename}\n" ! @bdb = BDB::Btree.open(@filename, nil, @flag, @permission) ! true ! else ! nil ! end ! end ! def close ! if @bdb then ! DEBUG.print "BDBMappingFile: close #{@filename}\n" ! @bdb.close @bdb = nil ! end ! nil ! end ! def records ! @bdb.size ! end ! alias :size :records ! # methods for writing ! def add(key, val) ! open ! val = val.to_a.join("\t") ! s = @bdb[key] ! if s then ! s << "\t" ! s << val ! val = s ! end ! @bdb[key] = val ! #DEBUG.print "add: key=#{key.inspect}, val=#{val.inspect}\n" ! val ! end ! def add_exclusive(key, val) ! open ! val = val.to_a.join("\t") ! s = @bdb[key] ! if s then ! raise RuntimeError, "keys must be unique, but key #{key.inspect} already exists" ! end ! @bdb[key] = val ! #DEBUG.print "add_exclusive: key=#{key.inspect}, val=#{val.inspect}\n" ! val ! end ! def add_overwrite(key, val) ! open ! val = val.to_a.join("\t") ! s = @bdb[key] ! if s then ! DEBUG.print "Warining: overwrote unique id #{key.inspect}\n" ! end ! @bdb[key] = val ! #DEBUG.print "add_overwrite: key=#{key.inspect}, val=#{val.inspect}\n" ! val ! end ! def add_nr(key, val) ! open ! s = @bdb[key] ! if s then ! a = s.split("\t") ! else ! a = [] ! end ! a.concat val.to_a ! a.sort! ! a.uniq! ! str = a.join("\t") ! @bdb[key] = str ! #DEBUG.print "add_nr: key=#{key.inspect}, val=#{str.inspect}\n" ! str ! end ! ! # methods for searching ! def search(key) ! open ! s = @bdb[key] ! if s then ! a = s.split("\t") ! a ! else ! [] ! end ! end end #class BDBMappingFile class PrimaryNameSpace < Template::NameSpace ! def mapping(filename) ! BDBMappingFile.new(filename) ! end ! def filename ! File.join(dbname, "key_#{name}") ! end ! def search(key) ! r = super(key) ! unless r.empty? then ! [ r ] ! else ! r ! end ! end end #class PrimaryNameSpace class SecondaryNameSpace < Template::NameSpace ! def mapping(filename) ! BDBMappingFile.new(filename) ! end ! def filename ! File.join(dbname, "id_#{name}") ! end #class SecondaryNameSpaces ! def search(key) ! r = super(key) ! file.close ! r ! end end #class SecondaryNameSpace end #module BDB_1 Index: index.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile/index.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** index.rb 27 Aug 2003 17:25:21 -0000 1.9 --- index.rb 8 Sep 2005 01:22:12 -0000 1.10 *************** *** 50,56 **** def closed? if @db then ! false else ! true end end --- 50,56 ---- def closed? if @db then [...1963 lines suppressed...] ! else ! n2 = names ! p = nil ! end ! s = secondary.search_names(key, *n2) ! s.push p if p ! s.sort! ! s.uniq! ! s end def search_namespaces(key, *names) ! s = search_namespaces_get_unique_id(key, *names) ! search_primary(*s) end def check_consistency ! fileids.check_all end end #class DataBank Index: indexer.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile/indexer.rb,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** indexer.rb 27 Aug 2003 17:25:21 -0000 1.17 --- indexer.rb 8 Sep 2005 01:22:12 -0000 1.18 *************** *** 27,702 **** class NameSpace ! def initialize(name, method) ! @name = name ! @proc = method ! end ! attr_reader :name, :proc end #class NameSpace class NameSpaces < Hash [...1427 lines suppressed...] ! Indexer::makeindexFlat(dbname, parser, options, *files) end end #def makeindex *************** *** 752,758 **** def self.update_index(dbname, format, options, *files) if format then ! parser = Indexer::Parser.new(dbclass) else ! parser = nil end Indexer::update_index(dbname, parser, options, *files) --- 752,758 ---- def self.update_index(dbname, format, options, *files) if format then ! parser = Indexer::Parser.new(dbclass) else ! parser = nil end Indexer::update_index(dbname, parser, options, *files) From k at pub.open-bio.org Wed Sep 7 21:22:13 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:12:15 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/tmhmm report.rb,1.2,1.3 Message-ID: <200509080122.j881MDdZ009103@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/tmhmm In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/appl/tmhmm Modified Files: report.rb Log Message: * expanded tab at the line head Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/tmhmm/report.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** report.rb 25 Feb 2003 15:44:18 -0000 1.2 --- report.rb 8 Sep 2005 01:22:11 -0000 1.3 *************** *** 29,58 **** ent_state = '' data.each_line do |line| ! if /^\#/ =~ line ! if ent_state == 'next' ! ent_state = 'entry' ! elsif ent_state == 'tmh' ! ent_state = 'next' ! end ! else ! ent_state = 'tmh' ! end ! if ent_state != 'next' ! entry << line ! else ! if block_given? ! yield Bio::TMHMM::Report.new(entry) ! else ! Bio::TMHMM::Report.new(entry) ! end ! entry = [line] ! end end if block_given? ! yield Bio::TMHMM::Report.new(entry) else ! Bio::TMHMM::Report.new(entry) end end --- 29,58 ---- ent_state = '' data.each_line do |line| ! if /^\#/ =~ line ! if ent_state == 'next' ! ent_state = 'entry' ! elsif ent_state == 'tmh' ! ent_state = 'next' ! end ! else ! ent_state = 'tmh' ! end ! if ent_state != 'next' ! entry << line ! else ! if block_given? ! yield Bio::TMHMM::Report.new(entry) ! else ! Bio::TMHMM::Report.new(entry) ! end ! entry = [line] ! end end if block_given? ! yield Bio::TMHMM::Report.new(entry) else ! Bio::TMHMM::Report.new(entry) end end *************** *** 62,87 **** def initialize(entry = nil) ! parse_header(entry) ! @tmhs = parse_tmhs(entry) end attr_reader :tmhs, :entry_id, :query_len, :predicted_tmhs, ! :exp_aas_in_tmhs, :exp_first_60aa, :total_prob_of_N_in alias :length :query_len def helix ! @tmhs.map {|t| t if t.status == 'TMhelix' }.compact end def to_s ! [ ! [ ! ["Length:", @query_len], ! ["Number of predicted TMHs:", @predicted_tmhs], ! ["Exp number of AAs in THMs:", @exp_aas_in_tmhs], ! ["Exp number, first 60 AAs:", @exp_first_60aa], ! ["Total prob of N-in:", @total_prob_of_N_in] ! ].map {|e| "\# " + [@entry_id, e].flatten.join("\t") }, ! tmhs.map {|ent| ent.to_s } ! ].flatten.join("\n") end --- 62,87 ---- def initialize(entry = nil) ! parse_header(entry) ! @tmhs = parse_tmhs(entry) end attr_reader :tmhs, :entry_id, :query_len, :predicted_tmhs, ! :exp_aas_in_tmhs, :exp_first_60aa, :total_prob_of_N_in alias :length :query_len def helix ! @tmhs.map {|t| t if t.status == 'TMhelix' }.compact end def to_s ! [ ! [ ! ["Length:", @query_len], ! ["Number of predicted TMHs:", @predicted_tmhs], ! ["Exp number of AAs in THMs:", @exp_aas_in_tmhs], ! ["Exp number, first 60 AAs:", @exp_first_60aa], ! ["Total prob of N-in:", @total_prob_of_N_in] ! ].map {|e| "\# " + [@entry_id, e].flatten.join("\t") }, ! tmhs.map {|ent| ent.to_s } ! ].flatten.join("\n") end *************** *** 90,125 **** def parse_header(raw) ! raw.each do |line| ! next unless /^#/.match(line) ! case line ! when / (\S.+) Length: +(\d+)/ ! @entry_id = $1.strip ! @query_len = $2.to_i ! when /Number of predicted TMHs: +(\d+)/ ! @predicted_tmhs = $1.to_i ! when /Exp number of AAs in TMHs: +([\d\.]+)/ ! @exp_aas_in_tmhs = $1.to_f ! when /Exp number, first 60 AAs: +([\d\.]+)/ ! @exp_first_60aa = $1.to_f ! when /Total prob of N-in: +([\d\.]+)/ ! @total_prob_of_N_in = $1.to_f ! end ! end end def parse_tmhs(raw) ! tmhs = [] ! raw.each do |line| ! case line ! when /^[^\#]/ ! eid,version,status,r0,r1 = line.split(/\s+/) ! tmhs << Bio::TMHMM::TMH.new(eid.strip, ! version.strip, ! status.strip, ! Range.new(r0.to_i, r1.to_i)) ! end ! end ! tmhs end --- 90,125 ---- def parse_header(raw) ! raw.each do |line| ! next unless /^#/.match(line) ! case line ! when / (\S.+) Length: +(\d+)/ ! @entry_id = $1.strip ! @query_len = $2.to_i ! when /Number of predicted TMHs: +(\d+)/ ! @predicted_tmhs = $1.to_i ! when /Exp number of AAs in TMHs: +([\d\.]+)/ ! @exp_aas_in_tmhs = $1.to_f ! when /Exp number, first 60 AAs: +([\d\.]+)/ ! @exp_first_60aa = $1.to_f ! when /Total prob of N-in: +([\d\.]+)/ ! @total_prob_of_N_in = $1.to_f ! end ! end end def parse_tmhs(raw) ! tmhs = [] ! raw.each do |line| ! case line ! when /^[^\#]/ ! eid,version,status,r0,r1 = line.split(/\s+/) ! tmhs << Bio::TMHMM::TMH.new(eid.strip, ! version.strip, ! status.strip, ! Range.new(r0.to_i, r1.to_i)) ! end ! end ! tmhs end *************** *** 130,137 **** def initialize(entry_id = nil, version = nil, status = nil, range = nil) ! @entry_id = entry_id ! @version = version ! @status = status ! @range = range end attr_accessor :entry_id, :version, :status, :range --- 130,137 ---- def initialize(entry_id = nil, version = nil, status = nil, range = nil) ! @entry_id = entry_id ! @version = version ! @status = status ! @range = range end attr_accessor :entry_id, :version, :status, :range *************** *** 139,143 **** def to_s ! [@entry_id, @version, @status, @range.first, @range.last].join("\t") end --- 139,143 ---- def to_s ! [@entry_id, @version, @status, @range.first, @range.last].join("\t") end From k at pub.open-bio.org Wed Sep 7 21:22:13 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:12:28 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/db/pdb atom.rb, 1.1, 1.2 pdb.rb, 1.1, 1.2 utils.rb, 1.1, 1.2 Message-ID: <200509080122.j881MDdZ009128@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/pdb In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/db/pdb Modified Files: atom.rb pdb.rb utils.rb Log Message: * expanded tab at the line head Index: atom.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/atom.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** atom.rb 8 Mar 2004 07:30:40 -0000 1.1 --- atom.rb 8 Sep 2005 01:22:11 -0000 1.2 *************** *** 63,67 **** attr_accessor :serial, :element, :alt_loc, :x, :y, :z, ! :occ, :bfac, :residue def initialize(serial, element, alt_loc, x, y, z, --- 63,67 ---- attr_accessor :serial, :element, :alt_loc, :x, :y, :z, ! :occ, :bfac, :residue def initialize(serial, element, alt_loc, x, y, z, *************** *** 71,77 **** @element = element @alt_loc = alt_loc ! @x = x ! @y = y ! @z = z @occ = occ @bfac = bfac --- 71,77 ---- @element = element @alt_loc = alt_loc ! @x = x ! @y = y ! @z = z @occ = occ @bfac = bfac *************** *** 88,92 **** #Returns an array of the xyz positions def to_a ! [@x,@y,@z] end --- 88,92 ---- #Returns an array of the xyz positions def to_a ! [@x,@y,@z] end Index: utils.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/utils.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** utils.rb 8 Mar 2004 07:30:40 -0000 1.1 --- utils.rb 8 Sep 2005 01:22:11 -0000 1.2 *************** *** 36,43 **** self.each_atom{ |atom| ! x += atom.x ! y += atom.y ! z += atom.z ! count += 1 } --- 36,43 ---- self.each_atom{ |atom| ! x += atom.x ! y += atom.y ! z += atom.z ! count += 1 } *************** *** 69,78 **** self.each_atom{ |atom| ! element = atom.element[0,1] ! mass = ElementMass[element] ! total += mass ! x += atom.x * mass ! y += atom.y * mass ! z += atom.z * mass } --- 69,78 ---- self.each_atom{ |atom| ! element = atom.element[0,1] ! mass = ElementMass[element] ! total += mass ! x += atom.x * mass ! y += atom.y * mass ! z += atom.z * mass } *************** *** 196,200 **** def each_chain() self.each_model{ |model| ! model.each{ |chain| yield chain } } end --- 196,200 ---- def each_chain() self.each_model{ |model| ! model.each{ |chain| yield chain } } end *************** *** 211,215 **** def each_residue() self.each_chain{ |chain| ! chain.each{ |residue| yield residue } } end --- 211,215 ---- def each_residue() self.each_chain{ |chain| ! chain.each{ |residue| yield residue } } end *************** *** 226,230 **** def each_atom() self.each_residue{ |residue| ! residue.each{ |atom| yield atom } } end --- 226,230 ---- def each_atom() self.each_residue{ |residue| ! residue.each{ |atom| yield atom } } end Index: pdb.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/pdb.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pdb.rb 8 Mar 2004 07:30:40 -0000 1.1 --- pdb.rb 8 Sep 2005 01:22:11 -0000 1.2 *************** *** 49,53 **** module Pdb_Integer def self.new(str) ! str.strip.to_i end end --- 49,53 ---- module Pdb_Integer def self.new(str) ! str.strip.to_i end [...2082 lines suppressed...] ! @seqres end end *************** *** 1356,1362 **** def dbref(chainID = nil) if chainID then ! self.record('DBREF').find_all { |f| f.chainID == chainID } else ! self.record('DBREF') end end --- 1356,1362 ---- def dbref(chainID = nil) if chainID then ! self.record('DBREF').find_all { |f| f.chainID == chainID } else ! self.record('DBREF') end end From k at pub.open-bio.org Wed Sep 7 21:22:13 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:12:57 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/db/kegg brite.rb, 0.5, 0.6 cell.rb, 1.6, 1.7 compound.rb, 0.10, 0.11 enzyme.rb, 0.7, 0.8 genes.rb, 0.19, 0.20 genome.rb, 0.13, 0.14 glycan.rb, 1.1, 1.2 keggtab.rb, 1.5, 1.6 ko.rb, 1.4, 1.5 reaction.rb, 1.2, 1.3 Message-ID: <200509080122.j881MDdZ009117@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/kegg In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/db/kegg Modified Files: brite.rb cell.rb compound.rb enzyme.rb genes.rb genome.rb glycan.rb keggtab.rb ko.rb reaction.rb Log Message: * expanded tab at the line head Index: genes.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/genes.rb,v retrieving revision 0.19 retrieving revision 0.20 diff -C2 -d -r0.19 -r0.20 *** genes.rb 9 Feb 2005 08:41:38 -0000 0.19 --- genes.rb 8 Sep 2005 01:22:11 -0000 0.20 *************** *** 33,85 **** def initialize(entry) ! super(entry, TAGSIZE) end def entry ! unless @data['ENTRY'] ! hash = Hash.new('') ! if get('ENTRY').length > 30 ! e = get('ENTRY') ! hash['id'] = e[12..29].strip ! hash['division'] = e[30..39].strip ! hash['organism'] = e[40..80].strip ! end ! @data['ENTRY'] = hash ! end ! @data['ENTRY'] end def entry_id ! entry['id'] end def division ! entry['division'] # CDS, tRNA etc. end def organism ! entry['organism'] # H.sapiens etc. end def name ! field_fetch('NAME') end def genes ! name.split(', ') end def gene ! genes.first end def definition ! field_fetch('DEFINITION') end def eclinks # definition.scan(/\[EC:(.*?)\]/).flatten ! if /\[EC:(.*?)\]/.match(definition) $1.split(/\s+/) else --- 33,85 ---- def initialize(entry) ! super(entry, TAGSIZE) end def entry ! unless @data['ENTRY'] ! hash = Hash.new('') ! if get('ENTRY').length > 30 ! e = get('ENTRY') ! hash['id'] = e[12..29].strip ! hash['division'] = e[30..39].strip ! hash['organism'] = e[40..80].strip ! end ! @data['ENTRY'] = hash ! end ! @data['ENTRY'] end def entry_id ! entry['id'] end def division ! entry['division'] # CDS, tRNA etc. end def organism ! entry['organism'] # H.sapiens etc. end def name ! field_fetch('NAME') end def genes ! name.split(', ') end def gene ! genes.first end def definition ! field_fetch('DEFINITION') end def eclinks # definition.scan(/\[EC:(.*?)\]/).flatten ! if /\[EC:(.*?)\]/.match(definition) $1.split(/\s+/) else *************** *** 90,94 **** def splinks # definition.scan(/\[SP:(.*?)\]/).flatten ! if /\[SP:(.*?)\]/.match(definition) $1.split(/\s+/) else --- 90,94 ---- def splinks # definition.scan(/\[SP:(.*?)\]/).flatten ! if /\[SP:(.*?)\]/.match(definition) $1.split(/\s+/) else *************** *** 98,102 **** def keggclass ! field_fetch('CLASS') end --- 98,102 ---- def keggclass ! field_fetch('CLASS') end *************** *** 106,157 **** def position ! unless @data['POSITION'] ! @data['POSITION'] = fetch('POSITION').gsub(/\s/, '') ! end ! @data['POSITION'] end def gbposition ! position.sub(/.*?:/, '') end def chromosome ! if position =~ /:/ ! position.sub(/:.*/, '') ! else ! nil ! end end def dblinks ! unless @data['DBLINKS'] ! hash = {} ! get('DBLINKS').scan(/(\S+):\s*(\S+)\n/).each do |k, v| ! hash[k] = v ! end ! @data['DBLINKS'] = hash ! end ! @data['DBLINKS'] # Hash of DB:ID in DBLINKS end def codon_usage(codon = nil) ! unless @data['CODON_USAGE'] ! ary = [] ! get('CODON_USAGE').sub(/.*/,'').each_line do |line| # cut 1st line ! line.chomp.sub(/^.{11}/, '').scan(/..../) do |cu| ! ary.push(cu.to_i) ! end ! end ! @data['CODON_USAGE'] = ary ! end ! if codon ! h = { 't' => 0, 'c' => 1, 'a' => 2, 'g' => 3 } ! x, y, z = codon.downcase.scan(/\w/) ! codon_num = h[x] * 16 + h[y] * 4 + h[z] ! @data['CODON_USAGE'][codon_num] # CODON_USAGE of the codon ! else ! return @data['CODON_USAGE'] # Array of CODON_USAGE (default) ! end end --- 106,157 ---- def position ! unless @data['POSITION'] ! @data['POSITION'] = fetch('POSITION').gsub(/\s/, '') ! end ! @data['POSITION'] end def gbposition ! position.sub(/.*?:/, '') end def chromosome ! if position =~ /:/ ! position.sub(/:.*/, '') ! else ! nil ! end end def dblinks ! unless @data['DBLINKS'] ! hash = {} ! get('DBLINKS').scan(/(\S+):\s*(\S+)\n/).each do |k, v| ! hash[k] = v ! end ! @data['DBLINKS'] = hash ! end ! @data['DBLINKS'] # Hash of DB:ID in DBLINKS end def codon_usage(codon = nil) ! unless @data['CODON_USAGE'] ! ary = [] ! get('CODON_USAGE').sub(/.*/,'').each_line do |line| # cut 1st line ! line.chomp.sub(/^.{11}/, '').scan(/..../) do |cu| ! ary.push(cu.to_i) ! end ! end ! @data['CODON_USAGE'] = ary ! end ! if codon ! h = { 't' => 0, 'c' => 1, 'a' => 2, 'g' => 3 } ! x, y, z = codon.downcase.scan(/\w/) ! codon_num = h[x] * 16 + h[y] * 4 + h[z] ! @data['CODON_USAGE'][codon_num] # CODON_USAGE of the codon ! else ! return @data['CODON_USAGE'] # Array of CODON_USAGE (default) ! end end *************** *** 171,194 **** def aaseq ! unless @data['AASEQ'] ! @data['AASEQ'] = Sequence::AA.new(fetch('AASEQ').gsub(/[\s\d\/]+/, '')) ! end ! @data['AASEQ'] end def aalen ! @data['AALEN'] = aaseq.length end def ntseq ! unless @data['NTSEQ'] ! @data['NTSEQ'] = Sequence::NA.new(fetch('NTSEQ').gsub(/[\s\d\/]+/, '')) ! end ! @data['NTSEQ'] end alias naseq ntseq def ntlen ! @data['NTLEN'] = ntseq.length end alias nalen ntlen --- 171,194 ---- def aaseq ! unless @data['AASEQ'] ! @data['AASEQ'] = Sequence::AA.new(fetch('AASEQ').gsub(/[\s\d\/]+/, '')) ! end ! @data['AASEQ'] end def aalen ! @data['AALEN'] = aaseq.length end def ntseq ! unless @data['NTSEQ'] ! @data['NTSEQ'] = Sequence::NA.new(fetch('NTSEQ').gsub(/[\s\d\/]+/, '')) ! end ! @data['NTSEQ'] end alias naseq ntseq def ntlen ! @data['NTLEN'] = ntseq.length end alias nalen ntlen Index: reaction.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/reaction.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** reaction.rb 22 Oct 2004 10:16:05 -0000 1.2 --- reaction.rb 8 Sep 2005 01:22:11 -0000 1.3 *************** *** 33,42 **** def initialize(entry) ! super(entry, TAGSIZE) end # ENTRY def entry_id ! field_fetch('ENTRY') end --- 33,42 ---- def initialize(entry) ! super(entry, TAGSIZE) end # ENTRY def entry_id ! field_fetch('ENTRY') end *************** *** 48,65 **** # DEFINITION def definition ! field_fetch('DEFINITION') end # EQUATION def equation ! field_fetch('EQUATION') end # RPAIR def rpairs ! unless @data['RPAIR'] ! @data['RPAIR'] = fetch('RPAIR').split(/\s+/) ! end ! @data['RPAIR'] end --- 48,65 ---- # DEFINITION def definition ! field_fetch('DEFINITION') end # EQUATION def equation ! field_fetch('EQUATION') end # RPAIR def rpairs ! unless @data['RPAIR'] ! @data['RPAIR'] = fetch('RPAIR').split(/\s+/) ! end ! @data['RPAIR'] end *************** *** 71,78 **** # ENZYME def enzymes ! unless @data['ENZYME'] @data['ENZYME'] = fetch('ENZYME').scan(/\S+/) ! end ! @data['ENZYME'] end --- 71,78 ---- # ENZYME def enzymes ! unless @data['ENZYME'] @data['ENZYME'] = fetch('ENZYME').scan(/\S+/) ! end ! @data['ENZYME'] end Index: brite.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/brite.rb,v retrieving revision 0.5 retrieving revision 0.6 diff -C2 -d -r0.5 -r0.6 *** brite.rb 15 Dec 2001 02:50:35 -0000 0.5 --- brite.rb 8 Sep 2005 01:22:11 -0000 0.6 *************** *** 33,37 **** def initialize(entry) ! super(entry, TAGSIZE) end --- 33,37 ---- def initialize(entry) ! super(entry, TAGSIZE) end Index: glycan.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/glycan.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** glycan.rb 25 Oct 2004 14:08:35 -0000 1.1 --- glycan.rb 8 Sep 2005 01:22:11 -0000 1.2 *************** *** 33,37 **** def initialize(entry) ! super(entry, TAGSIZE) end --- 33,37 ---- def initialize(entry) ! super(entry, TAGSIZE) end *************** *** 97,112 **** # COMPOUND def compounds ! unless @data['COMPOUND'] ! @data['COMPOUND'] = fetch('COMPOUND').split(/\s+/) ! end ! @data['COMPOUND'] end # REACTION def reactions ! unless @data['REACTION'] ! @data['REACTION'] = fetch('REACTION').split(/\s+/) ! end ! @data['REACTION'] end --- 97,112 ---- # COMPOUND def compounds ! unless @data['COMPOUND'] ! @data['COMPOUND'] = fetch('COMPOUND').split(/\s+/) ! end ! @data['COMPOUND'] end # REACTION def reactions ! unless @data['REACTION'] ! @data['REACTION'] = fetch('REACTION').split(/\s+/) ! end ! @data['REACTION'] end *************** *** 118,130 **** # ENZYME def enzymes ! unless @data['ENZYME'] ! field = fetch('ENZYME') ! if /\(/.match(field) # old version ! @data['ENZYME'] = field.scan(/\S+ \(\S+\)/) ! else ! @data['ENZYME'] = field.scan(/\S+/) ! end ! end ! @data['ENZYME'] end --- 118,130 ---- # ENZYME def enzymes ! unless @data['ENZYME'] ! field = fetch('ENZYME') ! if /\(/.match(field) # old version ! @data['ENZYME'] = field.scan(/\S+ \(\S+\)/) ! else ! @data['ENZYME'] = field.scan(/\S+/) ! end ! end ! @data['ENZYME'] end Index: compound.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/compound.rb,v retrieving revision 0.10 retrieving revision 0.11 diff -C2 -d -r0.10 -r0.11 *** compound.rb 7 Aug 2005 08:23:37 -0000 0.10 --- compound.rb 8 Sep 2005 01:22:11 -0000 0.11 *************** *** 33,37 **** def initialize(entry) ! super(entry, TAGSIZE) end --- 33,37 ---- def initialize(entry) ! super(entry, TAGSIZE) end *************** *** 49,79 **** end def name ! names[0] end # FORMULA def formula ! field_fetch('FORMULA') end # MASS def mass ! field_fetch('MASS').to_f end # REACTION def reactions ! unless @data['REACTION'] ! @data['REACTION'] = fetch('REACTION').split(/\s+/) ! end ! @data['REACTION'] end # RPAIR def rpairs ! unless @data['RPAIR'] ! @data['RPAIR'] = fetch('RPAIR').split(/\s+/) ! end ! @data['RPAIR'] end --- 49,79 ---- end def name ! names[0] end # FORMULA def formula ! field_fetch('FORMULA') end # MASS def mass ! field_fetch('MASS').to_f end # REACTION def reactions ! unless @data['REACTION'] ! @data['REACTION'] = fetch('REACTION').split(/\s+/) ! end ! @data['REACTION'] end # RPAIR def rpairs ! unless @data['RPAIR'] ! @data['RPAIR'] = fetch('RPAIR').split(/\s+/) ! end ! @data['RPAIR'] end *************** *** 85,97 **** # ENZYME def enzymes ! unless @data['ENZYME'] ! field = fetch('ENZYME') ! if /\(/.match(field) # old version ! @data['ENZYME'] = field.scan(/\S+ \(\S+\)/) ! else ! @data['ENZYME'] = field.scan(/\S+/) ! end ! end ! @data['ENZYME'] end --- 85,97 ---- # ENZYME def enzymes ! unless @data['ENZYME'] ! field = fetch('ENZYME') ! if /\(/.match(field) # old version ! @data['ENZYME'] = field.scan(/\S+ \(\S+\)/) ! else ! @data['ENZYME'] = field.scan(/\S+/) ! end ! end ! @data['ENZYME'] end Index: cell.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/cell.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** cell.rb 15 Dec 2001 02:55:07 -0000 1.6 --- cell.rb 8 Sep 2005 01:22:11 -0000 1.7 *************** *** 33,82 **** def initialize(entry) ! super(entry, TAGSIZE) end def entry_id ! field_fetch('ENTRY') end def definition ! field_fetch('DEFINITION') end def org ! field_fetch('ORGANISM') end alias organism org def mother ! field_fetch('MOTHER') end def daughter ! field_fetch('DAUGHTER').gsub(/ /, '').split(/,/) end def sister ! field_fetch('SISTER') end def fate ! field_fetch('CELL_FATE').gsub(/ /, '').split(/,/) end def contact ! field_fetch('CONTACT').gsub(/ /, '').split(/,/) end def expression ! field_fetch('EXPRESSION') end def fig ! field_fetch('FIGURE') end def ref ! field_fetch('REFERENCE') end --- 33,82 ---- def initialize(entry) ! super(entry, TAGSIZE) end def entry_id ! field_fetch('ENTRY') end def definition ! field_fetch('DEFINITION') end def org ! field_fetch('ORGANISM') end alias organism org def mother ! field_fetch('MOTHER') end def daughter ! field_fetch('DAUGHTER').gsub(/ /, '').split(/,/) end def sister ! field_fetch('SISTER') end def fate ! field_fetch('CELL_FATE').gsub(/ /, '').split(/,/) end def contact ! field_fetch('CONTACT').gsub(/ /, '').split(/,/) end def expression ! field_fetch('EXPRESSION') end def fig ! field_fetch('FIGURE') end def ref ! field_fetch('REFERENCE') end Index: enzyme.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/enzyme.rb,v retrieving revision 0.7 retrieving revision 0.8 diff -C2 -d -r0.7 -r0.8 *** enzyme.rb 4 Feb 2004 14:00:58 -0000 0.7 --- enzyme.rb 8 Sep 2005 01:22:11 -0000 0.8 *************** *** 33,47 **** def initialize(entry) ! super(entry, TAGSIZE) end # ENTRY def entry_id ! field_fetch('ENTRY') end # NAME def names ! lines_fetch('NAME') end def name --- 33,47 ---- def initialize(entry) ! super(entry, TAGSIZE) end # ENTRY def entry_id ! field_fetch('ENTRY') end # NAME def names ! lines_fetch('NAME') end def name *************** *** 51,119 **** # CLASS def classes ! lines_fetch('CLASS') end # SYSNAME def sysname ! field_fetch('SYSNAME') end # REACTION ';' def reaction ! field_fetch('REACTION') end # SUBSTRATE def substrates ! lines_fetch('SUBSTRATE') end # PRODUCT def products ! lines_fetch('PRODUCT') end # COFACTOR def cofactors ! lines_fetch('COFACTOR') end # COMMENT def comment ! field_fetch('COMMENT') end # PATHWAY def pathways ! lines_fetch('PATHWAY') end # GENES def genes ! lines_fetch('GENES') end # DISEASE def diseases ! lines_fetch('DISEASE') end # MOTIF def motifs ! lines_fetch('MOTIF') end # STRUCTURES def structures ! unless @data['STRUCTURES'] ! @data['STRUCTURES'] = ! fetch('STRUCTURES').sub(/(PDB: )*/,'').split(/\s+/) ! end ! @data['STRUCTURES'] end # DBLINKS def dblinks ! lines_fetch('DBLINKS') end --- 51,119 ---- # CLASS def classes ! lines_fetch('CLASS') end # SYSNAME def sysname ! field_fetch('SYSNAME') end # REACTION ';' def reaction ! field_fetch('REACTION') end # SUBSTRATE def substrates ! lines_fetch('SUBSTRATE') end # PRODUCT def products ! lines_fetch('PRODUCT') end # COFACTOR def cofactors ! lines_fetch('COFACTOR') end # COMMENT def comment ! field_fetch('COMMENT') end # PATHWAY def pathways ! lines_fetch('PATHWAY') end # GENES def genes ! lines_fetch('GENES') end # DISEASE def diseases ! lines_fetch('DISEASE') end # MOTIF def motifs ! lines_fetch('MOTIF') end # STRUCTURES def structures ! unless @data['STRUCTURES'] ! @data['STRUCTURES'] = ! fetch('STRUCTURES').sub(/(PDB: )*/,'').split(/\s+/) ! end ! @data['STRUCTURES'] end # DBLINKS def dblinks ! lines_fetch('DBLINKS') end Index: ko.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/ko.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ko.rb 23 Aug 2004 23:53:23 -0000 1.4 --- ko.rb 8 Sep 2005 01:22:11 -0000 1.5 *************** *** 34,99 **** def initialize(entry) ! super(entry, TAGSIZE) end def entry_id ! field_fetch('ENTRY')[/\S+/] end def name ! field_fetch('NAME') end def names ! name.split(', ') end def definition ! field_fetch('DEFINITION') end def keggclass ! field_fetch('CLASS') end def keggclasses ! keggclass.gsub(/ \[[^\]]+/, '').split(/\] ?/) end def pathways ! keggclass.scan(/\[PATH:(.*?)\]/).flatten end def dblinks ! unless @data['DBLINKS'] ! hash = {} ! get('DBLINKS').scan(/(\S+):\s*(.*)\n/).each do |k, v| ! hash[k] = v.split(/\s+/) ! end ! @data['DBLINKS'] = hash ! end ! @data['DBLINKS'] # Hash of DB:ID in DBLINKS end def genes ! unless @data['GENES'] ! hash = {} ! k = '' ! get('GENES').each_line do |line| ! line.chomp! ! line[0, @tagsize] = '' ! if line =~ /(\S+):/ ! k = $1 ! hash[k] = [] ! end ! line[0, 5] = '' ! line.gsub(/\(\S+/, '').each(' ') do |u| ! hash[k] << u.strip ! end ! end ! @data['GENES'] = hash end ! @data['GENES'] # Hash of DB:ID in DBLINKS end --- 34,99 ---- def initialize(entry) ! super(entry, TAGSIZE) end def entry_id ! field_fetch('ENTRY')[/\S+/] end def name ! field_fetch('NAME') end def names ! name.split(', ') end def definition ! field_fetch('DEFINITION') end def keggclass ! field_fetch('CLASS') end def keggclasses ! keggclass.gsub(/ \[[^\]]+/, '').split(/\] ?/) end def pathways ! keggclass.scan(/\[PATH:(.*?)\]/).flatten end def dblinks ! unless @data['DBLINKS'] ! hash = {} ! get('DBLINKS').scan(/(\S+):\s*(.*)\n/).each do |k, v| ! hash[k] = v.split(/\s+/) ! end ! @data['DBLINKS'] = hash ! end ! @data['DBLINKS'] # Hash of DB:ID in DBLINKS end def genes ! unless @data['GENES'] ! hash = {} ! k = '' ! get('GENES').each_line do |line| ! line.chomp! ! line[0, @tagsize] = '' ! if line =~ /(\S+):/ ! k = $1 ! hash[k] = [] ! end ! line[0, 5] = '' ! line.gsub(/\(\S+/, '').each(' ') do |u| ! hash[k] << u.strip ! end ! end ! @data['GENES'] = hash end ! @data['GENES'] # Hash of DB:ID in DBLINKS end Index: genome.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/genome.rb,v retrieving revision 0.13 retrieving revision 0.14 diff -C2 -d -r0.13 -r0.14 *** genome.rb 23 Aug 2004 23:53:23 -0000 0.13 --- genome.rb 8 Sep 2005 01:22:11 -0000 0.14 *************** *** 33,37 **** def initialize(entry) ! super(entry, TAGSIZE) end --- 33,37 ---- def initialize(entry) ! super(entry, TAGSIZE) end *************** *** 39,53 **** # ENTRY def entry_id ! field_fetch('ENTRY') end # NAME def name ! field_fetch('NAME') end # DEFINITION def definition ! field_fetch('DEFINITION') end alias organism definition --- 39,53 ---- # ENTRY def entry_id ! field_fetch('ENTRY') end # NAME def name ! field_fetch('NAME') end # DEFINITION def definition ! field_fetch('DEFINITION') end alias organism definition *************** *** 55,206 **** # TAXONOMY def taxonomy ! unless @data['TAXONOMY'] ! taxid, lineage = subtag2array(get('TAXONOMY')) ! taxid = taxid ? truncate(tag_cut(taxid)) : '' ! lineage = lineage ? truncate(tag_cut(lineage)) : '' ! @data['TAXONOMY'] = { ! 'taxid' => taxid, ! 'lineage' => lineage, ! } ! @data['TAXONOMY'].default = '' ! end ! @data['TAXONOMY'] end def taxid ! taxonomy['taxid'] end def lineage ! taxonomy['lineage'] end # COMMENT def comment ! field_fetch('COMMENT') end # REFERENCE def references ! unless @data['REFERENCE'] ! ary = [] ! toptag2array(get('REFERENCE')).each do |ref| ! hash = Hash.new('') ! subtag2array(ref).each do |field| ! case tag_get(field) ! when /AUTHORS/ ! authors = truncate(tag_cut(field)) ! authors = authors.split(', ') ! authors[-1] = authors[-1].split(/\s+and\s+/) ! authors = authors.flatten.map { |a| a.sub(',', ', ') } ! hash['authors'] = authors ! when /TITLE/ ! hash['title'] = truncate(tag_cut(field)) ! when /JOURNAL/ ! journal = truncate(tag_cut(field)) ! if journal =~ /(.*) (\d+):(\d+)-(\d+) \((\d+)\) \[UI:(\d+)\]$/ ! hash['journal'] = $1 ! hash['volume'] = $2 ! hash['pages'] = $3 ! hash['year'] = $5 ! hash['medline'] = $6 ! else ! hash['journal'] = journal ! end ! end ! end ! ary.push(Reference.new(hash)) ! end ! @data['REFERENCE'] = References.new(ary) ! end ! @data['REFERENCE'] end # CHROMOSOME def chromosomes ! unless @data['CHROMOSOME'] ! @data['CHROMOSOME'] = [] ! toptag2array(get('CHROMOSOME')).each do |chr| ! hash = Hash.new('') ! subtag2array(chr).each do |field| ! hash[tag_get(field)] = truncate(tag_cut(field)) ! end ! @data['CHROMOSOME'].push(hash) ! end ! end ! @data['CHROMOSOME'] end # PLASMID def plasmids ! unless @data['PLASMID'] ! @data['PLASMID'] = [] ! toptag2array(get('PLASMID')).each do |chr| ! hash = Hash.new('') ! subtag2array(chr).each do |field| ! hash[tag_get(field)] = truncate(tag_cut(field)) ! end ! @data['PLASMID'].push(hash) ! end ! end ! @data['PLASMID'] end # SCAFFOLD def scaffolds ! unless @data['SCAFFOLD'] ! @data['SCAFFOLD'] = [] ! toptag2array(get('SCAFFOLD')).each do |chr| ! hash = Hash.new('') ! subtag2array(chr).each do |field| ! hash[tag_get(field)] = truncate(tag_cut(field)) ! end ! @data['SCAFFOLD'].push(hash) ! end ! end ! @data['SCAFFOLD'] end # STATISTICS def statistics ! unless @data['STATISTICS'] ! hash = Hash.new(0.0) ! get('STATISTICS').each_line do |line| ! case line ! when /nucleotides:\s+(\d+)/ ! hash['nalen'] = $1.to_i ! when /protein genes:\s+(\d+)/ ! hash['num_gene'] = $1.to_i ! when /RNA genes:\s+(\d+)/ ! hash['num_rna'] = $1.to_i ! when /G\+C content:\s+(\d+.\d+)/ ! hash['gc'] = $1.to_f ! end ! end ! @data['STATISTICS'] = hash ! end ! @data['STATISTICS'] end def nalen ! statistics['nalen'] end alias length nalen def num_gene ! statistics['num_gene'] end def num_rna ! statistics['num_rna'] end def gc ! statistics['gc'] end # GENOMEMAP def genomemap ! field_fetch('GENOMEMAP') end --- 55,206 ---- # TAXONOMY def taxonomy ! unless @data['TAXONOMY'] ! taxid, lineage = subtag2array(get('TAXONOMY')) ! taxid = taxid ? truncate(tag_cut(taxid)) : '' ! lineage = lineage ? truncate(tag_cut(lineage)) : '' ! @data['TAXONOMY'] = { ! 'taxid' => taxid, ! 'lineage' => lineage, ! } ! @data['TAXONOMY'].default = '' ! end ! @data['TAXONOMY'] end def taxid ! taxonomy['taxid'] end def lineage ! taxonomy['lineage'] end # COMMENT def comment ! field_fetch('COMMENT') end # REFERENCE def references ! unless @data['REFERENCE'] ! ary = [] ! toptag2array(get('REFERENCE')).each do |ref| ! hash = Hash.new('') ! subtag2array(ref).each do |field| ! case tag_get(field) ! when /AUTHORS/ ! authors = truncate(tag_cut(field)) ! authors = authors.split(', ') ! authors[-1] = authors[-1].split(/\s+and\s+/) ! authors = authors.flatten.map { |a| a.sub(',', ', ') } ! hash['authors'] = authors ! when /TITLE/ ! hash['title'] = truncate(tag_cut(field)) ! when /JOURNAL/ ! journal = truncate(tag_cut(field)) ! if journal =~ /(.*) (\d+):(\d+)-(\d+) \((\d+)\) \[UI:(\d+)\]$/ ! hash['journal'] = $1 ! hash['volume'] = $2 ! hash['pages'] = $3 ! hash['year'] = $5 ! hash['medline'] = $6 ! else ! hash['journal'] = journal ! end ! end ! end ! ary.push(Reference.new(hash)) ! end ! @data['REFERENCE'] = References.new(ary) ! end ! @data['REFERENCE'] end # CHROMOSOME def chromosomes ! unless @data['CHROMOSOME'] ! @data['CHROMOSOME'] = [] ! toptag2array(get('CHROMOSOME')).each do |chr| ! hash = Hash.new('') ! subtag2array(chr).each do |field| ! hash[tag_get(field)] = truncate(tag_cut(field)) ! end ! @data['CHROMOSOME'].push(hash) ! end ! end ! @data['CHROMOSOME'] end # PLASMID def plasmids ! unless @data['PLASMID'] ! @data['PLASMID'] = [] ! toptag2array(get('PLASMID')).each do |chr| ! hash = Hash.new('') ! subtag2array(chr).each do |field| ! hash[tag_get(field)] = truncate(tag_cut(field)) ! end ! @data['PLASMID'].push(hash) ! end ! end ! @data['PLASMID'] end # SCAFFOLD def scaffolds ! unless @data['SCAFFOLD'] ! @data['SCAFFOLD'] = [] ! toptag2array(get('SCAFFOLD')).each do |chr| ! hash = Hash.new('') ! subtag2array(chr).each do |field| ! hash[tag_get(field)] = truncate(tag_cut(field)) ! end ! @data['SCAFFOLD'].push(hash) ! end ! end ! @data['SCAFFOLD'] end # STATISTICS def statistics ! unless @data['STATISTICS'] ! hash = Hash.new(0.0) ! get('STATISTICS').each_line do |line| ! case line ! when /nucleotides:\s+(\d+)/ ! hash['nalen'] = $1.to_i ! when /protein genes:\s+(\d+)/ ! hash['num_gene'] = $1.to_i ! when /RNA genes:\s+(\d+)/ ! hash['num_rna'] = $1.to_i ! when /G\+C content:\s+(\d+.\d+)/ ! hash['gc'] = $1.to_f ! end ! end ! @data['STATISTICS'] = hash ! end ! @data['STATISTICS'] end def nalen ! statistics['nalen'] end alias length nalen def num_gene ! statistics['num_gene'] end def num_rna ! statistics['num_rna'] end def gc ! statistics['gc'] end # GENOMEMAP def genomemap ! field_fetch('GENOMEMAP') end *************** *** 244,248 **** puts "### " + x.shift x.each do |m| ! p genome.send(m) end end --- 244,248 ---- puts "### " + x.shift x.each do |m| ! p genome.send(m) end end Index: keggtab.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/keggtab.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** keggtab.rb 23 Aug 2004 23:53:23 -0000 1.5 --- keggtab.rb 8 Sep 2005 01:22:11 -0000 1.6 *************** *** 28,36 **** def initialize(file_path, bioroot = nil) ! @bioroot = ENV['BIOROOT'] || bioroot ! @db_names = Hash.new ! @database = Hash.new ! @taxonomy = Hash.new ! parse_keggtab(File.open(file_path).read) end attr_reader :bioroot, :db_names --- 28,36 ---- def initialize(file_path, bioroot = nil) ! @bioroot = ENV['BIOROOT'] || bioroot ! @db_names = Hash.new ! @database = Hash.new ! @taxonomy = Hash.new ! parse_keggtab(File.open(file_path).read) end attr_reader :bioroot, :db_names *************** *** 40,53 **** class DB ! def initialize(db_name, db_type, db_path, db_abbrev) ! @name = db_name ! @type = db_type ! @path = db_path ! @abbrev = db_abbrev ! @aliases = Array.new ! end ! attr_reader :name, :type, :path, :abbrev, :aliases ! alias :korg :abbrev ! alias :keggorg :abbrev end --- 40,53 ---- class DB ! def initialize(db_name, db_type, db_path, db_abbrev) ! @name = db_name ! @type = db_type ! @path = db_path ! @abbrev = db_abbrev ! @aliases = Array.new ! end ! attr_reader :name, :type, :path, :abbrev, :aliases ! alias :korg :abbrev ! alias :keggorg :abbrev end *************** *** 56,118 **** def database(db_abbrev = nil) ! if db_abbrev ! @database[db_abbrev] ! else ! @database ! end end def aliases(db_abbrev) ! if @database[db_abbrev] ! @database[db_abbrev].aliases ! end end def name(db_abbrev) ! if @database[db_abbrev] ! @database[db_abbrev].name ! end end def path(db_abbrev) ! if @database[db_abbrev] ! file = @database[db_abbrev].name ! if @bioroot ! "#{@database[db_abbrev].path.sub(/\$BIOROOT/,@bioroot)}/#{file}" ! else ! "#{@database[db_abbrev].path}/#{file}" ! end ! end end def alias_list(db_name) ! if @db_names[db_name] ! @db_names[db_name].aliases ! end end def db_path(db_name) ! if @bioroot ! "#{@db_names[db_name].path.sub(/\$BIOROOT/,@bioroot)}/#{db_name}" ! else ! "#{@db_names[db_name].path}/#{db_name}" ! end end def db_by_abbrev(db_abbrev) ! @db_names.each do |k, db| ! return db if db.abbrev == db_abbrev ! end ! return nil end def name_by_abbrev(db_abbrev) ! db_by_abbrev(db_abbrev).name end def db_path_by_abbrev(db_abbrev) ! db_name = name_by_abbrev(db_abbrev) ! db_path(db_name) end --- 56,118 ---- def database(db_abbrev = nil) ! if db_abbrev ! @database[db_abbrev] ! else ! @database ! end end def aliases(db_abbrev) ! if @database[db_abbrev] ! @database[db_abbrev].aliases ! end end def name(db_abbrev) ! if @database[db_abbrev] ! @database[db_abbrev].name ! end end def path(db_abbrev) ! if @database[db_abbrev] ! file = @database[db_abbrev].name ! if @bioroot ! "#{@database[db_abbrev].path.sub(/\$BIOROOT/,@bioroot)}/#{file}" ! else ! "#{@database[db_abbrev].path}/#{file}" ! end ! end end def alias_list(db_name) ! if @db_names[db_name] ! @db_names[db_name].aliases ! end end def db_path(db_name) ! if @bioroot ! "#{@db_names[db_name].path.sub(/\$BIOROOT/,@bioroot)}/#{db_name}" ! else ! "#{@db_names[db_name].path}/#{db_name}" ! end end def db_by_abbrev(db_abbrev) ! @db_names.each do |k, db| ! return db if db.abbrev == db_abbrev ! end ! return nil end def name_by_abbrev(db_abbrev) ! db_by_abbrev(db_abbrev).name end def db_path_by_abbrev(db_abbrev) ! db_name = name_by_abbrev(db_abbrev) ! db_path(db_name) end *************** *** 121,153 **** def taxonomy(node = nil) ! if node ! @taxonomy[node] ! else ! @taxonomy ! end end def taxa_list ! @taxonomy.keys.sort end def child_nodes(node = 'genes') ! return @taxonomy[node] end def taxo2korgs(node = 'genes') ! if node.length == 3 ! return node ! else ! if @taxonomy[node] ! tmp = Array.new ! @taxonomy[node].each do |x| ! tmp.push(taxo2korgs(x)) ! end ! return tmp ! else ! return nil ! end ! end end alias :taxo2keggorgs :taxo2korgs --- 121,153 ---- def taxonomy(node = nil) ! if node ! @taxonomy[node] ! else ! @taxonomy ! end end def taxa_list ! @taxonomy.keys.sort end def child_nodes(node = 'genes') ! return @taxonomy[node] end def taxo2korgs(node = 'genes') ! if node.length == 3 ! return node ! else ! if @taxonomy[node] ! tmp = Array.new ! @taxonomy[node].each do |x| ! tmp.push(taxo2korgs(x)) ! end ! return tmp ! else ! return nil ! end ! end end alias :taxo2keggorgs :taxo2korgs *************** *** 156,171 **** def korg2taxo(keggorg) ! tmp = Array.new ! traverse = Proc.new {|keggorg| ! @taxonomy.each do |k,v| ! if v.include?(keggorg) ! tmp.push(k) ! traverse.call(k) ! break ! end ! end ! } ! traverse.call(keggorg) ! return tmp end alias :keggorg2taxo :korg2taxo --- 156,171 ---- def korg2taxo(keggorg) ! tmp = Array.new ! traverse = Proc.new {|keggorg| ! @taxonomy.each do |k,v| ! if v.include?(keggorg) ! tmp.push(k) ! traverse.call(k) ! break ! end ! end ! } ! traverse.call(keggorg) ! return tmp end alias :keggorg2taxo :korg2taxo *************** *** 177,208 **** def parse_keggtab(keggtab) ! in_taxonomy = nil ! keggtab.each do |line| ! case line ! when /^# Taxonomy/ # beginning of the taxonomy section ! in_taxonomy = true ! when /^#|^$/ ! next ! when /(^\w\S+)\s+(\w+)\s+(\$\S+)\s+(\w+)/ # db ! db_name = $1 ! db_type = $2 ! db_path = $3 ! db_abbrev = $4 ! @db_names[db_name] = ! Bio::KEGG::Keggtab::DB.new(db_name, db_type, db_path, db_abbrev) ! when /(^\w\S+)\s+alias\s+(\w.+\w)/ # alias ! db_alias = $1 ! db_name = $2#.downcase ! if in_taxonomy ! @taxonomy.update(db_alias => db_name.split('+')) ! elsif @db_names[db_name] ! @db_names[db_name].aliases.push(db_alias) ! end ! end ! end ! # convert keys-by-names hash @db_names to keys-by-abbrev hash @database ! @db_names.each do |k,v| ! @database[v.abbrev] = v ! end end --- 177,208 ---- def parse_keggtab(keggtab) ! in_taxonomy = nil ! keggtab.each do |line| ! case line ! when /^# Taxonomy/ # beginning of the taxonomy section ! in_taxonomy = true ! when /^#|^$/ ! next ! when /(^\w\S+)\s+(\w+)\s+(\$\S+)\s+(\w+)/ # db ! db_name = $1 ! db_type = $2 ! db_path = $3 ! db_abbrev = $4 ! @db_names[db_name] = ! Bio::KEGG::Keggtab::DB.new(db_name, db_type, db_path, db_abbrev) ! when /(^\w\S+)\s+alias\s+(\w.+\w)/ # alias ! db_alias = $1 ! db_name = $2#.downcase ! if in_taxonomy ! @taxonomy.update(db_alias => db_name.split('+')) ! elsif @db_names[db_name] ! @db_names[db_name].aliases.push(db_alias) ! end ! end ! end ! # convert keys-by-names hash @db_names to keys-by-abbrev hash @database ! @db_names.each do |k,v| ! @database[v.abbrev] = v ! end end From k at pub.open-bio.org Wed Sep 7 21:22:11 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:50:44 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/blat report.rb,1.1,1.2 Message-ID: <200509080122.j881MBdZ009063@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/blat In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/appl/blat Modified Files: report.rb Log Message: * expanded tab at the line head Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blat/report.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** report.rb 13 Oct 2004 16:52:26 -0000 1.1 --- report.rb 8 Sep 2005 01:22:09 -0000 1.2 *************** *** 44,86 **** end end ! @columns = parse_header(head) end attr_reader :hits, :columns def parse_header(ary) ! ary.shift # first line is removed ! a0 = ary.collect { |x| x.split(/\t/) } ! k = [] ! a0.each do |x| ! x.each_index do |i| ! y = x[i].strip ! k[i] = k[i].to_s + (y.sub!(/\-\z/, '') ? y : y + ' ') ! end ! end ! k.each { |x| x.strip! } ! k end private :parse_header class SeqDesc ! def initialize(gap_count, gap_bases, name, size, ! st, ed, starts, seqs) ! @gap_count = gap_count.to_i ! @gap_bases = gap_bases.to_i ! @name = name ! @size = size.to_i ! @start = st.to_i ! @end = ed.to_i ! @starts = starts.collect { |x| x.to_i } ! @seqs = seqs ! end ! attr_reader :gap_count, :gap_bases, ! :name, :size, :start, :end, :starts, :seqs end #class SeqDesc class SegmentPair ! def initialize(query_len, strand, blksize, qstart, tstart, qseq, tseq) ! @blocksize = blksize @qseq = qseq @hseq = hseq --- 44,86 ---- end end ! @columns = parse_header(head) end attr_reader :hits, :columns def parse_header(ary) ! ary.shift # first line is removed ! a0 = ary.collect { |x| x.split(/\t/) } ! k = [] ! a0.each do |x| ! x.each_index do |i| ! y = x[i].strip ! k[i] = k[i].to_s + (y.sub!(/\-\z/, '') ? y : y + ' ') ! end ! end ! k.each { |x| x.strip! } ! k end private :parse_header class SeqDesc ! def initialize(gap_count, gap_bases, name, size, ! st, ed, starts, seqs) ! @gap_count = gap_count.to_i ! @gap_bases = gap_bases.to_i ! @name = name ! @size = size.to_i ! @start = st.to_i ! @end = ed.to_i ! @starts = starts.collect { |x| x.to_i } ! @seqs = seqs ! end ! attr_reader :gap_count, :gap_bases, ! :name, :size, :start, :end, :starts, :seqs end #class SeqDesc class SegmentPair ! def initialize(query_len, strand, blksize, qstart, tstart, qseq, tseq) ! @blocksize = blksize @qseq = qseq @hseq = hseq *************** *** 106,111 **** @hit_to = tstart + blksize # - 1 + 1 end ! end ! attr_reader :query_from, :query_to, :qseq, :query_strand attr_reader :hit_from, :hit_to, :hseq, :hit_strand attr_reader :blocksize --- 106,111 ---- @hit_to = tstart + blksize # - 1 + 1 end ! end ! attr_reader :query_from, :query_to, :qseq, :query_strand attr_reader :hit_from, :hit_to, :hseq, :hit_strand attr_reader :blocksize *************** *** 157,161 **** @block_sizes = split_comma(@data[18]).collect { |x| x.to_i } end ! @block_sizes end --- 157,161 ---- @block_sizes = split_comma(@data[18]).collect { |x| x.to_i } end ! @block_sizes end From k at pub.open-bio.org Wed Sep 7 21:22:12 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:50:48 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/sim4 report.rb,1.2,1.3 Message-ID: <200509080122.j881MCdZ009088@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/sim4 In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/appl/sim4 Modified Files: report.rb Log Message: * expanded tab at the line head Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/sim4/report.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** report.rb 10 Oct 2004 14:54:23 -0000 1.2 --- report.rb 8 Sep 2005 01:22:10 -0000 1.3 *************** *** 58,62 **** def self.parse(str, str2 = nil) ! /^seq[12] \= (.*)(?: \((.*)\))?\,\s*(\d+)\s*bp\s*$/ =~ str seqid = $2 filename = $1 --- 58,62 ---- def self.parse(str, str2 = nil) ! /^seq[12] \= (.*)(?: \((.*)\))?\,\s*(\d+)\s*bp\s*$/ =~ str seqid = $2 filename = $1 *************** *** 87,92 **** def self.parse(str, aln) ! /^(\d+)\-(\d+)\s*\((\d+)\-(\d+)\)\s*([\d\.]+)\%\s*([\-\<\>]*)/ =~ str ! self.new(Segment.new($1, $2, aln[0]), Segment.new($3, $4, aln[2]), aln[1], $5, $6) --- 87,92 ---- def self.parse(str, aln) ! /^(\d+)\-(\d+)\s*\((\d+)\-(\d+)\)\s*([\d\.]+)\%\s*([\-\<\>]*)/ =~ str ! self.new(Segment.new($1, $2, aln[0]), Segment.new($3, $4, aln[2]), aln[1], $5, $6) From k at pub.open-bio.org Wed Sep 7 21:22:12 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:50:54 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/sosui report.rb,1.4,1.5 Message-ID: <200509080122.j881MCdZ009091@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/sosui In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/appl/sosui Modified Files: report.rb Log Message: * expanded tab at the line head Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/sosui/report.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** report.rb 8 Sep 2003 05:46:25 -0000 1.4 --- report.rb 8 Sep 2005 01:22:10 -0000 1.5 *************** *** 31,41 **** def initialize(entry) ! entry = entry.split(/\n/) ! @entry_id = entry[0].strip.sub(/^>/,'') ! @prediction = entry[1].strip ! @tmh = [] ! @tmhs = 0 ! parse_tmh(entry) if /MEMBRANE/ =~ @prediction end --- 31,41 ---- def initialize(entry) ! entry = entry.split(/\n/) ! @entry_id = entry[0].strip.sub(/^>/,'') ! @prediction = entry[1].strip ! @tmh = [] ! @tmhs = 0 ! parse_tmh(entry) if /MEMBRANE/ =~ @prediction end *************** *** 46,60 **** def parse_tmh(entry) ! entry.each do |line| ! if /NUMBER OF TM HELIX = (\d+)/ =~ line ! @tmhs = $1 ! elsif /TM (\d+) +(\d+)- *(\d+) (\w+) +(\w+)/ =~ line ! tmp = {'TMH' => $1.to_i, ! 'range' => Range.new($2.to_i, $3.to_i), ! 'grade' => $4, ! 'seq' => $5 } ! @tmh.push(tmp) ! end ! end end --- 46,60 ---- def parse_tmh(entry) ! entry.each do |line| ! if /NUMBER OF TM HELIX = (\d+)/ =~ line ! @tmhs = $1 ! elsif /TM (\d+) +(\d+)- *(\d+) (\w+) +(\w+)/ =~ line ! tmp = {'TMH' => $1.to_i, ! 'range' => Range.new($2.to_i, $3.to_i), ! 'grade' => $4, ! 'seq' => $5 } ! @tmh.push(tmp) ! end ! end end From k at pub.open-bio.org Wed Sep 7 21:22:12 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:50:55 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/hmmer report.rb,1.5,1.6 Message-ID: <200509080122.j881MCdZ009078@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/hmmer In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/appl/hmmer Modified Files: report.rb Log Message: * expanded tab at the line head Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/hmmer/report.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** report.rb 9 Aug 2005 09:58:19 -0000 1.5 --- report.rb 8 Sep 2005 01:22:09 -0000 1.6 *************** *** 33,42 **** @query_info =parse_query_info($3) ! case @program['name'] ! when /hmmsearch/ ! is_hmmsearch = true ! else ! is_hmmsearch = false # hmmpfam ! end # Scores for complete sequences. (parsed to Hit objects) --- 33,42 ---- @query_info =parse_query_info($3) ! case @program['name'] ! when /hmmsearch/ ! is_hmmsearch = true ! else ! is_hmmsearch = false # hmmpfam ! end # Scores for complete sequences. (parsed to Hit objects) *************** *** 62,67 **** $1.split(/^\S+.*?\n/).slice(1..-1).each_with_index do |al,k| al2 = al.gsub(/\n\n/,"\n").to_s.collect { |l| ! l.sub(/^.{19}/,'').sub(/\s(\d+|-)\s*$/,'') ! } align = ['', '', ''] al2.each_with_index { |s,i| align[i%3] += s.chomp } --- 62,67 ---- $1.split(/^\S+.*?\n/).slice(1..-1).each_with_index do |al,k| al2 = al.gsub(/\n\n/,"\n").to_s.collect { |l| ! l.sub(/^.{19}/,'').sub(/\s(\d+|-)\s*$/,'') ! } align = ['', '', ''] al2.each_with_index { |s,i| align[i%3] += s.chomp } *************** *** 108,118 **** end attr_reader :program, :parameter, :query_info, :hits, ! :histogram, :statistical_detail, :total_seq_searched, ! :whole_seq_top_hits, :domain_top_hits def each ! @hits.each do |x| ! yield x ! end end --- 108,118 ---- end attr_reader :program, :parameter, :query_info, :hits, ! :histogram, :statistical_detail, :total_seq_searched, ! :whole_seq_top_hits, :domain_top_hits def each ! @hits.each do |x| ! yield x ! end end *************** *** 122,127 **** @is_hmmsearch = is_hmmsearch ! @accession, @domain, seq_f, seq_t, @seq_ft, hmm_f, hmm_t, @hmm_ft, ! score, evalue = data.split(' ') @seq_f = seq_f.to_i @seq_t = seq_t.to_i --- 122,127 ---- @is_hmmsearch = is_hmmsearch ! @accession, @domain, seq_f, seq_t, @seq_ft, hmm_f, hmm_t, @hmm_ft, ! score, evalue = data.split(' ') @seq_f = seq_f.to_i @seq_t = seq_t.to_i *************** *** 137,142 **** end attr_accessor :accession, :domain, :seq_f, :seq_t, :seq_ft, ! :hmm_f, :hmm_t, :hmm_ft, :score, :evalue, :midline, :hmmseq, ! :flatseq, :query_frame, :target_frame def query_seq --- 137,142 ---- end attr_accessor :accession, :domain, :seq_f, :seq_t, :seq_ft, ! :hmm_f, :hmm_t, :hmm_ft, :score, :evalue, :midline, :hmmseq, ! :flatseq, :query_frame, :target_frame def query_seq *************** *** 174,178 **** if /^(\S+)\s+(.*)\s+(\S+)\s+(\S+)\s+(\S+)$/ =~ data @accession, @description, @score, @evalue, @num = ! [$1, $2, $3.to_f, $4.to_f, $5.to_i] end end --- 174,178 ---- if /^(\S+)\s+(.*)\s+(\S+)\s+(\S+)\s+(\S+)$/ =~ data @accession, @description, @score, @evalue, @num = ! [$1, $2, $3.to_f, $4.to_f, $5.to_i] end end *************** *** 206,210 **** hash = {} hash['name'], hash['version'], hash['copyright'], hash['license'] = ! data.split(/\n/) hash end --- 206,210 ---- hash = {} hash['name'], hash['version'], hash['copyright'], hash['license'] = ! data.split(/\n/) hash end From k at pub.open-bio.org Wed Sep 7 21:22:12 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:50:55 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/mafft report.rb,1.3,1.4 Message-ID: <200509080122.j881MCdZ009081@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/mafft In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/appl/mafft Modified Files: report.rb Log Message: * expanded tab at the line head Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/mafft/report.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** report.rb 4 Mar 2005 04:48:41 -0000 1.3 --- report.rb 8 Sep 2005 01:22:10 -0000 1.4 *************** *** 30,47 **** def initialize(ary, seqclass = nil) ! @data = ary ! @align = nil ! case seqclass ! when /PROTEIN/i ! @seqclass = Bio::Sequence::AA ! when /[DR]NA/i ! @seqclass = Bio::Sequence::NA ! else ! if seqclass.is_a?(Module) then ! @seqclass = seqclass ! else ! @seqclass = Bio::Sequence ! end ! end end attr_reader :data --- 30,47 ---- def initialize(ary, seqclass = nil) ! @data = ary ! @align = nil ! case seqclass ! when /PROTEIN/i ! @seqclass = Bio::Sequence::AA ! when /[DR]NA/i ! @seqclass = Bio::Sequence::NA ! else ! if seqclass.is_a?(Module) then ! @seqclass = seqclass ! else ! @seqclass = Bio::Sequence ! end ! end end attr_reader :data *************** *** 49,72 **** def align ! do_parse() unless @align ! @align end alias :alignment :align def to_fasta(*arg) ! align.to_fasta(*arg) end def to_a ! @data end private def do_parse ! return nil if @align ! @align = Bio::Alignment.new(@data) do |x| ! [ @seqclass.new(x.seq), x.definition ] ! end ! nil end --- 49,72 ---- def align ! do_parse() unless @align ! @align end alias :alignment :align def to_fasta(*arg) ! align.to_fasta(*arg) end def to_a ! @data end private def do_parse ! return nil if @align ! @align = Bio::Alignment.new(@data) do |x| ! [ @seqclass.new(x.seq), x.definition ] ! end ! nil end From k at pub.open-bio.org Wed Sep 7 21:22:12 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:50:56 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/psort report.rb,1.7,1.8 Message-ID: <200509080122.j881MCdZ009084@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/psort In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/appl/psort Modified Files: report.rb Log Message: * expanded tab at the line head Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/psort/report.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** report.rb 13 Jun 2004 09:26:11 -0000 1.7 --- report.rb 8 Sep 2005 01:22:10 -0000 1.8 *************** *** 32,78 **** class Report ! def self.parser(str) ! self.default_parser(str) ! end ! ! def self.default_parser(str) ! rpt = self.new ! rpt.raw = str ! query_info = str.scan(/^Query Information\n\n(.+?)\n\n/m)[0][0].split(/\n/) ! result_info = str.scan(/^Result Information\n\n(.+?)\n\n\*/m)[0][0] ! step1 = str.scan(/^\*\*\* Reasoning Step: 1\n\n(.+?)\n\n/m)[0][0] ! step2 = str.scan(/^\*\*\* Reasoning Step: 2\n\n(.+?)\n\n/m)[0][0] ! final_result = str.scan(/\n\n----- Final Results -----\n\n(.+?)\n\n\n/m)[0][0] ! rpt.entry_id = query_info[2].scan(/^>(\S+) */).to_s ! rpt.origin = query_info[0].scan(/ORIGIN (\w+)/).to_s ! rpt.sequence = Bio::Sequence::AA.new(query_info[3..query_info.size].to_s) ! # rpt.reasoning ! rpt.final_result = final_result.split(/\n/).map {|x| ! x = x.strip.split(/---/).map {|y| y.strip } ! { 'prediction' => x[0], ! 'certainty' => x[1].scan(/Certainty= (\d\.\d{3})/).to_s, ! 'comment' => x[1].scan(/\((\w+)\)/).to_s ! } ! } ! return rpt ! end ! # new ! def initialize(entry_id = '', origin = '', title = '', sequence = '', ! result_info = '', reasoning = {}, final_result = []) ! @entry_id = entry_id ! @origin = origin ! @title = title ! @sequence = sequence ! @result_info = result_info ! @reasoning = reasoning ! @final_result = final_result ! @raw = '' ! end ! attr_accessor :entry_id, :origin, :title, :sequence, ! :result_info, :reasoning,:final_result, :raw --- 32,78 ---- class Report ! def self.parser(str) ! self.default_parser(str) ! end ! ! def self.default_parser(str) ! rpt = self.new ! rpt.raw = str ! query_info = str.scan(/^Query Information\n\n(.+?)\n\n/m)[0][0].split(/\n/) ! result_info = str.scan(/^Result Information\n\n(.+?)\n\n\*/m)[0][0] ! step1 = str.scan(/^\*\*\* Reasoning Step: 1\n\n(.+?)\n\n/m)[0][0] ! step2 = str.scan(/^\*\*\* Reasoning Step: 2\n\n(.+?)\n\n/m)[0][0] ! final_result = str.scan(/\n\n----- Final Results -----\n\n(.+?)\n\n\n/m)[0][0] ! rpt.entry_id = query_info[2].scan(/^>(\S+) */).to_s ! rpt.origin = query_info[0].scan(/ORIGIN (\w+)/).to_s ! rpt.sequence = Bio::Sequence::AA.new(query_info[3..query_info.size].to_s) ! # rpt.reasoning ! rpt.final_result = final_result.split(/\n/).map {|x| ! x = x.strip.split(/---/).map {|y| y.strip } ! { 'prediction' => x[0], ! 'certainty' => x[1].scan(/Certainty= (\d\.\d{3})/).to_s, ! 'comment' => x[1].scan(/\((\w+)\)/).to_s ! } ! } ! return rpt ! end ! # new ! def initialize(entry_id = '', origin = '', title = '', sequence = '', ! result_info = '', reasoning = {}, final_result = []) ! @entry_id = entry_id ! @origin = origin ! @title = title ! @sequence = sequence ! @result_info = result_info ! @reasoning = reasoning ! @final_result = final_result ! @raw = '' ! end ! attr_accessor :entry_id, :origin, :title, :sequence, ! :result_info, :reasoning,:final_result, :raw *************** *** 86,176 **** SclNames = { ! 'csk' => 'cytoskeletal', ! 'cyt' => 'cytoplasmic', ! 'nuc' => 'nuclear', ! 'mit' => 'mitochondrial', ! 'ves' => 'vesicles of secretory system', ! 'end' => 'endoplasmic reticulum', ! 'gol' => 'Golgi', ! 'vac' => 'vacuolar', ! 'pla' => 'plasma membrane', ! 'pox' => 'peroxisomal', ! 'exc' => 'extracellular, including cell wall', ! '---' => 'other' } Features = [ ! 'psg', # PSG: PSG score ! 'gvh', # GvH: GvH score ! 'alm', # ALOM: $xmax ! 'tms', # ALOM: $count ! 'top', # MTOP: Charge difference: $mtopscr ! 'mit', # MITDISC: Score: $score ! 'mip', # Gavel: motif at $isite ! 'nuc', # NUCDISC: NLS Score: $score ! 'erl', # KDEL: ($seg|none) ! 'erm', # ER Membrane Retention Signals: ($cseg|none) $scr ! 'pox', # SKL: ($pat|none) $scr ! 'px2', # PTS2: (found|none) ($#match < 0) ? 0 : ($#match+1); ! 'vac', # VAC: (found|none) ($#match < 0) ? 0 : ($#match+1); ! 'rnp', # RNA-binding motif: (found|none) ($#match < 0) ? 0 : ($#match+1); ! 'act', # Actinin-type actin-binding motif: (found|none) $hit ! 'caa', # Prenylation motif: (2|1|0) CaaX,CXC,CC,nil ! 'yqr', # memYQRL: (found|none) $scr ! 'tyr', # Tyrosines in the tail: (none|\S+[,]) ! # 10 * scalar(@ylist) / ($end - $start + 1); ! 'leu', # Dileucine motif in the tail: (none|found) $scr ! 'gpi', # >>> Seem to be GPI anchored ! 'myr', # NMYR: (none|\w) $scr ! 'dna', # checking 63 PROSITE DNA binding motifs: $hit ! 'rib', # checking 71 PROSITE ribosomal protein motifs: $hit ! 'bac', # checking 33 PROSITE prokaryotic DNA binding motifs: $hit ! 'm1a', # $mtype eq '1a' ! 'm1b', # $mtype eq '1b' ! 'm2', # $mtype eq '2 ' ! 'mNt', # $mtype eq 'Nt' ! 'm3a', # $mtype eq '3a' ! 'm3b', # $mtype eq '3b' ! 'm_', # $mtype eq '__' tms == 0 ! 'ncn', # NNCN: ($NetOutput[1] > $NetOutput[0]) ? $output : (-$output); ! 'lps', # COIL: $count ! 'len' # $leng ] FeaturesLong = { ! 'psg' => 'PSG', ! 'gvh' => 'GvH', ! 'tms' => 'ALOM', ! 'alm' => 'ALOM', ! 'top' => 'MTOP', ! 'mit' => 'MITDISC', ! 'mip' => 'Gavel', ! 'nuc' => 'NUCDISC', ! 'erl' => 'KDEL', ! 'erm' => 'ER Membrane Retention Signals', ! 'pox' => 'SKL', ! 'px2' => 'PTS2', ! 'vac' => 'VAC', ! 'rnp' => 'RNA-binding motif', ! 'act' => 'Actinin-type actin-binding motif', ! 'caa' => 'Prenylation motif', ! 'yqr' => 'memYQRL', ! 'tyr' => 'Tyrosines in the tail', ! 'leu' => 'Dileucine motif in the tail', ! 'gpi' => '>>> Seems to be GPI anchored', ! 'myr' => 'NMYR', ! 'dna' => 'checking 63 PROSITE DNA binding motifs', ! 'rib' => 'checking 71 PROSITE ribosomal protein motifs', ! 'bac' => 'ochecking 33 PROSITE prokaryotic DNA binding motifs:', ! 'm1a' => '', ! 'm1b' => '', ! 'm2' => '', ! 'mNt' => '', ! 'm3a' => '', ! 'm3b' => '', ! 'm_' => '', ! 'ncn' => 'NNCN', ! 'lps' => 'COIL', ! 'len' => 'AA' # length of input sequence } --- 86,176 ---- SclNames = { ! 'csk' => 'cytoskeletal', ! 'cyt' => 'cytoplasmic', ! 'nuc' => 'nuclear', ! 'mit' => 'mitochondrial', ! 'ves' => 'vesicles of secretory system', ! 'end' => 'endoplasmic reticulum', ! 'gol' => 'Golgi', ! 'vac' => 'vacuolar', ! 'pla' => 'plasma membrane', ! 'pox' => 'peroxisomal', ! 'exc' => 'extracellular, including cell wall', ! '---' => 'other' } Features = [ ! 'psg', # PSG: PSG score ! 'gvh', # GvH: GvH score ! 'alm', # ALOM: $xmax ! 'tms', # ALOM: $count ! 'top', # MTOP: Charge difference: $mtopscr ! 'mit', # MITDISC: Score: $score ! 'mip', # Gavel: motif at $isite ! 'nuc', # NUCDISC: NLS Score: $score ! 'erl', # KDEL: ($seg|none) ! 'erm', # ER Membrane Retention Signals: ($cseg|none) $scr ! 'pox', # SKL: ($pat|none) $scr ! 'px2', # PTS2: (found|none) ($#match < 0) ? 0 : ($#match+1); ! 'vac', # VAC: (found|none) ($#match < 0) ? 0 : ($#match+1); ! 'rnp', # RNA-binding motif: (found|none) ($#match < 0) ? 0 : ($#match+1); ! 'act', # Actinin-type actin-binding motif: (found|none) $hit ! 'caa', # Prenylation motif: (2|1|0) CaaX,CXC,CC,nil ! 'yqr', # memYQRL: (found|none) $scr ! 'tyr', # Tyrosines in the tail: (none|\S+[,]) ! # 10 * scalar(@ylist) / ($end - $start + 1); ! 'leu', # Dileucine motif in the tail: (none|found) $scr ! 'gpi', # >>> Seem to be GPI anchored ! 'myr', # NMYR: (none|\w) $scr ! 'dna', # checking 63 PROSITE DNA binding motifs: $hit ! 'rib', # checking 71 PROSITE ribosomal protein motifs: $hit ! 'bac', # checking 33 PROSITE prokaryotic DNA binding motifs: $hit ! 'm1a', # $mtype eq '1a' ! 'm1b', # $mtype eq '1b' ! 'm2', # $mtype eq '2 ' ! 'mNt', # $mtype eq 'Nt' ! 'm3a', # $mtype eq '3a' ! 'm3b', # $mtype eq '3b' ! 'm_', # $mtype eq '__' tms == 0 ! 'ncn', # NNCN: ($NetOutput[1] > $NetOutput[0]) ? $output : (-$output); ! 'lps', # COIL: $count ! 'len' # $leng ] FeaturesLong = { ! 'psg' => 'PSG', ! 'gvh' => 'GvH', ! 'tms' => 'ALOM', ! 'alm' => 'ALOM', ! 'top' => 'MTOP', ! 'mit' => 'MITDISC', ! 'mip' => 'Gavel', ! 'nuc' => 'NUCDISC', ! 'erl' => 'KDEL', ! 'erm' => 'ER Membrane Retention Signals', ! 'pox' => 'SKL', ! 'px2' => 'PTS2', ! 'vac' => 'VAC', ! 'rnp' => 'RNA-binding motif', ! 'act' => 'Actinin-type actin-binding motif', ! 'caa' => 'Prenylation motif', ! 'yqr' => 'memYQRL', ! 'tyr' => 'Tyrosines in the tail', ! 'leu' => 'Dileucine motif in the tail', ! 'gpi' => '>>> Seems to be GPI anchored', ! 'myr' => 'NMYR', ! 'dna' => 'checking 63 PROSITE DNA binding motifs', ! 'rib' => 'checking 71 PROSITE ribosomal protein motifs', ! 'bac' => 'ochecking 33 PROSITE prokaryotic DNA binding motifs:', ! 'm1a' => '', ! 'm1b' => '', ! 'm2' => '', ! 'mNt' => '', ! 'm3a' => '', ! 'm3b' => '', ! 'm_' => '', ! 'ncn' => 'NNCN', ! 'lps' => 'COIL', ! 'len' => 'AA' # length of input sequence } *************** *** 178,364 **** class Report ! BOUNDARY = '-' * 75 ! RS = DELIMITER = "\)\n\n#{BOUNDARY}" ! def initialize(raw = '', entry_id = nil, scl = nil, definition = nil, ! seq = nil, k = nil, features = {}, prob = {}, pred = nil) ! @entry_id = entry_id ! @scl = scl ! @definition = definition ! @seq = seq ! @features = features ! @prob = prob ! @pred = pred ! @k = k ! @raw = raw ! end ! attr_accessor :entry_id, :scl, :definition, :seq, ! :k, :features, :prob, :pred, :raw ! ! # report format to be auto detection ! def self.parser(str, entry_id) ! case str ! when /^ psg:/ # default report ! self.default_parser(str, entry_id) ! when /^PSG:/ # -v report ! self.v_parser(str, entry_id) ! when /: too short length / ! self.too_short_parser(str, entry_id) ! when /PSORT II server/ ! tmp = self.new(ent, entry_id) ! else ! raise ArgumentError, "invalid format\n[#{str}]" ! end ! end ! # $id: too short length ($leng), skipped\n"; ! def self.too_short_parser(ent, entry_id = nil) ! report = self.new(ent) ! report.entry_id = entry_id ! if ent =~ /^(.+)?: too short length/ ! report.entry_id = $1 unless report.entry_id ! report.scl = '---' ! end ! report ! end ! # default report ! # ``psort test.faa'' output ! def self.default_parser(ent, entry_id = nil) ! report = self.new(ent, entry_id) ! ent = ent.split(/\n\n/).map {|e| e.chomp } ! report.set_header_line(ent[0]) ! # feature matrix ! ent[1].gsub(/\n/,' ').strip.split(/ /).map {|fe| ! pair = fe.split(/: /) ! report.features[pair[0].strip] = pair[1].strip.to_f ! } ! report.prob = self.set_kNN_prob(ent[2]) ! report.set_prediction(ent[3]) ! return report ! end ! def set_header_line(str) ! str.sub!(/^-+\n/,'') ! tmp = str.split(/\t| /) ! @entry_id = tmp.shift.sub(/^-+/,'').strip unless @entry_id ! case tmp.join(' ').chomp ! when /\(\d+ aa\) (.+)$/ ! @definition = $1 ! else ! @definition = tmp.join(' ').chomp ! end ! scl = @definition.split(' ')[0] ! @scl = scl if SclNames.keys.index(scl) ! end ! def self.set_kNN_prob(str) ! prob = Hash.new ! Bio::PSORT::PSORT2::SclNames.keys.each {|a| ! prob.update( {a => 0.0} ) ! } ! str.gsub(/\t/,'').split(/\n/).each {|a| ! val,scl = a.strip.split(/ %: /) ! key = Bio::PSORT::PSORT2::SclNames.index(scl) ! prob[key] = val.to_f ! } ! return prob ! end ! def set_prediction(str) ! case str ! when /prediction for (\S+?) is (\w{3}) \(k=(\d+)\)/ ! @entry_id ||= $1 unless @entry_id ! @pred = $2 ! @k = $3 ! else ! raise ArgumentError, ! "Invalid format at(#{self.entry_id}):\n[#{str}]\n" ! end ! end ! # ``psort -v report'' and WWW server output ! def self.v_parser(ent, entry_id = nil) ! report = Bio::PSORT::PSORT2::Report.new(ent, entry_id) ! ent = ent.split(/\n\n/).map {|e| e.chomp } ! ent.each_with_index {|e, i| ! unless /^(\w|-|\>|\t)/ =~ e ! j = self.__send__(:search_j, i, ent) ! ent[i - j] += e ! ent[i] = nil ! end ! if /^none/ =~ e # for psort output bug ! j = self.__send__(:search_j, i, ent) ! ent[i - j] += e ! ent[i] = nil ! end ! } ! ent.compact! ! # ent.each_with_index {|e,i| p [i.to_s.ljust(2), e] } ! if /^ PSORT II server/ =~ ent[0] # for WWW version ! ent.shift ! delline = '' ! ent.each {|e| delline = e if /^Results of Subprograms/ =~ e } ! i = ent.index(delline) ! ent.delete(delline) ! ent.delete_at(i - 1) ! end ! report.set_header_line(ent.shift) ! report.seq = Bio::Sequence::AA.new(ent.shift) ! fent, pent = self.divent(ent) ! report.set_features(fent) ! report.prob = self.set_kNN_prob(pent[0].strip) ! report.set_prediction(pent[1].strip) ! return report ! end ! def self.search_j(i, ent) ! j = 1 ! 1.upto(ent.size) {|x| ! if ent[i - x] ! j = x ! break ! end ! } ! return j ! end ! private_class_method :search_j ! # divide entry body ! def self.divent(ent) ! boundary = ent.index(BOUNDARY) ! return ent[0..(boundary - 1)], ent[(boundary + 2)..ent.length] ! end ! def set_features(fary) ! fary.each {|fent| ! key = fent.split(/\:( |\n)/)[0].strip ! self.features[key] = fent # unless /^\>/ =~ key ! } ! self.features['AA'] = self.seq.length ! end ! end # class Report --- 178,364 ---- class Report ! BOUNDARY = '-' * 75 ! RS = DELIMITER = "\)\n\n#{BOUNDARY}" ! def initialize(raw = '', entry_id = nil, scl = nil, definition = nil, ! seq = nil, k = nil, features = {}, prob = {}, pred = nil) ! @entry_id = entry_id ! @scl = scl ! @definition = definition ! @seq = seq ! @features = features ! @prob = prob ! @pred = pred ! @k = k ! @raw = raw ! end ! attr_accessor :entry_id, :scl, :definition, :seq, ! :k, :features, :prob, :pred, :raw ! ! # report format to be auto detection ! def self.parser(str, entry_id) ! case str ! when /^ psg:/ # default report ! self.default_parser(str, entry_id) ! when /^PSG:/ # -v report ! self.v_parser(str, entry_id) ! when /: too short length / ! self.too_short_parser(str, entry_id) ! when /PSORT II server/ ! tmp = self.new(ent, entry_id) ! else ! raise ArgumentError, "invalid format\n[#{str}]" ! end ! end ! # $id: too short length ($leng), skipped\n"; ! def self.too_short_parser(ent, entry_id = nil) ! report = self.new(ent) ! report.entry_id = entry_id ! if ent =~ /^(.+)?: too short length/ ! report.entry_id = $1 unless report.entry_id ! report.scl = '---' ! end ! report ! end ! # default report ! # ``psort test.faa'' output ! def self.default_parser(ent, entry_id = nil) ! report = self.new(ent, entry_id) ! ent = ent.split(/\n\n/).map {|e| e.chomp } ! report.set_header_line(ent[0]) ! # feature matrix ! ent[1].gsub(/\n/,' ').strip.split(/ /).map {|fe| ! pair = fe.split(/: /) ! report.features[pair[0].strip] = pair[1].strip.to_f ! } ! report.prob = self.set_kNN_prob(ent[2]) ! report.set_prediction(ent[3]) ! return report ! end ! def set_header_line(str) ! str.sub!(/^-+\n/,'') ! tmp = str.split(/\t| /) ! @entry_id = tmp.shift.sub(/^-+/,'').strip unless @entry_id ! case tmp.join(' ').chomp ! when /\(\d+ aa\) (.+)$/ ! @definition = $1 ! else ! @definition = tmp.join(' ').chomp ! end ! scl = @definition.split(' ')[0] ! @scl = scl if SclNames.keys.index(scl) ! end ! def self.set_kNN_prob(str) ! prob = Hash.new ! Bio::PSORT::PSORT2::SclNames.keys.each {|a| ! prob.update( {a => 0.0} ) ! } ! str.gsub(/\t/,'').split(/\n/).each {|a| ! val,scl = a.strip.split(/ %: /) ! key = Bio::PSORT::PSORT2::SclNames.index(scl) ! prob[key] = val.to_f ! } ! return prob ! end ! def set_prediction(str) ! case str ! when /prediction for (\S+?) is (\w{3}) \(k=(\d+)\)/ ! @entry_id ||= $1 unless @entry_id ! @pred = $2 ! @k = $3 ! else ! raise ArgumentError, ! "Invalid format at(#{self.entry_id}):\n[#{str}]\n" ! end ! end ! # ``psort -v report'' and WWW server output ! def self.v_parser(ent, entry_id = nil) ! report = Bio::PSORT::PSORT2::Report.new(ent, entry_id) ! ent = ent.split(/\n\n/).map {|e| e.chomp } ! ent.each_with_index {|e, i| ! unless /^(\w|-|\>|\t)/ =~ e ! j = self.__send__(:search_j, i, ent) ! ent[i - j] += e ! ent[i] = nil ! end ! if /^none/ =~ e # for psort output bug ! j = self.__send__(:search_j, i, ent) ! ent[i - j] += e ! ent[i] = nil ! end ! } ! ent.compact! ! # ent.each_with_index {|e,i| p [i.to_s.ljust(2), e] } ! if /^ PSORT II server/ =~ ent[0] # for WWW version ! ent.shift ! delline = '' ! ent.each {|e| delline = e if /^Results of Subprograms/ =~ e } ! i = ent.index(delline) ! ent.delete(delline) ! ent.delete_at(i - 1) ! end ! report.set_header_line(ent.shift) ! report.seq = Bio::Sequence::AA.new(ent.shift) ! fent, pent = self.divent(ent) ! report.set_features(fent) ! report.prob = self.set_kNN_prob(pent[0].strip) ! report.set_prediction(pent[1].strip) ! return report ! end ! def self.search_j(i, ent) ! j = 1 ! 1.upto(ent.size) {|x| ! if ent[i - x] ! j = x ! break ! end ! } ! return j ! end ! private_class_method :search_j ! # divide entry body ! def self.divent(ent) ! boundary = ent.index(BOUNDARY) ! return ent[0..(boundary - 1)], ent[(boundary + 2)..ent.length] ! end ! def set_features(fary) ! fary.each {|fent| ! key = fent.split(/\:( |\n)/)[0].strip ! self.features[key] = fent # unless /^\>/ =~ key ! } ! self.features['AA'] = self.seq.length ! end ! end # class Report From k at pub.open-bio.org Wed Sep 7 21:22:12 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:50:56 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/spidey report.rb,1.2,1.3 Message-ID: <200509080122.j881MCdZ009095@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/spidey In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/appl/spidey Modified Files: report.rb Log Message: * expanded tab at the line head Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/spidey/report.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** report.rb 13 Oct 2004 16:53:03 -0000 1.2 --- report.rb 8 Sep 2005 01:22:10 -0000 1.3 *************** *** 33,41 **** def initialize(str) ! str = str.sub(/\A\s+/, '') ! str.sub!(/\n(^\-\-SPIDEY .*)/m, '') # remove trailing entries for sure ! @entry_overrun = $1 ! data = str.split(/\r?\n(?:\r?\n)+/) ! d0 = data.shift.to_s.split(/\r?\n/) @hit = Hit.new(data, d0) @all_hits = [ @hit ] --- 33,41 ---- def initialize(str) ! str = str.sub(/\A\s+/, '') ! str.sub!(/\n(^\-\-SPIDEY .*)/m, '') # remove trailing entries for sure ! @entry_overrun = $1 ! data = str.split(/\r?\n(?:\r?\n)+/) ! d0 = data.shift.to_s.split(/\r?\n/) @hit = Hit.new(data, d0) @all_hits = [ @hit ] *************** *** 58,68 **** attr_reader :entry_id, :definition, :len ! def self.parse(str) ! /^(Genomic|mRNA)\:\s*(([^\s]*) (.+))\, (\d+) bp\s*$/ =~ str.to_s ! seqid = $3 seqdef = $2 ! len = ($5 ? $5.to_i : nil) self.new(seqid, seqdef, len) ! end end #class SeqDesc --- 58,68 ---- attr_reader :entry_id, :definition, :len ! def self.parse(str) ! /^(Genomic|mRNA)\:\s*(([^\s]*) (.+))\, (\d+) bp\s*$/ =~ str.to_s ! seqid = $3 seqdef = $2 ! len = ($5 ? $5.to_i : nil) self.new(seqid, seqdef, len) ! end end #class SeqDesc *************** *** 89,94 **** genomic = Segment.new(from, to, strand, aln[0]) mrna = Segment.new(nil, nil, nil, aln[2]) ! midline = aln[1] ! aaseqline = aln[3] self.new(genomic, mrna, midline, aaseqline, nil, nil, nil, nil, nil) --- 89,94 ---- genomic = Segment.new(from, to, strand, aln[0]) mrna = Segment.new(nil, nil, nil, aln[2]) ! midline = aln[1] ! aaseqline = aln[3] self.new(genomic, mrna, midline, aaseqline, nil, nil, nil, nil, nil) *************** *** 96,100 **** def self.parse(str, strand, complement, aln) ! /\AExon\s*\d+(\(\-\))?\:\s*(\d+)\-(\d+)\s*\(gen\)\s+(\d+)\-(\d+)\s*\(mRNA\)\s+id\s*([\d\.]+)\s*\%\s+mismatches\s+(\d+)\s+gaps\s+(\d+)\s+splice site\s*\(d +a\)\s*\:\s*(\d+)\s+(\d+)/ =~ str if strand == 'minus' then genomic = Segment.new($3, $2, strand, aln[0]) --- 96,100 ---- def self.parse(str, strand, complement, aln) ! /\AExon\s*\d+(\(\-\))?\:\s*(\d+)\-(\d+)\s*\(gen\)\s+(\d+)\-(\d+)\s*\(mRNA\)\s+id\s*([\d\.]+)\s*\%\s+mismatches\s+(\d+)\s+gaps\s+(\d+)\s+splice site\s*\(d +a\)\s*\:\s*(\d+)\s+(\d+)/ =~ str if strand == 'minus' then genomic = Segment.new($3, $2, strand, aln[0]) *************** *** 107,123 **** mrna = Segment.new($4, $5, 'plus', aln[2]) end ! percent_identity = $6 ! mismatches = ($7 ? $7.to_i : nil) ! gaps = ($8 ? $8.to_i : nil) ! splice_site = { ! :d => ($9 ? $9.to_i : nil), ! :a => ($10 ? $10.to_i : nil) ! } ! midline = aln[1] ! aaseqline = aln[3] self.new(genomic, mrna, midline, aaseqline, percent_identity, mismatches, gaps, splice_site, (midline ? midline.length : nil)) ! end # Bio::BLAST::*::Report::Hsp compatible methods --- 107,123 ---- mrna = Segment.new($4, $5, 'plus', aln[2]) end ! percent_identity = $6 ! mismatches = ($7 ? $7.to_i : nil) ! gaps = ($8 ? $8.to_i : nil) ! splice_site = { ! :d => ($9 ? $9.to_i : nil), ! :a => ($10 ? $10.to_i : nil) ! } ! midline = aln[1] ! aaseqline = aln[3] self.new(genomic, mrna, midline, aaseqline, percent_identity, mismatches, gaps, splice_site, (midline ? midline.length : nil)) ! end # Bio::BLAST::*::Report::Hsp compatible methods From k at pub.open-bio.org Wed Sep 7 21:22:10 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:50:57 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/bl2seq report.rb,1.2,1.3 Message-ID: <200509080122.j881MAdZ009052@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/bl2seq In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/appl/bl2seq Modified Files: report.rb Log Message: * expanded tab at the line head Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/bl2seq/report.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** report.rb 10 Aug 2005 12:55:41 -0000 1.2 --- report.rb 8 Sep 2005 01:22:08 -0000 1.3 *************** *** 37,91 **** undef format0_parse_header undef program, version, version_number, version_date, ! message, converged?, reference, db def format0_split_headers(data) ! @f0query = data.shift end def format0_split_search(data) ! iterations = [] ! while r = data[0] and /^\>/ =~ r ! iterations << Iteration.new(data) ! end ! if iterations.size <= 0 then ! iterations << Iteration.new(data) ! end ! iterations end class F0dbstat < Bio::Blast::Default::Report::F0dbstat ! def db_num ! unless defined?(@db_num) ! parse_params ! @db_num = @hash['Number of Sequences'].to_i ! end ! @db_num ! end ! def db_len ! unless defined?(@db_len) ! parse_params ! @db_len = @hash['length of database'].to_i ! end ! @db_len ! end end #class F0dbstat class Iteration < Bio::Blast::Default::Report::Iteration ! def initialize(data) ! @f0stat = [] ! @f0dbstat = nil ! @hits = [] ! @num = 1 ! while r = data[0] and /^\>/ =~ r ! @hits << Hit.new(data) ! end ! end ! def hits; @hits; end ! undef message, pattern_in_database, f0message, f0hitlist, ! pattern, pattern_positions, hits_found_again, ! hits_newly_found, hits_for_pattern, parse_hitlist, ! converged? end #class Iteration --- 37,91 ---- undef format0_parse_header undef program, version, version_number, version_date, ! message, converged?, reference, db def format0_split_headers(data) ! @f0query = data.shift end def format0_split_search(data) ! iterations = [] ! while r = data[0] and /^\>/ =~ r ! iterations << Iteration.new(data) ! end ! if iterations.size <= 0 then ! iterations << Iteration.new(data) ! end ! iterations end class F0dbstat < Bio::Blast::Default::Report::F0dbstat ! def db_num ! unless defined?(@db_num) ! parse_params ! @db_num = @hash['Number of Sequences'].to_i ! end ! @db_num ! end ! def db_len ! unless defined?(@db_len) ! parse_params ! @db_len = @hash['length of database'].to_i ! end ! @db_len ! end end #class F0dbstat class Iteration < Bio::Blast::Default::Report::Iteration ! def initialize(data) ! @f0stat = [] ! @f0dbstat = nil ! @hits = [] ! @num = 1 ! while r = data[0] and /^\>/ =~ r ! @hits << Hit.new(data) ! end ! end ! def hits; @hits; end ! undef message, pattern_in_database, f0message, f0hitlist, ! pattern, pattern_positions, hits_found_again, ! hits_newly_found, hits_for_pattern, parse_hitlist, ! converged? end #class Iteration From k at pub.open-bio.org Wed Sep 7 21:22:11 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:50:57 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/genscan report.rb,1.4,1.5 Message-ID: <200509080122.j881MBdZ009074@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/genscan In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/appl/genscan Modified Files: report.rb Log Message: * expanded tab at the line head Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/genscan/report.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** report.rb 7 Aug 2005 05:35:18 -0000 1.4 --- report.rb 8 Sep 2005 01:22:09 -0000 1.5 *************** *** 202,206 **** end ! # Bio::Genescan::Report::Gene#seq_naseq def set_naseq(seq) --- 202,206 ---- end ! # Bio::Genescan::Report::Gene#seq_naseq def set_naseq(seq) *************** *** 287,291 **** end ! # Bio::Genescan::Report::Exon#range def range --- 287,291 ---- end ! # Bio::Genescan::Report::Exon#range def range From k at pub.open-bio.org Wed Sep 7 21:22:11 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:50:58 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/clustalw report.rb,1.4,1.5 Message-ID: <200509080122.j881MBdZ009066@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/clustalw In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/appl/clustalw Modified Files: report.rb Log Message: * expanded tab at the line head Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/clustalw/report.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** report.rb 4 Mar 2005 04:48:41 -0000 1.4 --- report.rb 8 Sep 2005 01:22:09 -0000 1.5 *************** *** 32,51 **** def initialize(str, seqclass = nil) ! @raw = str ! @align = nil ! @match_line = nil ! @header = nil ! case seqclass ! when /PROTEIN/i ! @seqclass = Bio::Sequence::AA ! when /[DR]NA/i ! @seqclass = Bio::Sequence::NA ! else ! if seqclass.is_a?(Module) then ! @seqclass = seqclass ! else ! @seqclass = Bio::Sequence ! end ! end end attr_reader :raw --- 32,51 ---- def initialize(str, seqclass = nil) ! @raw = str ! @align = nil ! @match_line = nil ! @header = nil ! case seqclass ! when /PROTEIN/i ! @seqclass = Bio::Sequence::AA ! when /[DR]NA/i ! @seqclass = Bio::Sequence::NA ! else ! if seqclass.is_a?(Module) then ! @seqclass = seqclass ! else ! @seqclass = Bio::Sequence ! end ! end end attr_reader :raw *************** *** 53,107 **** def header ! @header or (do_parse or @header) end def match_line ! @match_line or (do_parse or @match_line) end def align ! do_parse() unless @align ! @align end alias :alignment :align def to_fasta(*arg) ! align.to_fasta(*arg) end def to_a ! align.to_fastaformat_array end private def do_parse ! return nil if @align ! a = @raw.split(/\r?\n\r?\n/) ! @header = a.shift.to_s ! xalign = Bio::Alignment.new ! @match_line = '' ! if a.size > 0 then ! a[0].gsub!(/\A(\r?\n)+/, '') ! a.collect! { |x| x.split(/\r?\n/) } a.each { |x| x.each { |y| y.sub!(/ +\d+\s*$/, '') }} #for -SEQNOS=on option ! @tagsize = ( a[0][0].rindex(/\s/) or -1 ) + 1 ! a.each do |x| ! @match_line << x.pop.to_s[@tagsize..-1] ! end ! a[0].each do |y| ! xalign.store(y[0, @tagsize].sub(/\s+\z/, ''), '') ! end ! a.each do |x| ! x.each do |y| ! name = y[0, @tagsize].sub(/\s+\z/, '') ! seq = y[@tagsize..-1] ! xalign[name] << seq ! end ! end ! xalign.collect! { |x| @seqclass.new(x) } ! end @align = xalign ! nil end --- 53,107 ---- def header ! @header or (do_parse or @header) end def match_line ! @match_line or (do_parse or @match_line) end def align ! do_parse() unless @align ! @align end alias :alignment :align def to_fasta(*arg) ! align.to_fasta(*arg) end def to_a ! align.to_fastaformat_array end private def do_parse ! return nil if @align ! a = @raw.split(/\r?\n\r?\n/) ! @header = a.shift.to_s ! xalign = Bio::Alignment.new ! @match_line = '' ! if a.size > 0 then ! a[0].gsub!(/\A(\r?\n)+/, '') ! a.collect! { |x| x.split(/\r?\n/) } a.each { |x| x.each { |y| y.sub!(/ +\d+\s*$/, '') }} #for -SEQNOS=on option ! @tagsize = ( a[0][0].rindex(/\s/) or -1 ) + 1 ! a.each do |x| ! @match_line << x.pop.to_s[@tagsize..-1] ! end ! a[0].each do |y| ! xalign.store(y[0, @tagsize].sub(/\s+\z/, ''), '') ! end ! a.each do |x| ! x.each do |y| ! name = y[0, @tagsize].sub(/\s+\z/, '') ! seq = y[@tagsize..-1] ! xalign[name] << seq ! end ! end ! xalign.collect! { |x| @seqclass.new(x) } ! end @align = xalign ! nil end From k at pub.open-bio.org Wed Sep 7 21:22:11 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:50:59 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/fasta format10.rb, 1.3, 1.4 format6.rb, 1.1, 1.2 Message-ID: <200509080122.j881MBdZ009070@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/fasta In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/appl/fasta Modified Files: format10.rb format6.rb Log Message: * expanded tab at the line head Index: format10.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/fasta/format10.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** format10.rb 3 Feb 2003 14:29:47 -0000 1.3 --- format10.rb 8 Sep 2005 01:22:09 -0000 1.4 *************** *** 27,259 **** def initialize(data) ! # header lines - brief list of the hits if data.sub!(/.*\nThe best scores are/m, '') ! data.sub!(/(.*)\n\n>>>/m, '') ! @list = "The best scores are" + $1 ! else ! data.sub!(/.*\n!!\s+/m, '') ! data.sub!(/.*/) { |x| @list = x; '' } ! end ! # body lines - fasta execution result ! program, *hits = data.split(/\n>>/) ! # trailing lines - log messages of the execution ! @log = hits.pop @log.sub!(/.*<\n/m, '') @log.strip! ! # parse results ! @program = Program.new(program) ! @hits = [] ! hits.each do |x| ! @hits.push(Hit.new(x)) ! end end attr_reader :list, :log, :program, :hits def each ! @hits.each do |x| ! yield x ! end end def threshold(evalue_max = 0.1) ! list = [] ! @hits.each do |x| ! list.push(x) if x.evalue < evalue_max ! end ! return list end def lap_over(length_min = 0) ! list = [] ! @hits.each do |x| ! list.push(x) if x.overlap > length_min ! end ! return list end class Program ! def initialize(data) ! @definition, *program = data.split(/\n/) ! @program = {} ! pat = /;\s+([^:]+):\s+(.*)/ ! program.each do |x| ! if pat.match(x) ! @program[$1] = $2 ! end ! end ! end ! attr_reader :definition, :program end class Hit ! def initialize(data) ! score, query, target = data.split(/\n>/) ! @definition, *score = score.split(/\n/) ! @score = {} ! pat = /;\s+([^:]+):\s+(.*)/ ! score.each do |x| ! if pat.match(x) ! @score[$1] = $2 ! end ! end ! @query = Query.new(query) ! @target = Target.new(target) ! end ! attr_reader :definition, :score, :query, :target ! def evalue ! if @score['fa_expect'] ! @score['fa_expect'].to_f ! elsif @score['sw_expect'] ! @score['sw_expect'].to_f ! elsif @score['fx_expect'] ! @score['fx_expect'].to_f ! elsif @score['tx_expect'] ! @score['tx_expect'].to_f ! end ! end ! def bit_score ! if @score['fa_bits'] ! @score['fa_bits'].to_f ! elsif @score['sw_bits'] ! @score['sw_bits'].to_f ! elsif @score['fx_bits'] ! @score['fx_bits'].to_f ! elsif @score['tx_bits'] ! @score['tx_bits'].to_f ! end ! end ! def direction ! @score['fa_frame'] || @score['sw_frame'] || @score['fx_frame'] || @score['tx_frame'] ! end ! def sw ! @score['sw_score'].to_i ! end ! def identity ! @score['sw_ident'].to_f ! end ! def overlap ! @score['sw_overlap'].to_i ! end ! def query_id ! @query.entry_id ! end ! def target_id ! @target.entry_id ! end ! def query_def ! @query.definition ! end ! def target_def ! @target.definition ! end ! def query_len ! @query.length ! end ! def target_len ! @target.length ! end ! def query_seq ! @query.sequence ! end ! def target_seq ! @target.sequence ! end ! def query_type ! @query.moltype ! end ! def target_type ! @target.moltype ! end ! def query_start ! @query.start ! end ! def query_end ! @query.stop ! end ! def target_start ! @target.start ! end ! def target_end ! @target.stop ! end ! def lap_at ! [ query_start, query_end, target_start, target_end ] ! end ! class Query ! def initialize(data) ! @definition, *data = data.split(/\n/) ! @data = {} ! @sequence = '' ! pat = /;\s+([^:]+):\s+(.*)/ ! data.each do |x| ! if pat.match(x) ! @data[$1] = $2 ! else ! @sequence += x ! end ! end ! end ! attr_reader :definition, :data, :sequence ! def entry_id ! @definition[/\S+/] ! end ! def length ! @data['sq_len'].to_i ! end ! def moltype ! @data['sq_type'] ! end ! def start ! @data['al_start'].to_i ! end ! def stop ! @data['al_stop'].to_i ! end ! end ! class Target < Query; end end --- 27,259 ---- def initialize(data) ! # header lines - brief list of the hits if data.sub!(/.*\nThe best scores are/m, '') ! data.sub!(/(.*)\n\n>>>/m, '') ! @list = "The best scores are" + $1 ! else ! data.sub!(/.*\n!!\s+/m, '') ! data.sub!(/.*/) { |x| @list = x; '' } ! end ! # body lines - fasta execution result ! program, *hits = data.split(/\n>>/) ! # trailing lines - log messages of the execution ! @log = hits.pop @log.sub!(/.*<\n/m, '') @log.strip! ! # parse results ! @program = Program.new(program) ! @hits = [] ! hits.each do |x| ! @hits.push(Hit.new(x)) ! end end attr_reader :list, :log, :program, :hits def each ! @hits.each do |x| ! yield x ! end end def threshold(evalue_max = 0.1) ! list = [] ! @hits.each do |x| ! list.push(x) if x.evalue < evalue_max ! end ! return list end def lap_over(length_min = 0) ! list = [] ! @hits.each do |x| ! list.push(x) if x.overlap > length_min ! end ! return list end class Program ! def initialize(data) ! @definition, *program = data.split(/\n/) ! @program = {} ! pat = /;\s+([^:]+):\s+(.*)/ ! program.each do |x| ! if pat.match(x) ! @program[$1] = $2 ! end ! end ! end ! attr_reader :definition, :program end class Hit ! def initialize(data) ! score, query, target = data.split(/\n>/) ! @definition, *score = score.split(/\n/) ! @score = {} ! pat = /;\s+([^:]+):\s+(.*)/ ! score.each do |x| ! if pat.match(x) ! @score[$1] = $2 ! end ! end ! @query = Query.new(query) ! @target = Target.new(target) ! end ! attr_reader :definition, :score, :query, :target ! def evalue ! if @score['fa_expect'] ! @score['fa_expect'].to_f ! elsif @score['sw_expect'] ! @score['sw_expect'].to_f ! elsif @score['fx_expect'] ! @score['fx_expect'].to_f ! elsif @score['tx_expect'] ! @score['tx_expect'].to_f ! end ! end ! def bit_score ! if @score['fa_bits'] ! @score['fa_bits'].to_f ! elsif @score['sw_bits'] ! @score['sw_bits'].to_f ! elsif @score['fx_bits'] ! @score['fx_bits'].to_f ! elsif @score['tx_bits'] ! @score['tx_bits'].to_f ! end ! end ! def direction ! @score['fa_frame'] || @score['sw_frame'] || @score['fx_frame'] || @score['tx_frame'] ! end ! def sw ! @score['sw_score'].to_i ! end ! def identity ! @score['sw_ident'].to_f ! end ! def overlap ! @score['sw_overlap'].to_i ! end ! def query_id ! @query.entry_id ! end ! def target_id ! @target.entry_id ! end ! def query_def ! @query.definition ! end ! def target_def ! @target.definition ! end ! def query_len ! @query.length ! end ! def target_len ! @target.length ! end ! def query_seq ! @query.sequence ! end ! def target_seq ! @target.sequence ! end ! def query_type ! @query.moltype ! end ! def target_type ! @target.moltype ! end ! def query_start ! @query.start ! end ! def query_end ! @query.stop ! end ! def target_start ! @target.start ! end ! def target_end ! @target.stop ! end ! def lap_at ! [ query_start, query_end, target_start, target_end ] ! end ! class Query ! def initialize(data) ! @definition, *data = data.split(/\n/) ! @data = {} ! @sequence = '' ! pat = /;\s+([^:]+):\s+(.*)/ ! data.each do |x| ! if pat.match(x) ! @data[$1] = $2 ! else ! @sequence += x ! end ! end ! end ! attr_reader :definition, :data, :sequence ! def entry_id ! @definition[/\S+/] ! end ! def length ! @data['sq_len'].to_i ! end ! def moltype ! @data['sq_type'] ! end ! def start ! @data['al_start'].to_i ! end ! def stop ! @data['al_stop'].to_i ! end ! end ! class Target < Query; end end Index: format6.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/fasta/format6.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** format6.rb 28 May 2002 14:49:07 -0000 1.1 --- format6.rb 8 Sep 2005 01:22:09 -0000 1.2 *************** *** 29,33 **** def initialize ! raise NotImplementedError end end --- 29,33 ---- def initialize ! raise NotImplementedError end end From k at pub.open-bio.org Wed Sep 7 21:22:10 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:51:01 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl blast.rb, 1.21, 1.22 clustalw.rb, 1.5, 1.6 emboss.rb, 1.1, 1.2 fasta.rb, 1.17, 1.18 mafft.rb, 1.4, 1.5 psort.rb, 1.4, 1.5 Message-ID: <200509080122.j881MAdZ009048@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/appl Modified Files: blast.rb clustalw.rb emboss.rb fasta.rb mafft.rb psort.rb Log Message: * expanded tab at the line head Index: emboss.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/emboss.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** emboss.rb 19 Aug 2002 02:49:29 -0000 1.1 --- emboss.rb 8 Sep 2005 01:22:08 -0000 1.2 *************** *** 31,39 **** def exec begin ! @io = IO.popen(@cmd_line, "w+") ! @result = @io.read ! return @result ensure ! @io.close end end --- 31,39 ---- def exec begin ! @io = IO.popen(@cmd_line, "w+") ! @result = @io.read ! return @result ensure ! @io.close end end Index: blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast.rb,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** blast.rb 16 Aug 2005 09:38:34 -0000 1.21 --- blast.rb 8 Sep 2005 01:22:08 -0000 1.22 *************** *** 36,42 **** def initialize(program, db, opt = [], server = 'local') if defined?(XMLParser) or defined?(REXML) ! @format = 7 else ! @format = 8 end --- 36,42 ---- def initialize(program, db, opt = [], server = 'local') if defined?(XMLParser) or defined?(REXML) ! @format = 7 else ! @format = 8 end *************** *** 118,130 **** form = { ! 'style' => 'raw', ! 'prog' => @program, ! 'dbname' => @db, ! 'sequence' => CGI.escape(query), ! 'other_param' => CGI.escape(make_command_line_unix(@options)), ! 'matrix' => matrix, ! 'filter' => filter, ! 'V_value' => 500, # default value for GenomeNet ! 'B_value' => 250, # default value for GenomeNet 'alignment_view' => 0, } --- 118,130 ---- form = { ! 'style' => 'raw', ! 'prog' => @program, ! 'dbname' => @db, ! 'sequence' => CGI.escape(query), ! 'other_param' => CGI.escape(make_command_line_unix(@options)), ! 'matrix' => matrix, ! 'filter' => filter, ! 'V_value' => 500, # default value for GenomeNet ! 'B_value' => 250, # default value for GenomeNet 'alignment_view' => 0, } *************** *** 133,137 **** form.each do |k, v| ! data.push("#{k}=#{v}") if v end --- 133,137 ---- form.each do |k, v| ! data.push("#{k}=#{v}") if v end *************** *** 142,146 **** http.open_timeout = 300 http.read_timeout = 600 ! result, = http.post(path, data.join('&')) @output = result.body # workaround 2005.08.12 --- 142,146 ---- http.open_timeout = 300 http.read_timeout = 600 ! result, = http.post(path, data.join('&')) @output = result.body # workaround 2005.08.12 Index: clustalw.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/clustalw.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** clustalw.rb 4 Mar 2005 04:48:41 -0000 1.5 --- clustalw.rb 8 Sep 2005 01:22:08 -0000 1.6 *************** *** 45,51 **** def query(seqs) if seqs then ! query_align(seqs) else ! exec_local(@option) end end --- 45,51 ---- def query(seqs) if seqs then ! query_align(seqs) else ! exec_local(@option) end end *************** *** 55,67 **** seqtype = nil unless seqs.is_a?(Bio::Alignment) ! seqs = Bio::Alignment.new(seqs) end seqs.each do |s| ! if s.is_a?(Bio::Sequence::AA) then ! seqtype = 'PROTEIN' ! elsif s.is_a?(Bio::Sequence::NA) then ! seqtype = 'DNA' ! end ! break if seqtype end query_string(seqs.to_fasta(70, :avoid_same_name => true), seqtype) --- 55,67 ---- seqtype = nil unless seqs.is_a?(Bio::Alignment) ! seqs = Bio::Alignment.new(seqs) end seqs.each do |s| ! if s.is_a?(Bio::Sequence::AA) then ! seqtype = 'PROTEIN' ! elsif s.is_a?(Bio::Sequence::NA) then ! seqtype = 'DNA' ! end ! break if seqtype end query_string(seqs.to_fasta(70, :avoid_same_name => true), seqtype) *************** *** 70,77 **** def query_string(str, *arg) begin ! tf_in = Tempfile.open('align') ! tf_in.print str ensure ! tf_in.close(false) end r = query_by_filename(tf_in.path, *arg) --- 70,77 ---- def query_string(str, *arg) begin ! tf_in = Tempfile.open('align') ! tf_in.print str ensure ! tf_in.close(false) end r = query_by_filename(tf_in.path, *arg) *************** *** 89,96 **** opt = [ "-align", ! "-infile=#{path}", ! "-outfile=#{tf_out.path}", ! "-newtree=#{tf_dnd.path}", ! "-outorder=input" ] opt << "-type=#{seqtype}" if seqtype --- 89,96 ---- opt = [ "-align", ! "-infile=#{path}", ! "-outfile=#{tf_out.path}", ! "-newtree=#{tf_dnd.path}", ! "-outorder=input" ] opt << "-type=#{seqtype}" if seqtype *************** *** 117,125 **** Open3.popen3(*@command) do |din, dout, derr| din.close ! t = Thread.start do ! @errorlog = derr.read ! end ! @log = dout.read ! t.join end # @command_string = @command.join(" ") --- 117,125 ---- Open3.popen3(*@command) do |din, dout, derr| din.close ! t = Thread.start do ! @errorlog = derr.read ! end ! @log = dout.read ! t.join end # @command_string = @command.join(" ") Index: psort.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/psort.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** psort.rb 21 Jul 2004 03:12:02 -0000 1.4 --- psort.rb 8 Sep 2005 01:22:08 -0000 1.5 *************** *** 40,47 **** 'Okazaki' => {'host' => 'psort.nibb.ac.jp', 'PSORT1' => '/cgi-bin/okumura.pl', ! 'PSORT2' => '/cgi-bin/runpsort.pl'}, 'Peking' => {'host' => 'srs.pku.edu.en:8088', 'PSORT1' => '/cgi-bin/okumura.pl', ! 'PSORT2' => '/cgi-bin/runpsort.pl'} } --- 40,47 ---- 'Okazaki' => {'host' => 'psort.nibb.ac.jp', 'PSORT1' => '/cgi-bin/okumura.pl', ! 'PSORT2' => '/cgi-bin/runpsort.pl'}, 'Peking' => {'host' => 'srs.pku.edu.en:8088', 'PSORT1' => '/cgi-bin/okumura.pl', ! 'PSORT2' => '/cgi-bin/runpsort.pl'} } *************** *** 53,60 **** class CGIDriver def initialize(host = '', path = '') ! @host = host ! @path = path ! @args = {} ! @report end attr_accessor :args --- 53,60 ---- class CGIDriver def initialize(host = '', path = '') ! @host = host ! @path = path ! @args = {} ! @report end attr_accessor :args *************** *** 64,76 **** # CGIDriver#exec(query) -> aReport def exec(query) ! data = make_args(query) ! begin ! result, = Net::HTTP.new(@host).post(@path, data) ! @report = result.body ! output = parse_report(@report) ! end ! return output end --- 64,76 ---- # CGIDriver#exec(query) -> aReport def exec(query) ! data = make_args(query) ! begin ! result, = Net::HTTP.new(@host).post(@path, data) ! @report = result.body ! output = parse_report(@report) ! end ! return output end *************** *** 79,87 **** def make_args(args_hash) ! # The routin should be provided in the inherited class end def parse_report(result_body) ! # The routin should be provided in the inherited class end --- 79,87 ---- def make_args(args_hash) ! # The routin should be provided in the inherited class end def parse_report(result_body) ! # The routin should be provided in the inherited class end *************** *** 89,101 **** def erase_html_tags(str) ! return str.gsub(/<\S.*?>/,'') end def args_join(hash, delim = '&') ! tmp = [] ! hash.each do |key, val| ! tmp << CGI.escape(key.to_s) + '=' + CGI.escape(val.to_s) ! end ! return tmp.join(delim) # not ';' but '&' in psort's cgi end --- 89,101 ---- def erase_html_tags(str) ! return str.gsub(/<\S.*?>/,'') end def args_join(hash, delim = '&') ! tmp = [] ! hash.each do |key, val| ! tmp << CGI.escape(key.to_s) + '=' + CGI.escape(val.to_s) ! end ! return tmp.join(delim) # not ';' but '&' in psort's cgi end *************** *** 108,132 **** def self.imsut ! self.new(Remote.new(WWWServer['IMSUT']['host'], ! WWWServer['IMSUT']['PSORT1'])) end def self.okazaki ! self.new(Remote.new(WWWServer['Okazaki']['host'], ! WWWServer['Okazaki']['PSORT1'])) end def self.peking ! self.new(Remote.new(WWWServer['Peking']['host'], ! WWWServer['Peking']['PSORT1'])) end # def initialize(serv) ! @serv = serv ! @origin = 'yeast' # Gram-positive bacterium, Gram-negative bacterium, ! # yeast, aminal, plant ! @title = 'MYSEQ' ! @sequence = '' end attr_accessor :origin, :sequence, :title --- 108,132 ---- def self.imsut ! self.new(Remote.new(WWWServer['IMSUT']['host'], ! WWWServer['IMSUT']['PSORT1'])) end def self.okazaki ! self.new(Remote.new(WWWServer['Okazaki']['host'], ! WWWServer['Okazaki']['PSORT1'])) end def self.peking ! self.new(Remote.new(WWWServer['Peking']['host'], ! WWWServer['Peking']['PSORT1'])) end # def initialize(serv) ! @serv = serv ! @origin = 'yeast' # Gram-positive bacterium, Gram-negative bacterium, ! # yeast, aminal, plant ! @title = 'MYSEQ' ! @sequence = '' end attr_accessor :origin, :sequence, :title *************** *** 134,146 **** # def exec(faa, parsing = true) ! if faa.class == Bio::FastaFormat ! @title = faa.entry_id if @title == 'MYSEQ' ! @sequence = faa.seq ! @serv.args = {'title' => @title, 'origin' => @origin} ! @serv.parsing = parsing ! return @serv.exec(sequence) ! else ! self.exec(Bio::FastaFormat.new(faa), parsing) ! end end --- 134,146 ---- # def exec(faa, parsing = true) ! if faa.class == Bio::FastaFormat ! @title = faa.entry_id if @title == 'MYSEQ' ! @sequence = faa.seq ! @serv.args = {'title' => @title, 'origin' => @origin} ! @serv.parsing = parsing ! return @serv.exec(sequence) ! else ! self.exec(Bio::FastaFormat.new(faa), parsing) ! end end *************** *** 149,175 **** class Remote < CGIDriver ! def initialize(host, path) ! @origin = 'yeast' # Gram-positive bacterium, # Gram-negative bacterium, ! # yeast, aminal, plant ! @title = 'MYSEQ' ! @parsing = true ! super(host, path) ! end ! attr_accessor :origin, :title, :parsing ! private ! def make_args(query) ! @args.update({'sequence' => query}) ! return args_join(@args) ! end ! def parse_report(str) ! str = erase_html_tags(str) ! str = Bio::PSORT::PSORT1::Report.parser(str) if @parsing ! return str ! end end # Class Remote --- 149,175 ---- class Remote < CGIDriver ! def initialize(host, path) ! @origin = 'yeast' # Gram-positive bacterium, # Gram-negative bacterium, ! # yeast, aminal, plant ! @title = 'MYSEQ' ! @parsing = true ! super(host, path) ! end ! attr_accessor :origin, :title, :parsing ! private ! def make_args(query) ! @args.update({'sequence' => query}) ! return args_join(@args) ! end ! def parse_report(str) ! str = erase_html_tags(str) ! str = Bio::PSORT::PSORT1::Report.parser(str) if @parsing ! return str ! end end # Class Remote *************** *** 184,223 **** # remote def self.remote(host, path) ! self.new(Remote.new(host, path)) end def self.imsut ! self.remote(WWWServer['IMSUT']['host'], ! WWWServer['IMSUT']['PSORT2']) end def self.okazaki ! self.remote(WWWServer['Okazaki']['host'], ! WWWServer['Okazaki']['PSORT2']) end def self.peking ! self.remote(WWWServer['Peking']['host'], ! WWWServer['Peking']['PSORT2']) end # wrapper for ``psort'' command def initialize(serv, origin = 'yeast') ! @serv = serv ! @origin = origin ! @title = nil end attr_accessor :origin, :title def exec(faa, parsing = true) ! if faa.class == Bio::FastaFormat ! @title = faa.entry_id if @title == nil ! @sequence = faa.seq ! @serv.args = {'origin' => @origin, 'title' => @title} ! @serv.parsing = parsing ! return @serv.exec(@sequence) ! else ! self.exec(Bio::FastaFormat.new(faa), parsing) ! end end --- 184,223 ---- # remote def self.remote(host, path) ! self.new(Remote.new(host, path)) end def self.imsut ! self.remote(WWWServer['IMSUT']['host'], ! WWWServer['IMSUT']['PSORT2']) end def self.okazaki ! self.remote(WWWServer['Okazaki']['host'], ! WWWServer['Okazaki']['PSORT2']) end def self.peking ! self.remote(WWWServer['Peking']['host'], ! WWWServer['Peking']['PSORT2']) end # wrapper for ``psort'' command def initialize(serv, origin = 'yeast') ! @serv = serv ! @origin = origin ! @title = nil end attr_accessor :origin, :title def exec(faa, parsing = true) ! if faa.class == Bio::FastaFormat ! @title = faa.entry_id if @title == nil ! @sequence = faa.seq ! @serv.args = {'origin' => @origin, 'title' => @title} ! @serv.parsing = parsing ! return @serv.exec(@sequence) ! else ! self.exec(Bio::FastaFormat.new(faa), parsing) ! end end *************** *** 225,249 **** # PSORT2 specific CGIDriver class Remote < CGIDriver ! def initialize(host, path) ! @origin = 'yeast' ! super(host, path) ! @parsing = true ! end ! attr_accessor :origin, :parsing ! ! private ! ! def make_args(query) ! @args.update({'sequence' => query}) ! return args_join(@args) ! end ! def parse_report(str) ! str = str.gsub(/\n
/i, Report::BOUNDARY) ! str = erase_html_tags(str) ! str = Bio::PSORT::PSORT2::Report.parser(str, self.args['title']) if @parsing ! return str ! end end # class Remote --- 225,249 ---- # PSORT2 specific CGIDriver class Remote < CGIDriver ! def initialize(host, path) ! @origin = 'yeast' ! super(host, path) ! @parsing = true ! end ! attr_accessor :origin, :parsing ! ! private ! ! def make_args(query) ! @args.update({'sequence' => query}) ! return args_join(@args) ! end ! def parse_report(str) ! str = str.gsub(/\n
/i, Report::BOUNDARY) ! str = erase_html_tags(str) ! str = Bio::PSORT::PSORT2::Report.parser(str, self.args['title']) if @parsing ! return str ! end end # class Remote Index: fasta.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/fasta.rb,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** fasta.rb 16 Aug 2005 09:38:34 -0000 1.17 --- fasta.rb 8 Sep 2005 01:22:08 -0000 1.18 *************** *** 98,104 **** case @format when 6 ! require 'bio/appl/fasta/format6' when 10 ! require 'bio/appl/fasta/format10' end Report.new(data) --- 98,104 ---- case @format when 6 ! require 'bio/appl/fasta/format6' when 10 ! require 'bio/appl/fasta/format10' end Report.new(data) *************** *** 125,135 **** form = { ! 'style' => 'raw', ! 'prog' => @program, ! 'dbname' => @db, ! 'sequence' => CGI.escape(query), ! 'other_param' => CGI.escape(make_command_line_unix(@options)), ! 'ktup_value' => @ktup, ! 'matrix' => @matrix, } --- 125,135 ---- form = { ! 'style' => 'raw', ! 'prog' => @program, ! 'dbname' => @db, ! 'sequence' => CGI.escape(query), ! 'other_param' => CGI.escape(make_command_line_unix(@options)), ! 'ktup_value' => @ktup, ! 'matrix' => @matrix, } *************** *** 137,141 **** form.each do |k, v| ! data.push("#{k}=#{v}") if v end --- 137,141 ---- form.each do |k, v| ! data.push("#{k}=#{v}") if v end *************** *** 146,150 **** http.open_timeout = 300 http.read_timeout = 600 ! result, = http.post(path, data.join('&')) @output = result.body # workaround 2005.08.12 --- 146,150 ---- http.open_timeout = 300 http.read_timeout = 600 ! result, = http.post(path, data.join('&')) @output = result.body # workaround 2005.08.12 Index: mafft.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/mafft.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** mafft.rb 4 Mar 2005 04:48:41 -0000 1.4 --- mafft.rb 8 Sep 2005 01:22:08 -0000 1.5 *************** *** 35,42 **** opt = [] if n.to_s == 'i' then ! self.new2(nil, 'fftnsi', *opt) else ! opt << n.to_s if n ! self.new2(nil, 'fftns', *opt) end end --- 35,42 ---- opt = [] if n.to_s == 'i' then ! self.new2(nil, 'fftnsi', *opt) else ! opt << n.to_s if n ! self.new2(nil, 'fftns', *opt) end end *************** *** 50,57 **** opt << '--all-positive' if ap if n.to_s == 'i' then ! self.new2(nil, 'nwnsi', *opt) else ! opt << n.to_s if n ! self.new2(nil, 'nwns', *opt) end end --- 50,57 ---- opt << '--all-positive' if ap if n.to_s == 'i' then ! self.new2(nil, 'nwnsi', *opt) else ! opt << n.to_s if n ! self.new2(nil, 'nwns', *opt) end end *************** *** 69,73 **** def self.new2(dir, prog, *opt) if dir then ! prog = File.join(dir, prog) end self.new(prog, opt) --- 69,73 ---- def self.new2(dir, prog, *opt) if dir then ! prog = File.join(dir, prog) end self.new(prog, opt) *************** *** 88,94 **** def query(seqs) if seqs then ! query_align(seqs) else ! exec_local(@option) end end --- 88,94 ---- def query(seqs) if seqs then ! query_align(seqs) else ! exec_local(@option) end end *************** *** 97,101 **** # seqs should be Bio::Alignment or Array of sequences or nil unless seqs.is_a?(Bio::Alignment) ! seqs = Bio::Alignment.new(seqs, *arg) end query_string(seqs.to_fasta(70)) --- 97,101 ---- # seqs should be Bio::Alignment or Array of sequences or nil unless seqs.is_a?(Bio::Alignment) ! seqs = Bio::Alignment.new(seqs, *arg) end query_string(seqs.to_fasta(70)) *************** *** 104,111 **** def query_string(str, *arg) begin ! tf_in = Tempfile.open('align') ! tf_in.print str ensure ! tf_in.close(false) end r = query_by_filename(tf_in.path, *arg) --- 104,111 ---- def query_string(str, *arg) begin ! tf_in = Tempfile.open('align') ! tf_in.print str ensure ! tf_in.close(false) end r = query_by_filename(tf_in.path, *arg) *************** *** 128,139 **** @log = nil Open3.popen3(*@command) do |din, dout, derr| ! din.close ! derr.sync = true ! t = Thread.start do ! @log = derr.read ! end ! ff = Bio::FlatFile.new(Bio::FastaFormat, dout) ! @output = ff.to_a ! t.join end @log --- 128,139 ---- @log = nil Open3.popen3(*@command) do |din, dout, derr| ! din.close ! derr.sync = true ! t = Thread.start do ! @log = derr.read ! end ! ff = Bio::FlatFile.new(Bio::FastaFormat, dout) ! @output = ff.to_a ! t.join end @log From k at pub.open-bio.org Wed Sep 7 21:22:10 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed Sep 7 22:51:12 2005 Subject: [BioRuby-cvs] bioruby/lib/bio alignment.rb, 1.7, 1.8 db.rb, 0.27, 0.28 feature.rb, 1.5, 1.6 location.rb, 0.18, 0.19 pathway.rb, 1.29, 1.30 reference.rb, 1.16, 1.17 sequence.rb, 0.40, 0.41 Message-ID: <200509080122.j881MAdZ009044@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio Modified Files: alignment.rb db.rb feature.rb location.rb pathway.rb reference.rb sequence.rb Log Message: * expanded tab at the line head Index: location.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/location.rb,v retrieving revision 0.18 retrieving revision 0.19 diff -C2 -d -r0.18 -r0.19 *** location.rb 14 May 2004 03:07:26 -0000 0.18 --- location.rb 8 Sep 2005 01:22:08 -0000 0.19 *************** *** 30,42 **** if location ! if location =~ /:/ # (G) ID:location ! xref_id, location = location.split(':') ! end ! if location =~ / ! lt = true ! end ! if location =~ />/ ! gt = true ! end end --- 30,42 ---- if location ! if location =~ /:/ # (G) ID:location ! xref_id, location = location.split(':') ! end ! if location =~ / ! lt = true ! end ! if location =~ />/ ! gt = true ! end end *************** *** 44,69 **** case location when /^[<>]?(\d+)$/ # (A, I) n ! s = e = $1.to_i when /^[<>]?(\d+)\.\.[<>]?(\d+)$/ # (B, I) n..m ! s = $1.to_i ! e = $2.to_i ! if e - s < 0 # raise "[Error] invalid range : #{location}" ! $stderr.puts "[Warning] invalid range : #{location}" if $DEBUG ! end when /^[<>]?(\d+)\^[<>]?(\d+)$/ # (C, I) n^m ! s = $1.to_i ! e = $2.to_i ! if e - s != 1 # raise "[Error] invalid range : #{location}" ! $stderr.puts "[Warning] invalid range : #{location}" if $DEBUG ! end when /^"?([ATGCatgc]+)"?$/ # (H) literal sequence ! sequence = $1.downcase ! s = e = nil when nil ! ; else ! raise "[Error] unknown location format : #{location}" end --- 44,69 ---- case location when /^[<>]?(\d+)$/ # (A, I) n ! s = e = $1.to_i when /^[<>]?(\d+)\.\.[<>]?(\d+)$/ # (B, I) n..m ! s = $1.to_i ! e = $2.to_i ! if e - s < 0 # raise "[Error] invalid range : #{location}" ! $stderr.puts "[Warning] invalid range : #{location}" if $DEBUG ! end when /^[<>]?(\d+)\^[<>]?(\d+)$/ # (C, I) n^m ! s = $1.to_i ! e = $2.to_i ! if e - s != 1 # raise "[Error] invalid range : #{location}" ! $stderr.puts "[Warning] invalid range : #{location}" if $DEBUG ! end when /^"?([ATGCatgc]+)"?$/ # (H) literal sequence ! sequence = $1.downcase ! s = e = nil when nil ! ; else ! raise "[Error] unknown location format : #{location}" end *************** *** 71,75 **** @to = e # end position of the location @strand = 1 # strand direction of the location ! # forward => 1 or complement => -1 @sequence = sequence # literal sequence of the location @lt = lt # true if the position contains '<' --- 71,75 ---- @to = e # end position of the location @strand = 1 # strand direction of the location ! # forward => 1 or complement => -1 @sequence = sequence # literal sequence of the location @lt = lt # true if the position contains '<' *************** *** 105,112 **** def initialize(position) if position.is_a? Array ! @locations = position else ! position = gbl_cleanup(position) # preprocessing ! @locations = gbl_pos2loc(position) # create an Array of Location end end --- 105,112 ---- def initialize(position) if position.is_a? Array ! @locations = position else ! position = gbl_cleanup(position) # preprocessing ! @locations = gbl_pos2loc(position) # create an Array of Location end end *************** *** 115,119 **** def each @locations.each do |x| ! yield(x) end end --- 115,119 ---- def each @locations.each do |x| ! yield(x) end end *************** *** 145,153 **** len = 0 @locations.each do |x| ! if x.sequence ! len += x.sequence.size ! else ! len += (x.to - x.from + 1) ! end end len --- 145,153 ---- len = 0 @locations.each do |x| ! if x.sequence ! len += x.sequence.size ! else ! len += (x.to - x.from + 1) ! end end len *************** *** 158,170 **** case type when :location ! ; when :aa ! if n = abs2rel(n) ! (n - 1) / 3 + 1 ! else ! nil ! end else ! abs2rel(n) end end --- 158,170 ---- case type when :location ! ; when :aa ! if n = abs2rel(n) ! (n - 1) / 3 + 1 ! else ! nil ! end else ! abs2rel(n) end end *************** *** 173,182 **** case type when :location ! ; when :aa ! n = (n - 1) * 3 + 1 ! rel2abs(n) else ! rel2abs(n) end end --- 173,182 ---- case type when :location ! ; when :aa ! n = (n - 1) * 3 + 1 ! rel2abs(n) else ! rel2abs(n) end end *************** *** 195,203 **** # $1 ( $2 $3 not ) position.gsub!(/(\.{2})?\(?([<>\d]+)\.([<>\d]+)(?!:)\)?/) do |match| ! if $1 ! $1 + $3 # ..(n.m) => ..m ! else ! $2 # (?n.m)? => n ! end end --- 195,203 ---- # $1 ( $2 $3 not ) position.gsub!(/(\.{2})?\(?([<>\d]+)\.([<>\d]+)(?!:)\)?/) do |match| ! if $1 ! $1 + $3 # ..(n.m) => ..m ! else ! $2 # (?n.m)? => n ! end end *************** *** 205,213 **** # .. one-of ($2 ,$3 ) position.gsub!(/(\.{2})?one-of\(([^,]+),([^)]+)\)/) do |match| ! if $1 ! $1 + $3.gsub(/.*,(.*)/, '\1') # ..one-of(n,m) => ..m ! else ! $2 # one-of(n,m) => n ! end end --- 205,213 ---- # .. one-of ($2 ,$3 ) position.gsub!(/(\.{2})?one-of\(([^,]+),([^)]+)\)/) do |match| ! if $1 ! $1 + $3.gsub(/.*,(.*)/, '\1') # ..one-of(n,m) => ..m ! else ! $2 # one-of(n,m) => n ! end end *************** *** 226,274 **** when /^join\((.*)\)$/ # (F) join() ! position = $1 ! join_list = [] # sub positions to join ! bracket = [] # position with bracket ! s_count = 0 # stack counter ! position.split(',').each do |sub_pos| ! case sub_pos ! when /\(.*\)/ ! join_list << sub_pos ! when /\(/ ! s_count += 1 ! bracket << sub_pos ! when /\)/ ! s_count -= 1 ! bracket << sub_pos ! if s_count == 0 ! join_list << bracket.join(',') ! end ! else ! if s_count == 0 ! join_list << sub_pos ! else ! bracket << sub_pos ! end ! end ! end ! join_list.each do |position| ! ary << gbl_pos2loc(position) ! end when /^complement\((.*)\)$/ # (J) complement() ! position = $1 ! gbl_pos2loc(position).reverse_each do |location| ! ary << location.complement ! end when /^replace\(([^,]+),"?([^"]*)"?\)/ # (K) replace() ! position = $1 ! sequence = $2 ! ary << gbl_pos2loc(position).first.replace(sequence) else # (A, B, C, G, H, I) ! ary << Location.new(position) end --- 226,274 ---- when /^join\((.*)\)$/ # (F) join() ! position = $1 ! join_list = [] # sub positions to join ! bracket = [] # position with bracket ! s_count = 0 # stack counter ! position.split(',').each do |sub_pos| ! case sub_pos ! when /\(.*\)/ ! join_list << sub_pos ! when /\(/ ! s_count += 1 ! bracket << sub_pos ! when /\)/ ! s_count -= 1 ! bracket << sub_pos ! if s_count == 0 ! join_list << bracket.join(',') ! end ! else ! if s_count == 0 ! join_list << sub_pos ! else ! bracket << sub_pos ! end ! end ! end ! join_list.each do |position| ! ary << gbl_pos2loc(position) ! end when /^complement\((.*)\)$/ # (J) complement() ! position = $1 ! gbl_pos2loc(position).reverse_each do |location| ! ary << location.complement ! end when /^replace\(([^,]+),"?([^"]*)"?\)/ # (K) replace() ! position = $1 ! sequence = $2 ! ary << gbl_pos2loc(position).first.replace(sequence) else # (A, B, C, G, H, I) ! ary << Location.new(position) end *************** *** 306,323 **** cursor = 0 @locations.each do |x| ! if x.sequence ! len = x.sequence.size ! else ! len = x.to - x.from + 1 ! end ! if n < x.from or n > x.to then ! cursor += len ! else ! if x.strand < 0 then ! return x.to - (n - cursor - 1) ! else ! return n + cursor + 1 - x.from ! end ! end end return nil # out of range --- 306,323 ---- cursor = 0 @locations.each do |x| ! if x.sequence ! len = x.sequence.size ! else ! len = x.to - x.from + 1 ! end ! if n < x.from or n > x.to then ! cursor += len ! else ! if x.strand < 0 then ! return x.to - (n - cursor - 1) ! else ! return n + cursor + 1 - x.from ! end ! end end return nil # out of range Index: pathway.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/pathway.rb,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** pathway.rb 29 Jan 2004 01:29:15 -0000 1.29 --- pathway.rb 8 Sep 2005 01:22:08 -0000 1.30 *************** *** 50,55 **** def directed if undirected? ! @undirected = false ! self.to_list end end --- 50,55 ---- def directed if undirected? ! @undirected = false ! self.to_list end end *************** *** 57,62 **** def undirected if directed? ! @undirected = true ! self.to_list end end --- 57,62 ---- def undirected if directed? ! @undirected = true ! self.to_list end end *************** *** 83,87 **** @graph.clear @relations.each do |rel| ! append(rel, false) # append to @graph without push to @relations end end --- 83,87 ---- @graph.clear @relations.each do |rel| ! append(rel, false) # append to @graph without push to @relations end end *************** *** 90,97 **** @relations.push(rel) if add_rel if @graph[rel.from].nil? ! @graph[rel.from] = {} end if @graph[rel.to].nil? ! @graph[rel.to] = {} end @graph[rel.from][rel.to] = rel.relation --- 90,97 ---- @relations.push(rel) if add_rel if @graph[rel.from].nil? ! @graph[rel.from] = {} end if @graph[rel.to].nil? ! @graph[rel.to] = {} end @graph[rel.from][rel.to] = rel.relation *************** *** 101,105 **** def delete(rel) @relations.delete_if do |x| ! x === rel end @graph[rel.from].delete(rel.to) --- 101,105 ---- def delete(rel) @relations.delete_if do |x| ! x === rel end @graph[rel.from].delete(rel.to) *************** *** 114,118 **** edges = 0 @graph.each_value do |v| ! edges += v.size end edges --- 114,118 ---- edges = 0 @graph.each_value do |v| ! edges += v.size end edges *************** *** 132,164 **** matrix = Array.new nodes.times do ! matrix.push(Array.new(nodes, default_value)) end if diagonal_value ! nodes.times do |i| ! matrix[i][i] = diagonal_value ! end end # assign index number for each node @graph.keys.each_with_index do |k, i| ! @index[k] = i end if @relations.empty? # only used after clear_relations! ! @graph.each do |from, hash| ! hash.each do |to, relation| ! x = @index[from] ! y = @index[to] ! matrix[x][y] = relation ! end ! end else ! @relations.each do |rel| ! x = @index[rel.from] ! y = @index[rel.to] ! matrix[x][y] = rel.relation ! matrix[y][x] = rel.relation if @undirected ! end end Matrix[*matrix] --- 132,164 ---- matrix = Array.new nodes.times do ! matrix.push(Array.new(nodes, default_value)) end if diagonal_value ! nodes.times do |i| ! matrix[i][i] = diagonal_value ! end end # assign index number for each node @graph.keys.each_with_index do |k, i| ! @index[k] = i end if @relations.empty? # only used after clear_relations! ! @graph.each do |from, hash| ! hash.each do |to, relation| ! x = @index[from] ! y = @index[to] ! matrix[x][y] = relation ! end ! end else ! @relations.each do |rel| ! x = @index[rel.from] ! y = @index[rel.to] ! matrix[x][y] = rel.relation ! matrix[y][x] = rel.relation if @undirected ! end end Matrix[*matrix] *************** *** 171,175 **** sorted = @index.sort {|a,b| a[1] <=> b[1]} "[# " + sorted.collect{|x| x[0]}.join(", ") + "\n" + ! matrix.to_a.collect{|row| ' ' + row.inspect}.join(",\n") + "\n]" end --- 171,175 ---- sorted = @index.sort {|a,b| a[1] <=> b[1]} "[# " + sorted.collect{|x| x[0]}.join(", ") + "\n" + ! matrix.to_a.collect{|row| ' ' + row.inspect}.join(",\n") + "\n]" end *************** *** 178,187 **** list = "" @graph.each do |from, hash| ! list << "#{from} => " ! a = [] ! hash.each do |to, relation| ! a.push("#{to} (#{relation})") ! end ! list << a.join(", ") + "\n" end list --- 178,187 ---- list = "" @graph.each do |from, hash| ! list << "#{from} => " ! a = [] ! hash.each do |to, relation| ! a.push("#{to} (#{relation})") ! end ! list << a.join(", ") + "\n" end list *************** *** 192,207 **** def subgraph(list = nil) if list ! @label.clear ! list.each do |node| ! @label[node] = true ! end end sub_graph = Pathway.new([], @undirected) @graph.each do |from, hash| ! next unless @label[from] ! hash.each do |to, relation| ! next unless @label[to] ! sub_graph.append(Relation.new(from, to, relation)) ! end end return sub_graph --- 192,207 ---- def subgraph(list = nil) if list ! @label.clear ! list.each do |node| ! @label[node] = true ! end end sub_graph = Pathway.new([], @undirected) @graph.each do |from, hash| ! next unless @label[from] ! hash.each do |to, relation| ! next unless @label[to] ! sub_graph.append(Relation.new(from, to, relation)) ! end end return sub_graph *************** *** 238,242 **** freq = Hash.new(0) @graph.each_value do |v| ! freq[v.size] += 1 end return freq --- 238,242 ---- freq = Hash.new(0) @graph.each_value do |v| ! freq[v.size] += 1 end return freq *************** *** 258,270 **** while from = queue.shift ! next unless @graph[from] ! @graph[from].each_key do |to| ! unless visited[to] ! visited[to] = true ! distance[to] = distance[from] + 1 ! predecessor[to] = from ! queue.push(to) ! end ! end end return distance, predecessor --- 258,270 ---- while from = queue.shift ! next unless @graph[from] ! @graph[from].each_key do |to| ! unless visited[to] ! visited[to] = true ! distance[to] = distance[from] + 1 ! predecessor[to] = from ! queue.push(to) ! end ! end end return distance, predecessor *************** *** 279,284 **** path = [ node2 ] while node != node1 and route[node] ! node = route[node] ! path.unshift(node) end return step, path --- 279,284 ---- path = [ node2 ] while node != node1 and route[node] ! node = route[node] ! path.unshift(node) end return step, path *************** *** 298,334 **** dfs_visit = Proc.new { |from| ! visited[from] = true ! timestamp[from] = [count += 1] ! @graph[from].each_key do |to| ! if visited[to] ! if timestamp[to].size > 1 ! if timestamp[from].first < timestamp[to].first ! # forward edge (black) ! p "#{from} -> #{to} : forward edge" if $DEBUG ! forward_edges[from] = to ! else ! # cross edge (black) ! p "#{from} -> #{to} : cross edge" if $DEBUG ! cross_edges[from] = to ! end ! else ! # back edge (gray) ! p "#{from} -> #{to} : back edge" if $DEBUG ! back_edges[from] = to ! end ! else ! # tree edge (white) ! p "#{from} -> #{to} : tree edge" if $DEBUG ! tree_edges[to] = from ! dfs_visit.call(to) ! end ! end ! timestamp[from].push(count += 1) } @graph.each_key do |node| ! unless visited[node] ! dfs_visit.call(node) ! end end return timestamp, tree_edges, back_edges, cross_edges, forward_edges --- 298,334 ---- dfs_visit = Proc.new { |from| ! visited[from] = true ! timestamp[from] = [count += 1] ! @graph[from].each_key do |to| ! if visited[to] ! if timestamp[to].size > 1 ! if timestamp[from].first < timestamp[to].first ! # forward edge (black) ! p "#{from} -> #{to} : forward edge" if $DEBUG ! forward_edges[from] = to ! else ! # cross edge (black) ! p "#{from} -> #{to} : cross edge" if $DEBUG ! cross_edges[from] = to ! end ! else ! # back edge (gray) ! p "#{from} -> #{to} : back edge" if $DEBUG ! back_edges[from] = to ! end ! else ! # tree edge (white) ! p "#{from} -> #{to} : tree edge" if $DEBUG ! tree_edges[to] = from ! dfs_visit.call(to) ! end ! end ! timestamp[from].push(count += 1) } @graph.each_key do |node| ! unless visited[node] ! dfs_visit.call(node) ! end end return timestamp, tree_edges, back_edges, cross_edges, forward_edges *************** *** 355,362 **** while queue.size != 0 ! min = queue.min {|a, b| a[1] <=> b[1]} ! u = min[0] # extranct a node having minimal distance @graph[u].each do |k, v| ! # relaxing procedure of root -> 'u' -> 'k' if distance[k] > distance[u] + v distance[k] = distance[u] + v --- 355,362 ---- while queue.size != 0 ! min = queue.min {|a, b| a[1] <=> b[1]} ! u = min[0] # extranct a node having minimal distance @graph[u].each do |k, v| ! # relaxing procedure of root -> 'u' -> 'k' if distance[k] > distance[u] + v distance[k] = distance[u] + v *************** *** 364,368 **** end end ! queue.delete(u) end return distance, predecessor --- 364,368 ---- end end ! queue.delete(u) end return distance, predecessor *************** *** 377,381 **** @graph.each_key do |u| @graph[u].each do |v, w| ! # relaxing procedure of root -> 'u' -> 'v' if distance[v] > distance[u] + w distance[v] = distance[u] + w --- 377,381 ---- @graph.each_key do |u| @graph[u].each do |v, w| ! # relaxing procedure of root -> 'u' -> 'v' if distance[v] > distance[u] + w distance[v] = distance[u] + w *************** *** 516,528 **** def ===(rel) if self.edge == rel.edge ! if self.node[0] == rel.node[0] and self.node[1] == rel.node[1] ! return true ! elsif self.node[0] == rel.node[1] and self.node[1] == rel.node[0] ! return true ! else ! return false ! end else ! return false end end --- 516,528 ---- def ===(rel) if self.edge == rel.edge ! if self.node[0] == rel.node[0] and self.node[1] == rel.node[1] ! return true ! elsif self.node[0] == rel.node[1] and self.node[1] == rel.node[0] ! return true ! else ! return false ! end else ! return false end end *************** *** 531,535 **** def <=>(rel) unless self.edge.kind_of? Comparable ! raise "[Error] edges are not comparable" end if self.edge > rel.edge --- 531,535 ---- def <=>(rel) unless self.edge.kind_of? Comparable ! raise "[Error] edges are not comparable" end if self.edge > rel.edge Index: alignment.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/alignment.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** alignment.rb 13 Nov 2004 15:41:10 -0000 1.7 --- alignment.rb 8 Sep 2005 01:22:08 -0000 1.8 *************** *** 39,53 **** seq = nil if seq.is_a?(Bio::Sequence) then ! seq = s else ! for m in [ :seq, :naseq, :aaseq ] ! begin ! seq = s.send(m) ! rescue NameError, ArgumentError ! seq = nil ! end [...1503 lines suppressed...] ! p end module_function :ungapped_pos def gapped_pos(seq, pos, gap_regexp) ! olen = seq.gsub(gap_regexp, '').length ! pos = olen if pos >= olen ! pos = olen + pos if pos < 0 ! ! i = 0 ! l = pos + 1 ! while l > 0 and i < seq.length ! x = seq[i, l].gsub(gap_regexp, '').length ! i += l ! l -= x ! end ! i -= 1 if i > 0 ! i end module_function :gapped_pos Index: sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence.rb,v retrieving revision 0.40 retrieving revision 0.41 diff -C2 -d -r0.40 -r0.41 *** sequence.rb 10 Aug 2005 12:53:02 -0000 0.40 --- sequence.rb 8 Sep 2005 01:22:08 -0000 0.41 *************** *** 69,75 **** ">#{header}\n" + if width ! self.to_s.gsub(Regexp.new(".{1,#{width}}"), "\\0\n") else ! self.to_s + "\n" end end --- 69,75 ---- ">#{header}\n" + if width ! self.to_s.gsub(Regexp.new(".{1,#{width}}"), "\\0\n") else ! self.to_s + "\n" end end *************** *** 95,101 **** sum = 0.0 self.each_byte do |x| ! begin ! sum += hash[x.chr] ! end end return sum --- 95,101 ---- sum = 0.0 self.each_byte do |x| ! begin ! sum += hash[x.chr] ! end end return sum *************** *** 105,109 **** count = Hash.new(0) self.scan(/./) do |x| ! count[x] += 1 end return count --- 105,109 ---- count = Hash.new(0) self.scan(/./) do |x| ! count[x] += 1 end return count *************** *** 113,120 **** length = self.length if hash ! count = hash.clone ! count.each_value {|x| length += x} else ! count = self.composition end --- 113,120 ---- length = self.length if hash ! count = hash.clone ! count.each_value {|x| length += x} else ! count = self.composition end *************** *** 122,136 **** tmp = {} length.times do ! count.each do |k, v| ! tmp[k] = v * rand ! end ! max = tmp.max {|a, b| a[1] <=> b[1]} ! count[max.first] -= 1 ! if block_given? ! yield max.first ! else ! seq += max.first ! end end return self.class.new(seq) --- 122,136 ---- tmp = {} length.times do ! count.each do |k, v| ! tmp[k] = v * rand ! end ! max = tmp.max {|a, b| a[1] <=> b[1]} ! count[max.first] -= 1 ! if block_given? ! yield max.first ! else ! seq += max.first ! end end return self.class.new(seq) *************** *** 144,161 **** def splicing(position) unless position.is_a?(Locations) then ! position = Locations.new(position) end s = '' position.each do |location| ! if location.sequence ! s << location.sequence ! else ! exon = self.subseq(location.from, location.to) ! begin ! exon.complement! if location.strand < 0 ! rescue NameError ! end ! s << exon ! end end return self.class.new(s) --- 144,161 ---- def splicing(position) unless position.is_a?(Locations) then ! position = Locations.new(position) end s = '' position.each do |location| ! if location.sequence ! s << location.sequence ! else ! exon = self.subseq(location.from, location.to) ! begin ! exon.complement! if location.strand < 0 ! rescue NameError ! end ! s << exon ! end end return self.class.new(s) *************** *** 168,239 **** def initialize(str) ! super ! self.downcase! ! self.tr!(" \t\n\r",'') end # This method depends on Locations class, see bio/location.rb def splicing(position) ! mRNA = super ! if mRNA.rna? ! mRNA.tr!('t', 'u') ! else ! mRNA.tr!('u', 't') ! end ! mRNA end def complement ! s = self.class.new(self) ! s.complement! ! s end def complement! ! if self.rna? ! self.reverse! ! self.tr!('augcrymkdhvbswn', 'uacgyrkmhdbvswn') ! else ! self.reverse! ! self.tr!('atgcrymkdhvbswn', 'tacgyrkmhdbvswn') ! end ! self end def translate(frame = 1, table = 1, unknown = 'X') if table.is_a?(Bio::CodonTable) ! ct = table else ct = Bio::CodonTable[table] end ! naseq = self.dna ! case frame ! when 1, 2, 3 ! frame -= 1 ! when 4, 5, 6 ! frame -= 4 ! naseq.complement! ! when -1, -2, -3 ! frame = -1 - frame ! naseq.complement! ! else ! frame = 0 ! end nalen = naseq.length - (naseq.length - frame) % 3 ! aaseq = naseq[frame, nalen].gsub(/.{3}/) {|codon| ct[codon] or unknown} ! return Bio::Sequence::AA.new(aaseq) end def gc_percent ! count = self.composition ! at = count['a'] + count['t'] + count['u'] ! gc = count['g'] + count['c'] ! gc = format("%.1f", gc.to_f / (at + gc) * 100) ! return gc.to_f end alias :gc :gc_percent def illegal_bases ! self.scan(/[^atgcu]/).sort.uniq end --- 168,239 ---- def initialize(str) ! super ! self.downcase! ! self.tr!(" \t\n\r",'') end # This method depends on Locations class, see bio/location.rb def splicing(position) ! mRNA = super ! if mRNA.rna? ! mRNA.tr!('t', 'u') ! else ! mRNA.tr!('u', 't') ! end ! mRNA end def complement ! s = self.class.new(self) ! s.complement! ! s end def complement! ! if self.rna? ! self.reverse! ! self.tr!('augcrymkdhvbswn', 'uacgyrkmhdbvswn') ! else ! self.reverse! ! self.tr!('atgcrymkdhvbswn', 'tacgyrkmhdbvswn') ! end ! self end def translate(frame = 1, table = 1, unknown = 'X') if table.is_a?(Bio::CodonTable) ! ct = table else ct = Bio::CodonTable[table] end ! naseq = self.dna ! case frame ! when 1, 2, 3 ! frame -= 1 ! when 4, 5, 6 ! frame -= 4 ! naseq.complement! ! when -1, -2, -3 ! frame = -1 - frame ! naseq.complement! ! else ! frame = 0 ! end nalen = naseq.length - (naseq.length - frame) % 3 ! aaseq = naseq[frame, nalen].gsub(/.{3}/) {|codon| ct[codon] or unknown} ! return Bio::Sequence::AA.new(aaseq) end def gc_percent ! count = self.composition ! at = count['a'] + count['t'] + count['u'] ! gc = count['g'] + count['c'] ! gc = format("%.1f", gc.to_f / (at + gc) * 100) ! return gc.to_f end alias :gc :gc_percent def illegal_bases ! self.scan(/[^atgcu]/).sort.uniq end *************** *** 248,252 **** def to_re ! if self.rna? NucleicAcid.to_re(self.dna, true) else --- 248,252 ---- def to_re ! if self.rna? NucleicAcid.to_re(self.dna, true) else *************** *** 256,264 **** def names ! array = [] ! self.each_byte do |x| ! array.push(NucleicAcid.names[x.chr.upcase]) ! end ! return array end --- 256,264 ---- def names ! array = [] ! self.each_byte do |x| ! array.push(NucleicAcid.names[x.chr.upcase]) ! end ! return array end *************** *** 280,289 **** def rna? ! self.index('u') end protected :rna? def pikachu ! self.dna.tr("atgc", "pika") # joke, of course :-) end --- 280,289 ---- def rna? ! self.index('u') end protected :rna? def pikachu ! self.dna.tr("atgc", "pika") # joke, of course :-) end *************** *** 296,302 **** def initialize(str) ! super ! self.upcase! ! self.tr!(" \t\n\r",'') end --- 296,302 ---- def initialize(str) ! super ! self.upcase! ! self.tr!(" \t\n\r",'') end *************** *** 307,325 **** def to_re ! AminoAcid.to_re(self) end def codes ! array = [] ! self.each_byte do |x| ! array.push(AminoAcid.names[x.chr]) ! end ! return array end def names ! self.codes.map do |x| ! AminoAcid.names[x] ! end end --- 307,325 ---- def to_re ! AminoAcid.to_re(self) end def codes ! array = [] ! self.each_byte do |x| ! array.push(AminoAcid.names[x.chr]) ! end ! return array end def names ! self.codes.map do |x| ! AminoAcid.names[x] ! end end Index: db.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db.rb,v retrieving revision 0.27 retrieving revision 0.28 diff -C2 -d -r0.27 -r0.28 *** db.rb 7 Aug 2005 08:26:38 -0000 0.27 --- db.rb 8 Sep 2005 01:22:08 -0000 0.28 *************** *** 72,76 **** def field_fetch(tag, skip = 0) unless @data[tag] ! @data[tag] = fetch(tag, skip) end return @data[tag] --- 72,76 ---- def field_fetch(tag, skip = 0) unless @data[tag] ! @data[tag] = fetch(tag, skip) end return @data[tag] *************** *** 114,119 **** fields.each do |field| ! tag = tag_get(field) ! hash[tag] += field end return hash --- 114,119 ---- fields.each do |field| ! tag = tag_get(field) ! hash[tag] += field end return hash *************** *** 141,148 **** hash = Hash.new('') entry.each_line do |line| ! tag = tag_get(line) ! next if tag == 'XX' ! tag = 'R' if tag =~ /^R./ # Reference lines ! hash[tag] += line end return hash --- 141,148 ---- hash = Hash.new('') entry.each_line do |line| ! tag = tag_get(line) ! next if tag == 'XX' ! tag = 'R' if tag =~ /^R./ # Reference lines ! hash[tag] += line end return hash Index: feature.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/feature.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** feature.rb 25 Feb 2003 12:22:00 -0000 1.5 --- feature.rb 8 Sep 2005 01:22:08 -0000 1.6 *************** *** 43,47 **** def each @qualifiers.each do |x| ! yield x end end --- 43,47 ---- def each @qualifiers.each do |x| ! yield x end end *************** *** 59,63 **** def initialize(key, value) ! @qualifier, @value = key, value end attr_reader :qualifier, :value --- 59,63 ---- def initialize(key, value) ! @qualifier, @value = key, value end attr_reader :qualifier, :value *************** *** 82,87 **** def each(arg = nil) @features.each do |x| ! next if arg and x.feature != arg ! yield x end end --- 82,87 ---- def each(arg = nil) @features.each do |x| ! next if arg and x.feature != arg ! yield x end end Index: reference.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/reference.rb,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** reference.rb 26 May 2005 13:16:23 -0000 1.16 --- reference.rb 8 Sep 2005 01:22:08 -0000 1.17 *************** *** 52,78 **** return endnote when 'bibitem' ! return bibitem(option) when 'bibtex' ! return bibtex(option) when 'rd' ! return rd(option) when /^nature$/i ! return nature(option) when /^science$/i ! return science when /^genome\s*_*biol/i ! return genome_biol when /^genome\s*_*res/i ! return genome_res when /^nar$/i ! return nar when /^current/i ! return current when /^trends/i ! return trends when /^cell$/i ! return cell else ! return general end end --- 52,78 ---- return endnote when 'bibitem' ! return bibitem(option) when 'bibtex' ! return bibtex(option) when 'rd' ! return rd(option) when /^nature$/i ! return nature(option) when /^science$/i ! return science when /^genome\s*_*biol/i ! return genome_biol when /^genome\s*_*res/i ! return genome_res when /^nar$/i ! return nar when /^current/i ! return current when /^trends/i ! return trends when /^cell$/i ! return cell else ! return general end end *************** *** 109,116 **** pages = @pages.sub('-', '--') return <<-"END".collect {|line| line.strip}.join("\n") ! \\bibitem{#{item}} ! #{@authors.join(', ')} ! #{@title}, ! {\\em #{@journal}}, #{@volume}(#{@issue}):#{pages}, #{@year}. END end --- 109,116 ---- pages = @pages.sub('-', '--') return <<-"END".collect {|line| line.strip}.join("\n") ! \\bibitem{#{item}} ! #{@authors.join(', ')} ! #{@title}, ! {\\em #{@journal}}, #{@volume}(#{@issue}):#{pages}, #{@year}. END end *************** *** 121,133 **** pages = @pages.sub('-', '--') return <<-"END".gsub(/\t/, '') ! @#{section}{PMID:#{@pubmed}, ! author = {#{authors}}, ! title = {#{@title}}, ! journal = {#{@journal}}, ! year = {#{@year}}, ! volume = {#{@volume}}, ! number = {#{@issue}}, ! pages = {#{pages}}, ! } END end --- 121,133 ---- pages = @pages.sub('-', '--') return <<-"END".gsub(/\t/, '') ! @#{section}{PMID:#{@pubmed}, ! author = {#{authors}}, ! title = {#{@title}}, ! journal = {#{@journal}}, ! year = {#{@year}}, ! volume = {#{@volume}}, ! number = {#{@issue}}, ! pages = {#{pages}}, ! } END end *************** *** 150,164 **** def nature(short = false) if short ! if @authors.size > 4 ! authors = "#{@authors[0]} et al." ! elsif @authors.size == 1 ! authors = "#{@authors[0]}" ! else ! authors = authors_join(' & ') ! end ! "#{authors} #{@journal} #{@volume}, #{@pages} (#{@year})." else ! authors = authors_join(' & ') ! "#{authors} #{@title} #{@journal} #{@volume}, #{@pages} (#{@year})." end end --- 150,164 ---- def nature(short = false) if short ! if @authors.size > 4 ! authors = "#{@authors[0]} et al." ! elsif @authors.size == 1 ! authors = "#{@authors[0]}" ! else ! authors = authors_join(' & ') ! end ! "#{authors} #{@journal} #{@volume}, #{@pages} (#{@year})." else ! authors = authors_join(' & ') ! "#{authors} #{@title} #{@journal} #{@volume}, #{@pages} (#{@year})." end end *************** *** 166,172 **** def science if @authors.size > 4 ! authors = rev_name(@authors[0]) + " et al." else ! authors = @authors.collect {|name| rev_name(name)}.join(', ') end page_from, = @pages.split('-') --- 166,172 ---- def science if @authors.size > 4 ! authors = rev_name(@authors[0]) + " et al." else ! authors = @authors.collect {|name| rev_name(name)}.join(', ') end page_from, = @pages.split('-') *************** *** 198,206 **** def trends if @authors.size > 2 ! authors = "#{@authors[0]} et al." elsif @authors.size == 1 ! authors = "#{@authors[0]}" else ! authors = authors_join(' and ') end "#{authors} (#{@year}) #{@title} #{@journal} #{@volume}, #{@pages}" --- 198,206 ---- def trends if @authors.size > 2 ! authors = "#{@authors[0]} et al." elsif @authors.size == 1 ! authors = "#{@authors[0]}" else ! authors = authors_join(' and ') end "#{authors} (#{@year}) #{@title} #{@journal} #{@volume}, #{@pages}" *************** *** 217,226 **** authors = @authors.clone if authors.length > 1 ! last = authors.pop ! authors = authors.join(sep) + "#{amp}" + last elsif authors.length == 1 ! authors = authors.pop else ! authors = "" end end --- 217,226 ---- authors = @authors.clone if authors.length > 1 ! last = authors.pop ! authors = authors.join(sep) + "#{amp}" + last elsif authors.length == 1 ! authors = authors.pop else ! authors = "" end end *************** *** 228,233 **** def rev_name(name) if name =~ /,/ ! name, initial = name.split(/,\s+/) ! name = "#{initial} #{name}" end return name --- 228,233 ---- def rev_name(name) if name =~ /,/ ! name, initial = name.split(/,\s+/) ! name = "#{initial} #{name}" end return name *************** *** 251,255 **** def each @references.each do |x| ! yield x end end --- 251,255 ---- def each @references.each do |x| ! yield x end end From k at pub.open-bio.org Wed Sep 7 21:22:14 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri Sep 9 13:29:26 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/io brdb.rb, 1.2, 1.3 das.rb, 1.7, 1.8 dbget.rb, 1.9, 1.10 flatfile.rb, 1.35, 1.36 pubmed.rb, 1.11, 1.12 registry.rb, 1.12, 1.13 sql.rb, 1.2, 1.3 Message-ID: <200509080122.j881MEdZ009132@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/io Modified Files: brdb.rb das.rb dbget.rb flatfile.rb pubmed.rb registry.rb sql.rb Log Message: * expanded tab at the line head Index: pubmed.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/pubmed.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pubmed.rb 5 Feb 2004 12:58:57 -0000 1.11 --- pubmed.rb 8 Sep 2005 01:22:12 -0000 1.12 *************** *** 36,43 **** result = response.body if result =~ /#{id}\s+Error/ ! raise( result ) else ! result = result.gsub("\r", "\n").squeeze("\n").gsub(/<\/?pre>/, '') ! return result end end --- 36,43 ---- result = response.body if result =~ /#{id}\s+Error/ ! raise( result ) else ! result = result.gsub("\r", "\n").squeeze("\n").gsub(/<\/?pre>/, '') ! return result end end *************** *** 51,58 **** result = response.body if result =~ /#{id}\s+Error/ ! raise( result ) else ! result = result.gsub("\r", "\n").squeeze("\n").gsub(/<\/?pre>/, '') ! return result end end --- 51,58 ---- result = response.body if result =~ /#{id}\s+Error/ ! raise( result ) else ! result = result.gsub("\r", "\n").squeeze("\n").gsub(/<\/?pre>/, '') ! return result end end Index: registry.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/registry.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** registry.rb 15 Feb 2004 01:44:02 -0000 1.12 --- registry.rb 8 Sep 2005 01:22:12 -0000 1.13 *************** *** 39,49 **** env_path = ENV['OBDA_SEARCH_PATH'] if env_path and env_path.size > 0 ! read_env(env_path) else ! read_local("#{ENV['HOME']}/.bioinformatics/seqdatabase.ini") ! read_local("/etc/bioinformatics/seqdatabase.ini") ! if @registry.empty? ! read_remote("http://www.open-bio.org/registry/seqdatabase.ini") ! end end end --- 39,49 ---- env_path = ENV['OBDA_SEARCH_PATH'] if env_path and env_path.size > 0 ! read_env(env_path) else ! read_local("#{ENV['HOME']}/.bioinformatics/seqdatabase.ini") ! read_local("/etc/bioinformatics/seqdatabase.ini") ! if @registry.empty? ! read_remote("http://www.open-bio.org/registry/seqdatabase.ini") ! end end end *************** *** 51,68 **** def get_database(dbname) @registry.each do |db| ! if db.database == dbname.downcase ! case db.protocol ! when 'biofetch' ! return serv_biofetch(db) ! when 'biosql' ! return serv_biosql(db) ! when 'flat', 'index-flat', 'index-berkeleydb' ! return serv_flat(db) ! when 'bsane-corba', 'biocorba' ! raise NotImplementedError ! when 'xembl' ! raise NotImplementedError ! end ! end end return nil --- 51,68 ---- def get_database(dbname) @registry.each do |db| ! if db.database == dbname.downcase ! case db.protocol ! when 'biofetch' ! return serv_biofetch(db) ! when 'biosql' ! return serv_biosql(db) ! when 'flat', 'index-flat', 'index-berkeleydb' ! return serv_flat(db) ! when 'bsane-corba', 'biocorba' ! raise NotImplementedError ! when 'xembl' ! raise NotImplementedError ! end ! end end return nil *************** *** 72,76 **** def query(dbname) @registry.each do |db| ! return db if db.database == dbname.downcase end end --- 72,76 ---- def query(dbname) @registry.each do |db| ! return db if db.database == dbname.downcase end end *************** *** 80,88 **** def read_env(path) path.split('+').each do |elem| ! if /:/.match(elem) ! read_remote(elem) ! else ! read_local(elem) ! end end end --- 80,88 ---- def read_env(path) path.split('+').each do |elem| ! if /:/.match(elem) ! read_remote(elem) ! else ! read_local(elem) ! end end end *************** *** 90,95 **** def read_local(file) if File.readable?(file) ! stanza = File.open(file).read ! parse_stanza(stanza) end end --- 90,95 ---- def read_local(file) if File.readable?(file) ! stanza = File.open(file).read ! parse_stanza(stanza) end end *************** *** 98,103 **** schema, user, host, port, reg, path, = URI.split(url) Net::HTTP.start(host, port) do |http| ! response, = http.get(path) ! parse_stanza(response.body) end end --- 98,103 ---- schema, user, host, port, reg, path, = URI.split(url) Net::HTTP.start(host, port) do |http| ! response, = http.get(path) ! parse_stanza(response.body) end end *************** *** 106,122 **** return unless stanza if stanza[/.*/] =~ /VERSION\s*=\s*(\S+)/ ! @spec_version = $1 # for internal use (may differ on each file) ! stanza[/.*/] = '' # remove VERSION line end stanza.each_line do |line| ! case line ! when /^\[(.*)\]/ dbname = $1.downcase ! db = Bio::Registry::DB.new($1) ! @registry.push(db) ! when /=/ ! tag, value = line.chomp.split(/\s*=\s*/) ! @registry.last[tag] = value ! end end end --- 106,122 ---- return unless stanza if stanza[/.*/] =~ /VERSION\s*=\s*(\S+)/ ! @spec_version = $1 # for internal use (may differ on each file) ! stanza[/.*/] = '' # remove VERSION line end stanza.each_line do |line| ! case line ! when /^\[(.*)\]/ dbname = $1.downcase ! db = Bio::Registry::DB.new($1) ! @registry.push(db) ! when /=/ ! tag, value = line.chomp.split(/\s*=\s*/) ! @registry.last[tag] = value ! end end end *************** *** 134,140 **** case db.driver when /mysql/i ! driver = 'Mysql' when /pg|postgres/i ! driver = 'Pg' when /oracle/ when /sybase/ --- 134,140 ---- case db.driver when /mysql/i ! driver = 'Mysql' when /pg|postgres/i ! driver = 'Pg' when /oracle/ when /sybase/ *************** *** 168,182 **** def initialize(dbname) ! @database = dbname ! @property = Hash.new end attr_reader :database def method_missing(meth_id) ! @property[meth_id.id2name] end def []=(tag, value) ! @property[tag] = value end --- 168,182 ---- def initialize(dbname) ! @database = dbname ! @property = Hash.new end attr_reader :database def method_missing(meth_id) ! @property[meth_id.id2name] end def []=(tag, value) ! @property[tag] = value end Index: brdb.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/brdb.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** brdb.rb 26 Jun 2002 00:12:29 -0000 1.2 --- brdb.rb 8 Sep 2005 01:22:11 -0000 1.3 *************** *** 36,41 **** def fetch(db_table, entry_id) DBI.connect(*@brdb) do |dbh| ! query = "select * from #{db_table} where id = ?" ! dbh.execute(query, entry_id).fetch_all end end --- 36,41 ---- def fetch(db_table, entry_id) DBI.connect(*@brdb) do |dbh| ! query = "select * from #{db_table} where id = ?" ! dbh.execute(query, entry_id).fetch_all end end *************** *** 43,51 **** def insert(db_table, values) if values.is_a?(Array) ! values = values.map{ |x| '"' + DBI.quote(x) + '"' }.join(",") end DBI.connect(*@brdb) do |dbh| ! query = "insert into #{db_table} values (?);" ! dbh.execute(query, values) end end --- 43,51 ---- def insert(db_table, values) if values.is_a?(Array) ! values = values.map{ |x| '"' + DBI.quote(x) + '"' }.join(",") end DBI.connect(*@brdb) do |dbh| ! query = "insert into #{db_table} values (?);" ! dbh.execute(query, values) end end *************** *** 53,61 **** def update(db_table, entry_id, values) if values.is_a?(Hash) ! values = values.to_a.map{ |k, v| "#{k}='#{DBI.quote(v)}'" }.join(',') end DBI.connect(*@brdb) do |dbh| ! query = "update #{db_table} set ? where id = ?" ! dbh.execute(query, values, entry_id) end end --- 53,61 ---- def update(db_table, entry_id, values) if values.is_a?(Hash) ! values = values.to_a.map{ |k, v| "#{k}='#{DBI.quote(v)}'" }.join(',') end DBI.connect(*@brdb) do |dbh| ! query = "update #{db_table} set ? where id = ?" ! dbh.execute(query, values, entry_id) end end Index: dbget.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/dbget.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dbget.rb 24 Aug 2004 00:05:58 -0000 1.9 --- dbget.rb 8 Sep 2005 01:22:11 -0000 1.10 *************** *** 35,41 **** unless serv or port # if both of serv and port are nil ! if ENV["DBGET"] =~ /:/ # and ENV["DBGET"] exists ! serv, port = ENV["DBGET"].split(':') ! end end serv = serv ? serv : SERV --- 35,41 ---- unless serv or port # if both of serv and port are nil ! if ENV["DBGET"] =~ /:/ # and ENV["DBGET"] exists ! serv, port = ENV["DBGET"].split(':') ! end end serv = serv ? serv : SERV *************** *** 43,47 **** if arg.empty? ! arg = "-h" # DBGET help message end --- 43,47 ---- if arg.empty? ! arg = "-h" # DBGET help message end Index: das.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/das.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** das.rb 26 Aug 2004 10:25:35 -0000 1.7 --- das.rb 8 Sep 2005 01:22:11 -0000 1.8 *************** *** 47,52 **** dsn = DSN.new e.elements.each do |e| ! case e.name ! when 'SOURCE' dsn.source = e.text dsn.source_id = e.attributes['id'] --- 47,52 ---- dsn = DSN.new e.elements.each do |e| ! case e.name ! when 'SOURCE' dsn.source = e.text dsn.source_id = e.attributes['id'] *************** *** 70,85 **** doc = REXML::Document.new(result.body) doc.elements.each('/descendant::ENTRY_POINTS') do |e| ! entry_point.href = e.attributes['href'] ! entry_point.version = e.attributes['version'] ! e.elements.each do |e| ! segment = SEGMENT.new ! segment.entry_id = e.attributes['id'] ! segment.start = e.attributes['start'] ! segment.stop = e.attributes['stop'] ! segment.stop = e.attributes['orientation'] ! segment.subparts = e.attributes['subparts'] ! segment.description = e.text ! entry_point.segments << segment ! end end entry_point --- 70,85 ---- doc = REXML::Document.new(result.body) doc.elements.each('/descendant::ENTRY_POINTS') do |e| ! entry_point.href = e.attributes['href'] ! entry_point.version = e.attributes['version'] ! e.elements.each do |e| ! segment = SEGMENT.new ! segment.entry_id = e.attributes['id'] ! segment.start = e.attributes['start'] ! segment.stop = e.attributes['stop'] ! segment.stop = e.attributes['orientation'] ! segment.subparts = e.attributes['subparts'] ! segment.description = e.text ! entry_point.segments << segment ! end end entry_point *************** *** 94,98 **** opts = [] segments.each do |s| ! opts << "segment=#{s.entry_id}:#{s.start},#{s.stop}" end query = opts.join(';') --- 94,98 ---- opts = [] segments.each do |s| ! opts << "segment=#{s.entry_id}:#{s.start},#{s.stop}" end query = opts.join(';') *************** *** 101,113 **** doc = REXML::Document.new(result.body) doc.elements.each('/descendant::SEQUENCE') do |e| ! sequence = DNA.new ! sequence.entry_id = e.attributes['id'] ! sequence.start = e.attributes['start'] ! sequence.stop = e.attributes['stop'] ! sequence.version = e.attributes['version'] ! e.elements.each do |e| ! sequence.sequence = Bio::Sequence::NA.new(e.text) ! sequence.length = e.attributes['length'].to_i ! end ary << sequence end --- 101,113 ---- doc = REXML::Document.new(result.body) doc.elements.each('/descendant::SEQUENCE') do |e| ! sequence = DNA.new ! sequence.entry_id = e.attributes['id'] ! sequence.start = e.attributes['start'] ! sequence.stop = e.attributes['stop'] ! sequence.version = e.attributes['version'] ! e.elements.each do |e| ! sequence.sequence = Bio::Sequence::NA.new(e.text) ! sequence.length = e.attributes['length'].to_i ! end ary << sequence end *************** *** 123,127 **** opts = [] segments.each do |s| ! opts << "segment=#{s.entry_id}:#{s.start},#{s.stop}" end query = opts.join(';') --- 123,127 ---- opts = [] segments.each do |s| ! opts << "segment=#{s.entry_id}:#{s.start},#{s.stop}" end query = opts.join(';') *************** *** 130,147 **** doc = REXML::Document.new(result.body) doc.elements.each('/descendant::SEQUENCE') do |e| ! sequence = SEQUENCE.new ! sequence.entry_id = e.attributes['id'] ! sequence.start = e.attributes['start'] ! sequence.stop = e.attributes['stop'] ! sequence.moltype = e.attributes['moltype'] ! sequence.version = e.attributes['version'] ! case sequence.moltype ! when /dna|rna/i # 'DNA', 'ssRNA', 'dsRNA' ! sequence.sequence = Bio::Sequence::NA.new(e.text) ! when /protein/i # 'Protein ! sequence.sequence = Bio::Sequence::AA.new(e.text) ! else ! sequence.sequence = e.text ! end ary << sequence end --- 130,147 ---- doc = REXML::Document.new(result.body) doc.elements.each('/descendant::SEQUENCE') do |e| ! sequence = SEQUENCE.new ! sequence.entry_id = e.attributes['id'] ! sequence.start = e.attributes['start'] ! sequence.stop = e.attributes['stop'] ! sequence.moltype = e.attributes['moltype'] ! sequence.version = e.attributes['version'] ! case sequence.moltype ! when /dna|rna/i # 'DNA', 'ssRNA', 'dsRNA' ! sequence.sequence = Bio::Sequence::NA.new(e.text) ! when /protein/i # 'Protein ! sequence.sequence = Bio::Sequence::AA.new(e.text) ! else ! sequence.sequence = e.text ! end ary << sequence end *************** *** 157,161 **** opts = [] segments.each do |s| ! opts << "segment=#{s.entry_id}:#{s.start},#{s.stop}" end query = opts.join(';') --- 157,161 ---- opts = [] segments.each do |s| ! opts << "segment=#{s.entry_id}:#{s.start},#{s.stop}" end query = opts.join(';') *************** *** 164,186 **** doc = REXML::Document.new(result.body) doc.elements.each('/descendant::GFF') do |e| ! types.version = e.attributes['version'] ! types.href = e.attributes['href'] ! e.elements.each do |e| ! segment = SEGMENT.new ! segment.entry_id = e.attributes['id'] ! segment.start = e.attributes['start'] ! segment.stop = e.attributes['stop'] ! segment.version = e.attributes['version'] ! segment.label = e.attributes['label'] ! e.elements.each do |e| ! t = TYPE.new ! t.entry_id = e.attributes['id'] ! t.method = e.attributes['method'] ! t.category = e.attributes['category'] ! t.count = e.text.to_i ! segment.types << t ! end ! types.segments << segment ! end end types --- 164,186 ---- doc = REXML::Document.new(result.body) doc.elements.each('/descendant::GFF') do |e| ! types.version = e.attributes['version'] ! types.href = e.attributes['href'] ! e.elements.each do |e| ! segment = SEGMENT.new ! segment.entry_id = e.attributes['id'] ! segment.start = e.attributes['start'] ! segment.stop = e.attributes['stop'] ! segment.version = e.attributes['version'] ! segment.label = e.attributes['label'] ! e.elements.each do |e| ! t = TYPE.new ! t.entry_id = e.attributes['id'] ! t.method = e.attributes['method'] ! t.category = e.attributes['category'] ! t.count = e.text.to_i ! segment.types << t ! end ! types.segments << segment ! end end types *************** *** 196,209 **** opts = [] segments.each do |s| ! opts << "segment=#{s.entry_id}:#{s.start},#{s.stop}" end if categorize ! opts << "categorize=yes" # default is 'no' end feature_ids.each do |fid| ! opts << "feature_id=#{fid}" end group_ids.each do |gid| ! opts << "group_id=#{gid}" end query = opts.join(';') --- 196,209 ---- opts = [] segments.each do |s| ! opts << "segment=#{s.entry_id}:#{s.start},#{s.stop}" end if categorize ! opts << "categorize=yes" # default is 'no' end feature_ids.each do |fid| ! opts << "feature_id=#{fid}" end group_ids.each do |gid| ! opts << "group_id=#{gid}" end query = opts.join(';') *************** *** 215,294 **** gff.href = e.attributes['href'] e.elements.each('SEGMENT') do |e| ! segment = SEGMENT.new ! segment.entry_id = e.attributes['id'] ! segment.start = e.attributes['start'] ! segment.stop = e.attributes['stop'] ! segment.version = e.attributes['version'] ! segment.label = e.attributes['label'] ! e.elements.each do |e| ! feature = FEATURE.new ! feature.entry_id = e.attributes['id'] ! feature.label = e.attributes['label'] ! e.elements.each do |e| ! case e.name ! when 'TYPE' ! type = TYPE.new ! type.entry_id = e.attributes['id'] ! type.category = e.attributes['category'] ! type.reference = e.attributes['referrence'] ! type.label = e.text ! feature.types << type ! when 'METHOD' ! feature.method_id = e.attributes['id'] ! feature.method = e.text ! when 'START' ! feature.start = e.text ! when 'STOP', 'END' ! feature.stop = e.text ! when 'SCORE' ! feature.score = e.text ! when 'ORIENTATION' ! feature.orientation = e.text ! when 'PHASE' ! feature.phase = e.text ! when 'NOTE' ! feature.notes << e.text ! when 'LINK' ! link = LINK.new ! link.href = e.attributes['href'] ! link.text = e.text ! feature.links << link ! when 'TARGET' ! target = TARGET.new ! target.entry_id = e.attributes['id'] ! target.start = e.attributes['start'] ! target.stop = e.attributes['stop'] ! target.name = e.text ! feature.targets << target ! when 'GROUP' ! group = GROUP.new ! group.entry_id = e.attributes['id'] ! group.label = e.attributes['label'] ! group.type = e.attributes['type'] ! e.elements.each do |e| ! case e.name ! when 'NOTE' # in GROUP ! group.notes << e.text ! when 'LINK' # in GROUP ! link = LINK.new ! link.href = e.attributes['href'] ! link.text = e.text ! group.links << link ! when 'TARGET' # in GROUP ! target = TARGET.new ! target.entry_id = e.attributes['id'] ! target.start = e.attributes['start'] ! target.stop = e.attributes['stop'] ! target.name = e.text ! group.targets << target ! end ! end ! feature.groups << group ! end ! end ! segment.features << feature ! end ! gff.segments << segment ! end end gff --- 215,294 ---- gff.href = e.attributes['href'] e.elements.each('SEGMENT') do |e| ! segment = SEGMENT.new ! segment.entry_id = e.attributes['id'] ! segment.start = e.attributes['start'] ! segment.stop = e.attributes['stop'] ! segment.version = e.attributes['version'] ! segment.label = e.attributes['label'] ! e.elements.each do |e| ! feature = FEATURE.new ! feature.entry_id = e.attributes['id'] ! feature.label = e.attributes['label'] ! e.elements.each do |e| ! case e.name ! when 'TYPE' ! type = TYPE.new ! type.entry_id = e.attributes['id'] ! type.category = e.attributes['category'] ! type.reference = e.attributes['referrence'] ! type.label = e.text ! feature.types << type ! when 'METHOD' ! feature.method_id = e.attributes['id'] ! feature.method = e.text ! when 'START' ! feature.start = e.text ! when 'STOP', 'END' ! feature.stop = e.text ! when 'SCORE' ! feature.score = e.text ! when 'ORIENTATION' ! feature.orientation = e.text ! when 'PHASE' ! feature.phase = e.text ! when 'NOTE' ! feature.notes << e.text ! when 'LINK' ! link = LINK.new ! link.href = e.attributes['href'] ! link.text = e.text ! feature.links << link ! when 'TARGET' ! target = TARGET.new ! target.entry_id = e.attributes['id'] ! target.start = e.attributes['start'] ! target.stop = e.attributes['stop'] ! target.name = e.text ! feature.targets << target ! when 'GROUP' ! group = GROUP.new ! group.entry_id = e.attributes['id'] ! group.label = e.attributes['label'] ! group.type = e.attributes['type'] ! e.elements.each do |e| ! case e.name ! when 'NOTE' # in GROUP ! group.notes << e.text ! when 'LINK' # in GROUP ! link = LINK.new ! link.href = e.attributes['href'] ! link.text = e.text ! group.links << link ! when 'TARGET' # in GROUP ! target = TARGET.new ! target.entry_id = e.attributes['id'] ! target.start = e.attributes['start'] ! target.stop = e.attributes['stop'] ! target.name = e.text ! group.targets << target ! end ! end ! feature.groups << group ! end ! end ! segment.features << feature ! end ! gff.segments << segment ! end end gff *************** *** 298,307 **** class DSN attr_accessor :source, :source_id, :source_version, ! :mapmaster, :description, :description_href end class ENTRY_POINT def initialize ! @segments = Array.new end attr_reader :segments --- 298,307 ---- class DSN attr_accessor :source, :source_id, :source_version, ! :mapmaster, :description, :description_href end class ENTRY_POINT def initialize ! @segments = Array.new end attr_reader :segments *************** *** 317,335 **** class SEGMENT def self.region(entry_id, start, stop) ! segment = self.new ! segment.entry_id = entry_id ! segment.start = start ! segment.stop = stop ! return segment end def initialize ! @features = Array.new # for FEATURE ! @types = Array.new # for TYPE end attr_accessor :entry_id, :start, :stop, :orientation, :description, ! :subparts, # optional ! :features, :version, :label, # for FEATURE ! :types # for TYPE end --- 317,335 ---- class SEGMENT def self.region(entry_id, start, stop) ! segment = self.new ! segment.entry_id = entry_id ! segment.start = start ! segment.stop = stop ! return segment end def initialize ! @features = Array.new # for FEATURE ! @types = Array.new # for TYPE end attr_accessor :entry_id, :start, :stop, :orientation, :description, ! :subparts, # optional ! :features, :version, :label, # for FEATURE ! :types # for TYPE end *************** *** 346,355 **** class TYPE attr_accessor :entry_id, :method, :category, :count, ! :reference, :label # for FEATURE end class GFF def initialize ! @segments = Array.new end attr_reader :segments --- 346,355 ---- class TYPE attr_accessor :entry_id, :method, :category, :count, ! :reference, :label # for FEATURE end class GFF def initialize ! @segments = Array.new end attr_reader :segments *************** *** 359,370 **** class FEATURE def initialize ! @notes = Array.new ! @links = Array.new ! @types = Array.new ! @targets = Array.new ! @groups = Array.new end attr_accessor :entry_id, :label, ! :method_id, :method, :start, :stop, :score, :orientation, :phase attr_reader :notes, :links, :types, :targets, :groups end --- 359,370 ---- class FEATURE def initialize ! @notes = Array.new ! @links = Array.new ! @types = Array.new ! @targets = Array.new ! @groups = Array.new end attr_accessor :entry_id, :label, ! :method_id, :method, :start, :stop, :score, :orientation, :phase attr_reader :notes, :links, :types, :targets, :groups end *************** *** 380,386 **** class GROUP def initialize ! @notes = Array.new ! @links = Array.new ! @targets = Array.new end attr_accessor :entry_id, :label, :type --- 380,386 ---- class GROUP def initialize ! @notes = Array.new ! @links = Array.new ! @targets = Array.new end attr_accessor :entry_id, :label, :type Index: sql.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/sql.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sql.rb 25 Feb 2003 15:47:47 -0000 1.2 --- sql.rb 8 Sep 2005 01:22:12 -0000 1.3 *************** *** 58,68 **** def initialize(dbh, entry) ! @dbh = dbh ! @bioentry_id = entry['bioentry_id'] ! @database_id = entry['biodatabase_id'] ! @entry_id = entry['display_id'] ! @accession = entry['accession'] ! @version = entry['entry_version'] ! @division = entry['division'] end attr_reader :accession, :division, :entry_id, :version --- 58,68 ---- def initialize(dbh, entry) ! @dbh = dbh ! @bioentry_id = entry['bioentry_id'] ! @database_id = entry['biodatabase_id'] ! @entry_id = entry['display_id'] ! @accession = entry['accession'] ! @version = entry['entry_version'] ! @division = entry['division'] end attr_reader :accession, :division, :entry_id, :version *************** *** 70,243 **** def to_fasta ! if seq = seq ! return seq.to_fasta(@accession) ! end end def seq ! query = "select * from biosequence where bioentry_id = ?" ! row = @dbh.execute(query, @bioentry_id).fetch ! return unless row ! mol = row['molecule'] ! seq = row['biosequence_str'] ! case mol ! when /.na/i # 'dna' or 'rna' ! Bio::Sequence::NA.new(seq) ! else # 'protein' ! Bio::Sequence::AA.new(seq) ! end end def subseq(from, to) ! length = to - from + 1 ! query = "select molecule, substring(biosequence_str, ?, ?) as subseq" + ! " from biosequence where bioentry_id = ?" ! row = @dbh.execute(query, from, length, @bioentry_id).fetch ! return unless row ! mol = row['molecule'] ! seq = row['subseq'] ! case mol ! when /.na/i # 'dna' or 'rna' ! Bio::Sequence::NA.new(seq) ! else # 'protein' ! Bio::Sequence::AA.new(seq) ! end end def features ! array = [] ! query = "select * from seqfeature where bioentry_id = ?" ! @dbh.execute(query, @bioentry_id).fetch_all.each do |row| ! next unless row ! f_id = row['seqfeature_id'] ! k_id = row['seqfeature_key_id'] ! s_id = row['seqfeature_source_id'] ! rank = row['seqfeature_rank'].to_i - 1 ! # key : type (gene, CDS, ...) ! type = feature_key(k_id) ! # source : database (EMBL/GenBank/SwissProt) ! database = feature_source(s_id) ! # location : position ! locations = feature_locations(f_id) ! # qualifier ! qualifiers = feature_qualifiers(f_id) ! # rank ! array[rank] = Bio::Feature.new(type, locations, qualifiers) ! end ! return Bio::Features.new(array) end def references ! array = [] ! query = <<-END ! select * from bioentry_reference, reference ! where bioentry_id = ? and ! bioentry_reference.reference_id = reference.reference_id ! END ! @dbh.execute(query, @bioentry_id).fetch_all.each do |row| ! next unless row ! hash = { ! 'start' => row['reference_start'], ! 'end' => row['reference_end'], ! 'journal' => row['reference_location'], ! 'title' => row['reference_title'], ! 'authors' => row['reference_authors'], ! 'medline' => row['reference_medline'] ! } ! hash.default = '' ! rank = row['reference_rank'].to_i - 1 ! array[rank] = hash ! end ! return array end def comment ! query = "select * from comment where bioentry_id = ?" ! row = @dbh.execute(query, @bioentry_id).fetch ! row ? row['comment_text'] : '' end def comments ! array = [] ! query = "select * from comment where bioentry_id = ?" ! @dbh.execute(query, @bioentry_id).fetch_all.each do |row| ! next unless row ! rank = row['comment_rank'].to_i - 1 ! array[rank] = row['comment_text'] ! end ! return array end def database ! query = "select * from biodatabase where biodatabase_id = ?" ! row = @dbh.execute(query, @database_id).fetch ! row ? row['name'] : '' end def date ! query = "select * from bioentry_date where bioentry_id = ?" ! row = @dbh.execute(query, @bioentry_id).fetch ! row ? row['date'] : '' end def dblink ! query = "select * from bioentry_direct_links where source_bioentry_id = ?" ! row = @dbh.execute(query, @bioentry_id).fetch ! row ? [row['dbname'], row['accession']] : [] end def definition ! query = "select * from bioentry_description where bioentry_id = ?" ! row = @dbh.execute(query, @bioentry_id).fetch ! row ? row['description'] : '' end def keyword ! query = "select * from bioentry_keywords where bioentry_id = ?" ! row = @dbh.execute(query, @bioentry_id).fetch ! row ? row['keywords'] : '' end def taxonomy ! query = <<-END ! select full_lineage, common_name, ncbi_taxa_id ! from bioentry_taxa, taxa ! where bioentry_id = ? and bioentry_taxa.taxa_id = taxa.taxa_id ! END ! row = @dbh.execute(query, @bioentry_id).fetch ! @lineage = row ? row['full_lineage'] : '' ! @common_name = row ? row['common_name'] : '' ! @ncbi_taxa_id = row ? row['ncbi_taxa_id'] : '' ! row ? [@lineage, @common_name, @ncbi_taxa_id] : [] end def lineage ! taxonomy unless @lineage ! return @lineage end def common_name ! taxonomy unless @common_name ! return @common_name end def ncbi_taxa_id ! taxonomy unless @ncbi_taxa_id ! return @ncbi_taxa_id end --- 70,243 ---- def to_fasta ! if seq = seq ! return seq.to_fasta(@accession) ! end end def seq ! query = "select * from biosequence where bioentry_id = ?" ! row = @dbh.execute(query, @bioentry_id).fetch ! return unless row ! mol = row['molecule'] ! seq = row['biosequence_str'] ! case mol ! when /.na/i # 'dna' or 'rna' ! Bio::Sequence::NA.new(seq) ! else # 'protein' ! Bio::Sequence::AA.new(seq) ! end end def subseq(from, to) ! length = to - from + 1 ! query = "select molecule, substring(biosequence_str, ?, ?) as subseq" + ! " from biosequence where bioentry_id = ?" ! row = @dbh.execute(query, from, length, @bioentry_id).fetch ! return unless row ! mol = row['molecule'] ! seq = row['subseq'] ! case mol ! when /.na/i # 'dna' or 'rna' ! Bio::Sequence::NA.new(seq) ! else # 'protein' ! Bio::Sequence::AA.new(seq) ! end end def features ! array = [] ! query = "select * from seqfeature where bioentry_id = ?" ! @dbh.execute(query, @bioentry_id).fetch_all.each do |row| ! next unless row ! f_id = row['seqfeature_id'] ! k_id = row['seqfeature_key_id'] ! s_id = row['seqfeature_source_id'] ! rank = row['seqfeature_rank'].to_i - 1 ! # key : type (gene, CDS, ...) ! type = feature_key(k_id) ! # source : database (EMBL/GenBank/SwissProt) ! database = feature_source(s_id) ! # location : position ! locations = feature_locations(f_id) ! # qualifier ! qualifiers = feature_qualifiers(f_id) ! # rank ! array[rank] = Bio::Feature.new(type, locations, qualifiers) ! end ! return Bio::Features.new(array) end def references ! array = [] ! query = <<-END ! select * from bioentry_reference, reference ! where bioentry_id = ? and ! bioentry_reference.reference_id = reference.reference_id ! END ! @dbh.execute(query, @bioentry_id).fetch_all.each do |row| ! next unless row ! hash = { ! 'start' => row['reference_start'], ! 'end' => row['reference_end'], ! 'journal' => row['reference_location'], ! 'title' => row['reference_title'], ! 'authors' => row['reference_authors'], ! 'medline' => row['reference_medline'] ! } ! hash.default = '' ! rank = row['reference_rank'].to_i - 1 ! array[rank] = hash ! end ! return array end def comment ! query = "select * from comment where bioentry_id = ?" ! row = @dbh.execute(query, @bioentry_id).fetch ! row ? row['comment_text'] : '' end def comments ! array = [] ! query = "select * from comment where bioentry_id = ?" ! @dbh.execute(query, @bioentry_id).fetch_all.each do |row| ! next unless row ! rank = row['comment_rank'].to_i - 1 ! array[rank] = row['comment_text'] ! end ! return array end def database ! query = "select * from biodatabase where biodatabase_id = ?" ! row = @dbh.execute(query, @database_id).fetch ! row ? row['name'] : '' end def date ! query = "select * from bioentry_date where bioentry_id = ?" ! row = @dbh.execute(query, @bioentry_id).fetch ! row ? row['date'] : '' end def dblink ! query = "select * from bioentry_direct_links where source_bioentry_id = ?" ! row = @dbh.execute(query, @bioentry_id).fetch ! row ? [row['dbname'], row['accession']] : [] end def definition ! query = "select * from bioentry_description where bioentry_id = ?" ! row = @dbh.execute(query, @bioentry_id).fetch ! row ? row['description'] : '' end def keyword ! query = "select * from bioentry_keywords where bioentry_id = ?" ! row = @dbh.execute(query, @bioentry_id).fetch ! row ? row['keywords'] : '' end def taxonomy ! query = <<-END ! select full_lineage, common_name, ncbi_taxa_id ! from bioentry_taxa, taxa ! where bioentry_id = ? and bioentry_taxa.taxa_id = taxa.taxa_id ! END ! row = @dbh.execute(query, @bioentry_id).fetch ! @lineage = row ? row['full_lineage'] : '' ! @common_name = row ? row['common_name'] : '' ! @ncbi_taxa_id = row ? row['ncbi_taxa_id'] : '' ! row ? [@lineage, @common_name, @ncbi_taxa_id] : [] end def lineage ! taxonomy unless @lineage ! return @lineage end def common_name ! taxonomy unless @common_name ! return @common_name end def ncbi_taxa_id ! taxonomy unless @ncbi_taxa_id ! return @ncbi_taxa_id end *************** *** 246,315 **** def feature_key(k_id) ! query = "select * from seqfeature_key where seqfeature_key_id = ?" ! row = @dbh.execute(query, k_id).fetch ! row ? row['key_name'] : '' end def feature_source(s_id) ! query = "select * from seqfeature_source where seqfeature_source_id = ?" ! row = @dbh.execute(query, s_id).fetch ! row ? row['source_name'] : '' end def feature_locations(f_id) ! locations = [] ! query = "select * from seqfeature_location where seqfeature_id = ?" ! @dbh.execute(query, f_id).fetch_all.each do |row| ! next unless row ! location = Bio::Location.new ! location.strand = row['seq_strand'] ! location.from = row['seq_start'] ! location.to = row['seq_end'] ! xref = feature_locations_remote(row['seqfeature_location_id']) ! location.xref_id = xref.shift unless xref.empty? ! # just omit fuzzy location for now... ! #feature_locations_qv(row['seqfeature_location_id']) ! rank = row['location_rank'].to_i - 1 ! locations[rank] = location ! end ! return Bio::Locations.new(locations) end def feature_locations_remote(l_id) ! query = "select * from remote_seqfeature_name where seqfeature_location_id = ?" ! row = @dbh.execute(query, l_id).fetch ! row ? [row['accession'], row['version']] : [] end def feature_locations_qv(l_id) ! query = "select * from location_qualifier_value where seqfeature_location_id = ?" ! row = @dbh.execute(query, l_id).fetch ! row ? [row['qualifier_value'], row['slot_value']] : [] end def feature_qualifiers(f_id) ! qualifiers = [] ! query = "select * from seqfeature_qualifier_value where seqfeature_id = ?" ! @dbh.execute(query, f_id).fetch_all.each do |row| ! next unless row ! key = feature_qualifiers_key(row['seqfeature_qualifier_id']) ! value = row['qualifier_value'] ! qualifier = Bio::Feature::Qualifier.new(key, value) ! rank = row['seqfeature_qualifier_rank'].to_i - 1 ! qualifiers[rank] = qualifier ! end ! return qualifiers.compact # .compact is nasty hack for a while end def feature_qualifiers_key(q_id) ! query = "select * from seqfeature_qualifier where seqfeature_qualifier_id = ?" ! row = @dbh.execute(query, q_id).fetch ! row ? row['qualifier_name'] : '' end end --- 246,315 ---- def feature_key(k_id) ! query = "select * from seqfeature_key where seqfeature_key_id = ?" ! row = @dbh.execute(query, k_id).fetch ! row ? row['key_name'] : '' end def feature_source(s_id) ! query = "select * from seqfeature_source where seqfeature_source_id = ?" ! row = @dbh.execute(query, s_id).fetch ! row ? row['source_name'] : '' end def feature_locations(f_id) ! locations = [] ! query = "select * from seqfeature_location where seqfeature_id = ?" ! @dbh.execute(query, f_id).fetch_all.each do |row| ! next unless row ! location = Bio::Location.new ! location.strand = row['seq_strand'] ! location.from = row['seq_start'] ! location.to = row['seq_end'] ! xref = feature_locations_remote(row['seqfeature_location_id']) ! location.xref_id = xref.shift unless xref.empty? ! # just omit fuzzy location for now... ! #feature_locations_qv(row['seqfeature_location_id']) ! rank = row['location_rank'].to_i - 1 ! locations[rank] = location ! end ! return Bio::Locations.new(locations) end def feature_locations_remote(l_id) ! query = "select * from remote_seqfeature_name where seqfeature_location_id = ?" ! row = @dbh.execute(query, l_id).fetch ! row ? [row['accession'], row['version']] : [] end def feature_locations_qv(l_id) ! query = "select * from location_qualifier_value where seqfeature_location_id = ?" ! row = @dbh.execute(query, l_id).fetch ! row ? [row['qualifier_value'], row['slot_value']] : [] end def feature_qualifiers(f_id) ! qualifiers = [] ! query = "select * from seqfeature_qualifier_value where seqfeature_id = ?" ! @dbh.execute(query, f_id).fetch_all.each do |row| ! next unless row ! key = feature_qualifiers_key(row['seqfeature_qualifier_id']) ! value = row['qualifier_value'] ! qualifier = Bio::Feature::Qualifier.new(key, value) ! rank = row['seqfeature_qualifier_rank'].to_i - 1 ! qualifiers[rank] = qualifier ! end ! return qualifiers.compact # .compact is nasty hack for a while end def feature_qualifiers_key(q_id) ! query = "select * from seqfeature_qualifier where seqfeature_qualifier_id = ?" ! row = @dbh.execute(query, q_id).fetch ! row ? row['qualifier_name'] : '' end end Index: flatfile.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile.rb,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** flatfile.rb 10 Aug 2005 17:15:23 -0000 1.35 --- flatfile.rb 8 Sep 2005 01:22:11 -0000 1.36 *************** *** 31,35 **** openmode = [] while x = arg[0] and !x.is_a?(Hash) ! openmode << arg.shift end # rest of arg: passed to FlatFile.new --- 31,35 ---- openmode = [] while x = arg[0] and !x.is_a?(Hash) ! openmode << arg.shift end # rest of arg: passed to FlatFile.new *************** *** 78,84 **** # 1st arg: database class (or file format autodetection) if dbclass then ! self.dbclass = dbclass else ! autodetect end end --- 78,84 ---- # 1st arg: database class (or file format autodetection) if dbclass then ! self.dbclass = dbclass else ! autodetect end end *************** *** 89,105 **** return nil unless @entry_raw if raw then ! @entry_raw else ! e = @dbclass.new(@entry_raw) ! begin ! s = e.entry_overrun ! rescue NameError ! s = nil ! end ! if s then ! @entry_raw[-(s.length), s.length] = '' ! ungets(s) ! end ! e end end --- 89,105 ---- return nil unless @entry_raw if raw then ! @entry_raw else ! e = @dbclass.new(@entry_raw) ! begin ! s = e.entry_overrun ! rescue NameError ! s = nil ! end ! if s then ! @entry_raw[-(s.length), s.length] = '' ! ungets(s) ! end ! e end end *************** *** 108,112 **** def each_entry while e = self.next_entry ! yield e end end --- 108,112 ---- def each_entry while e = self.next_entry ! yield e end end *************** *** 135,141 **** def eof? if @prefetch.size > 0 ! false else ! @io.eof? end end --- 135,141 ---- def eof? if @prefetch.size > 0 ! false else ! @io.eof? end end *************** *** 143,176 **** def gets(io_rs = $/) if @prefetch.size > 0 ! if io_rs == nil then ! r = @prefetch + @io.gets(nil).to_s ! @prefetch = '' ! else ! if io_rs == '' then ! sp_rs = /\n\n/n ! sp_rs_orig = "\n\n" ! else ! sp_rs = Regexp.new(Regexp.escape(io_rs, 'n'), 0, 'n') ! sp_rs_orig = io_rs ! end ! a = @prefetch.split(sp_rs, 2) ! if a.size > 1 then ! r = a[0] + sp_rs_orig ! @prefetch = a[1] ! else ! @prefetch << @io.gets(io_rs).to_s ! a = @prefetch.split(sp_rs, 2) ! if a.size > 1 then ! r = a[0] + sp_rs_orig ! @prefetch = a[1].to_s ! else ! r = @prefetch ! @prefetch = '' ! end ! end ! end ! r else ! @io.gets(io_rs) end end --- 143,176 ---- def gets(io_rs = $/) if @prefetch.size > 0 ! if io_rs == nil then ! r = @prefetch + @io.gets(nil).to_s ! @prefetch = '' ! else ! if io_rs == '' then ! sp_rs = /\n\n/n ! sp_rs_orig = "\n\n" ! else ! sp_rs = Regexp.new(Regexp.escape(io_rs, 'n'), 0, 'n') ! sp_rs_orig = io_rs ! end ! a = @prefetch.split(sp_rs, 2) ! if a.size > 1 then ! r = a[0] + sp_rs_orig ! @prefetch = a[1] ! else ! @prefetch << @io.gets(io_rs).to_s ! a = @prefetch.split(sp_rs, 2) ! if a.size > 1 then ! r = a[0] + sp_rs_orig ! @prefetch = a[1].to_s ! else ! r = @prefetch ! @prefetch = '' ! end ! end ! end ! r else ! @io.gets(io_rs) end end *************** *** 183,190 **** def getc if @prefetch.size > 0 then ! r = @prefetch[0] ! @prefetch = @prefetch[1..-1] else ! r = @io.getc end r --- 183,190 ---- def getc if @prefetch.size > 0 then ! r = @prefetch[0] ! @prefetch = @prefetch[1..-1] else ! r = @io.getc end r *************** *** 203,211 **** def dbclass=(k) if k then ! @dbclass = k ! @rs = @dbclass::DELIMITER else ! @dbclass = nil ! @rs = $/ end end --- 203,211 ---- def dbclass=(k) if k then ! @dbclass = k ! @rs = @dbclass::DELIMITER else ! @dbclass = nil ! @rs = $/ end end *************** *** 216,229 **** r = nil 1.upto(lines) do |x| ! if line = @io.gets then ! @prefetch << line ! if line and line.strip.size > 0 then ! r = self.class.autodetect(@prefetch) ! if r then ! self.dbclass = r ! return r ! end ! end ! end end self.dbclass = nil unless dbclass --- 216,229 ---- r = nil 1.upto(lines) do |x| ! if line = @io.gets then ! @prefetch << line ! if line and line.strip.size > 0 then ! r = self.class.autodetect(@prefetch) ! if r then ! self.dbclass = r ! return r ! end ! end ! end end self.dbclass = nil unless dbclass *************** *** 248,309 **** case text when /^LOCUS .+ bp .*[a-z]*[DR]?NA/ ! Bio::GenBank when /^LOCUS .+ aa .+/ ! Bio::GenPept when /^UI \- [0-9]+$/ ! Bio::MEDLINE ! when /^ID .+\; *(DNA|RNA|XXX)\;/ ! Bio::EMBL when /^ID .+\; *PRT\;/ ! Bio::SPTR when /^ID [-A-Za-z0-9_\.]+\; (PATTERN|RULE|MATRIX)\.$/ ! Bio::PROSITE when /^AC [-A-Za-z0-9_\.]+$/ ! Bio::TRANSFAC when /^H [-A-Z0-9_\.]+$/ ! if text =~ /^M [rc]/ then ! Bio::AAindex2 ! elsif text =~ /^I A\/L/ then ! Bio::AAindex1 ! else ! false #fail to determine ! end when /^CODE [0-9]+$/ ! Bio::LITDB when /^Entry [A-Z0-9]+/ ! Bio::KEGG::BRITE ! when /^ENTRY .+ KO\s*$/ ! Bio::KEGG::KO when /^ENTRY .+ Glycan\s*$/ Bio::KEGG::GLYCAN when /^ENTRY .+ (CDS|gene|.*RNA) / ! Bio::KEGG::GENES when /^ENTRY EC [0-9\.]+$/ ! Bio::KEGG::ENZYME when /^ENTRY C[A-Za-z0-9\._]+$/ ! Bio::KEGG::COMPOUND when /^ENTRY R[A-Za-z0-9\._]+$/ ! Bio::KEGG::REACTION when /^ENTRY [a-z]+$/ ! Bio::KEGG::GENOME when /\<\!DOCTYPE\s+maxml\-(sequences|clusters)\s+SYSTEM/ ! if $1 == 'clusters' ! Bio::FANTOM::MaXML::Cluster ! elsif $1 == 'sequences' ! Bio::FANTOM::MaXML::Sequence ! else ! nil #unknown ! end when /^HEADER .{40}\d\d\-[A-Z]{3}\-\d\d [0-9A-Z]{4}/ ! Bio::PDB when /^CLUSTAL .*\(.*\).*sequence +alignment/ ! Bio::ClustalW::Report when /\<\!DOCTYPE BlastOutput PUBLIC / --- 248,309 ---- case text when /^LOCUS .+ bp .*[a-z]*[DR]?NA/ ! Bio::GenBank when /^LOCUS .+ aa .+/ ! Bio::GenPept when /^UI \- [0-9]+$/ ! Bio::MEDLINE ! when /^ID .+\; *(DNA|RNA|XXX)\;/ ! Bio::EMBL when /^ID .+\; *PRT\;/ ! Bio::SPTR when /^ID [-A-Za-z0-9_\.]+\; (PATTERN|RULE|MATRIX)\.$/ ! Bio::PROSITE when /^AC [-A-Za-z0-9_\.]+$/ ! Bio::TRANSFAC when /^H [-A-Z0-9_\.]+$/ ! if text =~ /^M [rc]/ then ! Bio::AAindex2 ! elsif text =~ /^I A\/L/ then ! Bio::AAindex1 ! else ! false #fail to determine ! end when /^CODE [0-9]+$/ ! Bio::LITDB when /^Entry [A-Z0-9]+/ ! Bio::KEGG::BRITE ! when /^ENTRY .+ KO\s*$/ ! Bio::KEGG::KO when /^ENTRY .+ Glycan\s*$/ Bio::KEGG::GLYCAN when /^ENTRY .+ (CDS|gene|.*RNA) / ! Bio::KEGG::GENES when /^ENTRY EC [0-9\.]+$/ ! Bio::KEGG::ENZYME when /^ENTRY C[A-Za-z0-9\._]+$/ ! Bio::KEGG::COMPOUND when /^ENTRY R[A-Za-z0-9\._]+$/ ! Bio::KEGG::REACTION when /^ENTRY [a-z]+$/ ! Bio::KEGG::GENOME when /\<\!DOCTYPE\s+maxml\-(sequences|clusters)\s+SYSTEM/ ! if $1 == 'clusters' ! Bio::FANTOM::MaXML::Cluster ! elsif $1 == 'sequences' ! Bio::FANTOM::MaXML::Sequence ! else ! nil #unknown ! end when /^HEADER .{40}\d\d\-[A-Z]{3}\-\d\d [0-9A-Z]{4}/ ! Bio::PDB when /^CLUSTAL .*\(.*\).*sequence +alignment/ ! Bio::ClustalW::Report when /\<\!DOCTYPE BlastOutput PUBLIC / *************** *** 311,327 **** when /^BLAST.? +[\-\.\w]+\-WashU +\[[\-\.\w ]+\]/ ! Bio::Blast::WU::Report when /^TBLAST.? +[\-\.\w]+\-WashU +\[[\-\.\w ]+\]/ ! Bio::Blast::WU::Report_TBlast when /^BLAST.? +[\-\.\w]+ +\[[\-\.\w ]+\]/ ! Bio::Blast::Default::Report when /^TBLAST.? +[\-\.\w]+ +\[[\-\.\w ]+\]/ ! Bio::Blast::Default::Report_TBlast when /^psLayout version \d+\s*$/ Bio::Blat::Report when /^\-\-SPIDEY version .+\-\-$/ ! Bio::Spidey::Report when /^seq1 \= .*\, \d+ bp(\r|\r?\n)seq2 \= .*\, \d+ bp(\r|\r?\n)/ --- 311,327 ---- when /^BLAST.? +[\-\.\w]+\-WashU +\[[\-\.\w ]+\]/ ! Bio::Blast::WU::Report when /^TBLAST.? +[\-\.\w]+\-WashU +\[[\-\.\w ]+\]/ ! Bio::Blast::WU::Report_TBlast when /^BLAST.? +[\-\.\w]+ +\[[\-\.\w ]+\]/ ! Bio::Blast::Default::Report when /^TBLAST.? +[\-\.\w]+ +\[[\-\.\w ]+\]/ ! Bio::Blast::Default::Report_TBlast when /^psLayout version \d+\s*$/ Bio::Blat::Report when /^\-\-SPIDEY version .+\-\-$/ ! Bio::Spidey::Report when /^seq1 \= .*\, \d+ bp(\r|\r?\n)seq2 \= .*\, \d+ bp(\r|\r?\n)/ *************** *** 329,344 **** when /^>.+$/ ! if text =~ /^>([PF]1|[DR][LC]|N[13]|XX)\;.+/ then ! Bio::NBRF ! elsif text =~ /^>.+$\s+(^\#.*$\s*)*^\s*\d*\s*[-a-zA-Z_\.\[\]\(\)\*\+\$]+/ then ! Bio::FastaFormat ! elsif text =~ /^>.+$\s+^\s*\d+(\s+\d+)*\s*$/ then ! Bio::FastaNumericFormat ! else ! false #fail to determine ! end else ! nil #not found end end --- 329,344 ---- when /^>.+$/ ! if text =~ /^>([PF]1|[DR][LC]|N[13]|XX)\;.+/ then ! Bio::NBRF ! elsif text =~ /^>.+$\s+(^\#.*$\s*)*^\s*\d*\s*[-a-zA-Z_\.\[\]\(\)\*\+\$]+/ then ! Bio::FastaFormat ! elsif text =~ /^>.+$\s+^\s*\d+(\s+\d+)*\s*$/ then ! Bio::FastaNumericFormat ! else ! false #fail to determine ! end else ! nil #not found end end From k at pub.open-bio.org Wed Sep 7 21:22:13 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri Sep 9 13:29:27 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/db aaindex.rb, 1.12, 1.13 fantom.rb, 1.9, 1.10 fasta.rb, 1.19, 1.20 gff.rb, 1.1, 1.2 go.rb, 1.6, 1.7 medline.rb, 1.11, 1.12 nbrf.rb, 1.2, 1.3 prosite.rb, 0.9, 0.10 transfac.rb, 1.8, 1.9 Message-ID: <200509080122.j881MDdZ009107@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/db Modified Files: aaindex.rb fantom.rb fasta.rb gff.rb go.rb medline.rb nbrf.rb prosite.rb transfac.rb Log Message: * expanded tab at the line head Index: prosite.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/prosite.rb,v retrieving revision 0.9 retrieving revision 0.10 diff -C2 -d -r0.9 -r0.10 *** prosite.rb 11 Dec 2004 03:44:37 -0000 0.9 --- prosite.rb 8 Sep 2005 01:22:11 -0000 0.10 *************** *** 41,45 **** def name unless @data['ID'] ! @data['ID'], @data['TYPE'] = fetch('ID').chomp('.').split('; ') end @data['ID'] --- 41,45 ---- def name unless @data['ID'] ! @data['ID'], @data['TYPE'] = fetch('ID').chomp('.').split('; ') end @data['ID'] *************** *** 47,51 **** def division unless @data['TYPE'] ! name end @data['TYPE'] --- 47,51 ---- def division unless @data['TYPE'] ! name end @data['TYPE'] *************** *** 59,63 **** def ac unless @data['AC'] ! @data['AC'] = fetch('AC').chomp(';') end @data['AC'] --- 59,63 ---- def ac unless @data['AC'] ! @data['AC'] = fetch('AC').chomp(';') end @data['AC'] *************** *** 140,159 **** def nr unless @data['NR'] ! hash = {} # temporal hash ! fetch('NR').scan(%r{/(\S+)=([^;]+);}).each do |k, v| ! if v =~ /^(\d+)\((\d+)\)$/ ! hits = $1.to_i # the number of hits ! seqs = $2.to_i # the number of sequences ! v = [hits, seqs] ! elsif v =~ /([\d\.]+),(\d+)/ ! sprel = $1 # the number of SWISS-PROT release ! spseq = $2.to_i # the number of SWISS-PROT sequences ! v = [sprel, spseq] ! else ! v = v.to_i ! end ! hash[k] = v ! end ! @data['NR'] = hash end @data['NR'] --- 140,159 ---- def nr unless @data['NR'] ! hash = {} # temporal hash ! fetch('NR').scan(%r{/(\S+)=([^;]+);}).each do |k, v| ! if v =~ /^(\d+)\((\d+)\)$/ ! hits = $1.to_i # the number of hits ! seqs = $2.to_i # the number of sequences ! v = [hits, seqs] ! elsif v =~ /([\d\.]+),(\d+)/ ! sprel = $1 # the number of SWISS-PROT release ! spseq = $2.to_i # the number of SWISS-PROT sequences ! v = [sprel, spseq] ! else ! v = v.to_i ! end ! hash[k] = v ! end ! @data['NR'] = hash end @data['NR'] *************** *** 244,252 **** def cc unless @data['CC'] ! hash = {} # temporal hash ! fetch('CC').scan(%r{/(\S+)=([^;]+);}).each do |k, v| ! hash[k] = v ! end ! @data['CC'] = hash end @data['CC'] --- 244,252 ---- def cc unless @data['CC'] ! hash = {} # temporal hash ! fetch('CC').scan(%r{/(\S+)=([^;]+);}).each do |k, v| ! hash[k] = v ! end ! @data['CC'] = hash end @data['CC'] *************** *** 257,271 **** range = comment['TAXO-RANGE'] if range and expand ! expand = [] ! range.scan(/./) do |x| ! case x ! when 'A'; expand.push('archaebacteria') ! when 'B'; expand.push('bacteriophages') ! when 'E'; expand.push('eukaryotes') ! when 'P'; expand.push('prokaryotes') ! when 'V'; expand.push('eukaryotic viruses') ! end ! end ! range = expand end return range --- 257,271 ---- range = comment['TAXO-RANGE'] if range and expand ! expand = [] ! range.scan(/./) do |x| ! case x ! when 'A'; expand.push('archaebacteria') ! when 'B'; expand.push('bacteriophages') ! when 'E'; expand.push('eukaryotes') ! when 'P'; expand.push('prokaryotes') ! when 'V'; expand.push('eukaryotic viruses') ! end ! end ! range = expand end return range *************** *** 278,282 **** def site if comment['SITE'] ! num, desc = comment['SITE'].split(',') end return [num.to_i, desc] --- 278,282 ---- def site if comment['SITE'] ! num, desc = comment['SITE'].split(',') end return [num.to_i, desc] *************** *** 285,289 **** def skip_flag if comment['SKIP-FLAG'] == 'TRUE' ! return true end end --- 285,289 ---- def skip_flag if comment['SKIP-FLAG'] == 'TRUE' ! return true end end *************** *** 314,324 **** def dr unless @data['DR'] ! hash = {} # temporal hash ! if fetch('DR') ! fetch('DR').scan(/(\w+)\s*, (\w+)\s*, (.);/).each do |a, e, c| ! hash[a] = [e, c] # SWISS-PROT : accession, entry, true/false ! end ! end ! @data['DR'] = hash end @data['DR'] --- 314,324 ---- def dr unless @data['DR'] ! hash = {} # temporal hash ! if fetch('DR') ! fetch('DR').scan(/(\w+)\s*, (\w+)\s*, (.);/).each do |a, e, c| ! hash[a] = [e, c] # SWISS-PROT : accession, entry, true/false ! end ! end ! @data['DR'] = hash end @data['DR'] *************** *** 329,340 **** ary = [] sp_xref.each do |sp_acc, value| ! if value[1] == flag ! if by_name ! sp_name = value[0] ! ary.push(sp_name) ! else ! ary.push(sp_acc) ! end ! end end return ary --- 329,340 ---- ary = [] sp_xref.each do |sp_acc, value| ! if value[1] == flag ! if by_name ! sp_name = value[0] ! ary.push(sp_name) ! else ! ary.push(sp_acc) ! end ! end end return ary *************** *** 368,372 **** def pdb_xref unless @data['3D'] ! @data['3D'] = fetch('3D').split(/; /) end @data['3D'] --- 368,372 ---- def pdb_xref unless @data['3D'] ! @data['3D'] = fetch('3D').split(/; /) end @data['3D'] *************** *** 427,434 **** pattern.sub!(/>$/, '$') # (2) restricted to the C-terminal : `>' pattern.gsub!(/\{(\w+)\}/) { |m| ! '[^' + $1 + ']' # (3) not accepted at a given position : '{}' } pattern.gsub!(/\(([\d,]+)\)/) { |m| ! '{' + $1 + '}' # (4) repetition of an element : (n), (n,m) } pattern.tr!('x', '.') # (5) any amino acid is accepted : 'x' --- 427,434 ---- pattern.sub!(/>$/, '$') # (2) restricted to the C-terminal : `>' pattern.gsub!(/\{(\w+)\}/) { |m| ! '[^' + $1 + ']' # (3) not accepted at a given position : '{}' } pattern.gsub!(/\(([\d,]+)\)/) { |m| ! '{' + $1 + '}' # (4) repetition of an element : (n), (n,m) } pattern.tr!('x', '.') # (5) any amino acid is accepted : 'x' Index: go.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/go.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** go.rb 4 Apr 2005 11:06:47 -0000 1.6 --- go.rb 8 Sep 2005 01:22:11 -0000 1.7 *************** *** 66,70 **** end ! # Bio::GO::Ontology.goid2term(goid) def goid2term(goid) --- 66,70 ---- end ! # Bio::GO::Ontology.goid2term(goid) def goid2term(goid) *************** *** 110,114 **** adj_list << Bio::Relation.new(stack[depth - 1], goid, rel) } ! if en == "" loop { --- 110,114 ---- adj_list << Bio::Relation.new(stack[depth - 1], goid, rel) } ! if en == "" loop { Index: aaindex.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/aaindex.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** aaindex.rb 21 Feb 2004 19:43:50 -0000 1.12 --- aaindex.rb 8 Sep 2005 01:22:11 -0000 1.13 *************** *** 81,85 **** if values.size != 20 ! raise "Invalid format in #{entry_id} : #{values.inspect}" end --- 81,85 ---- if values.size != 20 ! raise "Invalid format in #{entry_id} : #{values.inspect}" end *************** *** 107,120 **** aa.each_with_index do |a, i| ! case type ! when :string ! hash[a] = values[i] ! when :float ! hash[a] = values[i].to_f ! when :zscore ! hash[a] = (values[i].to_f - mean) / sd ! when :integer ! hash[a] = (values[i].to_f * 10 ** figure).to_i ! end end return hash --- 107,120 ---- aa.each_with_index do |a, i| ! case type ! when :string ! hash[a] = values[i] ! when :float ! hash[a] = values[i].to_f ! when :zscore ! hash[a] = (values[i].to_f - mean) / sd ! when :integer ! hash[a] = (values[i].to_f * 10 ** figure).to_i ! end end return hash *************** *** 161,188 **** case field when / (ARNDCQEGHILKMFPSTWYV)\s+(.*)/ # 20x19/2 matrix ! aalist = $1 ! values = $2.split(/\s+/) ! 0.upto(aalist.length - 1) do |i| ! @aa[aalist[i].chr] = i ! end ! ma = Array.new ! 20.times do ! ma.push(Array.new(20)) # 2D array of 20x(20) ! end ! for i in 0 .. 19 do ! for j in i .. 19 do ! ma[i][j] = values[i + j*(j+1)/2].to_f ! ma[j][i] = ma[i][j] ! end ! end ! Matrix[*ma] when / -ARNDCQEGHILKMFPSTWYV / # 21x20/2 matrix (with gap) ! raise NotImplementedError when / ACDEFGHIKLMNPQRSTVWYJ- / # 21x21 matrix (with gap) ! raise NotImplementedError end end --- 161,188 ---- case field when / (ARNDCQEGHILKMFPSTWYV)\s+(.*)/ # 20x19/2 matrix ! aalist = $1 ! values = $2.split(/\s+/) ! 0.upto(aalist.length - 1) do |i| ! @aa[aalist[i].chr] = i ! end ! ma = Array.new ! 20.times do ! ma.push(Array.new(20)) # 2D array of 20x(20) ! end ! for i in 0 .. 19 do ! for j in i .. 19 do ! ma[i][j] = values[i + j*(j+1)/2].to_f ! ma[j][i] = ma[i][j] ! end ! end ! Matrix[*ma] when / -ARNDCQEGHILKMFPSTWYV / # 21x20/2 matrix (with gap) ! raise NotImplementedError when / ACDEFGHIKLMNPQRSTVWYJ- / # 21x21 matrix (with gap) ! raise NotImplementedError end end Index: medline.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/medline.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** medline.rb 7 Aug 2005 08:13:42 -0000 1.11 --- medline.rb 8 Sep 2005 01:22:11 -0000 1.12 *************** *** 32,39 **** tag = '' entry.each_line do |line| ! if line =~ /^\w/ ! tag = line[0,4].strip ! end ! @pubmed[tag] += line[6..-1] if line.length > 6 end end --- 32,39 ---- tag = '' entry.each_line do |line| ! if line =~ /^\w/ ! tag = line[0,4].strip ! end ! @pubmed[tag] += line[6..-1] if line.length > 6 end end *************** *** 109,117 **** pages = pg if pages =~ /-/ ! from, to = pages.split('-') ! if (len = from.length - to.length) > 0 ! to = from[0,len] + to ! end ! pages = "#{from}-#{to}" end return pages --- 109,117 ---- pages = pg if pages =~ /-/ ! from, to = pages.split('-') ! if (len = from.length - to.length) > 0 ! to = from[0,len] + to ! end ! pages = "#{from}-#{to}" end return pages *************** *** 152,165 **** authors = [] au.split(/\n/).each do |author| ! if author =~ / / ! name = author.split(/\s+/) ! suffix = name[-2] =~ /^[A-Z]+$/ ? name.pop : nil # Jr etc. ! initial = name.pop.split(//).join('. ') ! author = "#{name.join(' ')}, #{initial}." ! end ! if suffix ! author << " " + suffix ! end ! authors.push(author) end return authors --- 152,165 ---- authors = [] au.split(/\n/).each do |author| ! if author =~ / / ! name = author.split(/\s+/) ! suffix = name[-2] =~ /^[A-Z]+$/ ? name.pop : nil # Jr etc. ! initial = name.pop.split(//).join('. ') ! author = "#{name.join(' ')}, #{initial}." ! end ! if suffix ! author << " " + suffix ! end ! authors.push(author) end return authors Index: gff.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/gff.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gff.rb 21 Feb 2003 04:11:58 -0000 1.1 --- gff.rb 8 Sep 2005 01:22:11 -0000 1.2 *************** *** 27,31 **** @records = Array.new str.each_line do |line| ! @records << Record.new(line) end end --- 27,31 ---- @records = Array.new str.each_line do |line| ! @records << Record.new(line) end end *************** *** 34,42 **** class Record def initialize(str) ! @comments = str.chomp[/#.*/] ! return if /^#/.match(str) ! @seqname, @source, @feature, @start, @end, @score, @strand, @frame, ! attributes, = str.chomp.split("\t") ! @attributes = parse_attributes(attributes) if attributes end attr_accessor :seqname, :source, :feature, :start, :end, :score, --- 34,42 ---- class Record def initialize(str) ! @comments = str.chomp[/#.*/] ! return if /^#/.match(str) ! @seqname, @source, @feature, @start, @end, @score, @strand, @frame, ! attributes, = str.chomp.split("\t") ! @attributes = parse_attributes(attributes) if attributes end attr_accessor :seqname, :source, :feature, :start, :end, :score, *************** *** 46,54 **** def parse_attributes(attributes) ! hash = Hash.new ! attributes.split(/[^\\];/).each do |atr| ! key, value = atr.split(' ', 2) ! hash[key] = value ! end return hash end --- 46,54 ---- def parse_attributes(attributes) ! hash = Hash.new ! attributes.split(/[^\\];/).each do |atr| ! key, value = atr.split(' ', 2) ! hash[key] = value ! end return hash end Index: fasta.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/fasta.rb,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** fasta.rb 15 Apr 2004 16:04:39 -0000 1.19 --- fasta.rb 8 Sep 2005 01:22:11 -0000 1.20 *************** *** 53,75 **** def seq unless defined?(@seq) ! unless /\A\s*^\#/ =~ @data then ! @seq = Sequence.new(@data.tr(" \t\r\n0-9", '')) # lazy clean up ! else ! a = @data.split(/(^\#.*$)/) ! i = 0 ! cmnt = {} ! s = [] ! a.each do |x| if /^# ?(.*)$/ =~ x then ! cmnt[i] ? cmnt[i] << "\n" << $1 : cmnt[i] = $1 ! else ! x.tr!(" \t\r\n0-9", '') # lazy clean up ! i += x.length ! s << x ! end ! end ! @comment = cmnt ! @seq = Bio::Sequence.new(s.join('')) ! end end @seq --- 53,75 ---- def seq unless defined?(@seq) ! unless /\A\s*^\#/ =~ @data then ! @seq = Sequence.new(@data.tr(" \t\r\n0-9", '')) # lazy clean up ! else ! a = @data.split(/(^\#.*$)/) ! i = 0 ! cmnt = {} ! s = [] ! a.each do |x| if /^# ?(.*)$/ =~ x then ! cmnt[i] ? cmnt[i] << "\n" << $1 : cmnt[i] = $1 ! else ! x.tr!(" \t\r\n0-9", '') # lazy clean up ! i += x.length ! s << x ! end ! end ! @comment = cmnt ! @seq = Bio::Sequence.new(s.join('')) ! end end @seq *************** *** 103,107 **** def identifiers unless defined?(@ids) then ! @ids = FastaDefline.new(@definition) end @ids --- 103,107 ---- def identifiers unless defined?(@ids) then ! @ids = FastaDefline.new(@definition) end @ids *************** *** 138,142 **** def data unless @list ! @list = @data.strip.split(/\s+/).map {|x| x.to_i} end @list --- 138,142 ---- def data unless @list ! @list = @data.strip.split(/\s+/).map {|x| x.to_i} end @list *************** *** 207,211 **** lines = str.split("\x01") lines.each do |line| ! add_defline(line) end end #def initialize --- 207,211 ---- lines = str.split("\x01") lines.each do |line| ! add_defline(line) end end #def initialize *************** *** 217,275 **** case str when /^\>?\s*((?:[^\|\s]*\|)+[^\s]+)\s*(.*)$/ ! # NSIDs ! # examples: ! # >gi|9910844|sp|Q9UWG2|RL3_METVA 50S ribosomal protein L3P ! # ! # note: regexp (:?) means grouping without backreferences ! i = $1 ! d = $2 ! tks = i.split('|') ! tks << '' if i[-1,1] == '|' ! a = parse_NSIDs(tks) ! i = a[0].join('|') ! a.unshift('|') ! d = tks.join('|') + ' ' + d unless tks.empty? ! a << d ! this_line = a ! match_EC(d) ! parse_square_brackets(d).each do |x| ! if !match_EC(x, false) and x =~ /\A[A-Z]/ then ! di = [ x ] ! @list_ids << di ! @info['organism'] = x unless @info['organism'] ! end ! end when /^\>?\s*([a-zA-Z0-9]+\:[^\s]+)\s*(.*)$/ ! # examples: ! # >sce:YBR160W CDC28, SRM5; cyclin-dependent protein kinase catalytic subunit [EC:2.7.1.-] [SP:CC28_YEAST] ! # >emb:CACDC28 [X80034] C.albicans CDC28 gene ! i = $1 ! d = $2 ! a = parse_ColonSepID(i) ! i = a.join(':') ! this_line = [ ':', a , d ] ! match_EC(d) ! parse_square_brackets(d).each do |x| ! if !match_EC(x, false) and x =~ /:/ then ! parse_ColonSepID(x) ! elsif x =~ /\A\s*([A-Z][A-Z0-9_\.]+)\s*\z/ then ! @list_ids << [ $1 ] ! end ! end when /^\>?\s*(\S+)(?:\s+(.+))?$/ ! # examples: ! # >ABC12345 this is test ! i = $1 ! d = $2.to_s ! @list_ids << [ i.chomp('.') ] ! this_line = [ '', [ i ], d ] ! match_EC(d) else ! i = str ! d = '' ! match_EC(i) ! this_line = [ '', [ i ], d ] end --- 217,275 ---- case str when /^\>?\s*((?:[^\|\s]*\|)+[^\s]+)\s*(.*)$/ ! # NSIDs ! # examples: ! # >gi|9910844|sp|Q9UWG2|RL3_METVA 50S ribosomal protein L3P ! # ! # note: regexp (:?) means grouping without backreferences ! i = $1 ! d = $2 ! tks = i.split('|') ! tks << '' if i[-1,1] == '|' ! a = parse_NSIDs(tks) ! i = a[0].join('|') ! a.unshift('|') ! d = tks.join('|') + ' ' + d unless tks.empty? ! a << d ! this_line = a ! match_EC(d) ! parse_square_brackets(d).each do |x| ! if !match_EC(x, false) and x =~ /\A[A-Z]/ then ! di = [ x ] ! @list_ids << di ! @info['organism'] = x unless @info['organism'] ! end ! end when /^\>?\s*([a-zA-Z0-9]+\:[^\s]+)\s*(.*)$/ ! # examples: ! # >sce:YBR160W CDC28, SRM5; cyclin-dependent protein kinase catalytic subunit [EC:2.7.1.-] [SP:CC28_YEAST] ! # >emb:CACDC28 [X80034] C.albicans CDC28 gene ! i = $1 ! d = $2 ! a = parse_ColonSepID(i) ! i = a.join(':') ! this_line = [ ':', a , d ] ! match_EC(d) ! parse_square_brackets(d).each do |x| ! if !match_EC(x, false) and x =~ /:/ then ! parse_ColonSepID(x) ! elsif x =~ /\A\s*([A-Z][A-Z0-9_\.]+)\s*\z/ then ! @list_ids << [ $1 ] ! end ! end when /^\>?\s*(\S+)(?:\s+(.+))?$/ ! # examples: ! # >ABC12345 this is test ! i = $1 ! d = $2.to_s ! @list_ids << [ i.chomp('.') ] ! this_line = [ '', [ i ], d ] ! match_EC(d) else ! i = str ! d = '' ! match_EC(i) ! this_line = [ '', [ i ], d ] end *************** *** 281,289 **** di = nil str.scan(/EC\:((:?[\-\d]+\.){3}(:?[\-\d]+))/i) do |x| ! di = [ 'EC', $1 ] ! if write_flag then ! @info['ec'] = di[1] if (!@info['ec'] or @info['ec'].to_s =~ /\-/) ! @list_ids << di ! end end di --- 281,289 ---- di = nil str.scan(/EC\:((:?[\-\d]+\.){3}(:?[\-\d]+))/i) do |x| ! di = [ 'EC', $1 ] ! if write_flag then ! @info['ec'] = di[1] if (!@info['ec'] or @info['ec'].to_s =~ /\-/) ! @list_ids << di ! end end di *************** *** 294,298 **** r = [] str.scan(/\[([^\]]*)\]/) do |x| ! r << x[0] end r --- 294,298 ---- r = [] str.scan(/\[([^\]]*)\]/) do |x| ! r << x[0] end r *************** *** 312,341 **** data = [] while token = ary.shift ! if labels = self.class::NSIDs[token] then ! di = [ token ] ! idtype = token ! labels.each do |x| ! token = ary.shift ! break unless token ! if self.class::NSIDs[token] then ! ary.unshift(token) ! break #each ! end ! if token.length > 0 then ! di << token ! else ! di << nil ! end ! end ! data << di ! else ! if token.length > 0 then ! # UCID (uncontrolled identifiers) ! di = [ token ] ! data << di ! @info['ucid'] = token unless @info['ucid'] ! end ! break #while ! end end #while @list_ids.concat data --- 312,341 ---- data = [] while token = ary.shift ! if labels = self.class::NSIDs[token] then ! di = [ token ] ! idtype = token ! labels.each do |x| ! token = ary.shift ! break unless token ! if self.class::NSIDs[token] then ! ary.unshift(token) ! break #each ! end ! if token.length > 0 then ! di << token ! else ! di << nil ! end ! end ! data << di ! else ! if token.length > 0 then ! # UCID (uncontrolled identifiers) ! di = [ token ] ! data << di ! @info['ucid'] = token unless @info['ucid'] ! end ! break #while ! end end #while @list_ids.concat data *************** *** 346,351 **** def to_s @deflines.collect { |a| ! s = a[0] ! (a[1..-2].collect { |x| x.join(s) }.join(s) + ' ' + a[-1]).strip }.join("\x01") end --- 346,351 ---- def to_s @deflines.collect { |a| ! s = a[0] ! (a[1..-2].collect { |x| x.join(s) }.join(s) + ' ' + a[-1]).strip }.join("\x01") end *************** *** 357,361 **** def descriptions @deflines.collect do |a| ! a[-1] end end --- 357,361 ---- def descriptions @deflines.collect do |a| ! a[-1] end end *************** *** 364,379 **** r = [] @list_ids.each do |a| ! if a.size >= 2 then ! r.concat a[1..-1].find_all { |x| x } ! else ! if a[0].to_s.size > 0 and a[0] =~ /\A[A-Za-z0-9\.\-\_]+\z/ ! r << a[0] ! end ! end end r.concat( words(true, []).find_all do |x| ! x =~ /\A[A-Z][A-Za-z0-9\_]*[0-9]+[A-Za-z0-9\_]+\z/ or ! x =~ /\A[A-Z][A-Z0-9]*\_[A-Z0-9\_]+\z/ ! end) r end --- 364,379 ---- r = [] @list_ids.each do |a| ! if a.size >= 2 then ! r.concat a[1..-1].find_all { |x| x } ! else ! if a[0].to_s.size > 0 and a[0] =~ /\A[A-Za-z0-9\.\-\_]+\z/ ! r << a[0] ! end ! end end r.concat( words(true, []).find_all do |x| ! x =~ /\A[A-Z][A-Za-z0-9\_]*[0-9]+[A-Za-z0-9\_]+\z/ or ! x =~ /\A[A-Z][A-Z0-9]*\_[A-Z0-9\_]+\z/ ! end) r end *************** *** 403,422 **** def words(case_sensitive = nil, kill_regexp = self.class::KillRegexpArray, ! kwhash = self.class::KillWordsHash) a = descriptions.join(' ').split(/[\.\,\;\:\(\)\[\]\{\}\<\>\"\'\`\~\/\|\?\!\&\@\#\s\x00-\x1f\x7f]+/) a.collect! do |x| ! x.sub!(/\A[\$\*\-\+]+/, '') ! x.sub!(/[\$\*\-\=]+\z/, '') ! if x.size <= 1 then ! nil ! elsif kwhash[x.downcase] then ! nil ! else ! if kill_regexp.find { |expr| expr =~ x } then ! nil ! else ! x ! end ! end end a.compact! --- 403,422 ---- def words(case_sensitive = nil, kill_regexp = self.class::KillRegexpArray, ! kwhash = self.class::KillWordsHash) a = descriptions.join(' ').split(/[\.\,\;\:\(\)\[\]\{\}\<\>\"\'\`\~\/\|\?\!\&\@\#\s\x00-\x1f\x7f]+/) a.collect! do |x| ! x.sub!(/\A[\$\*\-\+]+/, '') ! x.sub!(/[\$\*\-\=]+\z/, '') ! if x.size <= 1 then ! nil ! elsif kwhash[x.downcase] then ! nil ! else ! if kill_regexp.find { |expr| expr =~ x } then ! nil ! else ! x ! end ! end end a.compact! *************** *** 431,449 **** r = nil unless r = @info[db] then ! di = @list_ids.find { |x| x[0] == db.to_s } ! if di and di.size <= 2 then ! r = di[-1] ! elsif di then ! labels = self.class::NSIDs[db] ! [ 'acc_version', 'entry_id', ! 'locus', 'accession', 'number'].each do |x| ! if i = labels.index(x) then ! r = di[i+1] ! break if r ! end ! end ! r = di[1..-1].find { |x| x } unless r ! end ! @info[db] = r if r end r --- 431,449 ---- r = nil unless r = @info[db] then ! di = @list_ids.find { |x| x[0] == db.to_s } ! if di and di.size <= 2 then ! r = di[-1] ! elsif di then ! labels = self.class::NSIDs[db] ! [ 'acc_version', 'entry_id', ! 'locus', 'accession', 'number'].each do |x| ! if i = labels.index(x) then ! r = di[i+1] ! break if r ! end ! end ! r = di[1..-1].find { |x| x } unless r ! end ! @info[db] = r if r end r *************** *** 452,460 **** def get_by_type(tstr) @list_ids.each do |x| ! if labels = self.class::NSIDs[x[0]] then ! if i = labels.index(tstr) then ! return x[i+1] ! end ! end end nil --- 452,460 ---- def get_by_type(tstr) @list_ids.each do |x| ! if labels = self.class::NSIDs[x[0]] then ! if i = labels.index(tstr) then ! return x[i+1] ! end ! end end nil *************** *** 464,474 **** d = [] @list_ids.each do |x| ! if labels = self.class::NSIDs[x[0]] then ! tstrarg.each do |y| ! if i = labels.index(y) then ! d << x[i+1] if x[i+1] ! end ! end ! end end d --- 464,474 ---- d = [] @list_ids.each do |x| ! if labels = self.class::NSIDs[x[0]] then ! tstrarg.each do |y| ! if i = labels.index(y) then ! d << x[i+1] if x[i+1] ! end ! end ! end end d *************** *** 477,481 **** def locus unless defined?(@locus) ! @locus = get_by_type('locus') end @locus --- 477,481 ---- def locus unless defined?(@locus) ! @locus = get_by_type('locus') end @locus *************** *** 484,488 **** def gi unless defined?(@gi) then ! @gi = get_by_type('gi') end @gi --- 484,488 ---- def gi unless defined?(@gi) then ! @gi = get_by_type('gi') end @gi *************** *** 491,495 **** def acc_version unless defined?(@acc_version) then ! @acc_version = get_by_type('acc_version') end @acc_version --- 491,495 ---- def acc_version unless defined?(@acc_version) then ! @acc_version = get_by_type('acc_version') end @acc_version *************** *** 498,503 **** def accessions unless defined?(@accessions) then ! @accessions = get_all_by_type('accession', 'acc_version') ! @accessions.collect! { |x| x.sub(/\..*\z/, '') } end @accessions --- 498,503 ---- def accessions unless defined?(@accessions) then ! @accessions = get_all_by_type('accession', 'acc_version') ! @accessions.collect! { |x| x.sub(/\..*\z/, '') } end @accessions *************** *** 506,514 **** def accession unless defined?(@accession) then ! if acc_version then ! @accession = acc_version.split('.')[0] ! else ! @accession = accessions[0] ! end end @accession --- 506,514 ---- def accession unless defined?(@accession) then ! if acc_version then ! @accession = acc_version.split('.')[0] ! else ! @accession = accessions[0] ! end end @accession *************** *** 520,524 **** r = get(name, *args) if !r and !(self.class::NSIDs[name.to_s]) then ! raise "NameError: undefined method `#{name.inspect}'" end r --- 520,524 ---- r = get(name, *args) if !r and !(self.class::NSIDs[name.to_s]) then ! raise "NameError: undefined method `#{name.inspect}'" end r Index: fantom.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/fantom.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** fantom.rb 28 Jul 2003 08:32:10 -0000 1.9 --- fantom.rb 8 Sep 2005 01:22:11 -0000 1.10 *************** *** 49,54 **** xml = '' Net::HTTP.start(addr, port, proxy.host, proxy.port) do |http| ! response, = http.get(path) ! xml = response.body end xml --- 49,54 ---- xml = '' Net::HTTP.start(addr, port, proxy.host, proxy.port) do |http| ! response, = http.get(path) ! xml = response.body end xml *************** *** 68,385 **** def initialize(x) ! if x.is_a?(REXML::Element) then ! @elem = x ! else ! if x.is_a?(String) then ! x = x.sub(/#{Regexp.escape(DELIMITER)}\z/om, "\n") ! end ! doc = REXML::Document.new(x) ! @elem = doc.elements[self.class::Data_XPath] ! #raise 'element is null' unless @elem ! @elem = REXML::Document.new('') unless @elem ! end end attr_reader :elem def to_s ! @elem.to_s end def gsub_entities(str) ! # workaround for bug? ! if str then ! str.gsub(/\&\#(\d{1,3})\;/) { sprintf("%c", $1.to_i) } ! else ! str ! end end def entry_id ! unless defined?(@entry_id) ! @entry_id = @elem.attributes['id'] ! end ! @entry_id end def self.define_element_text_method(array) ! array.each do |tagstr| ! module_eval(" ! def #{tagstr} ! unless defined?(@#{tagstr}) ! @#{tagstr} = gsub_entities(@elem.text('#{tagstr}')) ! end ! @#{tagstr} ! end ! ") ! end end private_class_method :define_element_text_method class Cluster < MaXML ! # (MaXML cluster) ! # ftp://fantom2.gsc.riken.go.jp/fantom/2.1/allclust.sep.xml.gz ! Data_XPath = 'maxml-clusters/cluster' ! def representative_seqid ! unless defined?(@representative_seqid) ! @representative_seqid = ! gsub_entities(@elem.text('representative-seqid')) ! end ! @representative_seqid ! end ! def sequences ! unless defined?(@sequences) ! @sequences = MaXML::Sequences.new(@elem) ! end ! @sequences ! end ! def sequence(idstr = nil) ! idstr ? sequences[idstr] : representative_sequence ! end ! def representative_sequence ! unless defined?(@representative_sequence) ! rid = representative_seqid @representative_sequence = ! rid ? sequences[representative_seqid] : nil ! end ! @representative_sequence ! end ! alias :representative_clone :representative_sequence ! def representative_annotations ! e = representative_sequence ! e ? e.annotations : nil ! end ! def representative_cloneid ! e = representative_sequence ! e ? e.cloneid : nil ! end ! define_element_text_method(%w(fantomid)) end #class MaXML::Cluster class Sequences < MaXML ! Data_XPath = 'maxml-sequences' ! include Enumerable ! def each ! to_a.each { |x| yield x } ! end ! def to_a ! unless defined?(@sequences) ! @sequences = @elem.get_elements('sequence') ! @sequences.collect! { |e| MaXML::Sequence.new(e) } ! end ! @sequences ! end ! def get(idstr) ! unless defined?(@hash) ! @hash = {} ! end ! unless @hash.member?(idstr) then ! @hash[idstr] = self.find do |x| ! x.altid.values.index(idstr) ! end ! end ! @hash[idstr] ! end ! def [](*arg) ! if arg[0].is_a?(String) and arg.size == 1 then ! get(arg[0]) ! else ! to_a[*arg] ! end ! end ! def cloneids ! unless defined?(@cloneids) ! @cloneids = to_a.collect { |x| x.cloneid } ! end ! @cloneids ! end ! def id_strings ! unless defined?(@id_strings) ! @id_strings = to_a.collect { |x| x.id_strings } ! @id_strings.flatten! ! @id_strings.sort! ! @id_strings.uniq! ! end ! @id_strings ! end end #class MaXML::Sequences class Sequence < MaXML ! # (MaXML sequence) ! # ftp://fantom2.gsc.riken.go.jp/fantom/2.1/allseq.sep.xml.gz ! # ftp://fantom2.gsc.riken.go.jp/fantom/2.1/repseq.sep.xml.gz ! ! Data_XPath = 'maxml-sequences/sequence' ! def altid(t = nil) ! unless defined?(@altid) ! @altid = {} ! @elem.each_element('altid') do |e| ! @altid[e.attributes['type']] = gsub_entities(e.text) ! end ! end ! if t then ! @altid[t] ! else ! @altid ! end ! end ! def id_strings ! altid.values.sort.uniq ! end ! def library_id ! entry_id[0,2] ! end ! def annotations ! unless defined?(@annotations) ! @annotations = ! MaXML::Annotations.new(@elem.elements['annotations']) ! end ! @annotations ! end ! define_element_text_method(%w(annotator version modified_time comment)) ! def self.define_id_method(array) ! array.each do |tagstr| ! module_eval(" ! def #{tagstr} ! unless defined?(@#{tagstr}) ! @#{tagstr} = gsub_entities(@elem.text('#{tagstr}')) ! @#{tagstr} = altid('#{tagstr}') unless @#{tagstr} ! end ! @#{tagstr} ! end ! ") ! end end private_class_method :define_id_method ! define_id_method(%w(seqid fantomid cloneid rearrayid accession)) end #class MaXML::Sequence class Annotations < MaXML ! Data_XPath = nil ! include Enumerable ! def each ! to_a.each { |x| yield x } ! end ! def to_a ! unless defined?(@a) ! @a = @elem.get_elements('annotation') ! @a.collect! { |e| MaXML::Annotation.new(e) } ! end ! @a ! end ! def get_all_by_qualifier(qstr) ! unless defined?(@hash) ! @hash = {} ! end ! unless @hash.member?(qstr) then ! @hash[qstr] = self.find_all do |x| ! x.qualifier == qstr ! end ! end ! @hash[qstr] ! end ! def get_by_qualifier(qstr) ! a = get_all_by_qualifier(qstr) ! a ? a[0] : nil ! end ! def [](*arg) ! if arg[0].is_a?(String) and arg.size == 1 then ! get_by_qualifier(arg[0]) ! else ! to_a[*arg] ! end ! end ! def cds_start ! unless defined?(@cds_start) ! e = get_by_qualifier('cds_start') ! @cds_start = e ? e.anntext.to_i : nil ! end ! @cds_start ! end ! def cds_stop ! unless defined?(@cds_stop) ! e = get_by_qualifier('cds_stop') ! @cds_stop = e ? e.anntext.to_i : nil ! end ! @cds_stop ! end ! def gene_name ! unless defined?(@gene_name) ! e = get_by_qualifier('gene_name') ! @gene_name = e ? e.anntext : nil ! end ! @gene_name ! end ! def data_source ! unless defined?(@data_source) ! e = get_by_qualifier('gene_name') ! @data_source = e ? e.datasrc[0] : nil ! end ! @data_source ! end ! def evidence ! unless defined?(@evidence) ! e = get_by_qualifier('gene_name') ! @evidence = e ? e.evidence : nil ! end ! @evidence ! end end #class MaXML::Annotations class Annotation < MaXML ! def entry_id ! nil ! end ! class DataSrc < String ! def initialize(text, href) ! super(text) ! @href = href ! end ! attr_reader :href ! end ! def datasrc ! unless defined?(@datasrc) ! @datasrc = [] ! @elem.each_element('datasrc') do |e| ! text = e.text ! href = e.attributes['href'] ! @datasrc << DataSrc.new(gsub_entities(text), gsub_entities(href)) ! end ! end ! @datasrc ! end ! define_element_text_method(%w(qualifier srckey anntext evidence)) end #class MaXML::Annotation --- 68,385 ---- def initialize(x) ! if x.is_a?(REXML::Element) then ! @elem = x ! else ! if x.is_a?(String) then ! x = x.sub(/#{Regexp.escape(DELIMITER)}\z/om, "\n") ! end ! doc = REXML::Document.new(x) ! @elem = doc.elements[self.class::Data_XPath] ! #raise 'element is null' unless @elem ! @elem = REXML::Document.new('') unless @elem ! end end attr_reader :elem def to_s ! @elem.to_s end def gsub_entities(str) ! # workaround for bug? ! if str then ! str.gsub(/\&\#(\d{1,3})\;/) { sprintf("%c", $1.to_i) } ! else ! str ! end end def entry_id ! unless defined?(@entry_id) ! @entry_id = @elem.attributes['id'] ! end ! @entry_id end def self.define_element_text_method(array) ! array.each do |tagstr| ! module_eval(" ! def #{tagstr} ! unless defined?(@#{tagstr}) ! @#{tagstr} = gsub_entities(@elem.text('#{tagstr}')) ! end ! @#{tagstr} ! end ! ") ! end end private_class_method :define_element_text_method class Cluster < MaXML ! # (MaXML cluster) ! # ftp://fantom2.gsc.riken.go.jp/fantom/2.1/allclust.sep.xml.gz ! Data_XPath = 'maxml-clusters/cluster' ! def representative_seqid ! unless defined?(@representative_seqid) ! @representative_seqid = ! gsub_entities(@elem.text('representative-seqid')) ! end ! @representative_seqid ! end ! def sequences ! unless defined?(@sequences) ! @sequences = MaXML::Sequences.new(@elem) ! end ! @sequences ! end ! def sequence(idstr = nil) ! idstr ? sequences[idstr] : representative_sequence ! end ! def representative_sequence ! unless defined?(@representative_sequence) ! rid = representative_seqid @representative_sequence = ! rid ? sequences[representative_seqid] : nil ! end ! @representative_sequence ! end ! alias :representative_clone :representative_sequence ! def representative_annotations ! e = representative_sequence ! e ? e.annotations : nil ! end ! def representative_cloneid ! e = representative_sequence ! e ? e.cloneid : nil ! end ! define_element_text_method(%w(fantomid)) end #class MaXML::Cluster class Sequences < MaXML ! Data_XPath = 'maxml-sequences' ! include Enumerable ! def each ! to_a.each { |x| yield x } ! end ! def to_a ! unless defined?(@sequences) ! @sequences = @elem.get_elements('sequence') ! @sequences.collect! { |e| MaXML::Sequence.new(e) } ! end ! @sequences ! end ! def get(idstr) ! unless defined?(@hash) ! @hash = {} ! end ! unless @hash.member?(idstr) then ! @hash[idstr] = self.find do |x| ! x.altid.values.index(idstr) ! end ! end ! @hash[idstr] ! end ! def [](*arg) ! if arg[0].is_a?(String) and arg.size == 1 then ! get(arg[0]) ! else ! to_a[*arg] ! end ! end ! def cloneids ! unless defined?(@cloneids) ! @cloneids = to_a.collect { |x| x.cloneid } ! end ! @cloneids ! end ! def id_strings ! unless defined?(@id_strings) ! @id_strings = to_a.collect { |x| x.id_strings } ! @id_strings.flatten! ! @id_strings.sort! ! @id_strings.uniq! ! end ! @id_strings ! end end #class MaXML::Sequences class Sequence < MaXML ! # (MaXML sequence) ! # ftp://fantom2.gsc.riken.go.jp/fantom/2.1/allseq.sep.xml.gz ! # ftp://fantom2.gsc.riken.go.jp/fantom/2.1/repseq.sep.xml.gz ! ! Data_XPath = 'maxml-sequences/sequence' ! def altid(t = nil) ! unless defined?(@altid) ! @altid = {} ! @elem.each_element('altid') do |e| ! @altid[e.attributes['type']] = gsub_entities(e.text) ! end ! end ! if t then ! @altid[t] ! else ! @altid ! end ! end ! def id_strings ! altid.values.sort.uniq ! end ! def library_id ! entry_id[0,2] ! end ! def annotations ! unless defined?(@annotations) ! @annotations = ! MaXML::Annotations.new(@elem.elements['annotations']) ! end ! @annotations ! end ! define_element_text_method(%w(annotator version modified_time comment)) ! def self.define_id_method(array) ! array.each do |tagstr| ! module_eval(" ! def #{tagstr} ! unless defined?(@#{tagstr}) ! @#{tagstr} = gsub_entities(@elem.text('#{tagstr}')) ! @#{tagstr} = altid('#{tagstr}') unless @#{tagstr} ! end ! @#{tagstr} ! end ! ") ! end end private_class_method :define_id_method ! define_id_method(%w(seqid fantomid cloneid rearrayid accession)) end #class MaXML::Sequence class Annotations < MaXML ! Data_XPath = nil ! include Enumerable ! def each ! to_a.each { |x| yield x } ! end ! def to_a ! unless defined?(@a) ! @a = @elem.get_elements('annotation') ! @a.collect! { |e| MaXML::Annotation.new(e) } ! end ! @a ! end ! def get_all_by_qualifier(qstr) ! unless defined?(@hash) ! @hash = {} ! end ! unless @hash.member?(qstr) then ! @hash[qstr] = self.find_all do |x| ! x.qualifier == qstr ! end ! end ! @hash[qstr] ! end ! def get_by_qualifier(qstr) ! a = get_all_by_qualifier(qstr) ! a ? a[0] : nil ! end ! def [](*arg) ! if arg[0].is_a?(String) and arg.size == 1 then ! get_by_qualifier(arg[0]) ! else ! to_a[*arg] ! end ! end ! def cds_start ! unless defined?(@cds_start) ! e = get_by_qualifier('cds_start') ! @cds_start = e ? e.anntext.to_i : nil ! end ! @cds_start ! end ! def cds_stop ! unless defined?(@cds_stop) ! e = get_by_qualifier('cds_stop') ! @cds_stop = e ? e.anntext.to_i : nil ! end ! @cds_stop ! end ! def gene_name ! unless defined?(@gene_name) ! e = get_by_qualifier('gene_name') ! @gene_name = e ? e.anntext : nil ! end ! @gene_name ! end ! def data_source ! unless defined?(@data_source) ! e = get_by_qualifier('gene_name') ! @data_source = e ? e.datasrc[0] : nil ! end ! @data_source ! end ! def evidence ! unless defined?(@evidence) ! e = get_by_qualifier('gene_name') ! @evidence = e ? e.evidence : nil ! end ! @evidence ! end end #class MaXML::Annotations class Annotation < MaXML ! def entry_id ! nil ! end ! class DataSrc < String ! def initialize(text, href) ! super(text) ! @href = href ! end ! attr_reader :href ! end ! def datasrc ! unless defined?(@datasrc) ! @datasrc = [] ! @elem.each_element('datasrc') do |e| ! text = e.text ! href = e.attributes['href'] ! @datasrc << DataSrc.new(gsub_entities(text), gsub_entities(href)) ! end ! end ! @datasrc ! end ! define_element_text_method(%w(qualifier srckey anntext evidence)) end #class MaXML::Annotation Index: transfac.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/transfac.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** transfac.rb 30 Aug 2002 06:31:47 -0000 1.8 --- transfac.rb 8 Sep 2005 01:22:11 -0000 1.9 *************** *** 46,50 **** def ac unless @data['AC'] ! @data['AC'] = fetch('AC') end @data['AC'] --- 46,50 ---- def ac unless @data['AC'] ! @data['AC'] = fetch('AC') end @data['AC'] *************** *** 127,142 **** key = '' @orig.each do |k, v| ! if k =~ /^0*(\d+)/ ! key = $1.to_i ! ma_dat[key] = fetch(k) unless ma_dat[key] ! end end ma_dat.keys.sort.each_with_index do |k, i| ! rep_nt = ma_dat[k].slice!(-1, 1) ! ma_dat[k].slice!(-1, 1) ! ma_ary[i] = ma_dat[k].split(/\s+/) ! ma_ary[i].each_with_index do |x, j| ! ma_ary[i][j] = x.to_i ! end end Matrix[*ma_ary] --- 127,142 ---- key = '' @orig.each do |k, v| ! if k =~ /^0*(\d+)/ ! key = $1.to_i ! ma_dat[key] = fetch(k) unless ma_dat[key] ! end end ma_dat.keys.sort.each_with_index do |k, i| ! rep_nt = ma_dat[k].slice!(-1, 1) ! ma_dat[k].slice!(-1, 1) ! ma_ary[i] = ma_dat[k].split(/\s+/) ! ma_ary[i].each_with_index do |x, j| ! ma_ary[i][j] = x.to_i ! end end Matrix[*ma_ary] Index: nbrf.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/nbrf.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** nbrf.rb 10 Oct 2003 11:49:43 -0000 1.2 --- nbrf.rb 8 Sep 2005 01:22:11 -0000 1.3 *************** *** 43,48 **** @definition = line2.to_s.chomp if /^>?([A-Za-z0-9]{2})\;(.*)/ =~ line1.to_s then ! @seq_type = $1 ! @entry_id = $2 end end --- 43,48 ---- @definition = line2.to_s.chomp if /^>?([A-Za-z0-9]{2})\;(.*)/ =~ line1.to_s then ! @seq_type = $1 ! @entry_id = $2 end end *************** *** 60,70 **** case @seq_type when /[PF]1/ ! # protein ! Sequence::AA when /[DR][LC]/, /N[13]/ ! # nucleic ! Sequence::NA else ! Sequence end end --- 60,70 ---- case @seq_type when /[PF]1/ ! # protein ! Sequence::AA when /[DR][LC]/, /N[13]/ ! # nucleic ! Sequence::NA else ! Sequence end end *************** *** 72,76 **** def seq unless defined?(@seq) ! @seq = seq_class.new(@data.tr(" \t\r\n0-9", '')) # lazy clean up end @seq --- 72,76 ---- def seq unless defined?(@seq) ! @seq = seq_class.new(@data.tr(" \t\r\n0-9", '')) # lazy clean up end @seq *************** *** 83,91 **** def naseq if seq.is_a?(Bio::Sequence::AA) then ! raise 'not nucleic but protein sequence' elsif seq.is_a?(Bio::Sequence::NA) then ! seq else ! Bio::Sequence::NA.new(seq) end end --- 83,91 ---- def naseq if seq.is_a?(Bio::Sequence::AA) then ! raise 'not nucleic but protein sequence' elsif seq.is_a?(Bio::Sequence::NA) then ! seq else ! Bio::Sequence::NA.new(seq) end end *************** *** 97,105 **** def aaseq if seq.is_a?(Bio::Sequence::NA) then ! raise 'not nucleic but protein sequence' elsif seq.is_a?(Bio::Sequence::AA) then ! seq else ! Bio::Sequence::AA.new(seq) end end --- 97,105 ---- def aaseq if seq.is_a?(Bio::Sequence::NA) then ! raise 'not nucleic but protein sequence' elsif seq.is_a?(Bio::Sequence::AA) then ! seq else ! Bio::Sequence::AA.new(seq) end end *************** *** 114,131 **** seq = hash[:seq] unless seq_type ! if seq.is_a?(Bio::Sequence::AA) then ! seq_type = 'P1' ! elsif seq.is_a?(Bio::Sequence::NA) then ! seq_type = /u/i =~ seq ? 'RL' : 'DL' ! else ! seq_type = 'XX' ! end end width = hash.has_key?(:width) ? hash[:width] : 70 if width then ! seq = seq.to_s + "*" ! seq.gsub!(Regexp.new(".{1,#{width}}"), "\\0\n") else ! seq = seq.to_s + "*\n" end ">#{seq_type};#{hash[:entry_id]}\n#{hash[:definition]}\n#{seq}" --- 114,131 ---- seq = hash[:seq] unless seq_type ! if seq.is_a?(Bio::Sequence::AA) then ! seq_type = 'P1' ! elsif seq.is_a?(Bio::Sequence::NA) then ! seq_type = /u/i =~ seq ? 'RL' : 'DL' ! else ! seq_type = 'XX' ! end end width = hash.has_key?(:width) ? hash[:width] : 70 if width then ! seq = seq.to_s + "*" ! seq.gsub!(Regexp.new(".{1,#{width}}"), "\\0\n") else ! seq = seq.to_s + "*\n" end ">#{seq_type};#{hash[:entry_id]}\n#{hash[:definition]}\n#{seq}" From k at pub.open-bio.org Wed Sep 7 21:22:11 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri Sep 9 13:29:28 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/blast format0.rb, 1.9, 1.10 format8.rb, 1.4, 1.5 report.rb, 1.6, 1.7 rexml.rb, 1.9, 1.10 wublast.rb, 1.1, 1.2 xmlparser.rb, 1.12, 1.13 Message-ID: <200509080122.j881MBdZ009058@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/blast In directory pub.open-bio.org:/tmp/cvs-serv9021/lib/bio/appl/blast Modified Files: format0.rb format8.rb report.rb rexml.rb wublast.rb xmlparser.rb Log Message: * expanded tab at the line head Index: xmlparser.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/xmlparser.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** xmlparser.rb 29 Sep 2003 10:00:41 -0000 1.12 --- xmlparser.rb 8 Sep 2005 01:22:08 -0000 1.13 *************** *** 34,214 **** def xmlparser_parse(xml) ! parser = XMLParser.new ! def parser.default; end ! ! begin ! tag_stack = Array.new ! hash = Hash.new ! parser.parse(xml) do |type, name, data| ! #print "type=#{type.inspect} name=#{name.inspect} data=#{data.inspect}\n" # for DEBUG ! case type ! when XMLParser::START_ELEM ! tag_stack.push(name) ! hash.update(data) ! case name ! when 'Iteration' ! iteration = Iteration.new ! @iterations.push(iteration) ! when 'Hit' ! hit = Hit.new ! hit.query_id = @query_id ! hit.query_def = @query_def ! hit.query_len = @query_len ! @iterations.last.hits.push(hit) ! when 'Hsp' ! hsp = Hsp.new ! @iterations.last.hits.last.hsps.push(hsp) ! end ! when XMLParser::END_ELEM ! case name ! when /^BlastOutput/ ! xmlparser_parse_program(name,hash) ! hash = Hash.new ! when /^Parameters$/ ! xmlparser_parse_parameters(hash) ! hash = Hash.new ! when /^Iteration/ ! xmlparser_parse_iteration(name, hash) ! hash = Hash.new ! when /^Hit/ ! xmlparser_parse_hit(name, hash) ! hash = Hash.new ! when /^Hsp$/ ! xmlparser_parse_hsp(hash) ! hash = Hash.new ! when /^Statistics$/ ! xmlparser_parse_statistics(hash) ! hash = Hash.new ! end ! tag_stack.pop ! when XMLParser::CDATA ! if hash[tag_stack.last].nil? ! hash[tag_stack.last] = data unless data.strip.empty? ! else ! hash[tag_stack.last].concat(data) if data ! end ! when XMLParser::PI ! end ! end ! rescue XMLParserError ! line = parser.line ! column = parser.column ! print "Parse error at #{line}(#{column}) : #{$!}\n" ! end end def xmlparser_parse_program(tag, hash) ! case tag ! when 'BlastOutput_program' ! @program = hash[tag] ! when 'BlastOutput_version' ! @version = hash[tag] ! when 'BlastOutput_reference' ! @reference = hash[tag] ! when 'BlastOutput_db' ! @db = hash[tag].strip ! when 'BlastOutput_query-ID' ! @query_id = hash[tag] ! when 'BlastOutput_query-def' ! @query_def = hash[tag] ! when 'BlastOutput_query-len' ! @query_len = hash[tag].to_i ! end end def xmlparser_parse_parameters(hash) ! labels = { ! 'matrix' => 'Parameters_matrix', ! 'expect' => 'Parameters_expect', ! 'include' => 'Parameters_include', ! 'sc-match' => 'Parameters_sc-match', ! 'sc-mismatch' => 'Parameters_sc-mismatch', ! 'gap-open' => 'Parameters_gap-open', ! 'gap-extend' => 'Parameters_gap-extend', ! 'filter' => 'Parameters_filter', ! 'pattern' => 'Parameters_pattern', ! 'entrez-query'=> 'Parameters_entrez-query', ! } ! labels.each do |k,v| ! case k ! when 'filter', 'matrix' ! @parameters[k] = hash[v].to_s ! else ! @parameters[k] = hash[v].to_i ! end ! end end def xmlparser_parse_iteration(tag, hash) ! case tag ! when 'Iteration_iter-num' ! @iterations.last.num = hash[tag].to_i ! when 'Iteration_message' ! @iterations.last.message = hash[tag].to_s ! end end def xmlparser_parse_hit(tag, hash) ! hit = @iterations.last.hits.last ! case tag ! when 'Hit_num' ! hit.num = hash[tag].to_i ! when 'Hit_id' ! hit.hit_id = hash[tag].clone ! when 'Hit_def' ! hit.definition = hash[tag].clone ! when 'Hit_accession' ! hit.accession = hash[tag].clone ! when 'Hit_len' ! hit.len = hash[tag].clone.to_i ! end end def xmlparser_parse_hsp(hash) ! hsp = @iterations.last.hits.last.hsps.last ! hsp.num = hash['Hsp_num'].to_i ! hsp.bit_score = hash['Hsp_bit-score'].to_f ! hsp.score = hash['Hsp_score'].to_i ! hsp.evalue = hash['Hsp_evalue'].to_f ! hsp.query_from = hash['Hsp_query-from'].to_i ! hsp.query_to = hash['Hsp_query-to'].to_i ! hsp.hit_from = hash['Hsp_hit-from'].to_i ! hsp.hit_to = hash['Hsp_hit-to'].to_i ! hsp.pattern_from = hash['Hsp_pattern-from'].to_i ! hsp.pattern_to = hash['Hsp_pattern-to'].to_i hsp.query_frame = hash['Hsp_query-frame'].to_i ! hsp.hit_frame = hash['Hsp_hit-frame'].to_i ! hsp.identity = hash['Hsp_identity'].to_i ! hsp.positive = hash['Hsp_positive'].to_i ! hsp.gaps = hash['Hsp_gaps'].to_i ! hsp.align_len = hash['Hsp_align-len'].to_i ! hsp.density = hash['Hsp_density'].to_i ! hsp.qseq = hash['Hsp_qseq'] ! hsp.hseq = hash['Hsp_hseq'] ! hsp.midline = hash['Hsp_midline'] end def xmlparser_parse_statistics(hash) ! labels = { ! 'db-num' => 'Statistics_db-num', ! 'db-len' => 'Statistics_db-len', ! 'hsp-len' => 'Statistics_hsp-len', ! 'eff-space' => 'Statistics_eff-space', ! 'kappa' => 'Statistics_kappa', ! 'lambda' => 'Statistics_lambda', ! 'entropy' => 'Statistics_entropy' ! } ! labels.each do |k,v| ! case k ! when 'db-num', 'db-len', 'hsp-len' ! @iterations.last.statistics[k] = hash[v].to_i ! else ! @iterations.last.statistics[k] = hash[v].to_f ! end ! end end ! end end --- 34,214 ---- def xmlparser_parse(xml) ! parser = XMLParser.new ! def parser.default; end ! ! begin ! tag_stack = Array.new ! hash = Hash.new ! parser.parse(xml) do |type, name, data| ! #print "type=#{type.inspect} name=#{name.inspect} data=#{data.inspect}\n" # for DEBUG ! case type ! when XMLParser::START_ELEM ! tag_stack.push(name) ! hash.update(data) ! case name ! when 'Iteration' ! iteration = Iteration.new ! @iterations.push(iteration) ! when 'Hit' ! hit = Hit.new ! hit.query_id = @query_id ! hit.query_def = @query_def ! hit.query_len = @query_len ! @iterations.last.hits.push(hit) ! when 'Hsp' ! hsp = Hsp.new ! @iterations.last.hits.last.hsps.push(hsp) ! end ! when XMLParser::END_ELEM ! case name ! when /^BlastOutput/ ! xmlparser_parse_program(name,hash) ! hash = Hash.new ! when /^Parameters$/ ! xmlparser_parse_parameters(hash) ! hash = Hash.new ! when /^Iteration/ ! xmlparser_parse_iteration(name, hash) ! hash = Hash.new ! when /^Hit/ ! xmlparser_parse_hit(name, hash) ! hash = Hash.new ! when /^Hsp$/ ! xmlparser_parse_hsp(hash) ! hash = Hash.new ! when /^Statistics$/ ! xmlparser_parse_statistics(hash) ! hash = Hash.new ! end ! tag_stack.pop ! when XMLParser::CDATA ! if hash[tag_stack.last].nil? ! hash[tag_stack.last] = data unless data.strip.empty? ! else ! hash[tag_stack.last].concat(data) if data ! end ! when XMLParser::PI ! end ! end ! rescue XMLParserError ! line = parser.line ! column = parser.column ! print "Parse error at #{line}(#{column}) : #{$!}\n" ! end end def xmlparser_parse_program(tag, hash) ! case tag ! when 'BlastOutput_program' ! @program = hash[tag] ! when 'BlastOutput_version' ! @version = hash[tag] ! when 'BlastOutput_reference' ! @reference = hash[tag] ! when 'BlastOutput_db' ! @db = hash[tag].strip ! when 'BlastOutput_query-ID' ! @query_id = hash[tag] ! when 'BlastOutput_query-def' ! @query_def = hash[tag] ! when 'BlastOutput_query-len' ! @query_len = hash[tag].to_i ! end end def xmlparser_parse_parameters(hash) ! labels = { ! 'matrix' => 'Parameters_matrix', ! 'expect' => 'Parameters_expect', ! 'include' => 'Parameters_include', ! 'sc-match' => 'Parameters_sc-match', ! 'sc-mismatch' => 'Parameters_sc-mismatch', ! 'gap-open' => 'Parameters_gap-open', ! 'gap-extend' => 'Parameters_gap-extend', ! 'filter' => 'Parameters_filter', ! 'pattern' => 'Parameters_pattern', ! 'entrez-query'=> 'Parameters_entrez-query', ! } ! labels.each do |k,v| ! case k ! when 'filter', 'matrix' ! @parameters[k] = hash[v].to_s ! else ! @parameters[k] = hash[v].to_i ! end ! end end def xmlparser_parse_iteration(tag, hash) ! case tag ! when 'Iteration_iter-num' ! @iterations.last.num = hash[tag].to_i ! when 'Iteration_message' ! @iterations.last.message = hash[tag].to_s ! end end def xmlparser_parse_hit(tag, hash) ! hit = @iterations.last.hits.last ! case tag ! when 'Hit_num' ! hit.num = hash[tag].to_i ! when 'Hit_id' ! hit.hit_id = hash[tag].clone ! when 'Hit_def' ! hit.definition = hash[tag].clone ! when 'Hit_accession' ! hit.accession = hash[tag].clone ! when 'Hit_len' ! hit.len = hash[tag].clone.to_i ! end end def xmlparser_parse_hsp(hash) ! hsp = @iterations.last.hits.last.hsps.last ! hsp.num = hash['Hsp_num'].to_i ! hsp.bit_score = hash['Hsp_bit-score'].to_f ! hsp.score = hash['Hsp_score'].to_i ! hsp.evalue = hash['Hsp_evalue'].to_f ! hsp.query_from = hash['Hsp_query-from'].to_i ! hsp.query_to = hash['Hsp_query-to'].to_i ! hsp.hit_from = hash['Hsp_hit-from'].to_i ! hsp.hit_to = hash['Hsp_hit-to'].to_i ! hsp.pattern_from = hash['Hsp_pattern-from'].to_i ! hsp.pattern_to = hash['Hsp_pattern-to'].to_i hsp.query_frame = hash['Hsp_query-frame'].to_i ! hsp.hit_frame = hash['Hsp_hit-frame'].to_i ! hsp.identity = hash['Hsp_identity'].to_i ! hsp.positive = hash['Hsp_positive'].to_i ! hsp.gaps = hash['Hsp_gaps'].to_i ! hsp.align_len = hash['Hsp_align-len'].to_i ! hsp.density = hash['Hsp_density'].to_i ! hsp.qseq = hash['Hsp_qseq'] ! hsp.hseq = hash['Hsp_hseq'] ! hsp.midline = hash['Hsp_midline'] end def xmlparser_parse_statistics(hash) ! labels = { ! 'db-num' => 'Statistics_db-num', ! 'db-len' => 'Statistics_db-len', ! 'hsp-len' => 'Statistics_hsp-len', ! 'eff-space' => 'Statistics_eff-space', ! 'kappa' => 'Statistics_kappa', ! 'lambda' => 'Statistics_lambda', ! 'entropy' => 'Statistics_entropy' ! } ! labels.each do |k,v| ! case k ! when 'db-num', 'db-len', 'hsp-len' ! @iterations.last.statistics[k] = hash[v].to_i ! else ! @iterations.last.statistics[k] = hash[v].to_f ! end ! end end ! end end Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/report.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** report.rb 21 Jun 2005 07:03:28 -0000 1.6 --- report.rb 8 Sep 2005 01:22:08 -0000 1.7 *************** *** 31,41 **** ary = [] input.each("\n") do |xml| ! xml.sub!(/[^<]*( tag ! next if xml.empty? # skip trailing no hits ! if block_given? ! yield Report.new(xml, parser) ! else ! ary << Report.new(xml, parser) ! end end return ary --- 31,41 ---- ary = [] input.each("\n") do |xml| ! xml.sub!(/[^<]*( tag ! next if xml.empty? # skip trailing no hits ! if block_given? ! yield Report.new(xml, parser) ! else ! ary << Report.new(xml, parser) ! end end return ary *************** *** 49,90 **** def self.xmlparser(data) ! self.new(data, :xmlparser) end def self.rexml(data) ! self.new(data, :rexml) end def self.tab(data) ! self.new(data, :tab) end def auto_parse(data) ! if / def each_iteration ! @iterations.each do |x| ! yield x ! end end # shortcut for the last iteration's hits def each_hit ! @iterations.last.each do |x| ! yield x ! end end alias :each :each_hit --- 102,115 ---- # def each_iteration ! @iterations.each do |x| ! yield x ! end end # shortcut for the last iteration's hits def each_hit ! @iterations.last.each do |x| ! yield x ! end end alias :each :each_hit *************** *** 117,126 **** # shortcut for the last iteration's hits def hits ! @iterations.last.hits end # shortcut for the last iteration's statistics def statistics ! @iterations.last.statistics end def db_num; statistics['db-num']; end --- 117,126 ---- # shortcut for the last iteration's hits def hits ! @iterations.last.hits end # shortcut for the last iteration's statistics def statistics ! @iterations.last.statistics end def db_num; statistics['db-num']; end *************** *** 134,138 **** # shortcut for the last iteration's message (for checking 'CONVERGED') def message ! @iterations.last.message end --- 134,138 ---- # shortcut for the last iteration's message (for checking 'CONVERGED') def message ! @iterations.last.message end *************** *** 140,157 **** # Bio::Blast::Report::Iteration class Iteration ! def initialize ! @message = nil ! @statistics = {} ! @num = 1 ! @hits = [] ! end ! attr_reader :hits, :statistics ! attr_accessor :num, :message ! def each ! @hits.each do |x| ! yield x ! end ! end end --- 140,157 ---- # Bio::Blast::Report::Iteration class Iteration ! def initialize ! @message = nil ! @statistics = {} ! @num = 1 ! @hits = [] ! end ! attr_reader :hits, :statistics ! attr_accessor :num, :message ! def each ! @hits.each do |x| ! yield x ! end ! end end *************** *** 159,200 **** # Bio::Blast::Report::Hit class Hit ! def initialize ! @hsps = [] ! end ! attr_reader :hsps ! attr_accessor :query_id, :query_def, :query_len, ! :num, :hit_id, :len, :definition, :accession ! def each ! @hsps.each do |x| ! yield x ! end ! end ! # Compatible with Bio::Fasta::Report::Hit ! alias :target_id :accession ! alias :target_def :definition ! alias :target_len :len ! # Shortcut methods for the best Hsp ! def evalue; @hsps.first.evalue; end ! def bit_score; @hsps.first.bit_score; end ! def identity; @hsps.first.identity; end ! def percent_identity; @hsps.first.percent_identity; end ! def overlap; @hsps.first.align_len; end ! def query_seq; @hsps.first.qseq; end ! def target_seq; @hsps.first.hseq; end ! def midline; @hsps.first.midline; end ! def query_start; @hsps.first.query_from; end ! def query_end; @hsps.first.query_to; end ! def target_start; @hsps.first.hit_from; end ! def target_end; @hsps.first.hit_to; end ! def lap_at ! [ query_start, query_end, target_start, target_end ] ! end end --- 159,200 ---- # Bio::Blast::Report::Hit class Hit ! def initialize ! @hsps = [] ! end ! attr_reader :hsps ! attr_accessor :query_id, :query_def, :query_len, ! :num, :hit_id, :len, :definition, :accession ! def each ! @hsps.each do |x| ! yield x ! end ! end ! # Compatible with Bio::Fasta::Report::Hit ! alias :target_id :accession ! alias :target_def :definition ! alias :target_len :len ! # Shortcut methods for the best Hsp ! def evalue; @hsps.first.evalue; end ! def bit_score; @hsps.first.bit_score; end ! def identity; @hsps.first.identity; end ! def percent_identity; @hsps.first.percent_identity; end ! def overlap; @hsps.first.align_len; end ! def query_seq; @hsps.first.qseq; end ! def target_seq; @hsps.first.hseq; end ! def midline; @hsps.first.midline; end ! def query_start; @hsps.first.query_from; end ! def query_end; @hsps.first.query_to; end ! def target_start; @hsps.first.hit_from; end ! def target_end; @hsps.first.hit_to; end ! def lap_at ! [ query_start, query_end, target_start, target_end ] ! end end *************** *** 202,215 **** # Bio::Blast::Report::Hsp class Hsp ! def initialize ! @hsp = {} ! end ! attr_reader :hsp ! attr_accessor :num, :bit_score, :score, :evalue, ! :query_from, :query_to, :hit_from, :hit_to, ! :pattern_from, :pattern_to, :query_frame, :hit_frame, ! :identity, :positive, :gaps, :align_len, :density, ! :qseq, :hseq, :midline, ! :percent_identity, :mismatch_count # only for '-m 8' end --- 202,215 ---- # Bio::Blast::Report::Hsp class Hsp ! def initialize ! @hsp = {} ! end ! attr_reader :hsp ! attr_accessor :num, :bit_score, :score, :evalue, ! :query_from, :query_to, :hit_from, :hit_to, ! :pattern_from, :pattern_to, :query_frame, :hit_frame, ! :identity, :positive, :gaps, :align_len, :density, ! :qseq, :hseq, :midline, ! :percent_identity, :mismatch_count # only for '-m 8' end Index: wublast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/wublast.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** wublast.rb 11 Aug 2003 15:27:35 -0000 1.1 --- wublast.rb 8 Sep 2005 01:22:08 -0000 1.2 *************** *** 29,267 **** class Report < Default::Report ! def parameters ! parse_parameters ! @parameters ! end ! def parameter_matrix ! parse_parameters ! @parameter_matrix ! end ! def expect; parse_parameters; @parameters['E']; end ! def warnings ! unless defined?(@warnings) ! @warnings = @f0warnings ! iterations.each { |x| @warnings.concat(x.warnings) } ! end ! @warnings ! end ! def notice ! unless defined?(@notice) ! @notice = @f0notice.to_s.gsub(/\s+/, ' ').strip ! end #unless ! @notice ! end ! private ! def format0_split_headers(data) ! @f0header = data.shift ! while r = data.first ! case r ! when /^Reference\: / ! @f0reference = data.shift ! when /^Copyright / ! @f0copyright = data.shift ! when /^Notice\: / ! @f0notice = data.shift ! when /^Query\= / ! break ! else ! break ! end ! end ! @f0query = data.shift ! if r = data.first and !(/^Database\: / =~ r) ! @f0translate_info = data.shift ! end ! @f0database = data.shift ! end ! def format0_split_search(data) ! [ Iteration.new(data) ] ! end ! def format0_split_stat_params(data) ! @f0warnings = [] ! if r = data.first and r =~ /^WARNING\: / then ! @f0warnings << data.shift ! end ! @f0wu_params = [] ! @f0wu_stats = [] ! while r = data.shift and !(r =~ /^Statistics\:/) ! @f0wu_params << r ! end ! @f0wu_stats << r if r ! while r = data.shift ! @f0wu_stats << r ! end ! @f0dbstat = F0dbstat.new(@f0wu_stats) ! itr = @iterations[0] ! itr.f0dbstat = @f0dbstat if itr ! end ! def parse_parameters ! unless defined?(@parse_parameters) ! @parameters = {} ! @parameter_matrix = [] ! @f0wu_params.each do |x| ! if /^ Query/ =~ x then ! @parameter_matrix << x ! else ! x.split(/^/).each do |y| ! if /\A\s*(.+)\s*\=\s*(.*)\s*/ =~ y then ! @parameters[$1] = $2 ! elsif /\AParameters\:/ =~ y then ! ; #ignore this ! elsif /\A\s*(.+)\s*$/ =~ y then ! @parameters[$1] = true ! end ! end ! end ! end ! @parse_parameters = true ! end ! end ! class F0dbstat < Default::Report::F0dbstat ! def initialize(ary) ! @f0stat = ary ! @hash = {} ! end ! #undef :f0params ! #undef :matrix, :gap_open, :gap_extend, ! # :eff_space, :expect, :sc_match, :sc_mismatch, ! # :num_hits ! def parse_dbstat ! unless defined?(@parse_dbstat) ! @f0stat.each do |x| ! parse_colon_separated(@hash, x) ! end ! @database = @hash['Database'] ! @posted_date = @hash['Posted'] ! if val = @hash['# of letters in database'] then ! @db_len = val.tr(',', '').to_i ! end ! if val = @hash['# of sequences in database'] then ! @db_num = val.tr(',', '').to_i ! end ! @parse_dbstat = true ! end #unless ! end #def ! private :parse_dbstat ! end #class F0dbstat ! class Frame ! end #class FrameParams ! class Iteration < Default::Report::Iteration ! def initialize(data) ! @f0stat = [] ! @f0dbstat = nil ! @f0hitlist = [] ! @hits = [] ! @num = 1 ! @f0message = [] ! @f0warnings = [] ! return unless r = data.shift ! @f0hitlist << r ! return unless r = data.shift ! unless /\*{3} +NONE +\*{3}/ =~ r then ! @f0hitlist << r ! while r = data.first and /^WARNING\: / =~ r ! @f0warnings << data.shift ! end ! while r = data.first and /^\>/ =~ r ! @hits << Hit.new(data) ! end ! end #unless ! end ! def warnings ! @f0warnings ! end ! private ! def parse_hitlist ! unless defined?(@parse_hitlist) ! r = @f0hitlist.shift.to_s ! if /Reading/ =~ r and /Frame/ =~ r then ! flag_tblast = true ! spnum = 5 ! else ! flag_tblast = nil ! spnum = 4 ! end ! i = 0 ! @f0hitlist.each do |x| ! b = x.split(/^/) ! b.collect! { |y| y.empty? ? nil : y } ! b.compact! ! b.each do |y| ! y.strip! ! y.reverse! ! z = y.split(/\s+/, spnum) ! z.each { |y| y.reverse! } ! dfl = z.pop ! h = @hits[i] ! unless h then ! h = Hit.new([ dfl.to_s.sub(/\.+\z/, '') ]) ! @hits[i] = h ! end ! z.pop if flag_tblast #ignore Reading Frame ! scr = z.pop.to_s ! pval = z.pop.to_s ! nnum = z.pop.to_i ! #ev = '1' + ev if ev[0] == ?e ! h.instance_eval { ! @score = scr ! @pvalue = pval ! @n_number = nnum ! } ! i += 1 ! end ! end #each ! @parse_hitlist = true ! end #unless ! end ! end #class Iteration ! class Hit < Default::Report::Hit ! def initialize(data) ! @f0hitname = data.shift ! @hsps = [] ! while r = data.first ! if r =~ /^\s*(?:Plus|Minus) +Strand +HSPs\:/ then ! data.shift ! r = data.first ! end ! if /^\s+Score/ =~ r then ! @hsps << HSP.new(data) ! else ! break ! end ! end ! @again = false ! end ! def score ! @score ! end ! attr_reader :pvalue, :n_number ! end #class Hit ! class HSP < Default::Report::HSP ! method_after_parse_score :pvalue, :p_sum_n ! end #class HSP end #class Report class Report_TBlast < Report ! DELIMITER = RS = "\nTBLAST" end #class Report_TBlast --- 29,267 ---- class Report < Default::Report ! def parameters ! parse_parameters ! @parameters ! end ! def parameter_matrix ! parse_parameters ! @parameter_matrix ! end ! def expect; parse_parameters; @parameters['E']; end ! def warnings ! unless defined?(@warnings) ! @warnings = @f0warnings ! iterations.each { |x| @warnings.concat(x.warnings) } ! end ! @warnings ! end ! def notice ! unless defined?(@notice) ! @notice = @f0notice.to_s.gsub(/\s+/, ' ').strip ! end #unless ! @notice ! end ! private ! def format0_split_headers(data) ! @f0header = data.shift ! while r = data.first ! case r ! when /^Reference\: / ! @f0reference = data.shift ! when /^Copyright / ! @f0copyright = data.shift ! when /^Notice\: / ! @f0notice = data.shift ! when /^Query\= / ! break ! else ! break ! end ! end ! @f0query = data.shift ! if r = data.first and !(/^Database\: / =~ r) ! @f0translate_info = data.shift ! end ! @f0database = data.shift ! end ! def format0_split_search(data) ! [ Iteration.new(data) ] ! end ! def format0_split_stat_params(data) ! @f0warnings = [] ! if r = data.first and r =~ /^WARNING\: / then ! @f0warnings << data.shift ! end ! @f0wu_params = [] ! @f0wu_stats = [] ! while r = data.shift and !(r =~ /^Statistics\:/) ! @f0wu_params << r ! end ! @f0wu_stats << r if r ! while r = data.shift ! @f0wu_stats << r ! end ! @f0dbstat = F0dbstat.new(@f0wu_stats) ! itr = @iterations[0] ! itr.f0dbstat = @f0dbstat if itr ! end ! def parse_parameters ! unless defined?(@parse_parameters) ! @parameters = {} ! @parameter_matrix = [] ! @f0wu_params.each do |x| ! if /^ Query/ =~ x then ! @parameter_matrix << x ! else ! x.split(/^/).each do |y| ! if /\A\s*(.+)\s*\=\s*(.*)\s*/ =~ y then ! @parameters[$1] = $2 ! elsif /\AParameters\:/ =~ y then ! ; #ignore this ! elsif /\A\s*(.+)\s*$/ =~ y then ! @parameters[$1] = true ! end ! end ! end ! end ! @parse_parameters = true ! end ! end ! class F0dbstat < Default::Report::F0dbstat ! def initialize(ary) ! @f0stat = ary ! @hash = {} ! end ! #undef :f0params ! #undef :matrix, :gap_open, :gap_extend, ! # :eff_space, :expect, :sc_match, :sc_mismatch, ! # :num_hits ! def parse_dbstat ! unless defined?(@parse_dbstat) ! @f0stat.each do |x| ! parse_colon_separated(@hash, x) ! end ! @database = @hash['Database'] ! @posted_date = @hash['Posted'] ! if val = @hash['# of letters in database'] then ! @db_len = val.tr(',', '').to_i ! end ! if val = @hash['# of sequences in database'] then ! @db_num = val.tr(',', '').to_i ! end ! @parse_dbstat = true ! end #unless ! end #def ! private :parse_dbstat ! end #class F0dbstat ! class Frame ! end #class FrameParams ! class Iteration < Default::Report::Iteration ! def initialize(data) ! @f0stat = [] ! @f0dbstat = nil ! @f0hitlist = [] ! @hits = [] ! @num = 1 ! @f0message = [] ! @f0warnings = [] ! return unless r = data.shift ! @f0hitlist << r ! return unless r = data.shift ! unless /\*{3} +NONE +\*{3}/ =~ r then ! @f0hitlist << r ! while r = data.first and /^WARNING\: / =~ r ! @f0warnings << data.shift ! end ! while r = data.first and /^\>/ =~ r ! @hits << Hit.new(data) ! end ! end #unless ! end ! def warnings ! @f0warnings ! end ! private ! def parse_hitlist ! unless defined?(@parse_hitlist) ! r = @f0hitlist.shift.to_s ! if /Reading/ =~ r and /Frame/ =~ r then ! flag_tblast = true ! spnum = 5 ! else ! flag_tblast = nil ! spnum = 4 ! end ! i = 0 ! @f0hitlist.each do |x| ! b = x.split(/^/) ! b.collect! { |y| y.empty? ? nil : y } ! b.compact! ! b.each do |y| ! y.strip! ! y.reverse! ! z = y.split(/\s+/, spnum) ! z.each { |y| y.reverse! } ! dfl = z.pop ! h = @hits[i] ! unless h then ! h = Hit.new([ dfl.to_s.sub(/\.+\z/, '') ]) ! @hits[i] = h ! end ! z.pop if flag_tblast #ignore Reading Frame ! scr = z.pop.to_s ! pval = z.pop.to_s ! nnum = z.pop.to_i ! #ev = '1' + ev if ev[0] == ?e ! h.instance_eval { ! @score = scr ! @pvalue = pval ! @n_number = nnum ! } ! i += 1 ! end ! end #each ! @parse_hitlist = true ! end #unless ! end ! end #class Iteration ! class Hit < Default::Report::Hit ! def initialize(data) ! @f0hitname = data.shift ! @hsps = [] ! while r = data.first ! if r =~ /^\s*(?:Plus|Minus) +Strand +HSPs\:/ then ! data.shift ! r = data.first ! end ! if /^\s+Score/ =~ r then ! @hsps << HSP.new(data) ! else ! break ! end ! end ! @again = false ! end ! def score ! @score ! end ! attr_reader :pvalue, :n_number ! end #class Hit ! class HSP < Default::Report::HSP ! method_after_parse_score :pvalue, :p_sum_n ! end #class HSP end #class Report class Report_TBlast < Report ! DELIMITER = RS = "\nTBLAST" end #class Report_TBlast Index: format8.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/format8.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** format8.rb 5 Feb 2003 03:28:26 -0000 1.4 --- format8.rb 8 Sep 2005 01:22:08 -0000 1.5 *************** *** 28,85 **** def tab_parse(data) ! iteration = Iteration.new ! @iterations.push(iteration) ! @query_id = @query_def = data[/\S+/] ! target_prev = '' ! hit_num = 1 ! hsp_num = 1 ! hit = '' ! data.each do |line| ! ary = line.chomp.split("\t") ! query_id, target_id, hsp = tab_parse_hsp(ary) ! if target_prev != target_id ! hit = Hit.new ! hit.num = hit_num ! hit_num += 1 ! hit.query_id = hit.query_def = query_id ! hit.accession = hit.definition = target_id ! iteration.hits.push(hit) ! hsp_num = 1 ! end ! hsp.num = hsp_num ! hsp_num += 1 ! hit.hsps.push(hsp) ! target_prev = target_id ! end end def tab_parse_hsp(ary) ! query_id, target_id, ! percent_identity, ! align_len, ! mismatch_count, ! gaps, ! query_from, ! query_to, ! hit_from, ! hit_to, ! evalue, ! bit_score = *ary ! hsp = Hsp.new ! hsp.align_len = align_len.to_i ! hsp.gaps = gaps.to_i ! hsp.query_from = query_from.to_i ! hsp.query_to = query_to.to_i ! hsp.hit_from = hit_from.to_i ! hsp.hit_to = hit_to.to_i ! hsp.evalue = evalue.strip.to_f ! hsp.bit_score = bit_score.to_f ! hsp.percent_identity = percent_identity.to_f ! hsp.mismatch_count = mismatch_count.to_i ! return query_id, target_id, hsp end --- 28,85 ---- def tab_parse(data) ! iteration = Iteration.new ! @iterations.push(iteration) ! @query_id = @query_def = data[/\S+/] ! target_prev = '' ! hit_num = 1 ! hsp_num = 1 ! hit = '' ! data.each do |line| ! ary = line.chomp.split("\t") ! query_id, target_id, hsp = tab_parse_hsp(ary) ! if target_prev != target_id ! hit = Hit.new ! hit.num = hit_num ! hit_num += 1 ! hit.query_id = hit.query_def = query_id ! hit.accession = hit.definition = target_id ! iteration.hits.push(hit) ! hsp_num = 1 ! end ! hsp.num = hsp_num ! hsp_num += 1 ! hit.hsps.push(hsp) ! target_prev = target_id ! end end def tab_parse_hsp(ary) ! query_id, target_id, ! percent_identity, ! align_len, ! mismatch_count, ! gaps, ! query_from, ! query_to, ! hit_from, ! hit_to, ! evalue, ! bit_score = *ary ! hsp = Hsp.new ! hsp.align_len = align_len.to_i ! hsp.gaps = gaps.to_i ! hsp.query_from = query_from.to_i ! hsp.query_to = query_to.to_i ! hsp.hit_from = hit_from.to_i ! hsp.hit_to = hit_to.to_i ! hsp.evalue = evalue.strip.to_f ! hsp.bit_score = bit_score.to_f ! hsp.percent_identity = percent_identity.to_f ! hsp.mismatch_count = mismatch_count.to_i ! return query_id, target_id, hsp end Index: rexml.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/rexml.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** rexml.rb 29 Sep 2003 10:03:59 -0000 1.9 --- rexml.rb 8 Sep 2005 01:22:08 -0000 1.10 *************** *** 33,141 **** def rexml_parse(xml) ! dom = REXML::Document.new(xml) ! rexml_parse_program(dom) ! dom.elements.each("*//Iteration") do |e| ! @iterations.push(rexml_parse_iteration(e)) ! end end def rexml_parse_program(dom) ! hash = {} ! dom.root.each_element_with_text do |e| ! name, text = e.name, e.text ! case name ! when 'BlastOutput_param' ! e.elements["Parameters"].each_element_with_text do |p| ! k = p.name.sub(/Parameters_/, '') ! v = p.text =~ /\D/ ? p.text : p.text.to_i ! @parameters[k] = v ! end ! else ! hash[name] = text if text.strip.size > 0 ! end ! end ! @program = hash['BlastOutput_program'] ! @version = hash['BlastOutput_version'] ! @reference = hash['BlastOutput_reference'] ! @db = hash['BlastOutput_db'] ! @query_id = hash['BlastOutput_query-ID'] ! @query_def = hash['BlastOutput_query-def'] ! @query_len = hash['BlastOutput_query-len'].to_i end def rexml_parse_iteration(e) ! iteration = Iteration.new ! e.elements.each do |i| ! case i.name ! when 'Iteration_iter-num' ! iteration.num = i.text.to_i ! when 'Iteration_hits' ! i.elements.each("Hit") do |h| ! iteration.hits.push(rexml_parse_hit(h)) ! end ! when 'Iteration_message' ! iteration.message = i.text ! when 'Iteration_stat' ! i.elements["Statistics"].each_element_with_text do |s| ! k = s.name.sub(/Statistics_/, '') ! v = s.text =~ /\D/ ? s.text.to_f : s.text.to_i ! iteration.statistics[k] = v ! end ! end ! end ! return iteration end def rexml_parse_hit(e) ! hit = Hit.new ! hash = {} ! hit.query_id = @query_id ! hit.query_def = @query_def ! hit.query_len = @query_len ! e.elements.each do |h| ! case h.name ! when 'Hit_hsps' ! h.elements.each("Hsp") do |s| ! hit.hsps.push(rexml_parse_hsp(s)) ! end ! else ! hash[h.name] = h.text ! end ! end ! hit.num = hash['Hit_num'].to_i ! hit.hit_id = hash['Hit_id'] ! hit.len = hash['Hit_len'].to_i ! hit.definition = hash['Hit_def'] ! hit.accession = hash['Hit_accession'] ! return hit end def rexml_parse_hsp(e) ! hsp = Hsp.new ! hash = {} ! e.each_element_with_text do |h| ! hash[h.name] = h.text ! end ! hsp.num = hash['Hsp_num'].to_i ! hsp.bit_score = hash['Hsp_bit-score'].to_f ! hsp.score = hash['Hsp_score'].to_i ! hsp.evalue = hash['Hsp_evalue'].to_f ! hsp.query_from = hash['Hsp_query-from'].to_i ! hsp.query_to = hash['Hsp_query-to'].to_i ! hsp.hit_from = hash['Hsp_hit-from'].to_i ! hsp.hit_to = hash['Hsp_hit-to'].to_i ! hsp.pattern_from = hash['Hsp_pattern-from'].to_i ! hsp.pattern_to = hash['Hsp_pattern-to'].to_i ! hsp.query_frame = hash['Hsp_query-frame'].to_i ! hsp.hit_frame = hash['Hsp_hit-frame'].to_i ! hsp.identity = hash['Hsp_identity'].to_i ! hsp.positive = hash['Hsp_positive'].to_i ! hsp.gaps = hash['Hsp_gaps'].to_i ! hsp.align_len = hash['Hsp_align-len'].to_i ! hsp.density = hash['Hsp_density'].to_i ! hsp.qseq = hash['Hsp_qseq'] ! hsp.hseq = hash['Hsp_hseq'] ! hsp.midline = hash['Hsp_midline'] ! return hsp end --- 33,141 ---- def rexml_parse(xml) ! dom = REXML::Document.new(xml) ! rexml_parse_program(dom) ! dom.elements.each("*//Iteration") do |e| ! @iterations.push(rexml_parse_iteration(e)) ! end end def rexml_parse_program(dom) ! hash = {} ! dom.root.each_element_with_text do |e| ! name, text = e.name, e.text ! case name ! when 'BlastOutput_param' ! e.elements["Parameters"].each_element_with_text do |p| ! k = p.name.sub(/Parameters_/, '') ! v = p.text =~ /\D/ ? p.text : p.text.to_i ! @parameters[k] = v ! end ! else ! hash[name] = text if text.strip.size > 0 ! end ! end ! @program = hash['BlastOutput_program'] ! @version = hash['BlastOutput_version'] ! @reference = hash['BlastOutput_reference'] ! @db = hash['BlastOutput_db'] ! @query_id = hash['BlastOutput_query-ID'] ! @query_def = hash['BlastOutput_query-def'] ! @query_len = hash['BlastOutput_query-len'].to_i end def rexml_parse_iteration(e) ! iteration = Iteration.new ! e.elements.each do |i| ! case i.name ! when 'Iteration_iter-num' ! iteration.num = i.text.to_i ! when 'Iteration_hits' ! i.elements.each("Hit") do |h| ! iteration.hits.push(rexml_parse_hit(h)) ! end ! when 'Iteration_message' ! iteration.message = i.text ! when 'Iteration_stat' ! i.elements["Statistics"].each_element_with_text do |s| ! k = s.name.sub(/Statistics_/, '') ! v = s.text =~ /\D/ ? s.text.to_f : s.text.to_i ! iteration.statistics[k] = v ! end ! end ! end ! return iteration end def rexml_parse_hit(e) ! hit = Hit.new ! hash = {} ! hit.query_id = @query_id ! hit.query_def = @query_def ! hit.query_len = @query_len ! e.elements.each do |h| ! case h.name ! when 'Hit_hsps' ! h.elements.each("Hsp") do |s| ! hit.hsps.push(rexml_parse_hsp(s)) ! end ! else ! hash[h.name] = h.text ! end ! end ! hit.num = hash['Hit_num'].to_i ! hit.hit_id = hash['Hit_id'] ! hit.len = hash['Hit_len'].to_i ! hit.definition = hash['Hit_def'] ! hit.accession = hash['Hit_accession'] ! return hit end def rexml_parse_hsp(e) ! hsp = Hsp.new ! hash = {} ! e.each_element_with_text do |h| ! hash[h.name] = h.text ! end ! hsp.num = hash['Hsp_num'].to_i ! hsp.bit_score = hash['Hsp_bit-score'].to_f ! hsp.score = hash['Hsp_score'].to_i ! hsp.evalue = hash['Hsp_evalue'].to_f ! hsp.query_from = hash['Hsp_query-from'].to_i ! hsp.query_to = hash['Hsp_query-to'].to_i ! hsp.hit_from = hash['Hsp_hit-from'].to_i ! hsp.hit_to = hash['Hsp_hit-to'].to_i ! hsp.pattern_from = hash['Hsp_pattern-from'].to_i ! hsp.pattern_to = hash['Hsp_pattern-to'].to_i ! hsp.query_frame = hash['Hsp_query-frame'].to_i ! hsp.hit_frame = hash['Hsp_hit-frame'].to_i ! hsp.identity = hash['Hsp_identity'].to_i ! hsp.positive = hash['Hsp_positive'].to_i ! hsp.gaps = hash['Hsp_gaps'].to_i ! hsp.align_len = hash['Hsp_align-len'].to_i ! hsp.density = hash['Hsp_density'].to_i ! hsp.qseq = hash['Hsp_qseq'] ! hsp.hseq = hash['Hsp_hseq'] ! hsp.midline = hash['Hsp_midline'] ! return hsp end Index: format0.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/format0.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** format0.rb 7 Aug 2005 16:42:28 -0000 1.9 --- format0.rb 8 Sep 2005 01:22:08 -0000 1.10 *************** *** 34,280 **** class Report #< DB ! DELIMITER = RS = "\nBLAST" ! def self.open(filename, *mode) ! Bio::FlatFile.open(self, filename, *mode) ! end ! def initialize(str) ! str = str.sub(/\A\s+/, '') [...1502 lines suppressed...] ! end #unless ! end #def ! private :parse_alignment ! def self.method_after_parse_alignment(*names) ! names.each do |x| ! module_eval("def #{x}; parse_alignment; @#{x}; end") ! end ! end ! private_class_method :method_after_parse_alignment ! method_after_parse_alignment :qseq, :hseq, :midline, ! :query_from, :query_to, :hit_from, :hit_to ! end #class HSP end #class Report class Report_TBlast < Report ! DELIMITER = RS = "\nTBLAST" end #class Report_TBlast From pjotr at pub.open-bio.org Thu Sep 8 01:36:28 2005 From: pjotr at pub.open-bio.org (Pjotr Prins) Date: Fri Sep 9 13:29:29 2005 Subject: [BioRuby-cvs] bioruby/doc Tutorial.rd,1.2,1.3 Message-ID: <200509080536.j885aSdZ013610@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/doc In directory pub.open-bio.org:/tmp/cvs-serv13600 Modified Files: Tutorial.rd Log Message: Added warning and edited one paragraph Index: Tutorial.rd =================================================================== RCS file: /home/repository/bioruby/bioruby/doc/Tutorial.rd,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Tutorial.rd 31 Aug 2005 13:16:03 -0000 1.2 --- Tutorial.rd 8 Sep 2005 05:36:26 -0000 1.3 *************** *** 6,21 **** Translated into English: Naohisa Goto (to be written...) = How to use BioRuby == Manipulating nucleic / amino acid sequences (Bio::Sequence class) ! For simple example, by using a short DNA seuquence "atgcatgcaaaa", ! we are now converting into complemental strand, splicing subsequence, ! calculating nucleic acid compositions, translating to amino acid sequence, ! calculating molecular weight, and so on. About translation to ! amino acid sequences, you can specify frame where you want to start ! translation from and condon table ID defined in codontable.rb. --- 6,28 ---- Translated into English: Naohisa Goto + Edited by: PjotrPrins (to be written...) + IMPORTANT NOTICE: This page is maintained in the BioRuby + CVS repository. Please edit the file there, otherwise + changes may get lost. See (()) + for CVS and mailing list access. + = How to use BioRuby == Manipulating nucleic / amino acid sequences (Bio::Sequence class) ! A simple example: take a DNA sequence "atgcatgcaaaa", and convert it ! into the complemental strand, splice it into a subsequence, calculate ! the nucleic acid composition, translate it into the amino acid ! sequence, calculate molecular weight, and so on. Translating into ! amino acid sequences the frame can be specified - where you want to ! start the translation from and which condon table to use (ID defined ! in codontable.rb). From pjotr at pub.open-bio.org Thu Sep 8 01:43:12 2005 From: pjotr at pub.open-bio.org (Pjotr Prins) Date: Fri Sep 9 13:29:29 2005 Subject: [BioRuby-cvs] bioruby/doc Tutorial.rd,1.3,1.4 Message-ID: <200509080543.j885hCdZ013644@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/doc In directory pub.open-bio.org:/tmp/cvs-serv13634 Modified Files: Tutorial.rd Log Message: Wiki fixes Index: Tutorial.rd =================================================================== RCS file: /home/repository/bioruby/bioruby/doc/Tutorial.rd,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Tutorial.rd 8 Sep 2005 05:36:26 -0000 1.3 --- Tutorial.rd 8 Sep 2005 05:43:10 -0000 1.4 *************** *** 9,16 **** (to be written...) ! IMPORTANT NOTICE: This page is maintained in the BioRuby ! CVS repository. Please edit the file there, otherwise ! changes may get lost. See (()) ! for CVS and mailing list access. = How to use BioRuby --- 9,18 ---- (to be written...) ! NOTE: This page is a work in progress at this point ! ! IMPORTANT NOTICE: This page is maintained in the BioRuby ! CVS repository. Please edit the file there, otherwise ! changes may get lost. See (()) ! for CVS and mailing list access. = How to use BioRuby From ngoto at pub.open-bio.org Fri Sep 9 10:35:28 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:30 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/io/flatfile index.rb, 1.10, 1.11 indexer.rb, 1.18, 1.19 bdb.rb, 1.6, 1.7 Message-ID: <200509091435.j89EZSdZ021074@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io/flatfile In directory pub.open-bio.org:/tmp/cvs-serv21060/lib/bio/io/flatfile Modified Files: index.rb indexer.rb bdb.rb Log Message: Fixed Bio::FlatFileIndex autoload problem Index: bdb.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile/bdb.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** bdb.rb 8 Sep 2005 01:22:12 -0000 1.6 --- bdb.rb 9 Sep 2005 14:35:25 -0000 1.7 *************** *** 26,29 **** --- 26,32 ---- end + require 'bio/io/flatfile/index' + require 'bio/io/flatfile/indexer' + module Bio class FlatFileIndex Index: index.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile/index.rb,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** index.rb 8 Sep 2005 01:22:12 -0000 1.10 --- index.rb 9 Sep 2005 14:35:25 -0000 1.11 *************** *** 21,27 **** # - module Bio class FlatFileIndex MAGIC_FLAT = 'flat/1' MAGIC_BDB = 'BerkeleyDB/1' --- 21,32 ---- # module Bio class FlatFileIndex + + autoload :Indexer, 'bio/io/flatfile/indexer' + autoload :BDBdefault, 'bio/io/flatfile/bdb' + autoload :BDBwrapper, 'bio/io/flatfile/bdb' + autoload :BDB_1, 'bio/io/flatfile/bdb' + MAGIC_FLAT = 'flat/1' MAGIC_BDB = 'BerkeleyDB/1' Index: indexer.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile/indexer.rb,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** indexer.rb 8 Sep 2005 01:22:12 -0000 1.18 --- indexer.rb 9 Sep 2005 14:35:25 -0000 1.19 *************** *** 21,24 **** --- 21,26 ---- # + require 'bio/io/flatfile/index' + module Bio class FlatFileIndex From ngoto at pub.open-bio.org Fri Sep 9 10:35:27 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:30 2005 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.45,1.46 Message-ID: <200509091435.j89EZRdZ021072@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv21060/lib Modified Files: bio.rb Log Message: Fixed Bio::FlatFileIndex autoload problem Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** bio.rb 8 Sep 2005 01:15:52 -0000 1.45 --- bio.rb 9 Sep 2005 14:35:25 -0000 1.46 *************** *** 148,156 **** autoload :SQL, 'bio/io/sql' autoload :FlatFile, 'bio/io/flatfile' ! autoload :FlatFileIndex, 'bio/io/flatfile/index' # chage to FlatFile::Index ? ! class FlatFileIndex ! autoload :Indexer, 'bio/io/flatfile/indexer' # require 'flatfile/index' ! autoload :BDBdefault, 'bio/io/flatfile/bdb' # require 'flatfile/index' ! end autoload :PubMed, 'bio/io/pubmed' --- 148,158 ---- autoload :SQL, 'bio/io/sql' autoload :FlatFile, 'bio/io/flatfile' ! autoload :FlatFileIndex, 'bio/io/flatfile/index' # chage to FlatFile::Index ? ## below are described in bio/io/flatfile/index.rb ! #class FlatFileIndex ! # autoload :Indexer, 'bio/io/flatfile/indexer' ! # autoload :BDBdefault, 'bio/io/flatfile/bdb' ! # autoload :BDBwrapper, 'bio/io/flatfile/bdb' ! # autoload :BDB_1, 'bio/io/flatfile/bdb' ! #end autoload :PubMed, 'bio/io/pubmed' From ngoto at pub.open-bio.org Fri Sep 9 10:38:12 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:30 2005 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.46,1.47 Message-ID: <200509091438.j89EcCdZ021106@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv21096/lib Modified Files: bio.rb Log Message: fixed comments after autoload :FlatFileIndex Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** bio.rb 9 Sep 2005 14:35:25 -0000 1.46 --- bio.rb 9 Sep 2005 14:38:10 -0000 1.47 *************** *** 148,152 **** autoload :SQL, 'bio/io/sql' autoload :FlatFile, 'bio/io/flatfile' ! autoload :FlatFileIndex, 'bio/io/flatfile/index' # chage to FlatFile::Index ? ## below are described in bio/io/flatfile/index.rb #class FlatFileIndex # autoload :Indexer, 'bio/io/flatfile/indexer' --- 148,153 ---- autoload :SQL, 'bio/io/sql' autoload :FlatFile, 'bio/io/flatfile' ! autoload :FlatFileIndex, 'bio/io/flatfile/index' # chage to FlatFile::Index ? ! ## below are described in bio/io/flatfile/index.rb #class FlatFileIndex # autoload :Indexer, 'bio/io/flatfile/indexer' From ngoto at pub.open-bio.org Fri Sep 9 10:59:55 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:31 2005 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.47,1.48 Message-ID: <200509091459.j89ExtdZ021253@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv21239/lib Modified Files: bio.rb Log Message: * fixed autoload problem about Bio::Blast. * changed not to require bio/db.rb in format0.rb. Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** bio.rb 9 Sep 2005 14:38:10 -0000 1.47 --- bio.rb 9 Sep 2005 14:59:52 -0000 1.48 *************** *** 161,167 **** autoload :DBGET, 'bio/io/dbget' ! class Blast ! autoload :Fastacmd, 'bio/io/fastacmd' ! end class KEGG --- 161,168 ---- autoload :DBGET, 'bio/io/dbget' ! ## below are described in bio/appl/blast.rb ! #class Blast ! # autoload :Fastacmd, 'bio/io/fastacmd' ! #end class KEGG *************** *** 187,196 **** autoload :Blast, 'bio/appl/blast' ! class Blast ! autoload :Report, 'bio/appl/blast/report' ! autoload :Default, 'bio/appl/blast/format0' ! autoload :WU, 'bio/appl/blast/wublast' ! autoload :Bl2seq, 'bio/appl/bl2seq/report' ! end autoload :HMMER, 'bio/appl/hmmer' --- 188,199 ---- autoload :Blast, 'bio/appl/blast' ! ## below are described in bio/appl/blast.rb ! #class Blast ! # autoload :Fastacmd, 'bio/io/fastacmd' ! # autoload :Report, 'bio/appl/blast/report' ! # autoload :Default, 'bio/appl/blast/format0' ! # autoload :WU, 'bio/appl/blast/wublast' ! # autoload :Bl2seq, 'bio/appl/bl2seq/report' ! #end autoload :HMMER, 'bio/appl/hmmer' From ngoto at pub.open-bio.org Fri Sep 9 10:59:55 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:32 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl blast.rb,1.22,1.23 Message-ID: <200509091459.j89ExtdZ021257@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv21239/lib/bio/appl Modified Files: blast.rb Log Message: * fixed autoload problem about Bio::Blast. * changed not to require bio/db.rb in format0.rb. Index: blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast.rb,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** blast.rb 8 Sep 2005 01:22:08 -0000 1.22 --- blast.rb 9 Sep 2005 14:59:53 -0000 1.23 *************** *** 24,34 **** require 'net/http' require 'cgi' unless defined?(CGI) - require 'bio/appl/blast/report' require 'bio/command' require 'shellwords' module Bio class Blast include Bio::Command::Tools --- 24,42 ---- require 'net/http' require 'cgi' unless defined?(CGI) require 'bio/command' require 'shellwords' + require 'bio/appl/blast/report' # for Bio::Blast.reports method + module Bio class Blast + + autoload :Fastacmd, 'bio/io/fastacmd' + #autoload :Report, 'bio/appl/blast/report' + ## cannot autoload report.rb because of Bio::Blast.reports method + autoload :Default, 'bio/appl/blast/format0' + autoload :WU, 'bio/appl/blast/wublast' + autoload :Bl2seq, 'bio/appl/bl2seq/report' include Bio::Command::Tools From ngoto at pub.open-bio.org Fri Sep 9 10:59:55 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:32 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/blast format0.rb,1.10,1.11 Message-ID: <200509091459.j89ExtdZ021261@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/blast In directory pub.open-bio.org:/tmp/cvs-serv21239/lib/bio/appl/blast Modified Files: format0.rb Log Message: * fixed autoload problem about Bio::Blast. * changed not to require bio/db.rb in format0.rb. Index: format0.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/format0.rb,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** format0.rb 8 Sep 2005 01:22:08 -0000 1.10 --- format0.rb 9 Sep 2005 14:59:53 -0000 1.11 *************** *** 26,30 **** end ! require 'bio/db' require 'bio/io/flatfile' --- 26,30 ---- end ! #require 'bio/db' require 'bio/io/flatfile' From ngoto at pub.open-bio.org Fri Sep 9 11:09:39 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:33 2005 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.48,1.49 Message-ID: <200509091509.j89F9ddZ021317@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv21303/lib Modified Files: bio.rb Log Message: * fixed autoload problem about Bio::Fasta. * added "require 'bio/appl/fasta' in bio/appl/fasta/format10.rb. Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** bio.rb 9 Sep 2005 14:59:52 -0000 1.48 --- bio.rb 9 Sep 2005 15:09:37 -0000 1.49 *************** *** 185,189 **** autoload :Fasta, 'bio/appl/fasta' ! autoload :Report, 'bio/appl/fasta/format10' # improve format6 autoload :Blast, 'bio/appl/blast' --- 185,192 ---- autoload :Fasta, 'bio/appl/fasta' ! ## below are described in bio/appl/fasta.rb ! #class Fasta ! # autoload :Report, 'bio/appl/fasta/format10' ! #end autoload :Blast, 'bio/appl/blast' From ngoto at pub.open-bio.org Fri Sep 9 11:09:39 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:33 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl fasta.rb,1.18,1.19 Message-ID: <200509091509.j89F9ddZ021319@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv21303/lib/bio/appl Modified Files: fasta.rb Log Message: * fixed autoload problem about Bio::Fasta. * added "require 'bio/appl/fasta' in bio/appl/fasta/format10.rb. Index: fasta.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/fasta.rb,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** fasta.rb 8 Sep 2005 01:22:08 -0000 1.18 --- fasta.rb 9 Sep 2005 15:09:37 -0000 1.19 *************** *** 30,33 **** --- 30,36 ---- class Fasta + autoload :Report, 'bio/appl/fasta/format10' + #autoload :?????, 'bio/appl/fasta/format6' + include Bio::Command::Tools From ngoto at pub.open-bio.org Fri Sep 9 11:09:39 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:33 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/fasta format10.rb,1.4,1.5 Message-ID: <200509091509.j89F9ddZ021325@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/fasta In directory pub.open-bio.org:/tmp/cvs-serv21303/lib/bio/appl/fasta Modified Files: format10.rb Log Message: * fixed autoload problem about Bio::Fasta. * added "require 'bio/appl/fasta' in bio/appl/fasta/format10.rb. Index: format10.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/fasta/format10.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** format10.rb 8 Sep 2005 01:22:09 -0000 1.4 --- format10.rb 9 Sep 2005 15:09:37 -0000 1.5 *************** *** 21,24 **** --- 21,26 ---- # + require 'bio/appl/fasta' + module Bio class Fasta From ngoto at pub.open-bio.org Fri Sep 9 11:15:53 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:34 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl blast.rb,1.23,1.24 Message-ID: <200509091515.j89FFrdZ021384@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv21369/lib/bio/appl Modified Files: blast.rb Log Message: * moved Bio::Blast.reports method from blast/report.rb to blast.rb for autoload. * added "require 'bio/appl/blast'" in blast/report.rb. Index: blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast.rb,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** blast.rb 9 Sep 2005 14:59:53 -0000 1.23 --- blast.rb 9 Sep 2005 15:15:51 -0000 1.24 *************** *** 27,32 **** require 'shellwords' - require 'bio/appl/blast/report' # for Bio::Blast.reports method - module Bio --- 27,30 ---- *************** *** 34,39 **** autoload :Fastacmd, 'bio/io/fastacmd' ! #autoload :Report, 'bio/appl/blast/report' ! ## cannot autoload report.rb because of Bio::Blast.reports method autoload :Default, 'bio/appl/blast/format0' autoload :WU, 'bio/appl/blast/wublast' --- 32,36 ---- autoload :Fastacmd, 'bio/io/fastacmd' ! autoload :Report, 'bio/appl/blast/report' autoload :Default, 'bio/appl/blast/format0' autoload :WU, 'bio/appl/blast/wublast' *************** *** 92,95 **** --- 89,108 ---- # backward compatibility @options = Shellwords.shellwords(str) + end + + # the method Bio::Blast.report is moved from bio/appl/blast/report.rb. + # only for xml format + def self.reports(input, parser = nil) + ary = [] + input.each("\n") do |xml| + xml.sub!(/[^<]*( tag + next if xml.empty? # skip trailing no hits + if block_given? + yield Report.new(xml, parser) + else + ary << Report.new(xml, parser) + end + end + return ary end From ngoto at pub.open-bio.org Fri Sep 9 11:15:53 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:34 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/blast report.rb,1.7,1.8 Message-ID: <200509091515.j89FFrdZ021388@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/blast In directory pub.open-bio.org:/tmp/cvs-serv21369/lib/bio/appl/blast Modified Files: report.rb Log Message: * moved Bio::Blast.reports method from blast/report.rb to blast.rb for autoload. * added "require 'bio/appl/blast'" in blast/report.rb. Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/report.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** report.rb 8 Sep 2005 01:22:08 -0000 1.7 --- report.rb 9 Sep 2005 15:15:51 -0000 1.8 *************** *** 21,24 **** --- 21,25 ---- # + require 'bio/appl/blast' require 'bio/appl/blast/xmlparser' require 'bio/appl/blast/rexml' *************** *** 27,45 **** module Bio class Blast - - def self.reports(input, parser = nil) - ary = [] - input.each("\n") do |xml| - xml.sub!(/[^<]*( tag - next if xml.empty? # skip trailing no hits - if block_given? - yield Report.new(xml, parser) - else - ary << Report.new(xml, parser) - end - end - return ary - end - class Report --- 28,31 ---- From ngoto at pub.open-bio.org Fri Sep 9 11:34:30 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:35 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl hmmer.rb,1.2,1.3 Message-ID: <200509091534.j89FYUdZ021460@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv21442/lib/bio/appl Modified Files: hmmer.rb Log Message: * fixed autoload problem about Bio::HMMER. * added "require 'bio/appl/hmmer'" in bio/appl/hmmer/report.rb. Index: hmmer.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/hmmer.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** hmmer.rb 16 Aug 2005 09:38:34 -0000 1.2 --- hmmer.rb 9 Sep 2005 15:34:28 -0000 1.3 *************** *** 21,25 **** # - require 'bio/appl/hmmer/report' require 'bio/command' require 'shellwords' --- 21,24 ---- *************** *** 28,31 **** --- 27,32 ---- class HMMER + + autoload :Report, 'bio/appl/hmmer/report' include Bio::Command::Tools From ngoto at pub.open-bio.org Fri Sep 9 11:34:30 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:35 2005 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.49,1.50 Message-ID: <200509091534.j89FYUdZ021456@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv21442/lib Modified Files: bio.rb Log Message: * fixed autoload problem about Bio::HMMER. * added "require 'bio/appl/hmmer'" in bio/appl/hmmer/report.rb. Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** bio.rb 9 Sep 2005 15:09:37 -0000 1.49 --- bio.rb 9 Sep 2005 15:34:28 -0000 1.50 *************** *** 201,207 **** autoload :HMMER, 'bio/appl/hmmer' ! class HMMER ! autoload :Report, 'bio/appl/hmmer/report' ! end # autoload :EMBOSS, 'bio/appl/emboss' # use bio/command, improve --- 201,208 ---- autoload :HMMER, 'bio/appl/hmmer' ! ## below are described in bio/appl/hmmer.rb ! #class HMMER ! # autoload :Report, 'bio/appl/hmmer/report' ! #end # autoload :EMBOSS, 'bio/appl/emboss' # use bio/command, improve From ngoto at pub.open-bio.org Fri Sep 9 11:34:31 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:41 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/hmmer report.rb,1.6,1.7 Message-ID: <200509091534.j89FYVdZ021464@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/hmmer In directory pub.open-bio.org:/tmp/cvs-serv21442/lib/bio/appl/hmmer Modified Files: report.rb Log Message: * fixed autoload problem about Bio::HMMER. * added "require 'bio/appl/hmmer'" in bio/appl/hmmer/report.rb. Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/hmmer/report.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** report.rb 8 Sep 2005 01:22:09 -0000 1.6 --- report.rb 9 Sep 2005 15:34:28 -0000 1.7 *************** *** 21,24 **** --- 21,26 ---- # + require 'bio/appl/hmmer' + module Bio class HMMER From ngoto at pub.open-bio.org Fri Sep 9 11:48:19 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:41 2005 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.50,1.51 Message-ID: <200509091548.j89FmJdZ021540@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv21526/lib Modified Files: bio.rb Log Message: * fixed autoload problem about Bio::PSORT. * added "require 'bio/appl/psort'" in bio/appl/psort/report.rb. Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** bio.rb 9 Sep 2005 15:34:28 -0000 1.50 --- bio.rb 9 Sep 2005 15:48:17 -0000 1.51 *************** *** 209,216 **** autoload :PSORT, 'bio/appl/psort' ! class PSORT ! autoload :PSORT1, 'bio/appl/psort' ! autoload :PSORT2, 'bio/appl/psort' ! end autoload :TMHMM, 'bio/appl/tmhmm/report' --- 209,221 ---- autoload :PSORT, 'bio/appl/psort' ! ## below are described in bio/appl/psort.rb ! #class PSORT ! # class PSORT1 ! # autoload :Report, 'bio/appl/psort/report' ! # end ! # class PSORT2 ! # autoload :Report, 'bio/appl/psort/report' ! # end ! #end autoload :TMHMM, 'bio/appl/tmhmm/report' From ngoto at pub.open-bio.org Fri Sep 9 11:48:19 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:42 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/psort report.rb,1.8,1.9 Message-ID: <200509091548.j89FmJdZ021548@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/psort In directory pub.open-bio.org:/tmp/cvs-serv21526/lib/bio/appl/psort Modified Files: report.rb Log Message: * fixed autoload problem about Bio::PSORT. * added "require 'bio/appl/psort'" in bio/appl/psort/report.rb. Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/psort/report.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** report.rb 8 Sep 2005 01:22:10 -0000 1.8 --- report.rb 9 Sep 2005 15:48:17 -0000 1.9 *************** *** 22,25 **** --- 22,26 ---- require 'bio/sequence' + require 'bio/appl/psort' From ngoto at pub.open-bio.org Fri Sep 9 11:48:19 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:42 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl psort.rb,1.5,1.6 Message-ID: <200509091548.j89FmJdZ021544@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv21526/lib/bio/appl Modified Files: psort.rb Log Message: * fixed autoload problem about Bio::PSORT. * added "require 'bio/appl/psort'" in bio/appl/psort/report.rb. Index: psort.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/psort.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** psort.rb 8 Sep 2005 01:22:08 -0000 1.5 --- psort.rb 9 Sep 2005 15:48:17 -0000 1.6 *************** *** 25,29 **** require 'bio/sequence' require 'bio/db/fasta' - require 'bio/appl/psort/report' require 'net/http' require 'cgi' --- 25,28 ---- *************** *** 107,110 **** --- 106,111 ---- class PSORT1 + autoload :Report, 'bio/appl/psort/report' + def self.imsut self.new(Remote.new(WWWServer['IMSUT']['host'], *************** *** 181,184 **** --- 182,187 ---- # Nakai and Horton 1999 TiBS class PSORT2 + + autoload :Report, 'bio/appl/psort/report' # remote From ngoto at pub.open-bio.org Fri Sep 9 11:52:59 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:43 2005 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.51,1.52 Message-ID: <200509091552.j89FqxdZ021584@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv21572 Modified Files: bio.rb Log Message: fixed autoload problem about Bio::ClustalW. Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** bio.rb 9 Sep 2005 15:48:17 -0000 1.51 --- bio.rb 9 Sep 2005 15:52:57 -0000 1.52 *************** *** 225,231 **** autoload :ClustalW, 'bio/appl/clustalw' ! class ClustalW ! autoload :Report, 'bio/appl/clustalw/report' ! end autoload :MAFFT, 'bio/appl/mafft' --- 225,232 ---- autoload :ClustalW, 'bio/appl/clustalw' ! ## below are described in bio/appl/clustalw.rb ! #class ClustalW ! # autoload :Report, 'bio/appl/clustalw/report' ! #end autoload :MAFFT, 'bio/appl/mafft' From ngoto at pub.open-bio.org Fri Sep 9 11:52:59 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:45 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl clustalw.rb,1.6,1.7 Message-ID: <200509091552.j89FqxdZ021588@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv21572/bio/appl Modified Files: clustalw.rb Log Message: fixed autoload problem about Bio::ClustalW. Index: clustalw.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/clustalw.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** clustalw.rb 8 Sep 2005 01:22:08 -0000 1.6 --- clustalw.rb 9 Sep 2005 15:52:57 -0000 1.7 *************** *** 22,33 **** require 'tempfile' require 'bio/sequence' require 'bio/alignment' - #require 'bio/appl/factory' - - require 'open3' module Bio class ClustalW def initialize(program = 'clustalw', option = []) --- 22,34 ---- require 'tempfile' + require 'open3' + require 'bio/sequence' require 'bio/alignment' module Bio class ClustalW + + autoload :Report, 'bio/appl/clustalw/report' def initialize(program = 'clustalw', option = []) From ngoto at pub.open-bio.org Fri Sep 9 11:56:22 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:45 2005 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.52,1.53 Message-ID: <200509091556.j89FuMdZ021621@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv21609 Modified Files: bio.rb Log Message: fixed autoload problem about Bio::MAFFT. Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** bio.rb 9 Sep 2005 15:52:57 -0000 1.52 --- bio.rb 9 Sep 2005 15:56:20 -0000 1.53 *************** *** 231,237 **** autoload :MAFFT, 'bio/appl/mafft' ! class MAFFT ! autoload :Report, 'bio/appl/mafft/report' ! end autoload :Sim4, 'bio/appl/sim4' --- 231,238 ---- autoload :MAFFT, 'bio/appl/mafft' ! ## below are described in bio/appl/mafft.rb ! #class MAFFT ! # autoload :Report, 'bio/appl/mafft/report' ! #end autoload :Sim4, 'bio/appl/sim4' From ngoto at pub.open-bio.org Fri Sep 9 11:56:23 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:46 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl mafft.rb,1.5,1.6 Message-ID: <200509091556.j89FuNdZ021625@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv21609/bio/appl Modified Files: mafft.rb Log Message: fixed autoload problem about Bio::MAFFT. Index: mafft.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/mafft.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** mafft.rb 8 Sep 2005 01:22:08 -0000 1.5 --- mafft.rb 9 Sep 2005 15:56:20 -0000 1.6 *************** *** 23,28 **** require 'bio/db/fasta' require 'bio/io/flatfile' - require 'bio/appl/mafft/report' - #require 'bio/appl/factory' # We use Open3.popen3, because MAFFT on win32 requires Cygwin. --- 23,26 ---- *************** *** 31,34 **** --- 29,34 ---- module Bio class MAFFT + + autoload :Report, 'bio/appl/mafft/report' def self.fftns(n = nil) From ngoto at pub.open-bio.org Fri Sep 9 11:58:44 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:46 2005 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.53,1.54 Message-ID: <200509091558.j89FwidZ021665@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv21653 Modified Files: bio.rb Log Message: fixed autoload problem about Bio::Sim4. Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** bio.rb 9 Sep 2005 15:56:20 -0000 1.53 --- bio.rb 9 Sep 2005 15:58:41 -0000 1.54 *************** *** 237,243 **** autoload :Sim4, 'bio/appl/sim4' ! class Sim4 ! autoload :Report, 'bio/appl/sim4/report' ! end autoload :Spidey, 'bio/appl/spidey/report' --- 237,244 ---- autoload :Sim4, 'bio/appl/sim4' ! ## below are described in bio/appl/sim4.rb ! #class Sim4 ! # autoload :Report, 'bio/appl/sim4/report' ! #end autoload :Spidey, 'bio/appl/spidey/report' From ngoto at pub.open-bio.org Fri Sep 9 11:58:44 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:47 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl sim4.rb,1.1,1.2 Message-ID: <200509091558.j89FwidZ021669@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv21653/bio/appl Modified Files: sim4.rb Log Message: fixed autoload problem about Bio::Sim4. Index: sim4.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/sim4.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sim4.rb 8 Oct 2004 17:41:08 -0000 1.1 --- sim4.rb 9 Sep 2005 15:58:42 -0000 1.2 *************** *** 21,25 **** # - require 'bio/appl/sim4/report' require 'open3' require 'tempfile' --- 21,24 ---- *************** *** 27,30 **** --- 26,32 ---- module Bio class Sim4 + + autoload :Report, 'bio/appl/sim4/report' + def initialize(program = 'sim4', database = nil, option = []) @program = program From ngoto at pub.open-bio.org Fri Sep 9 12:02:06 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:47 2005 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.54,1.55 Message-ID: <200509091602.j89G26dZ021709@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv21697 Modified Files: bio.rb Log Message: fixed autoload problem about Bio::DDBJ and Bio::DDBJ::XML. Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** bio.rb 9 Sep 2005 15:58:41 -0000 1.54 --- bio.rb 9 Sep 2005 16:02:04 -0000 1.55 *************** *** 90,93 **** --- 90,97 ---- autoload :RefSeq, 'bio/db/genbank/refseq' autoload :DDBJ, 'bio/db/genbank/ddbj' + ## below are described in bio/db/genbank/ddbj.rb + #class DDBJ + # autoload :XML, 'bio/io/ddbjxml' + #end ## EMBL/TrEMBL/Swiss-Prot/SPTR *************** *** 170,176 **** end ! class DDBJ ! autoload :XML, 'bio/io/ddbjxml' ! end class HGC --- 174,181 ---- end ! ## below are described in bio/db/genbank/ddbj.rb ! #class DDBJ ! # autoload :XML, 'bio/io/ddbjxml' ! #end class HGC From ngoto at pub.open-bio.org Fri Sep 9 12:02:06 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:48 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/db/genbank ddbj.rb,1.6,1.7 Message-ID: <200509091602.j89G26dZ021713@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/genbank In directory pub.open-bio.org:/tmp/cvs-serv21697/bio/db/genbank Modified Files: ddbj.rb Log Message: fixed autoload problem about Bio::DDBJ and Bio::DDBJ::XML. Index: ddbj.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/genbank/ddbj.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ddbj.rb 23 Aug 2004 23:40:35 -0000 1.6 --- ddbj.rb 9 Sep 2005 16:02:04 -0000 1.7 *************** *** 26,29 **** --- 26,32 ---- class DDBJ < GenBank + + autoload :XML, 'bio/io/ddbjxml' + # Nothing to do (DDBJ database format is completely same as GenBank) end From ngoto at pub.open-bio.org Fri Sep 9 12:10:49 2005 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Fri Sep 9 13:29:48 2005 Subject: [BioRuby-cvs] bioruby ChangeLog,1.39,1.40 Message-ID: <200509091610.j89GAndZ021783@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv21773 Modified Files: ChangeLog Log Message: added changelog for fixing autoload. Index: ChangeLog =================================================================== RCS file: /home/repository/bioruby/bioruby/ChangeLog,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** ChangeLog 31 Aug 2005 13:42:29 -0000 1.39 --- ChangeLog 9 Sep 2005 16:10:47 -0000 1.40 *************** *** 1,2 **** --- 1,20 ---- + 2005-09-10 Naohisa Goto + + * lib/bio.rb, lib/bio/appl/blast.rb, lib/bio/appl/blast/format0.rb, + lib/bio/appl/blast/report.rb, lib/bio/appl/clustalw.rb, + lib/bio/appl/fasta.rb, lib/bio/appl/fasta/format10.rb, + lib/bio/appl/hmmer.rb, lib/bio/appl/hmmer/report.rb, + lib/bio/appl/mafft.rb, lib/bio/appl/psort.rb, + lib/bio/appl/psort/report.rb, lib/bio/appl/sim4.rb, + lib/bio/db/genbank/ddbj.rb, lib/bio/io/flatfile/bdb.rb, + lib/bio/io/flatfile/index.rb, lib/bio/io/flatfile/indexer.rb + + fixed autoload problem + + * lib/bio/appl/blast.rb, lib/bio/appl/blast/report.rb + + Bio::Blast.reports method was moved from lib/bio/appl/blast/report.rb + to lib/bio/appl/blast.rb for autoload. + 2005-08-31 Toshiaki Katayama From k at pub.open-bio.org Sat Sep 10 19:43:38 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Sat Sep 10 20:25:34 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/db/embl uniprot.rb,NONE,1.1 Message-ID: <200509102343.j8ANhcdZ026905@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/embl In directory pub.open-bio.org:/tmp/cvs-serv26891 Added Files: uniprot.rb Log Message: * reserved name space for the UniProt database --- NEW FILE: uniprot.rb --- # # bio/db/embl/uniprot.rb - UniProt database class # # Copyright (C) 2005 KATAYAMA Toshiaki # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # $Id: uniprot.rb,v 1.1 2005/09/10 23:43:35 k Exp $ # require 'bio/db/embl/sptr' module Bio class UniProt < SPTR # Nothing to do (UniProt format is abstracted in SPTR) end end From k at pub.open-bio.org Mon Sep 19 22:00:17 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 19 22:52:18 2005 Subject: [BioRuby-cvs] bioruby/lib/bio sequence.rb,0.41,0.42 Message-ID: <200509200200.j8K20HdZ003036@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv3027/lib/bio Modified Files: sequence.rb Log Message: * just for readability of the to_s method Index: sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence.rb,v retrieving revision 0.41 retrieving revision 0.42 diff -C2 -d -r0.41 -r0.42 *** sequence.rb 8 Sep 2005 01:22:08 -0000 0.41 --- sequence.rb 20 Sep 2005 02:00:15 -0000 0.42 *************** *** 35,39 **** def to_s ! "%s" % self end alias :to_str :to_s --- 35,39 ---- def to_s ! String.new(self) end alias :to_str :to_s From k at pub.open-bio.org Fri Sep 23 07:01:34 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri Sep 23 07:53:16 2005 Subject: [BioRuby-cvs] bioruby/test all_tests.rb,1.1,NONE Message-ID: <200509231101.j8NB1YdZ021854@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test In directory pub.open-bio.org:/tmp/cvs-serv21846 Removed Files: all_tests.rb Log Message: * migrated to runner.rb (test is also run by 'install.rb test') --- all_tests.rb DELETED --- From k at pub.open-bio.org Fri Sep 23 07:01:34 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri Sep 23 07:53:19 2005 Subject: [BioRuby-cvs] bioruby/test/bio suite_bio.rb,1.1,NONE Message-ID: <200509231101.j8NB1YdZ021855@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/bio In directory pub.open-bio.org:/tmp/cvs-serv21846/bio Removed Files: suite_bio.rb Log Message: * migrated to runner.rb (test is also run by 'install.rb test') --- suite_bio.rb DELETED --- From k at pub.open-bio.org Fri Sep 23 07:02:52 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri Sep 23 07:54:31 2005 Subject: [BioRuby-cvs] bioruby/test runner.rb,NONE,1.1 Message-ID: <200509231102.j8NB2qdZ021917@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test In directory pub.open-bio.org:/tmp/cvs-serv21913 Added Files: runner.rb Log Message: * migrated from all_tests.rb and bio/suite_bio.rb --- NEW FILE: runner.rb --- #!/usr/bin/env ruby require 'test/unit' exit Test::Unit::AutoRunner.run(false, File.dirname($0)) From k at pub.open-bio.org Fri Sep 23 09:12:52 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri Sep 23 10:05:42 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/shell - New directory Message-ID: <200509231312.j8NDCqdZ022760@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv22756/lib/bio/shell Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell added to the repository From k at pub.open-bio.org Fri Sep 23 09:13:45 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri Sep 23 10:06:24 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin - New directory Message-ID: <200509231313.j8NDDjdZ022786@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv22782/plugin Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/plugin added to the repository From k at pub.open-bio.org Fri Sep 23 09:57:10 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri Sep 23 10:53:43 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb, NONE, 1.1 session.rb, NONE, 1.1 Message-ID: <200509231357.j8NDvAdZ022973@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv22949/lib/bio/shell Added Files: core.rb session.rb Log Message: * Newly added BioRuby shell - command line user interface for the BioRuby --- NEW FILE: session.rb --- # # bio/shell/session.rb - core user interface of the BioRuby shell # # Copyright (C) 2005 KATAYAMA Toshiaki # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # $Id: session.rb,v 1.1 2005/09/23 13:57:08 k Exp $ # module Bio::Shell ### work space def ls display eval("local_variables", conf.workspace.binding).inspect end ### config def config(mode = :show, *opts) Bio::Shell.config(mode, *opts) end ### script def script(mode = :begin) Bio::Shell.script(mode) end ### plugin def reload_plugin Bio::Shell.load_plugin end ### pager def display(*obj) # The original idea is from http://sheepman.parfait.ne.jp/20050215.html if $bioruby_config[:PAGER] pg = IO.popen($bioruby_config[:PAGER], "w") begin stdout_save = STDOUT.clone STDOUT.reopen(pg) puts(*obj) ensure STDOUT.reopen(stdout_save) stdout_save.close pg.close end else puts(*obj) end end ### file system def cd(dir = ENV['HOME']) if dir Dir.chdir(dir) end display Dir.pwd.inspect end def pwd display Dir.pwd.inspect end def dir(file = nil) if file if File.directory?(file) files = Dir.glob("#{file}/*") else files = Dir.glob(file) end else files = Dir.glob("*") end if files str = " UGO Date Byte File\n" str << "------ ---------------------------- ----------- ------------\n" files.sort.each { |f| stat = File.lstat(f) mode = format("%6o", stat.mode) date = stat.mtime byte = stat.size name = f.inspect str << format("%s %s%13d %s\n", mode, date, byte, name) } display str end end def head(file, num = 10) str = "" File.open(file) do |f| num.times do if line = f.gets str << line end end end display str end end --- NEW FILE: core.rb --- # # bio/shell/core.rb - internal methods for BioRuby shell # # Copyright (C) 2005 KATAYAMA Toshiaki # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # $Id: core.rb,v 1.1 2005/09/23 13:57:08 k Exp $ # module Bio::Shell::Core CONFIG = "config" OBJECT = "object" HISTORY = "history" SCRIPT = "script.rb" PLUGIN = "plugin/" BIOFLAT = "bioflat/" SITEDIR = "/etc/bioinformatics/bioruby/" USERDIR = "#{ENV['HOME']}/.bioinformatics/bioruby/" SAVEDIR = ".bioruby/" MARSHAL = [ Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION ] MESSAGE = "...BioRuby in the shell..." ESC_SEQ = { :k => "\e[30m", :black => "\e[30m", :r => "\e[31m", :red => "\e[31m", :ruby => "\e[31m", :g => "\e[32m", :green => "\e[32m", :y => "\e[33m", :yellow => "\e[33m", :b => "\e[34m", :blue => "\e[34m", :m => "\e[35m", :magenta => "\e[35m", :c => "\e[36m", :cyan => "\e[36m", :w => "\e[37m", :white => "\e[37m", :n => "\e[00m", :none => "\e[00m", :reset => "\e[00m", } ### save/restore the environment def setup load_config load_plugin version_check end # *TODO* is this needed? (for reset) def reload load_config load_plugin load_object end def opening load_object load_history opening_splash end def closing closing_splash save_history save_object save_config end # *TODO* This works, but sometimes causes terminal collapse def opening_thread begin t1 = Thread.new do load_object load_history end t2 = Thread.new do opening_splash end t1.join t2.join rescue end end ### setup def version_check if RUBY_VERSION < "1.8.2" raise "BioRuby shell runs on Ruby version >= 1.8.2" end if $bioruby_config[:MARSHAL] and $bioruby_config[:MARSHAL] != MARSHAL raise "Marshal version mismatch" end end def create_save_dir(dir = SAVEDIR) create_real_dir(dir) create_real_dir(dir + PLUGIN) create_real_dir(dir + BIOFLAT) end def create_real_dir(dir) unless File.directory?(dir) begin print "Creating directory (#{dir}) ... " Dir.mkdir(dir) puts "done" rescue raise "Failed to create #{dir} : #{$!}" end end end ### config def load_config load_config_file(SITEDIR + CONFIG) load_config_file(USERDIR + CONFIG) load_config_file(SAVEDIR + CONFIG) end def load_config_file(file) if File.exists?(file) print "Loading config (#{file}) ... " if hash = YAML.load(File.read(file)) $bioruby_config.update(hash) end puts "done" end end def save_config create_save_dir file = SAVEDIR + CONFIG begin print "Saving config (#{file}) ... " File.open(file, "w") do |f| f.puts $bioruby_config.to_yaml end puts "done" rescue raise "Failed to save (#{file}) : #{$!}" end end def config(mode, *opts) case mode when :show, "show" config_show when :echo, "echo" config_echo when :color, "color" config_color when :pager, "pager" config_pager(*opts) when :message, "message" config_message(*opts) end end def config_show $bioruby_config.each do |k, v| puts "#{k}\t= #{v.inspect}" end end def config_echo bind = IRB.conf[:MAIN_CONTEXT].workspace.binding flag = ! $bioruby_config[:ECHO] $bioruby_config[:ECHO] = IRB.conf[:ECHO] = flag eval("conf.echo = #{flag}", bind) puts "Echo #{flag ? 'on' : 'off'}" end def config_color bind = IRB.conf[:MAIN_CONTEXT].workspace.binding flag = ! $bioruby_config[:COLOR] $bioruby_config[:COLOR] = flag if flag IRB.conf[:PROMPT_MODE] = :BIORUBY_COLOR eval("conf.prompt_mode = :BIORUBY_COLOR", bind) else IRB.conf[:PROMPT_MODE] = :BIORUBY eval("conf.prompt_mode = :BIORUBY", bind) end end def config_pager(cmd = nil) $bioruby_config[:PAGER] = cmd end def config_message(str = nil) str ||= Bio::Shell::Core::MESSAGE $bioruby_config[:MESSAGE] = str end ### plugin def load_plugin load_plugin_dir(SITEDIR + PLUGIN) load_plugin_dir(USERDIR + PLUGIN) load_plugin_dir(SAVEDIR + PLUGIN) end def load_plugin_dir(dir) if File.directory?(dir) Dir.glob("#{dir}/*.rb").sort.each do |file| print "Loading plugin (#{file}) ... " load file puts "done" end end end ### object def load_object load_object_file(SAVEDIR + OBJECT) end def load_object_file(file) if File.exists?(file) print "Loading object (#{file}) ... " begin bind = IRB.conf[:MAIN_CONTEXT].workspace.binding hash = Marshal.load(File.read(file)) hash.each do |k, v| # p [k, v, v.class, Marshal.load(v)] eval("#{k} = Marshal.load('#{v}')", bind) end rescue raise "Failed to load (#{file}) : #{$!}" end puts "done" end end def save_object create_save_dir save_object_file(SAVEDIR + OBJECT) end def save_object_file(file) begin print "Saving object (#{file}) ... " File.open(file, "w") do |f| begin bind = IRB.conf[:MAIN_CONTEXT].workspace.binding list = eval("local_variables", bind) list -= ["_"] hash = {} list.each do |elem| hash[elem] = Marshal.dump(eval(elem, bind)) end Marshal.dump(hash, f) $bioruby_config[:MARSHAL] = MARSHAL rescue raise "Failed to dump (#{file}) : #{$!}" end end puts "done" rescue raise "Failed to save (#{file}) : #{$!}" end end ### history def load_history load_history_file(SAVEDIR + HISTORY) end def load_history_file(file) if File.exists?(file) print "Loading history (#{file}) ... " File.open(file).each do |line| Readline::HISTORY.push line.chomp end puts "done" end end def save_history create_save_dir save_history_file(SAVEDIR + HISTORY) end def save_history_file(file) begin print "Saving history (#{file}) ... " File.open(file, "w") do |f| f.puts Readline::HISTORY.to_a end puts "done" rescue raise "Failed to save (#{file}) : #{$!}" end end ### script def script(mode) case mode when :begin, "begin", :start, "start" script_begin when :end, "end", :stop, "stop" script_end script_save end end def script_begin puts "-- 8< -- 8< -- 8< -- Script -- 8< -- 8< -- 8< --" @script_begin = Readline::HISTORY.size end def script_end puts "-- >8 -- >8 -- >8 -- Script -- >8 -- >8 -- >8 --" @script_end = Readline::HISTORY.size - 2 end def script_save create_save_dir if @script_begin and @script_end and @script_begin <= @script_end script_save_file(SAVEDIR + SCRIPT) else raise "Script range '#{@script_begin}' .. '#{@script_end}' is invalid" end end def script_save_file(file) begin print "Saving script (#{file}) ... " File.open(file, "w") do |f| f.print "#!/usr/bin/env ruby\n\n" f.print "require 'bio/shell'\n\n" f.print "include Bio::Shell\n\n" f.print "Bio::Shell.setup\n\n" f.puts Readline::HISTORY.to_a[@script_begin..@script_end] end puts "done" rescue @script_begin = nil raise "Failed to save (#{file}) : #{$!}" end end ### splash def splash_message $bioruby_config[:MESSAGE] ||= MESSAGE $bioruby_config[:MESSAGE].to_s.split(//).join(" ") end def splash_message_color str = splash_message ruby = ESC_SEQ[:ruby] none = ESC_SEQ[:none] return str.sub(/R u b y/) { "#{ruby}R u b y#{none}" } end def opening_splash s = splash_message l = s.length c = ESC_SEQ x = " " print "\n" if $bioruby_config[:COLOR] 0.step(l,2) do |i| l1 = l-i; l2 = l1/2; l4 = l2/2 print "#{c[:n]}#{s[0,i]}#{x*l1}#{c[:y]}#{s[i,1]}\r" sleep(0.001) print "#{c[:n]}#{s[0,i]}#{x*l2}#{c[:g]}#{s[i,1]}#{x*(l1-l2)}\r" sleep(0.002) print "#{c[:n]}#{s[0,i]}#{x*l4}#{c[:r]}#{s[i,1]}#{x*(l2-l4)}\r" sleep(0.004) print "#{c[:n]}#{s[0,i+1]}#{x*l4}\r" sleep(0.008) end end if $bioruby_config[:COLOR] print splash_message_color else print splash_message end print "\n\n" print " Version : BioRuby #{Bio::BIORUBY_VERSION.join(".")}" print " / Ruby #{RUBY_VERSION}\n\n" end def closing_splash print "\n\n" if $bioruby_config[:COLOR] print splash_message_color else print splash_message end print "\n\n" end end From k at pub.open-bio.org Fri Sep 23 09:57:10 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri Sep 23 10:54:06 2005 Subject: [BioRuby-cvs] bioruby/lib/bio shell.rb,NONE,1.1 Message-ID: <200509231357.j8NDvAdZ022969@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv22949/lib/bio Added Files: shell.rb Log Message: * Newly added BioRuby shell - command line user interface for the BioRuby --- NEW FILE: shell.rb --- # # bio/shell.rb - Loading all BioRuby shell features # # Copyright (C) 2005 KATAYAMA Toshiaki # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # $Id: shell.rb,v 1.1 2005/09/23 13:57:08 k Exp $ # require 'bio' require 'yaml' require 'pp' $bioruby_config = {} module Bio::Shell require 'bio/shell/core' require 'bio/shell/session' require 'bio/shell/plugin/seq' require 'bio/shell/plugin/flatfile' require 'bio/shell/plugin/obda' extend Core end From k at pub.open-bio.org Fri Sep 23 09:57:10 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri Sep 23 10:54:09 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin seq.rb, NONE, 1.1 flatfile.rb, NONE, 1.1 obda.rb, NONE, 1.1 Message-ID: <200509231357.j8NDvAdZ022978@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv22949/lib/bio/shell/plugin Added Files: seq.rb flatfile.rb obda.rb Log Message: * Newly added BioRuby shell - command line user interface for the BioRuby --- NEW FILE: obda.rb --- # # bio/shell/plugin/obda.rb - plugin for OBDA # # Copyright (C) 2005 KATAYAMA Toshiaki # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # $Id: obda.rb,v 1.1 2005/09/23 13:57:08 k Exp $ # require 'bio/io/registry' module Bio::Shell def bioregistry @obda = Bio::Registry.new end def getentry(dbname, entry_id) bioregistry unless @obda db = @obda.get_database(dbname) entry = db.get_by_id(entry_id) if block_given? yield entry else display entry end return entry end end --- NEW FILE: flatfile.rb --- # # bio/shell/plugin/flatfile.rb - plugin for flatfile database # # Copyright (C) 2005 KATAYAMA Toshiaki # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # $Id: flatfile.rb,v 1.1 2005/09/23 13:57:08 k Exp $ # require 'bio/io/flatfile' module Bio::Shell def convert_to_fasta(fastafile, *flatfiles) puts "Saving fasta file (#{fastafile}) ... " File.open(fastafile, "w") do |fasta| flatfiles.each do |flatfile| puts " converting -- #{flatfile}" Bio::FlatFile.auto(flatfile) do |flat| flat.each do |entry| header = "#{entry.entry_id} #{entry.definition}" fasta.puts entry.seq.to_fasta(header, 50) end end end end puts "done" end def bioflat_index(dbname, *flatfiles) prefix = Core::SAVEDIR + Core::BIOFLAT unless File.directory?(prefix) Bio::Shell.create_save_dir end dir = prefix + dbname.to_s bdb = format = options = nil begin print "Creating BioFlat index (#{dir}) ... " Bio::FlatFileIndex.makeindex(bdb, dir, format, options, *flatfiles) puts "done" rescue raise "Failed to create index (#{dir}) : #{$!}" end end def bioflat_search(dbname, keyword) dir = Core::SAVEDIR + Core::BIOFLAT + dbname.to_s # Bio::FlatFileIndex.open(dir) do |db| db = Bio::FlatFileIndex.open(dir) if results = db.include?(keyword) results.each do |entry_id| display db.search_primary(entry_id) end else display "No hits found" end # end db.close end def bioflat_namespaces(dbname) dir = Core::SAVEDIR + Core::BIOFLAT + dbname.to_s db = Bio::FlatFileIndex.open(dir) display db.namespaces.inspect db.close end end --- NEW FILE: seq.rb --- # # bio/shell/plugin/seq.rb - plugin for biological sequence manipulations # # Copyright (C) 2005 KATAYAMA Toshiaki # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # $Id: seq.rb,v 1.1 2005/09/23 13:57:08 k Exp $ # require 'bio/sequence' module Bio::Shell def naseq(str) Bio::Sequence::NA.new(str) end def aaseq(str) Bio::Sequence::AA.new(str) end def revseq(str) seq = Bio::Sequence::NA.new(str) res = seq.complement display res return res end def translate(str) seq = Bio::Sequence::NA.new(str) res = seq.translate display res return res end def seq_report(str) if File.exist?(str) Bio::FlatFile.open(nil, arg).each do |f| seq = f.seq if seq.class == Bio::Sequence::NA na_report(seq) else aa_report(seq) end end else case Bio::Seq.guess(str) when :NA display na_report(str) when :AA display aa_report(str) end return Bio::Seq.guess(str) end end def na_report(seq) seq = naseq(seq) unless seq === Bio::Sequence::NA str = "" str << "input sequence : #{seq}\n" str << "reverse complement : #{seq.complement}\n" str << "translation 1 : #{seq.translate}\n" str << "translation 2 : #{seq.translate(2)}\n" str << "translation 3 : #{seq.translate(3)}\n" str << "translation -1 : #{seq.translate(-1)}\n" str << "translation -2 : #{seq.translate(-2)}\n" str << "translation -3 : #{seq.translate(-3)}\n" str << "gc percent : #{seq.gc} %\n" str << "composition : #{seq.composition.inspect}\n" str << "molecular weight : #{seq.molecular_weight}\n" str << "complemnet weight : #{seq.complement.molecular_weight}\n" str << "protein weight : #{seq.translate.molecular_weight}\n" str << "//\n" return str end def aa_report(seq) seq = aaseq(seq) unless seq === Bio::Sequence::AA str = "" str << "input sequence : #{seq}\n" str << "composition : #{seq.composition.inspect}\n" str << "protein weight : #{seq.molecular_weight}\n" str << "amino acid codes : #{seq.codes.inspect}\n" str << "amino acid names : #{seq.names.inspect}\n" str << "//\n" return str end end From k at pub.open-bio.org Fri Sep 23 10:01:56 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri Sep 23 10:54:13 2005 Subject: [BioRuby-cvs] bioruby/doc Changes-0.7.rd,NONE,1.1 Message-ID: <200509231401.j8NE1udZ023046@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/doc In directory pub.open-bio.org:/tmp/cvs-serv23034 Added Files: Changes-0.7.rd Log Message: * Newly added summary file for new features and incompatible chages made between 0.6 and 0.7 releases --- NEW FILE: Changes-0.7.rd --- = Incompatible changes from BioRuby 0.6 == Bio::Sequence * Bio::Sequence::NA#gc_percent returns integer instead of float * Bio::Sequence::NA#gc (alias to gc_percent) is removed From k at pub.open-bio.org Fri Sep 23 09:57:10 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri Sep 23 11:00:38 2005 Subject: [BioRuby-cvs] bioruby/bin bioruby,NONE,1.1 Message-ID: <200509231357.j8NDvAdZ022965@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv22949/bin Added Files: bioruby Log Message: * Newly added BioRuby shell - command line user interface for the BioRuby --- NEW FILE: bioruby --- #!/usr/bin/env ruby # # BioRuby shell - command line interface for the BioRuby library # # Copyright (C) 2005 KATAYAMA Toshiaki # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # $Id: bioruby,v 1.1 2005/09/23 13:57:07 k Exp $ # require 'bio/shell' include Bio::Shell # loading configuration and plugins Bio::Shell.setup ### IRB setup require 'irb' begin require 'irb/completion' rescue LoadError # readline is missing end IRB.setup(nil) # set application name IRB.conf[:AP_NAME] = 'bioruby' # change prompt for bioruby $_ = Bio::Shell::Core::ESC_SEQ IRB.conf[:PROMPT][:BIORUBY_COLOR] = { :PROMPT_I => "bio#{$_[:ruby]}ruby#{$_[:none]}> ", :PROMPT_S => "bio#{$_[:ruby]}ruby#{$_[:none]}%l ", :PROMPT_C => "bio#{$_[:ruby]}ruby#{$_[:none]}+ ", :RETURN => " ==> %s\n" } IRB.conf[:PROMPT][:BIORUBY] = { :PROMPT_I => "bioruby> ", :PROMPT_S => "bioruby%l ", :PROMPT_C => "bioruby+ ", :RETURN => " ==> %s\n" } if $bioruby_config[:COLOR] IRB.conf[:PROMPT_MODE] = :BIORUBY_COLOR else IRB.conf[:PROMPT_MODE] = :BIORUBY end IRB.conf[:ECHO] = $bioruby_config[:ECHO] # irb/input-method.rb >= v1.5 (not in 1.8.2) #IRB.conf[:SAVE_HISTORY] = 100000 # not beautifully works #IRB.conf[:AUTO_INDENT] = true ### IRB main loop irb = IRB::Irb.new # needed for method completion IRB.conf[:MAIN_CONTEXT] = irb.context # loading workspace and command history Bio::Shell.opening Signal.trap("SIGINT") do irb.signal_handle end catch(:IRB_EXIT) do irb.eval_input end # saving workspace, command history and configuration before exit Bio::Shell.closing From k at pub.open-bio.org Fri Sep 23 10:28:01 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri Sep 23 11:21:06 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin seq.rb,1.1,1.2 Message-ID: <200509231428.j8NES1dZ023153@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv23142/shell/plugin Modified Files: seq.rb Log Message: * Bio::Sequence::NA#gc_percent is changed returns integer instead of float * Bio::Sequence::NA#gc method is removed * added Bio::Sequence#guess and Bio::Sequence.guess * plugin - modified to use new guess method Index: seq.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/seq.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** seq.rb 23 Sep 2005 13:57:08 -0000 1.1 --- seq.rb 23 Sep 2005 14:27:59 -0000 1.2 *************** *** 58,65 **** end else ! case Bio::Seq.guess(str) ! when :NA display na_report(str) ! when :AA display aa_report(str) end --- 58,65 ---- end else ! moltype = Bio::Seq.guess(str) ! if moltype == Bio::Sequence::NA display na_report(str) ! elsif moltype == Bio::Sequence::AA display aa_report(str) end *************** *** 79,83 **** str << "translation -2 : #{seq.translate(-2)}\n" str << "translation -3 : #{seq.translate(-3)}\n" ! str << "gc percent : #{seq.gc} %\n" str << "composition : #{seq.composition.inspect}\n" str << "molecular weight : #{seq.molecular_weight}\n" --- 79,83 ---- str << "translation -2 : #{seq.translate(-2)}\n" str << "translation -3 : #{seq.translate(-3)}\n" ! str << "gc percent : #{seq.gc_percent} %\n" str << "composition : #{seq.composition.inspect}\n" str << "molecular weight : #{seq.molecular_weight}\n" From k at pub.open-bio.org Fri Sep 23 10:28:01 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri Sep 23 11:22:35 2005 Subject: [BioRuby-cvs] bioruby/lib/bio sequence.rb,0.42,0.43 Message-ID: <200509231428.j8NES1dZ023149@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv23142 Modified Files: sequence.rb Log Message: * Bio::Sequence::NA#gc_percent is changed returns integer instead of float * Bio::Sequence::NA#gc method is removed * added Bio::Sequence#guess and Bio::Sequence.guess * plugin - modified to use new guess method Index: sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence.rb,v retrieving revision 0.42 retrieving revision 0.43 diff -C2 -d -r0.42 -r0.43 *** sequence.rb 20 Sep 2005 02:00:15 -0000 0.42 --- sequence.rb 23 Sep 2005 14:27:59 -0000 0.43 *************** *** 110,113 **** --- 110,132 ---- end + def guess(threshold = 0.9) + cmp = self.composition + + bases = cmp['A'] + cmp['T'] + cmp['G'] + cmp['C'] + + cmp['a'] + cmp['t'] + cmp['g'] + cmp['c'] + + total = self.length - cmp['N'] - cmp['n'] + + if bases.to_f / total > threshold + return NA + else + return AA + end + end + + def self.guess(str, *args) + self.new(str).guess(*args) + end + def randomize(hash = nil) length = self.length *************** *** 229,236 **** at = count['a'] + count['t'] + count['u'] gc = count['g'] + count['c'] ! gc = format("%.1f", gc.to_f / (at + gc) * 100) ! return gc.to_f end - alias :gc :gc_percent def illegal_bases --- 248,254 ---- at = count['a'] + count['t'] + count['u'] gc = count['g'] + count['c'] ! gc = 100 * gc / (at + gc) ! return gc end def illegal_bases From k at pub.open-bio.org Fri Sep 23 23:25:51 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Sat Sep 24 00:18:34 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.1,1.2 Message-ID: <200509240325.j8O3PpdZ026644@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv26638 Modified Files: core.rb Log Message: * Changed not to raise when the object couldn't restored in load_object i.e. an instance of user defined class which is not loaded by default. * Changed not to save object whose value is nil in save_object. Index: core.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** core.rb 23 Sep 2005 13:57:08 -0000 1.1 --- core.rb 24 Sep 2005 03:25:49 -0000 1.2 *************** *** 237,242 **** hash = Marshal.load(File.read(file)) hash.each do |k, v| ! # p [k, v, v.class, Marshal.load(v)] ! eval("#{k} = Marshal.load('#{v}')", bind) end rescue --- 237,246 ---- hash = Marshal.load(File.read(file)) hash.each do |k, v| ! begin ! # p [k, v, v.class, Marshal.load(v)] ! eval("#{k} = Marshal.load('#{v}')", bind) ! rescue ! puts "Warning: object '#{k}' couldn't be loaded : #{$!}" ! end end rescue *************** *** 262,266 **** hash = {} list.each do |elem| ! hash[elem] = Marshal.dump(eval(elem, bind)) end Marshal.dump(hash, f) --- 266,273 ---- hash = {} list.each do |elem| ! value = eval(elem, bind) ! if value ! hash[elem] = Marshal.dump(value) ! end end Marshal.dump(hash, f) From k at pub.open-bio.org Sat Sep 24 08:33:09 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Sat Sep 24 09:25:09 2005 Subject: [BioRuby-cvs] bioruby/bin bioruby,1.1,1.2 Message-ID: <200509241233.j8OCX9dZ028112@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv28103/bin Modified Files: bioruby Log Message: * load/save history is suppressed when readline isn't available * $bioruby_cache variable is introduced for non persistent configuration Index: bioruby =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/bioruby,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** bioruby 23 Sep 2005 13:57:07 -0000 1.1 --- bioruby 24 Sep 2005 12:33:07 -0000 1.2 *************** *** 35,39 **** require 'irb/completion' rescue LoadError ! # readline is missing end --- 35,39 ---- require 'irb/completion' rescue LoadError ! $bioruby_cache[:no_readline] = true end *************** *** 62,66 **** IRB.conf[:PROMPT_MODE] = :BIORUBY end ! IRB.conf[:ECHO] = $bioruby_config[:ECHO] # irb/input-method.rb >= v1.5 (not in 1.8.2) --- 62,66 ---- IRB.conf[:PROMPT_MODE] = :BIORUBY end ! IRB.conf[:ECHO] = $bioruby_config[:ECHO] || false # irb/input-method.rb >= v1.5 (not in 1.8.2) From k at pub.open-bio.org Sat Sep 24 08:33:10 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Sat Sep 24 09:25:16 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.2,1.3 Message-ID: <200509241233.j8OCXAdZ028116@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv28103/lib/bio/shell Modified Files: core.rb Log Message: * load/save history is suppressed when readline isn't available * $bioruby_cache variable is introduced for non persistent configuration Index: core.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** core.rb 24 Sep 2005 03:25:49 -0000 1.2 --- core.rb 24 Sep 2005 12:33:07 -0000 1.3 *************** *** 286,290 **** def load_history ! load_history_file(SAVEDIR + HISTORY) end --- 286,290 ---- def load_history ! load_history_file(SAVEDIR + HISTORY) unless $bioruby_cache[:no_readline] end *************** *** 301,305 **** def save_history create_save_dir ! save_history_file(SAVEDIR + HISTORY) end --- 301,305 ---- def save_history create_save_dir ! save_history_file(SAVEDIR + HISTORY) unless $bioruby_cache[:no_readline] end From k at pub.open-bio.org Sat Sep 24 08:33:09 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Sat Sep 24 09:26:09 2005 Subject: [BioRuby-cvs] bioruby/lib/bio shell.rb,1.1,1.2 Message-ID: <200509241233.j8OCX9dZ028114@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv28103/lib/bio Modified Files: shell.rb Log Message: * load/save history is suppressed when readline isn't available * $bioruby_cache variable is introduced for non persistent configuration Index: shell.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** shell.rb 23 Sep 2005 13:57:08 -0000 1.1 --- shell.rb 24 Sep 2005 12:33:07 -0000 1.2 *************** *** 26,29 **** --- 26,30 ---- $bioruby_config = {} + $bioruby_cache = {} module Bio::Shell From k at pub.open-bio.org Sat Sep 24 11:06:56 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Sat Sep 24 11:58:33 2005 Subject: [BioRuby-cvs] bioruby README.DEV,NONE,1.1 Message-ID: <200509241506.j8OF6udZ028597@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv28592 Added Files: README.DEV Log Message: * Newly added guide for contribution to the BioRuby development --- NEW FILE: README.DEV --- =begin $Id: README.DEV,v 1.1 2005/09/24 15:06:54 k Exp $ Copyright (C) 2005 Toshiaki Katayama = How to contribute to the BioRuby project? There are many possible ways to contribute to the BioRuby project, such as * Join the discussion on the BioRuby mailing list * Send a bug report, write a bug fix patch * Add and correcting documentations * Development codes for new features etc. and all of these are welcome! However, here we describe on the last option -- how to contribute and include your codes to the BioRuby distribution. We would like to include your contribution as long as the scope of your module meets the field of bioinformatics. == Licence If you wish your module to be included in the BioRuby distribution, you need to agree that your module is licensed under the GNU's LGPL as the BioRuby chosen LGPL for its license. == Coding style You need to follow the typical coding styles of the BioRuby modules: === Use the following naming conventions * CamelCase for module and class names, * '_'-separated lowercase names for method names, * '_'-separated lowercase names for variable names, and * all uppercase names for constants. === Each file must start with the following text # # bio/foo/bar.rb - foo bar class # # Copyright (C) 2005 Ruby B. Hacker # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # $Id: README.DEV,v 1.1 2005/09/24 15:06:54 k Exp $ # === Documentation should be written in the RDoc format in the source code The RDoc format is becoming de facto standard for the Ruby documentation. So, we are now in transition from the RD format to the RDoc format as we had been written the API documentations in the RD format and put them at the end of each file. Additional tutorial documents and some working examples are also welcome when you contribute your codes. === Testing code should use 'test/unit' Unit test should come with your modules by which you can assure what you meant to do with each method. The test code is also able to make your maintainance procedure easy and stable. === Using autoload To make fast start up, we replaced most of 'require' to 'autoload' since the BioRuby version 0.7. During this change, we have found some tips: You sholud not separate a same namespace into several files. * For example, if you have separated definitions of the Bio::Foo class in two files (e.g. 'bio/foo.rb' and 'bio/bar.rb'), you need to resolve the dependency of them (including the order of loading these two files) by yourself. * It is not the case that you have a definition of Bio::Foo in 'bio/foo.rb' and a definition of Bio::Foo::Bar in 'bio/bar.rb'. In this case, you just need to add following line in the 'bio/foo.rb' file. autoload :Bar, 'bio/foo/bar' You should not put several top level namespaces in one file. * For example, if you have Bio::A, Bio::B and Bio::C in the file 'bio/foo.rb', you need autoload :A, 'bio/foo' autoload :B, 'bio/foo' autoload :C, 'bio/foo' to load the module automatically (instead of require 'bio/foo'). In this case, you should put them under the new namespace like Bio::Foo::A, Bio::Foo::B and Bio::Foo::C in the file 'bio/foo', then use autoload :Foo, 'bio/foo' to make autoload can be written in 1 line. == Name space Your module should be located under the module Bio and put under the 'bioruby/lib/bio' directory. The class/module names and the file names should be short and descriptive. There are already several sub directories in 'bioruby/lib': bio/*.rb -- general and widely used basic classes bio/appl/ -- wrapper and parser for the external applications bio/data/ -- basic biological data bio/db/ -- flatfile database entry parsers bio/io/ -- I/O interfaces for files, RDB, web services etc. bio/util/ -- utilities and algorithms for bioinformatics If your module doesn't match to any of the above, please propose an appropriate directory name when you contribute. == Maintainance Finally, please keep maintain the code your contrubuted. The BioRuby staff is willing to give you CVS privilege if needed. =end From k at pub.open-bio.org Sun Sep 25 01:25:17 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Sun Sep 25 02:17:43 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin flatfile.rb,1.1,1.2 Message-ID: <200509250525.j8P5PHdZ001793@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv1787/lib/bio/shell/plugin Modified Files: flatfile.rb Log Message: * changed to use Bio::FlatFileIndex#search through block Index: flatfile.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/flatfile.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** flatfile.rb 23 Sep 2005 13:57:08 -0000 1.1 --- flatfile.rb 25 Sep 2005 05:25:14 -0000 1.2 *************** *** 59,64 **** def bioflat_search(dbname, keyword) dir = Core::SAVEDIR + Core::BIOFLAT + dbname.to_s ! # Bio::FlatFileIndex.open(dir) do |db| ! db = Bio::FlatFileIndex.open(dir) if results = db.include?(keyword) results.each do |entry_id| --- 59,63 ---- def bioflat_search(dbname, keyword) dir = Core::SAVEDIR + Core::BIOFLAT + dbname.to_s ! Bio::FlatFileIndex.open(dir) do |db| if results = db.include?(keyword) results.each do |entry_id| *************** *** 68,73 **** display "No hits found" end ! # end ! db.close end --- 67,71 ---- display "No hits found" end ! end end From k at pub.open-bio.org Sun Sep 25 20:48:06 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Sun Sep 25 21:39:50 2005 Subject: [BioRuby-cvs] bioruby README,1.9,1.10 Message-ID: <200509260048.j8Q0m6dZ014903@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv14898 Modified Files: README Log Message: * rewrited -- ruby 1.6 is no longer supported, instructions for rubygems are included etc. Index: README =================================================================== RCS file: /home/repository/bioruby/bioruby/README,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** README 9 Aug 2005 11:43:02 -0000 1.9 --- README 26 Sep 2005 00:48:04 -0000 1.10 *************** *** 1,29 **** = BioRuby ! BioRuby project aims to implement integrated environment for Bioinformatics. ! Object oriented scripting language Ruby has many good points suitable for ! bioinfomatics research. Powerful regular expressions like Perl, purely ! object oriented, simple and very clean syntax -- easy to learn for beginners, ! easy to use for biologists, powerful enough for developers. - In BioRuby, you can retrieve biological database entries from flat files, - internet web servers and local relational databases. These database entries - can be parsed to extract any information you need. Biological sequences are - treated with Ruby's powerful string methods and regular expressions. Daily - tools like Blast, Fasta and Hmmer programs can be executed and the results - are fully parsed to extract scores and/or alignments. BioRuby also supports - some databases and web services developed in Japan such as KEGG, AAindex, - and DBGET etc. ! == WHERE TO GET ! * WWW -- (()) - http://bioruby.org/archive/ ! * CVS -- (()) % cvs -d :pserver:anonymous@cvs.bioruby.org:/export/cvs login --- 1,56 ---- + =begin + + $Id$ + + Copyright (C) 2001-2005 Toshiaki Katayama = BioRuby ! BioRuby is an open source Ruby library for developing bioinformatics ! software. Object oriented scripting language Ruby has many features ! suitable for bioinfomatics research, for example, clear syntax to ! express complex objects, regular expressions for text handling as ! powerful as Perl's, a wide variety of libraries including web service ! etc. As the syntax of the Ruby language is simple and very clean, we ! believe that it is easy to learn for beginners, easy to use for ! biologists, and also powerful enough for the software developers. ! In BioRuby, you can retrieve biological database entries from flat ! files, internet web servers and local relational databases. These ! database entries can be parsed to extract information you need. ! Biological sequences can be treated with the fulfilling methods of the ! Ruby's String class and with regular expressions. Daily tools like ! Blast, Fasta, Hmmer and many other softwares for the biological ! analysis can be executed within the BioRuby script, and the results ! can be fully parsed to extract the portion you need. BioRuby supports ! major biological database formats and provides many ways for accessing ! them through flatfile indexing, SQL, web services etc. Various web ! services including KEGG API can be easily utilized by the BioRuby. + == FOR MORE INFORMATION ! BioRuby's official website is at (()). ! You will find links to the related resouces including downloads, ! mailing lists, Wiki documentations etc. in the top page. ! * (()) ! == WHERE TO OBTAIN ! ! --- WWW ! ! The stable release is freely available from the BioRuby website. ! ! * (()) ! ! --- CVS ! ! If you need the latest development version, anonymous CVS is provided at ! ! * (()) ! ! and can be obtained by the following procedure. % cvs -d :pserver:anonymous@cvs.bioruby.org:/export/cvs login *************** *** 31,65 **** % cvs -d :pserver:anonymous@cvs.bioruby.org:/export/cvs co bioruby == REQUIREMENTS ! * Ruby 1.6.6 or newer -- (()) == OPTIONAL REQUIREMENTS ! * Ruby library -- (()) ! * [RAA:strscan] for parsing Blast default output. ! * [RAA:rexml] for parsing Blast XML output and using DAS. ! * [RAA:xmlparser] can be used for faster Blast XML parsing. ! * [RAA:ruby-dbi] and at least one driver from [RAA:mysql-ruby], ! [RAA:postgres], [RAA:oracle] to use with BioSQL. ! * [RAA:bdb] for faster flat file indexing. ! * [RAA:pp] for pretty print in debug. ! * [RAA:soap4r] (version >= 1.4.8.1) for KEGG API. Note that libraries ! which SOAP4R depends such as [RAA:date2], [RAA:devel-logger], ! [RAA:http-access] (version >= j) with one of [RAA:xmlscan], [RAA:rexml], ! [RAA:rexml-stable], [RAA:xmlparser], [RAA:nqxml] are also needed. ! Note that 'strscan', 'rexml', 'pp', 'date2' and 'xmlscan' are ! included in the Ruby 1.8.0 distibution (you don't need to install ! them by yourself). ! * External applications can be used if installed ! * Blast (version >= 2.2.5) for blast execution on local computer ! * FASTA for fasta, ssearch execution on local computer ! * HMMER for hmmsearch, hmmpfam execution on local computer --- 58,92 ---- % cvs -d :pserver:anonymous@cvs.bioruby.org:/export/cvs co bioruby + --- RubyGems + + (()) version of + the BioRuby package is also available for easy installation. + + * (()) + == REQUIREMENTS ! * Ruby 1.8.2 or later -- (()) == OPTIONAL REQUIREMENTS ! Some optional libraries can be utilized to extend BioRuby's functionality. ! If your needs meets the following conditions, install them from the "Ruby ! Application Archive" at (()). ! For faster parsing of the BLAST XML output format: ! * [RAA:xmlparser] ! Creating faster flatfile index using Berkley DB: ! * [RAA:bdb] ! ! Accessing BioSQL database created by other Open Bio* libraries: ! ! * [RAA:ruby-dbi] and at least one driver from [RAA:mysql-ruby], ! [RAA:postgres], [RAA:oracle] *************** *** 74,78 **** # ruby install.rb install ! If you are using Mac OS X, you should use 'sudo' command instead of 'su'. % ruby install.rb config --- 101,106 ---- # ruby install.rb install ! If your operating system supports 'sudo' command (such as Mac OS X), ! try the following procedure instead of the above. % ruby install.rb config *************** *** 80,84 **** % sudo ruby install.rb install ! You can try % ruby install.rb --help --- 108,116 ---- % sudo ruby install.rb install ! You can run tests by ! ! % ruby install.rb test ! ! and run % ruby install.rb --help *************** *** 86,94 **** for more details. If you want to use the OBDA (Open Bio Database Access) to obtain database ! entries, copy a sample config file ! etc/bioinformatics/seqdatabase.ini to --- 118,134 ---- for more details. + --- RubyGems + + If you are using RubyGems, just type + + % gems install bio + + + == SETUP If you want to use the OBDA (Open Bio Database Access) to obtain database ! entries, copy a sample configtation file in the BioRuby distribution ! bioruby-x.x.x/etc/bioinformatics/seqdatabase.ini to *************** *** 106,131 **** == USAGE ! You can load all BioRuby classes just by require 'bio' and all the ! BioRuby classes are defined under the module Bio for the name space. ! See the documentation for each class. #!/usr/bin/env ruby require 'bio' == LICENCE ! GPL for applications, LGPL for libraries. Note that, install.rb ! included in the BioRuby package comes from [RAA:setup] by Minero Aoki. - == AUTHORS ! * KATAYAMA Toshiaki , project leader ! * Yoshinori K. Okuji ! * Mitsuteru C. Nakao ! * KAWASHIMA Shuichi ! * GOTO Naohisa ! * and many others on the Internet... --- 146,182 ---- == USAGE ! You can load all BioRuby classes just by requiring 'bio.rb'. All the ! BioRuby classes and modules are located under the module name 'Bio' to ! separate the name space. #!/usr/bin/env ruby require 'bio' + Also read other documentations in the 'doc' directory. + + bioruby-x.x.x/doc/ + + --- RubyGems + + In RubyGems, you need to load 'rubygems' library before using 'bio'. + + #!/usr/bin/env ruby + require 'rubygems' + require_gem 'bio' == LICENCE ! BioRuby can be freely distributed under the GNU LGPL licence. + Note that, install.rb included in the BioRuby package comes from + [RAA:setup] developed by Minero Aoki, and modified by Moses Hohman. ! == CONTACT ! Current staffs of the BioRuby project can be reached by sending e-mail ! to . ! ! ! =end From k at pub.open-bio.org Sun Sep 25 22:07:04 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Sun Sep 25 22:58:44 2005 Subject: [BioRuby-cvs] bioruby README.DEV,1.1,1.2 Message-ID: <200509260207.j8Q274dZ015141@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv15137 Modified Files: README.DEV Log Message: * added documentation on indentation and comments Index: README.DEV =================================================================== RCS file: /home/repository/bioruby/bioruby/README.DEV,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README.DEV 24 Sep 2005 15:06:54 -0000 1.1 --- README.DEV 26 Sep 2005 02:07:02 -0000 1.2 *************** *** 35,42 **** === Use the following naming conventions ! * CamelCase for module and class names, ! * '_'-separated lowercase names for method names, ! * '_'-separated lowercase names for variable names, and ! * all uppercase names for constants. === Each file must start with the following text --- 35,52 ---- === Use the following naming conventions ! * CamelCase for module and class names, ! * '_'-separated lowercase names for method names, ! * '_'-separated lowercase names for variable names, and ! * all uppercase names for constants. ! ! === Indentation must not include tabs ! ! * Use 2 spaces for indentation. ! * Don't replace spaces at the line head to tabs. ! ! === Comments ! ! Don't use =begin and =end block for comments. If you need to add ! comments, include it in the RDoc documentation. === Each file must start with the following text From k at pub.open-bio.org Mon Sep 26 02:59:43 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 03:51:09 2005 Subject: [BioRuby-cvs] bioruby ChangeLog,1.40,1.41 Message-ID: <200509260659.j8Q6xhdZ015770@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv15766 Modified Files: ChangeLog Log Message: * updated on changes by Katayama made during the Karuizawa camp Index: ChangeLog =================================================================== RCS file: /home/repository/bioruby/bioruby/ChangeLog,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** ChangeLog 9 Sep 2005 16:10:47 -0000 1.40 --- ChangeLog 26 Sep 2005 06:59:40 -0000 1.41 *************** *** 1,2 **** --- 1,36 ---- + 2005-09-25 Toshiaki Katayama + + * README.DEV + + Newly added guideline document for the contributors. + + * README + + Updated and added instructions on RubyGems. + + 2005-09-23 Toshiaki Katayama + + * bin/bioruby, lib/bio/shell.rb, lib/bio/shell/core.rb, + lib/bio/shell/session.rb, lib/bio/shell/plugin/seq.rb, + lib/bio/shell/flatfile.rb, lib/bio/shell/obda.rb + + Newly added BioRuby shell, the command line user interface. + Try 'bioruby' command in your terminal. + + * doc/Changes-0.7.rd + + Newly added document describing incompatible and important + changes between the BioRuby 0.6 and 0.7 versions. + + * lib/bio/sequence.rb + + Bio::Sequence.guess, Bio::Sequence#guess methods are added + which guess the sequence type by following fomula (default + value for the threshold is 0.9). + + number of ATGC + --------------------------------------- > threshold + number of other chars - number of N + 2005-09-10 Naohisa Goto From k at pub.open-bio.org Mon Sep 26 03:27:21 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 04:19:51 2005 Subject: [BioRuby-cvs] bioruby/doc Changes-0.7.rd,1.1,1.2 Message-ID: <200509260727.j8Q7RLdZ015907@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/doc In directory pub.open-bio.org:/tmp/cvs-serv15902/doc Modified Files: Changes-0.7.rd Log Message: * added notes on important changes, new features and descriptions on changes. Index: Changes-0.7.rd =================================================================== RCS file: /home/repository/bioruby/bioruby/doc/Changes-0.7.rd,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Changes-0.7.rd 23 Sep 2005 14:01:54 -0000 1.1 --- Changes-0.7.rd 26 Sep 2005 07:27:19 -0000 1.2 *************** *** 1,7 **** ! = Incompatible changes from BioRuby 0.6 ! == Bio::Sequence * Bio::Sequence::NA#gc_percent returns integer instead of float ! * Bio::Sequence::NA#gc (alias to gc_percent) is removed --- 1,63 ---- ! = Incompatible and important changes since the BioRuby 0.6.4 release ! A lot of changes have been made to the BioRuby after the version 0.6.4 ! is released. ! ! --- Ruby 1.6 series are no longer supported. ! ! We use autoload functionality and many other libraries bundled in ! Ruby 1.8.2 (such as SOAP, open-uri, pp etc.) by default. ! ! --- BioRuby will be loaded about 30 times faster than before. ! ! As we changed to use autoload instead of require, time required ! to start up the BioRuby library made surprisingly faster. ! ! Other changes (including exciting BioRuby shell etc.) made in this release ! is described in this file. ! ! == New features ! ! --- BioRuby shell ! ! Command line user interface for the BioRuby is included. ! You can invoke the shell by ! ! % bioruby ! ! --- UnitTest ! ! Test::Unit now covers wide range of the BioRuby library. ! You can run them by ! ! % ruby test/runner.rb ! ! or ! ! % ruby install.rb config ! % ruby install.rb setup ! % ruby install.rb test ! ! during the installation procedure. ! ! --- Documents ! ! README, README.DEV, doc/Tutorial.rd, doc/Tutorial.rd.ja etc. are updated ! or newly added. ! ! == Incompatible changes ! ! --- Bio::Sequence * Bio::Sequence::NA#gc_percent returns integer instead of float ! * Bio::Sequence::NA#gc (was aliased to gc_percent) is removed ! ! In BioRuby, GC% is rounded to one decimal place. However, how many digits ! should be left when rounding the value is not clear and as the GC% is an ! rough measure by its nature, we have changed to return integer part only. ! If you need a precise value, you can calculate it by values from the ! 'composition' method by your own criteria. ! ! The 'gc' method is removed as the method name doesn't represent its value ! is ambiguous. From k at pub.open-bio.org Mon Sep 26 09:00:09 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:51:33 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/db fantom.rb, 1.10, 1.11 fasta.rb, 1.20, 1.21 gff.rb, 1.2, 1.3 go.rb, 1.7, 1.8 nbrf.rb, 1.3, 1.4 prosite.rb, 0.10, 0.11 Message-ID: <200509261300.j8QD09dZ017396@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/db Modified Files: fantom.rb fasta.rb gff.rb go.rb nbrf.rb prosite.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: prosite.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/prosite.rb,v retrieving revision 0.10 retrieving revision 0.11 diff -C2 -d -r0.10 -r0.11 *** prosite.rb 8 Sep 2005 01:22:11 -0000 0.10 --- prosite.rb 26 Sep 2005 13:00:06 -0000 0.11 *************** *** 455,459 **** begin require 'pp' ! alias :p :pp rescue LoadError end --- 455,459 ---- begin require 'pp' ! alias p pp rescue LoadError end Index: go.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/go.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** go.rb 8 Sep 2005 01:22:11 -0000 1.7 --- go.rb 26 Sep 2005 13:00:06 -0000 1.8 *************** *** 201,205 **** attr_reader :date attr_reader :assigned_by ! alias :entry_id :db_object_id --- 201,205 ---- attr_reader :date attr_reader :assigned_by ! alias entry_id db_object_id Index: nbrf.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/nbrf.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** nbrf.rb 8 Sep 2005 01:22:11 -0000 1.3 --- nbrf.rb 26 Sep 2005 13:00:06 -0000 1.4 *************** *** 50,59 **** attr_reader :entry_overrun ! alias :accession :entry_id def entry @entry = ">#{@seq_type or 'XX'};#{@entry_id}\n#{definition}\n#{@data}*\n" end ! alias :to_s :entry def seq_class --- 50,59 ---- attr_reader :entry_overrun ! alias accession entry_id def entry @entry = ">#{@seq_type or 'XX'};#{@entry_id}\n#{definition}\n#{@data}*\n" end ! alias to_s entry def seq_class Index: fasta.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/fasta.rb,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** fasta.rb 8 Sep 2005 01:22:11 -0000 1.20 --- fasta.rb 26 Sep 2005 13:00:06 -0000 1.21 *************** *** 43,53 **** @entry = ">#{@definition}\n#{@data.strip}\n" end ! alias :to_s :entry def query(factory) factory.query(@entry) end ! alias :fasta :query ! alias :blast :query def seq --- 43,53 ---- @entry = ">#{@definition}\n#{@data.strip}\n" end ! alias to_s entry def query(factory) factory.query(@entry) end ! alias fasta query ! alias blast query def seq Index: fantom.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/fantom.rb,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** fantom.rb 8 Sep 2005 01:22:11 -0000 1.10 --- fantom.rb 26 Sep 2005 13:00:06 -0000 1.11 *************** *** 148,152 **** @representative_sequence end ! alias :representative_clone :representative_sequence def representative_annotations --- 148,152 ---- @representative_sequence end ! alias representative_clone representative_sequence def representative_annotations Index: gff.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/gff.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gff.rb 8 Sep 2005 01:22:11 -0000 1.2 --- gff.rb 26 Sep 2005 13:00:06 -0000 1.3 *************** *** 70,74 **** begin require 'pp' ! alias :p :pp rescue LoadError end --- 70,74 ---- begin require 'pp' ! alias p pp rescue LoadError end From k at pub.open-bio.org Mon Sep 26 09:00:10 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:51:36 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/db/kegg keggtab.rb,1.6,1.7 Message-ID: <200509261300.j8QD0AdZ017411@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/kegg In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/db/kegg Modified Files: keggtab.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: keggtab.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/keggtab.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** keggtab.rb 8 Sep 2005 01:22:11 -0000 1.6 --- keggtab.rb 26 Sep 2005 13:00:07 -0000 1.7 *************** *** 48,53 **** end attr_reader :name, :type, :path, :abbrev, :aliases ! alias :korg :abbrev ! alias :keggorg :abbrev end --- 48,53 ---- end attr_reader :name, :type, :path, :abbrev, :aliases ! alias korg abbrev ! alias keggorg abbrev end *************** *** 151,157 **** end end ! alias :taxo2keggorgs :taxo2korgs ! alias :taxon2korgs :taxo2korgs ! alias :taxon2keggorgs :taxo2korgs def korg2taxo(keggorg) --- 151,157 ---- end end ! alias taxo2keggorgs taxo2korgs ! alias taxon2korgs taxo2korgs ! alias taxon2keggorgs taxo2korgs def korg2taxo(keggorg) *************** *** 169,175 **** return tmp end ! alias :keggorg2taxo :korg2taxo ! alias :korg2taxonomy :korg2taxo ! alias :keggorg2taxonomy :korg2taxo --- 169,175 ---- return tmp end ! alias keggorg2taxo korg2taxo ! alias korg2taxonomy korg2taxo ! alias keggorg2taxonomy korg2taxo *************** *** 218,222 **** begin require 'pp' ! alias :p :pp rescue LoadError end --- 218,222 ---- begin require 'pp' ! alias p pp rescue LoadError end From k at pub.open-bio.org Mon Sep 26 09:00:09 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:51:37 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/db/genbank common.rb, 1.5, 1.6 genbank.rb, 0.33, 0.34 genpept.rb, 1.6, 1.7 Message-ID: <200509261300.j8QD09dZ017405@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/genbank In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/db/genbank Modified Files: common.rb genbank.rb genpept.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: genpept.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/genbank/genpept.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** genpept.rb 23 Aug 2004 23:40:35 -0000 1.6 --- genpept.rb 26 Sep 2005 13:00:07 -0000 1.7 *************** *** 57,62 **** Bio::Sequence::AA.new(@data['SEQUENCE']) end ! alias :aaseq :seq ! alias :aalen :seq_len --- 57,62 ---- Bio::Sequence::AA.new(@data['SEQUENCE']) end ! alias aaseq seq ! alias aalen seq_len Index: genbank.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/genbank/genbank.rb,v retrieving revision 0.33 retrieving revision 0.34 diff -C2 -d -r0.33 -r0.34 *** genbank.rb 24 Sep 2005 01:16:22 -0000 0.33 --- genbank.rb 26 Sep 2005 13:00:07 -0000 0.34 *************** *** 73,78 **** Bio::Sequence::NA.new(@data['SEQUENCE']) end ! alias :naseq :seq ! alias :nalen :seq_len --- 73,78 ---- Bio::Sequence::NA.new(@data['SEQUENCE']) end ! alias naseq seq ! alias nalen seq_len *************** *** 128,132 **** begin require 'pp' ! alias :p :pp rescue LoadError end --- 128,132 ---- begin require 'pp' ! alias p pp rescue LoadError end Index: common.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/genbank/common.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** common.rb 24 Sep 2005 01:16:22 -0000 1.5 --- common.rb 26 Sep 2005 13:00:07 -0000 1.6 *************** *** 115,119 **** source['common_name'] end ! alias :varnacular_name :common_name def organism --- 115,119 ---- source['common_name'] end ! alias varnacular_name common_name def organism From k at pub.open-bio.org Mon Sep 26 09:00:10 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:51:41 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/io brdb.rb, 1.3, 1.4 das.rb, 1.8, 1.9 ddbjxml.rb, 1.5, 1.6 fastacmd.rb, 1.7, 1.8 flatfile.rb, 1.36, 1.37 higet.rb, 1.1, 1.2 keggapi.rb, 1.8, 1.9 registry.rb, 1.13, 1.14 Message-ID: <200509261300.j8QD0AdZ017422@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/io Modified Files: brdb.rb das.rb ddbjxml.rb fastacmd.rb flatfile.rb higet.rb keggapi.rb registry.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: registry.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/registry.rb,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** registry.rb 8 Sep 2005 01:22:12 -0000 1.13 --- registry.rb 26 Sep 2005 13:00:08 -0000 1.14 *************** *** 68,72 **** return nil end ! alias :db :get_database def query(dbname) --- 68,72 ---- return nil end ! alias db get_database def query(dbname) *************** *** 192,196 **** begin require 'pp' ! alias :p :pp rescue end --- 192,196 ---- begin require 'pp' ! alias p pp rescue end Index: brdb.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/brdb.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** brdb.rb 8 Sep 2005 01:22:11 -0000 1.3 --- brdb.rb 26 Sep 2005 13:00:08 -0000 1.4 *************** *** 72,76 **** begin require 'pp' ! alias :p :pp rescue LoadError end --- 72,76 ---- begin require 'pp' ! alias p pp rescue LoadError end Index: flatfile.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile.rb,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** flatfile.rb 8 Sep 2005 01:22:11 -0000 1.36 --- flatfile.rb 26 Sep 2005 13:00:08 -0000 1.37 *************** *** 111,115 **** end end ! alias :each :each_entry def rewind --- 111,115 ---- end end ! alias each each_entry def rewind Index: keggapi.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/keggapi.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** keggapi.rb 7 Aug 2005 09:49:22 -0000 1.8 --- keggapi.rb 26 Sep 2005 13:00:08 -0000 1.9 *************** *** 193,197 **** begin require 'pp' ! alias :p :pp rescue LoadError end --- 193,197 ---- begin require 'pp' ! alias p pp rescue LoadError end Index: fastacmd.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/fastacmd.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** fastacmd.rb 16 Aug 2005 09:38:34 -0000 1.7 --- fastacmd.rb 26 Sep 2005 13:00:08 -0000 1.8 *************** *** 72,76 **** self end ! alias :each :each_entry end --- 72,76 ---- self end ! alias each each_entry end Index: das.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/das.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** das.rb 8 Sep 2005 01:22:11 -0000 1.8 --- das.rb 26 Sep 2005 13:00:08 -0000 1.9 *************** *** 396,400 **** # begin # require 'pp' ! # alias :p :pp # rescue LoadError # end --- 396,400 ---- # begin # require 'pp' ! # alias p pp # rescue LoadError # end Index: ddbjxml.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/ddbjxml.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ddbjxml.rb 23 Jun 2004 14:35:26 -0000 1.5 --- ddbjxml.rb 26 Sep 2005 13:00:08 -0000 1.6 *************** *** 113,117 **** begin require 'pp' ! alias :p :pp rescue LoadError end --- 113,117 ---- begin require 'pp' ! alias p pp rescue LoadError end Index: higet.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/higet.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** higet.rb 11 Jul 2005 09:30:46 -0000 1.1 --- higet.rb 26 Sep 2005 13:00:08 -0000 1.2 *************** *** 52,56 **** begin require 'pp' ! alias :p :pp rescue LoadError end --- 52,56 ---- begin require 'pp' ! alias p pp rescue LoadError end From k at pub.open-bio.org Mon Sep 26 09:00:10 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:51:42 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/io/flatfile bdb.rb, 1.7, 1.8 index.rb, 1.13, 1.14 indexer.rb, 1.20, 1.21 Message-ID: <200509261300.j8QD0AdZ017431@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io/flatfile In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/io/flatfile Modified Files: bdb.rb index.rb indexer.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: bdb.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile/bdb.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** bdb.rb 9 Sep 2005 14:35:25 -0000 1.7 --- bdb.rb 26 Sep 2005 13:00:08 -0000 1.8 *************** *** 153,157 **** @bdb.size end ! alias :size :records # methods for writing --- 153,157 ---- @bdb.size end ! alias size records # methods for writing Index: index.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile/index.rb,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** index.rb 25 Sep 2005 05:30:21 -0000 1.13 --- index.rb 26 Sep 2005 13:00:08 -0000 1.14 *************** *** 199,206 **** end ! #alias :each_orig :each ! alias :each :each_value ! #alias :to_a_orig :to_a ! alias :to_a :values end #class Results --- 199,206 ---- end ! #alias each_orig each ! alias each each_value ! #alias to_a_orig to_a ! alias to_a values end #class Results *************** *** 449,453 **** r end ! alias :check :check_all def close_all --- 449,453 ---- r end ! alias check check_all def close_all *************** *** 457,461 **** nil end ! alias :close :close_all def recalc_all --- 457,461 ---- nil end ! alias close close_all def recalc_all *************** *** 466,470 **** true end ! alias :recalc :recalc_all end #class FileIDs --- 466,470 ---- true end ! alias recalc recalc_all end #class FileIDs *************** *** 570,574 **** @records end ! alias :size :records # methods for writing file --- 570,574 ---- @records end ! alias size records # methods for writing file *************** *** 844,848 **** values.each { |x| x.file.close } end ! alias :close :close_all def search(key) --- 844,848 ---- values.each { |x| x.file.close } end ! alias close close_all def search(key) Index: indexer.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile/indexer.rb,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** indexer.rb 23 Sep 2005 15:03:02 -0000 1.20 --- indexer.rb 26 Sep 2005 13:00:08 -0000 1.21 *************** *** 52,57 **** self.store(x.name, x) end ! #alias :each_orig :each ! alias :each :each_value end --- 52,57 ---- self.store(x.name, x) end ! #alias each_orig each ! alias each each_value end From k at pub.open-bio.org Mon Sep 26 09:00:06 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:55:23 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl blast.rb, 1.25, 1.26 fasta.rb, 1.19, 1.20 hmmer.rb, 1.3, 1.4 Message-ID: <200509261300.j8QD06dZ017363@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/appl Modified Files: blast.rb fasta.rb hmmer.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast.rb,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** blast.rb 24 Sep 2005 16:01:32 -0000 1.25 --- blast.rb 26 Sep 2005 13:00:04 -0000 1.26 *************** *** 202,206 **** begin require 'pp' ! alias :p :pp rescue end --- 202,206 ---- begin require 'pp' ! alias p pp rescue end Index: fasta.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/fasta.rb,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** fasta.rb 9 Sep 2005 15:09:37 -0000 1.19 --- fasta.rb 26 Sep 2005 13:00:04 -0000 1.20 *************** *** 181,185 **** begin require 'pp' ! alias :p :pp rescue end --- 181,185 ---- begin require 'pp' ! alias p pp rescue end Index: hmmer.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/hmmer.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** hmmer.rb 9 Sep 2005 15:34:28 -0000 1.3 --- hmmer.rb 26 Sep 2005 13:00:04 -0000 1.4 *************** *** 86,90 **** begin require 'pp' ! alias :p :pp rescue end --- 86,90 ---- begin require 'pp' ! alias p pp rescue end From k at pub.open-bio.org Mon Sep 26 09:00:06 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:55:34 2005 Subject: [BioRuby-cvs] bioruby/lib/bio alignment.rb, 1.8, 1.9 location.rb, 0.19, 0.20 sequence.rb, 0.43, 0.44 Message-ID: <200509261300.j8QD06dZ017359@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio Modified Files: alignment.rb location.rb sequence.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence.rb,v retrieving revision 0.43 retrieving revision 0.44 diff -C2 -d -r0.43 -r0.44 *** sequence.rb 23 Sep 2005 14:27:59 -0000 0.43 --- sequence.rb 26 Sep 2005 13:00:04 -0000 0.44 *************** *** 37,41 **** String.new(self) end ! alias :to_str :to_s def seq --- 37,41 ---- String.new(self) end ! alias to_str to_s def seq *************** *** 47,56 **** self end ! alias :seq! :normalize! def <<(*arg) super(self.class.new(*arg)) end ! alias :concat :<< def +(*arg) --- 47,56 ---- self end ! alias seq! normalize! def <<(*arg) super(self.class.new(*arg)) end ! alias concat << def +(*arg) Index: location.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/location.rb,v retrieving revision 0.19 retrieving revision 0.20 diff -C2 -d -r0.19 -r0.20 *** location.rb 8 Sep 2005 01:22:08 -0000 0.19 --- location.rb 26 Sep 2005 13:00:04 -0000 0.20 *************** *** 153,157 **** len end ! alias :size :length def relative(n, type = nil) --- 153,157 ---- len end ! alias size length def relative(n, type = nil) Index: alignment.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/alignment.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** alignment.rb 8 Sep 2005 01:22:08 -0000 1.8 --- alignment.rb 26 Sep 2005 13:00:04 -0000 1.9 *************** *** 251,255 **** end end ! alias :each_seq :each def each_pair --- 251,255 ---- end end ! alias each_seq each def each_pair *************** *** 587,591 **** cseq end ! alias :consensus :consensus_string IUPAC_NUC = [ --- 587,591 ---- cseq end ! alias consensus consensus_string IUPAC_NUC = [ From k at pub.open-bio.org Mon Sep 26 09:00:07 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:55:35 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/blast format0.rb, 1.11, 1.12 report.rb, 1.8, 1.9 Message-ID: <200509261300.j8QD07dZ017366@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/blast In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/appl/blast Modified Files: format0.rb report.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/report.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** report.rb 9 Sep 2005 15:15:51 -0000 1.8 --- report.rb 26 Sep 2005 13:00:04 -0000 1.9 *************** *** 99,103 **** end end ! alias :each :each_hit # shortcut for the last iteration's hits --- 99,103 ---- end end ! alias each each_hit # shortcut for the last iteration's hits *************** *** 160,166 **** # Compatible with Bio::Fasta::Report::Hit ! alias :target_id :accession ! alias :target_def :definition ! alias :target_len :len # Shortcut methods for the best Hsp --- 160,166 ---- # Compatible with Bio::Fasta::Report::Hit ! alias target_id accession ! alias target_def definition ! alias target_len len # Shortcut methods for the best Hsp *************** *** 211,215 **** begin # p is suitable than pp for the following test script require 'pp' ! alias :p :pp rescue end --- 211,215 ---- begin # p is suitable than pp for the following test script require 'pp' ! alias p pp rescue end Index: format0.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/format0.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** format0.rb 9 Sep 2005 14:59:53 -0000 1.11 --- format0.rb 26 Sep 2005 13:00:04 -0000 1.12 *************** *** 114,118 **** end end ! alias :each :each_hit # shortcut for the last iteration's hits --- 114,118 ---- end end ! alias each each_hit # shortcut for the last iteration's hits *************** *** 620,626 **** # Compatible with Bio::Fasta::Report::Hit ! #alias :target_id :accession ! alias :target_def :definition ! alias :target_len :len # Shortcut methods for the best Hsp --- 620,626 ---- # Compatible with Bio::Fasta::Report::Hit ! #alias target_id accession ! alias target_def definition ! alias target_len len # Shortcut methods for the best Hsp From k at pub.open-bio.org Mon Sep 26 09:00:07 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:55:36 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/hmmer report.rb,1.7,1.8 Message-ID: <200509261300.j8QD07dZ017373@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/hmmer In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/appl/hmmer Modified Files: report.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/hmmer/report.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** report.rb 9 Sep 2005 15:34:28 -0000 1.7 --- report.rb 26 Sep 2005 13:00:05 -0000 1.8 *************** *** 244,248 **** begin require 'pp' ! alias :p :pp rescue LoadError end --- 244,248 ---- begin require 'pp' ! alias p pp rescue LoadError end From k at pub.open-bio.org Mon Sep 26 09:00:08 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:55:50 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/db/embl common.rb, 1.3, 1.4 sptr.rb, 1.24, 1.25 Message-ID: <200509261300.j8QD08dZ017393@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/embl In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/db/embl Modified Files: common.rb sptr.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: sptr.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/embl/sptr.rb,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** sptr.rb 8 Aug 2005 06:41:13 -0000 1.24 --- sptr.rb 26 Sep 2005 13:00:06 -0000 1.25 *************** *** 691,696 **** begin require 'pp' ! alias p pp ! rescue LoadErrmr end --- 691,696 ---- begin require 'pp' ! alias pp p ! rescue LoadError end Index: common.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/embl/common.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** common.rb 24 Sep 2005 01:15:56 -0000 1.3 --- common.rb 26 Sep 2005 13:00:06 -0000 1.4 *************** *** 70,76 **** @data['DE'] end ! alias :description :de # API ! alias :definition :de --- 70,76 ---- @data['DE'] end ! alias description de # API ! alias definition de From k at pub.open-bio.org Mon Sep 26 09:00:07 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:55:50 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/mafft report.rb,1.4,1.5 Message-ID: <200509261300.j8QD07dZ017376@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/mafft In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/appl/mafft Modified Files: report.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/mafft/report.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** report.rb 8 Sep 2005 01:22:10 -0000 1.4 --- report.rb 26 Sep 2005 13:00:05 -0000 1.5 *************** *** 52,56 **** @align end ! alias :alignment :align def to_fasta(*arg) --- 52,56 ---- @align end ! alias alignment align def to_fasta(*arg) From k at pub.open-bio.org Mon Sep 26 09:00:07 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:55:51 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/sosui report.rb,1.5,1.6 Message-ID: <200509261300.j8QD07dZ017379@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/sosui In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/appl/sosui Modified Files: report.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/sosui/report.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** report.rb 8 Sep 2005 01:22:10 -0000 1.5 --- report.rb 26 Sep 2005 13:00:05 -0000 1.6 *************** *** 71,75 **** begin require 'pp' ! alias :p :pp rescue LoadError end --- 71,75 ---- begin require 'pp' ! alias p pp rescue LoadError end From k at pub.open-bio.org Mon Sep 26 09:00:08 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:55:52 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/tmhmm report.rb,1.3,1.4 Message-ID: <200509261300.j8QD08dZ017386@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/tmhmm In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/appl/tmhmm Modified Files: report.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/tmhmm/report.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** report.rb 8 Sep 2005 01:22:11 -0000 1.3 --- report.rb 26 Sep 2005 13:00:06 -0000 1.4 *************** *** 67,71 **** attr_reader :tmhs, :entry_id, :query_len, :predicted_tmhs, :exp_aas_in_tmhs, :exp_first_60aa, :total_prob_of_N_in ! alias :length :query_len def helix --- 67,71 ---- attr_reader :tmhs, :entry_id, :query_len, :predicted_tmhs, :exp_aas_in_tmhs, :exp_first_60aa, :total_prob_of_N_in ! alias length query_len def helix *************** *** 136,140 **** end attr_accessor :entry_id, :version, :status, :range ! alias :pos :range def to_s --- 136,140 ---- end attr_accessor :entry_id, :version, :status, :range ! alias pos range def to_s *************** *** 153,157 **** begin require 'pp' ! alias pp p rescue LoadError end --- 153,157 ---- begin require 'pp' ! alias p pp rescue LoadError end From k at pub.open-bio.org Mon Sep 26 09:00:08 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:55:53 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/data aa.rb, 0.11, 0.12 codontable.rb, 0.12, 0.13 na.rb, 0.13, 0.14 Message-ID: <200509261300.j8QD08dZ017389@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/data In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/data Modified Files: aa.rb codontable.rb na.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: aa.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/data/aa.rb,v retrieving revision 0.11 retrieving revision 0.12 diff -C2 -d -r0.11 -r0.12 *** aa.rb 31 Aug 2005 07:22:53 -0000 0.11 --- aa.rb 26 Sep 2005 13:00:06 -0000 0.12 *************** *** 140,144 **** Names end ! alias :aa :names def name(x) --- 140,144 ---- Names end ! alias aa names def name(x) *************** *** 161,165 **** end end ! alias :one :to_1 def to_3(x) --- 161,165 ---- end end ! alias one to_1 def to_3(x) *************** *** 173,177 **** end end ! alias :three :to_3 def one2three(x) --- 173,177 ---- end end ! alias three to_3 def one2three(x) *************** *** 259,263 **** # override when used as an instance method to improve performance ! alias :orig_reverse :reverse def reverse unless @reverse --- 259,263 ---- # override when used as an instance method to improve performance ! alias orig_reverse reverse def reverse unless @reverse Index: na.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/data/na.rb,v retrieving revision 0.13 retrieving revision 0.14 diff -C2 -d -r0.13 -r0.14 *** na.rb 10 Aug 2005 12:53:02 -0000 0.13 --- na.rb 26 Sep 2005 13:00:06 -0000 0.14 *************** *** 118,122 **** Names end ! alias :na :names def name(x) --- 118,122 ---- Names end ! alias na names def name(x) Index: codontable.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/data/codontable.rb,v retrieving revision 0.12 retrieving revision 0.13 diff -C2 -d -r0.12 -r0.13 *** codontable.rb 23 Aug 2004 23:51:29 -0000 0.12 --- codontable.rb 26 Sep 2005 13:00:06 -0000 0.13 *************** *** 673,677 **** begin require 'pp' ! alias :p :pp rescue LoadError end --- 673,677 ---- begin require 'pp' ! alias p pp rescue LoadError end From k at pub.open-bio.org Mon Sep 26 09:00:07 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:55:54 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/fasta format10.rb,1.5,1.6 Message-ID: <200509261300.j8QD07dZ017371@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/fasta In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/appl/fasta Modified Files: format10.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: format10.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/fasta/format10.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** format10.rb 9 Sep 2005 15:09:37 -0000 1.5 --- format10.rb 26 Sep 2005 13:00:05 -0000 1.6 *************** *** 269,273 **** begin require 'pp' ! alias :p :pp rescue end --- 269,273 ---- begin require 'pp' ! alias p pp rescue end From k at pub.open-bio.org Mon Sep 26 09:00:08 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:55:55 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/targetp report.rb,1.4,1.5 Message-ID: <200509261300.j8QD08dZ017382@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/targetp In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/appl/targetp Modified Files: report.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/targetp/report.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** report.rb 8 Sep 2005 01:22:10 -0000 1.4 --- report.rb 26 Sep 2005 13:00:05 -0000 1.5 *************** *** 43,52 **** :prediction, :cutoff ! alias :pred :prediction def name @prediction['Name'] end ! alias :entry_id :name def query_len --- 43,52 ---- :prediction, :cutoff ! alias pred prediction def name @prediction['Name'] end ! alias entry_id name def query_len *************** *** 57,61 **** end end ! alias :length :query_len def loc --- 57,61 ---- end end ! alias length query_len def loc *************** *** 131,135 **** begin require 'pp' ! alias :p :pp rescue LoadError end --- 131,135 ---- begin require 'pp' ! alias p pp rescue LoadError end From k at pub.open-bio.org Mon Sep 26 09:00:07 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:55:56 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/clustalw report.rb,1.5,1.6 Message-ID: <200509261300.j8QD07dZ017369@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/clustalw In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/appl/clustalw Modified Files: report.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/clustalw/report.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** report.rb 8 Sep 2005 01:22:09 -0000 1.5 --- report.rb 26 Sep 2005 13:00:05 -0000 1.6 *************** *** 64,68 **** @align end ! alias :alignment :align def to_fasta(*arg) --- 64,68 ---- @align end ! alias alignment align def to_fasta(*arg) From k at pub.open-bio.org Mon Sep 26 09:00:10 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:55:57 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/db/pdb chain.rb, 1.1, 1.2 model.rb, 1.1, 1.2 pdb.rb, 1.2, 1.3 residue.rb, 1.1, 1.2 Message-ID: <200509261300.j8QD0AdZ017415@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/pdb In directory pub.open-bio.org:/tmp/cvs-serv17319/lib/bio/db/pdb Modified Files: chain.rb model.rb pdb.rb residue.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: residue.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/residue.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** residue.rb 8 Mar 2004 07:30:40 -0000 1.1 --- residue.rb 26 Sep 2005 13:00:08 -0000 1.2 *************** *** 98,102 **** end #Alias to override AtomFinder#each_atom ! alias :each_atom :each #Sorts based on resSeq and iCode if need be --- 98,102 ---- end #Alias to override AtomFinder#each_atom ! alias each_atom each #Sorts based on resSeq and iCode if need be Index: model.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/model.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** model.rb 8 Mar 2004 07:30:40 -0000 1.1 --- model.rb 26 Sep 2005 13:00:08 -0000 1.2 *************** *** 72,76 **** end #Alias to override ChainFinder#each_chain ! alias :each_chain :each #Sorts models based on serial number --- 72,76 ---- end #Alias to override ChainFinder#each_chain ! alias each_chain each #Sorts models based on serial number Index: pdb.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/pdb.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pdb.rb 8 Sep 2005 01:22:11 -0000 1.2 --- pdb.rb 26 Sep 2005 13:00:08 -0000 1.3 *************** *** 1217,1221 **** end #Alias needed for Bio::PDB::ModelFinder ! alias :each_model :each #Provides keyed access to the models based on serial number --- 1217,1221 ---- end #Alias needed for Bio::PDB::ModelFinder ! alias each_model each #Provides keyed access to the models based on serial number Index: chain.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/chain.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** chain.rb 8 Mar 2004 07:30:40 -0000 1.1 --- chain.rb 26 Sep 2005 13:00:08 -0000 1.2 *************** *** 77,81 **** end #Alias to override ResidueFinder#each_residue ! alias :each_residue :each #Sort based on chain id --- 77,81 ---- end #Alias to override ResidueFinder#each_residue ! alias each_residue each #Sort based on chain id From k at pub.open-bio.org Mon Sep 26 09:04:30 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 09:59:47 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/io sql.rb,1.3,1.4 Message-ID: <200509261304.j8QD4UdZ017539@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory pub.open-bio.org:/tmp/cvs-serv17535/lib/bio/io Modified Files: sql.rb Log Message: * 'alias :foo :bar' is changed to 'alias foo bar' Index: sql.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/sql.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sql.rb 8 Sep 2005 01:22:12 -0000 1.3 --- sql.rb 26 Sep 2005 13:04:28 -0000 1.4 *************** *** 323,327 **** begin require 'pp' ! alias :p :pp rescue LoadError end --- 323,327 ---- begin require 'pp' ! alias p pp rescue LoadError end From k at pub.open-bio.org Mon Sep 26 09:13:25 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 10:04:49 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/db/genbank genpept.rb,1.7,1.8 Message-ID: <200509261313.j8QDDPdZ017598@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/genbank In directory pub.open-bio.org:/tmp/cvs-serv17593/lib/bio/db/genbank Modified Files: genpept.rb Log Message: * fixed that GenPept#entry_id causes NoMethodError (undefined method 'entry_id' for Bio::GenPept::Locus) by adding accessors for :entry_id, :seq_len, :circular, :division, :date in Locus class. Index: genpept.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/genbank/genpept.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** genpept.rb 26 Sep 2005 13:00:07 -0000 1.7 --- genpept.rb 26 Sep 2005 13:13:23 -0000 1.8 *************** *** 38,41 **** --- 38,42 ---- @date = locus_line[68..78].strip end + attr_accessor :entry_id, :seq_len, :circular, :division, :date end From k at pub.open-bio.org Mon Sep 26 09:24:27 2005 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon Sep 26 10:15:59 2005 Subject: [BioRuby-cvs] bioruby/lib/bio/db/genbank genbank.rb, 0.34, 0.35 genpept.rb, 1.8, 1.9 Message-ID: <200509261324.j8QDORdZ017644@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/genbank In directory pub.open-bio.org:/tmp/cvs-serv17639 Modified Files: genbank.rb genpept.rb Log Message: * 'seq_len' method is renamed to 'length' which returns the sequence length written in the LOCUS line * 'seq_len' method is re-defined as a method to count the actual sequence length in ORIGIN line by calling Bio::Sequence#length (which is inherited from the Ruby's String class) Index: genpept.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/genbank/genpept.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** genpept.rb 26 Sep 2005 13:13:23 -0000 1.8 --- genpept.rb 26 Sep 2005 13:24:25 -0000 1.9 *************** *** 33,42 **** def initialize(locus_line) @entry_id = locus_line[12..27].strip ! @seq_len = locus_line[29..39].to_i @circular = locus_line[55..62].strip # always linear @division = locus_line[63..66].strip @date = locus_line[68..78].strip end ! attr_accessor :entry_id, :seq_len, :circular, :division, :date end --- 33,42 ---- def initialize(locus_line) @entry_id = locus_line[12..27].strip ! @length = locus_line[29..39].to_i @circular = locus_line[55..62].strip # always linear @division = locus_line[63..66].strip @date = locus_line[68..78].strip end ! attr_accessor :entry_id, :length, :circular, :division, :date end *************** *** 45,49 **** end def entry_id; locus.entry_id; end ! def seq_len; locus.seq_len; end def circular; locus.circular; end def division; locus.division; end --- 45,49 ---- end def entry_id; locus.entry_id; end ! def length; locus.length; end def circular; locus.circular; end def division; locus.division; end *************** *** 59,64 **** end alias aaseq seq ! alias aalen seq_len # DBSOURCE --- 59,67 ---- end alias aaseq seq ! alias aalen length + def seq_len + seq.length + end # DBSOURCE Index: genbank.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/genbank/genbank.rb,v retrieving revision 0.34 retrieving revision 0.35 diff -C2 -d -r0.34 -r0.35 *** genbank.rb 26 Sep 2005 13:00:07 -0000 0.34 --- genbank.rb 26 Sep 2005 13:24:25 -0000 0.35 *************** *** 33,37 **** if locus_line.length > 75 # after Rel 126.0 @entry_id = locus_line[12..27].strip ! @seq_len = locus_line[29..39].to_i @strand = locus_line[44..46].strip @natype = locus_line[47..52].strip --- 33,37 ---- if locus_line.length > 75 # after Rel 126.0 @entry_id = locus_line[12..27].strip ! @length = locus_line[29..39].to_i @strand = locus_line[44..46].strip @natype = locus_line[47..52].strip *************** *** 41,45 **** else @entry_id = locus_line[12..21].strip ! @seq_len = locus_line[22..29].to_i @strand = locus_line[33..35].strip @natype = locus_line[36..39].strip --- 41,45 ---- else @entry_id = locus_line[12..21].strip ! @length = locus_line[22..29].to_i @strand = locus_line[33..35].strip @natype = locus_line[36..39].strip *************** *** 49,53 **** end end ! attr_accessor :entry_id, :seq_len, :strand, :natype, :circular, :division, :date end --- 49,53 ---- end end ! attr_accessor :entry_id, :length, :strand, :natype, :circular, :division, :date end *************** *** 57,61 **** end def entry_id; locus.entry_id; end ! def seq_len; locus.seq_len; end def circular; locus.circular; end def division; locus.division; end --- 57,61 ---- end def entry_id; locus.entry_id; end ! def length; locus.length; end def circular; locus.circular; end def division; locus.division; end *************** *** 74,78 **** end alias naseq seq ! alias nalen seq_len --- 74,82 ---- end alias naseq seq ! alias nalen length ! ! def seq_len ! seq.length ! end From pjotr at pub.open-bio.org Fri Sep 16 02:55:56 2005 From: pjotr at pub.open-bio.org (Pjotr Prins) Date: Thu Oct 27 10:06:33 2005 Subject: [BioRuby-cvs] bioruby/doc Tutorial.rd,1.4,1.5 Message-ID: <200509160603.j8G63UdZ021486@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/doc In directory pub.open-bio.org:/tmp/cvs-serv21476 Modified Files: Tutorial.rd Log Message: Edited English tutorial w. first additions Index: Tutorial.rd =================================================================== RCS file: /home/repository/bioruby/bioruby/doc/Tutorial.rd,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Tutorial.rd 8 Sep 2005 05:43:10 -0000 1.4 --- Tutorial.rd 16 Sep 2005 06:03:27 -0000 1.5 *************** *** 3,30 **** $Id$ ! Copyright (C) 2001-2003 KATAYAMA Toshiaki ! Translated into English: Naohisa Goto ! Edited by: PjotrPrins ! (to be written...) NOTE: This page is a work in progress at this point [...1506 lines suppressed...] ! ! The R libraries can be accessed from Ruby using the @@FIXME ! package. This allows at least use of the standard R library ! functions. Unfortunately there is no binding for dynamic R - so at ! this point you'll have to create some command line interface. ! ! == Using BioPerl from Ruby == Installing required external library ! At this point for using BioRuby no additional libraries are needed. ! This may change, so keep an eye on the Bioruby website. Also when ! a package is missing BioRuby should show an informative message. ! At this point installing third party Ruby packages can be a bit ! painful, as the gem standard for packages evolved late and some still ! force you to copy things by hand. Therefore read the README's ! carefully that come with each package. =end From pjotr at pub.open-bio.org Fri Sep 23 04:35:46 2005 From: pjotr at pub.open-bio.org (Pjotr Prins) Date: Thu Oct 27 10:06:48 2005 Subject: [BioRuby-cvs] bioruby/doc Tutorial.rd,1.5,1.6 Message-ID: <200509230743.j8N7hMdZ020995@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/doc In directory pub.open-bio.org:/tmp/cvs-serv20985 Modified Files: Tutorial.rd Log Message: Added assignment info to tutorial Index: Tutorial.rd =================================================================== RCS file: /home/repository/bioruby/bioruby/doc/Tutorial.rd,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Tutorial.rd 16 Sep 2005 06:03:27 -0000 1.5 --- Tutorial.rd 23 Sep 2005 07:43:20 -0000 1.6 *************** *** 52,82 **** #!/usr/bin/env ruby ! require 'bio' ! seq = Bio::Sequence::NA.new("atgcatgcaaaa") ! puts seq # original sequence puts seq.complement # complemental sequence (Bio::Sequence::NA object) puts seq.subseq(3,8) # gets subsequence of positions 3 to 8 ! p seq.gc_percent # GC percent (Float) p seq.composition # nucleic acid compositions (Hash) ! puts seq.translate # translation (Bio::Sequence::AA object) puts seq.translate(2) # translation from frame 2 (default is frame 1) puts seq.translate(1,11) # using codon table No.11 (see http://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi) ! p seq.translate.codes # shows three-letter codes (Array) p seq.translate.names # shows amino acid names (Array) p seq.translate.composition # amino acid compositions (Hash) p seq.translate.molecular_weight # calculating molecular weight (Float) ! puts seq.complement.translate # translation of complemental strand The p, print and puts methods are standard Ruby ways of outputting to the screen. If you want to know more about standard Ruby commands you ! can use the 'ri' command on the command line (or the help command in ! Windows). For example % ri p --- 52,82 ---- #!/usr/bin/env ruby ! require 'bio' ! seq = Bio::Sequence::NA.new("atgcatgcaaaa") ! puts seq # original sequence puts seq.complement # complemental sequence (Bio::Sequence::NA object) puts seq.subseq(3,8) # gets subsequence of positions 3 to 8 ! p seq.gc_percent # GC percent (Float) p seq.composition # nucleic acid compositions (Hash) ! puts seq.translate # translation (Bio::Sequence::AA object) puts seq.translate(2) # translation from frame 2 (default is frame 1) puts seq.translate(1,11) # using codon table No.11 (see http://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi) ! p seq.translate.codes # shows three-letter codes (Array) p seq.translate.names # shows amino acid names (Array) p seq.translate.composition # amino acid compositions (Hash) p seq.translate.molecular_weight # calculating molecular weight (Float) ! puts seq.complement.translate # translation of complemental strand The p, print and puts methods are standard Ruby ways of outputting to the screen. If you want to know more about standard Ruby commands you ! can use the 'ri' command on the command line (or the help command in ! Windows). For example % ri p *************** *** 97,109 **** >a ! So when using String methods, you should subtract 1 from positions conventionally used in biology. (subseq method returns nil if you specify positions smaller than or equal to 0 for either one of the ! "from" or "to".) (TRANSLATOR'S NOTE: the text in Japanese is something wrong?) (EDITOR'S NOTE: should 'subseq' not throw an exception instead?) ! The window_search(window_size, step_size) method shows a typical Ruby way of writing conscise and clear code using 'closures'. Each sliding --- 97,109 ---- >a ! So when using String methods, you should subtract 1 from positions conventionally used in biology. (subseq method returns nil if you specify positions smaller than or equal to 0 for either one of the ! "from" or "to".) (TRANSLATOR'S NOTE: the text in Japanese is something wrong?) (EDITOR'S NOTE: should 'subseq' not throw an exception instead?) ! The window_search(window_size, step_size) method shows a typical Ruby way of writing conscise and clear code using 'closures'. Each sliding *************** *** 163,174 **** In most cases, sequences are read from files or retrieved from databases. For example: ! require 'bio' ! input_seq = ARGF.read # reads all files in arguments ! my_naseq = Bio::Sequence::NA.new(input_seq) my_aaseq = my_naseq.translate ! puts my_aaseq --- 163,174 ---- In most cases, sequences are read from files or retrieved from databases. For example: ! require 'bio' ! input_seq = ARGF.read # reads all files in arguments ! my_naseq = Bio::Sequence::NA.new(input_seq) my_aaseq = my_naseq.translate ! puts my_aaseq *************** *** 185,189 **** % ruby na2aa.rb my_naseq.txt ! Outputs VAIFPKAMTGAKNQSSDICLMPHVGLIRRGQRRIRHLVQMSDAA* --- 185,189 ---- % ruby na2aa.rb my_naseq.txt ! Outputs VAIFPKAMTGAKNQSSDICLMPHVGLIRRGQRRIRHLVQMSDAA* *************** *** 209,219 **** #!/usr/bin/env ruby ! require 'bio' ! ! # Read all lines from STDIN split by the GenBank delimiter while entry = gets(Bio::GenBank::DELIMITER) gb = Bio::GenBank.new(entry) # creates GenBank object ! print ">#{gb.accession} " # Accession puts gb.definition # Definition --- 209,219 ---- #!/usr/bin/env ruby ! require 'bio' ! ! # Read all lines from STDIN split by the GenBank delimiter while entry = gets(Bio::GenBank::DELIMITER) gb = Bio::GenBank.new(entry) # creates GenBank object ! print ">#{gb.accession} " # Accession puts gb.definition # Definition *************** *** 226,236 **** #!/usr/bin/env ruby ! require 'bio' ! ff = Bio::FlatFile.new(Bio::GenBank, ARGF) ff.each_entry do |gb| definition = "#{gb.accession} #{gb.definition}" ! puts gb.naseq.to_fasta(definition, 60) end --- 226,236 ---- #!/usr/bin/env ruby ! require 'bio' ! ff = Bio::FlatFile.new(Bio::GenBank, ARGF) ff.each_entry do |gb| definition = "#{gb.accession} #{gb.definition}" ! puts gb.naseq.to_fasta(definition, 60) end *************** *** 238,244 **** #!/usr/bin/env ruby ! require 'bio' ! ff = Bio::FlatFile.new(Bio::FastaFormat, ARGF) ff.each_entry do |f| --- 238,244 ---- #!/usr/bin/env ruby ! require 'bio' ! ff = Bio::FlatFile.new(Bio::FastaFormat, ARGF) ff.each_entry do |f| *************** *** 254,264 **** #!/usr/bin/env ruby ! require 'bio' ! ff = Bio::GenBank.open("gbvrl1.seq") ff.each_entry do |gb| definition = "#{gb.accession} #{gb.definition}" ! puts gb.naseq.to_fasta(definition, 60) end --- 254,264 ---- #!/usr/bin/env ruby ! require 'bio' ! ff = Bio::GenBank.open("gbvrl1.seq") ff.each_entry do |gb| definition = "#{gb.accession} #{gb.definition}" ! puts gb.naseq.to_fasta(definition, 60) end *************** *** 270,276 **** #!/usr/bin/env ruby ! require 'bio' ! ff = Bio::FlatFile.new(Bio::GenBank, ARGF) --- 270,276 ---- #!/usr/bin/env ruby ! require 'bio' ! ff = Bio::FlatFile.new(Bio::GenBank, ARGF) *************** *** 280,288 **** # shows accession and organism puts "# #{gb.accession} - #{gb.organism}" ! # iterates over each element in 'features' ! gb.features.each do |feature| position = feature.position ! hash = feature.assoc # put into Hash # skips the entry if "/translation=" is not found --- 280,288 ---- # shows accession and organism puts "# #{gb.accession} - #{gb.organism}" ! # iterates over each element in 'features' ! gb.features.each do |feature| position = feature.position ! hash = feature.assoc # put into Hash # skips the entry if "/translation=" is not found *************** *** 317,325 **** Bio::Sequence#splicing splices subsequence from nucleic acid sequence according to location information used in GenBank, EMBL and DDBJ. ! (TRANSLATOR'S NOTE: EMBL and DDBJ should be added in Japanese document.) When the specified translation table is different from the default (universal), or when the first codon is not "atg" or the protein ! contains selenocysteine, the two amino acid sequences will differ. (TRANSLATOR'S NOTE: Some cases are added when two amino acid sequences --- 317,325 ---- Bio::Sequence#splicing splices subsequence from nucleic acid sequence according to location information used in GenBank, EMBL and DDBJ. ! (TRANSLATOR'S NOTE: EMBL and DDBJ should be added in Japanese document.) When the specified translation table is different from the default (universal), or when the first codon is not "atg" or the protein ! contains selenocysteine, the two amino acid sequences will differ. (TRANSLATOR'S NOTE: Some cases are added when two amino acid sequences *************** *** 349,352 **** --- 349,392 ---- (EDITOR's NOTE: why use STRINGs here?) + === Alignments (Bio::Alignment) + + Bio::Alignment class in bio/alignment.rb is a container class like Ruby's Hash, + Array and BioPerl's Bio::SimpleAlign. A very simple example is: + + require 'bio' + + seqs = [ 'atgca', 'aagca', 'acgca', 'acgcg' ] + seqs = seqs.collect{ |x| Bio::Sequence::NA.new(x) } + + # creates alignment object + a = Bio::Alignment.new(seqs) + + # shows consensus sequence + p a.consensus # ==> "a?gc?" + + # shows IUPAC consensus + p a.consensus_iupac # ==> "ahgcr" + + # iterates over each seq + a.each { |x| p x } + # ==> + # "atgca" + # "aagca" + # "acgca" + # "acgcg" + # iterates over each site + a.each_site { |x| p x } + # ==> + # ["a", "a", "a", "a"] + # ["t", "a", "c", "c"] + # ["g", "g", "g", "g"] + # ["c", "c", "c", "c"] + # ["a", "a", "a", "g"] + + # doing alignment by using CLUSTAL W. + # clustalw command must be installed. + factory = Bio::ClustalW.new + a2 = a.do_align(factory) + === More databases *************** *** 356,360 **** In many cases the Bio::DatabaseClass acts as a factory pattern ! and recognises the database type automatically - returning a parsed object. For example using Bio::FlatFile --- 396,400 ---- In many cases the Bio::DatabaseClass acts as a factory pattern ! and recognises the database type automatically - returning a parsed object. For example using Bio::FlatFile *************** *** 366,375 **** Isn't it wonderful that Bio::FlatFile automagically recognizes each ! database class? #!/usr/bin/env ruby ! require 'bio' ! ff = Bio::FlatFile.auto(ARGF) ff.each_entry do |entry| --- 406,415 ---- Isn't it wonderful that Bio::FlatFile automagically recognizes each ! database class? #!/usr/bin/env ruby ! require 'bio' ! ff = Bio::FlatFile.auto(ARGF) ff.each_entry do |entry| *************** *** 416,437 **** #!/usr/bin/env ruby ! require 'bio' ! # Creates FASTA factory object ("ssearch" instead of "fasta34" can also work) factory = Bio::Fasta.local('fasta34', ARGV.pop) (EDITOR's NOTE: not consistent pop command) ! # Reads FASTA-formatted files (TRANSLATOR'S NOTE: something wrong in Japanese text) ff = Bio::FlatFile.new(Bio::FastaFormat, ARGF) ! # Iterates over each entry. the variable "entry" is a Bio::FastaFormat object. ff.each do |entry| # shows definition line (begins with '>') to the standard error output $stderr.puts "Searching ... " + entry.definition ! # executes homology search. Returns Bio::Fasta::Report object. report = factory.query(entry) ! # Iterates over each hit report.each do |hit| --- 456,477 ---- #!/usr/bin/env ruby ! require 'bio' ! # Creates FASTA factory object ("ssearch" instead of "fasta34" can also work) factory = Bio::Fasta.local('fasta34', ARGV.pop) (EDITOR's NOTE: not consistent pop command) ! # Reads FASTA-formatted files (TRANSLATOR'S NOTE: something wrong in Japanese text) ff = Bio::FlatFile.new(Bio::FastaFormat, ARGF) ! # Iterates over each entry. the variable "entry" is a Bio::FastaFormat object. ff.each do |entry| # shows definition line (begins with '>') to the standard error output $stderr.puts "Searching ... " + entry.definition ! # executes homology search. Returns Bio::Fasta::Report object. report = factory.query(entry) ! # Iterates over each hit report.each do |hit| *************** *** 534,538 **** program = 'fasta' database = 'genes' ! factory = Bio::Fasta.remote(program, database) --- 574,578 ---- program = 'fasta' database = 'genes' ! factory = Bio::Fasta.remote(program, database) *************** *** 548,552 **** # create BLAST factory object ! factory = Bio::Blast.local('blastp', ARGV.pop) For remote execution of BLAST in GenomeNet, Bio::Blast.remote is used. --- 588,592 ---- # create BLAST factory object ! factory = Bio::Blast.local('blastp', ARGV.pop) For remote execution of BLAST in GenomeNet, Bio::Blast.remote is used. *************** *** 581,585 **** puts hit.midline # middle line string of alignment of homologous region (*) puts hit.target_seq # hit sequence (TRANSLATOR'S NOTE: sequence of homologous region of query sequence) ! puts hit.evalue # E-value puts hit.identity # % identity --- 621,625 ---- puts hit.midline # middle line string of alignment of homologous region (*) puts hit.target_seq # hit sequence (TRANSLATOR'S NOTE: sequence of homologous region of query sequence) ! puts hit.evalue # E-value puts hit.identity # % identity *************** *** 622,626 **** #!/usr/bin/env ruby ! require 'bio' --- 662,666 ---- #!/usr/bin/env ruby ! require 'bio' *************** *** 670,676 **** #!/usr/bin/env ruby ! require 'bio' ! ARGV.each do |id| entry = Bio::PubMed.query(id) # searches PubMed and get entry --- 710,716 ---- #!/usr/bin/env ruby ! require 'bio' ! ARGV.each do |id| entry = Bio::PubMed.query(id) # searches PubMed and get entry *************** *** 691,703 **** #!/usr/bin/env ruby ! require 'bio' ! # Concatinates argument keyword list to a string keywords = ARGV.join(' ') ! # PubMed keyword search entries = Bio::PubMed.search(keywords) ! entries.each do |entry| medline = Bio::MEDLINE.new(entry) # creates Bio::MEDLINE object from text --- 731,743 ---- #!/usr/bin/env ruby ! require 'bio' ! # Concatinates argument keyword list to a string keywords = ARGV.join(' ') ! # PubMed keyword search entries = Bio::PubMed.search(keywords) ! entries.each do |entry| medline = Bio::MEDLINE.new(entry) # creates Bio::MEDLINE object from text *************** *** 724,739 **** #!/usr/bin/env ruby ! require 'bio' ! keywords = ARGV.join(' ') ! options = { 'maxdate' => '2003/05/31', 'retmax' => 1000, } ! entries = Bio::PubMed.esearch(keywords, options) ! Bio::PubMed.efetch(entries).each do |entry| medline = Bio::MEDLINE.new(entry) --- 764,779 ---- #!/usr/bin/env ruby ! require 'bio' ! keywords = ARGV.join(' ') ! options = { 'maxdate' => '2003/05/31', 'retmax' => 1000, } ! entries = Bio::PubMed.esearch(keywords, options) ! Bio::PubMed.efetch(entries).each do |entry| medline = Bio::MEDLINE.new(entry) *************** *** 761,765 **** The BibTeX can be used with Tex or LaTeX to form bibliography ! information with your journal article. For more information on BibTex see (EDITORS NOTE: insert URL). A quick example: --- 801,805 ---- The BibTeX can be used with Tex or LaTeX to form bibliography ! information with your journal article. For more information on BibTex see (EDITORS NOTE: insert URL). A quick example: *************** *** 782,786 **** Now, you get hoge.dvi and hoge.ps - the latter you can view any Postscript viewer. ! === Bio::Reference#bibitem --- 822,826 ---- Now, you get hoge.dvi and hoge.ps - the latter you can view any Postscript viewer. ! === Bio::Reference#bibitem *************** *** 854,859 **** * http://www.open-bio.org/registry/seqdatabase.ini ! Note that the last locaation refers to www.open-bio.org and is only used ! when all local configulation files are not available. In the current BioRuby implementation all local configulation files --- 894,899 ---- * http://www.open-bio.org/registry/seqdatabase.ini ! Note that the last locaation refers to www.open-bio.org and is only used ! when all local configulation files are not available. In the current BioRuby implementation all local configulation files *************** *** 905,909 **** # connects to the database "genbank" serv = reg.get_database('genbank') ! # gets entry of the ID entry = serv.get_by_id('AA2CG') --- 945,949 ---- # connects to the database "genbank" serv = reg.get_database('genbank') ! # gets entry of the ID entry = serv.get_by_id('AA2CG') *************** *** 911,915 **** The variable "serv" is a server object corresponding to the setting ! written in configuration files. The class of the object is one of Bio::SQL, Bio::Fetch, and so on. Note that Bio::Registry#get_database("name") returns nil if no database is found. --- 951,955 ---- The variable "serv" is a server object corresponding to the setting ! written in configuration files. The class of the object is one of Bio::SQL, Bio::Fetch, and so on. Note that Bio::Registry#get_database("name") returns nil if no database is found. *************** *** 923,927 **** these entries fast. There are two index types. index-flat is a simple index performing binary search without using an external library of Ruby. index-berkeleydb ! uses Berkeley DB for indexing - but requires installing bdb on your computer, as well as the BDB Ruby package. For creating the index itself, you can use br_bioflat.rb command bundled with BioRuby. --- 963,967 ---- these entries fast. There are two index types. index-flat is a simple index performing binary search without using an external library of Ruby. index-berkeleydb ! uses Berkeley DB for indexing - but requires installing bdb on your computer, as well as the BDB Ruby package. For creating the index itself, you can use br_bioflat.rb command bundled with BioRuby. *************** *** 1008,1023 **** #!/usr/bin/env ruby ! require 'bio' entry = Bio::Fetch.query('hal', 'VNG1467G') aaseq = Bio::KEGG::GENES.new(entry).aaseq ! entry = Bio::Fetch.query('aax1', 'BURA740101') helix = Bio::AAindex1.new(entry).index ! position = 1 win_size = 15 ! aaseq.window_search(win_size) do |subseq| score = subseq.total(helix) --- 1048,1063 ---- #!/usr/bin/env ruby ! require 'bio' entry = Bio::Fetch.query('hal', 'VNG1467G') aaseq = Bio::KEGG::GENES.new(entry).aaseq ! entry = Bio::Fetch.query('aax1', 'BURA740101') helix = Bio::AAindex1.new(entry).index ! position = 1 win_size = 15 ! aaseq.window_search(win_size) do |subseq| score = subseq.total(helix) *************** *** 1076,1080 **** At this point for using BioRuby no additional libraries are needed. ! This may change, so keep an eye on the Bioruby website. Also when a package is missing BioRuby should show an informative message. --- 1116,1120 ---- At this point for using BioRuby no additional libraries are needed. ! This may change, so keep an eye on the Bioruby website. Also when a package is missing BioRuby should show an informative message.