From nakao at pub.open-bio.org Thu Feb 2 11:30:32 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 02 Feb 2006 16:30:32 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io ddbjxml.rb,1.9,1.10 Message-ID: <200602021630.k12GUWVL001709@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory pub.open-bio.org:/tmp/cvs-serv1699/lib/bio/io Modified Files: ddbjxml.rb Log Message: * Updated RDoc. Index: ddbjxml.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/ddbjxml.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ddbjxml.rb 26 Nov 2005 09:37:11 -0000 1.9 --- ddbjxml.rb 2 Feb 2006 16:30:29 -0000 1.10 *************** *** 37,41 **** # = Bio::DDBJ::XML # ! # Accessing the DDBJ web services at # # * http://xml.nig.ac.jp/ --- 37,41 ---- # = Bio::DDBJ::XML # ! # Accessing the DDBJ web services. # # * http://xml.nig.ac.jp/ *************** *** 46,77 **** BASE_URI = "http://xml.nig.ac.jp/wsdl/" ! # = Blast # ! # BLAST Database Search # # * http://xml.nig.ac.jp/doc/Blast.txt # ! # == Examples # ! # serv = Bio::DDBJ::XML::Blast.new ! # query = "MSSRIARALALVVTLLHLTRLALSTCPAACHCPLEAPKCAPGVGLVRDGCGCCKVCAKQL" # ! # report = serv.searchSimple('blastp', 'SWISS', query) ! # Bio::Blast::Default::Report.new(report).each_hit do |hit| ! # hit.hsps.find_all {|x| x.evalue < 0.1 }.each do |hsp| ! # p [hsps.evalue, hsps.identity, hsps.definition] ! # end ! # end ! # ! # puts serv.searchParam('tblastn', 'ddbjvrl', query, '-m 8') # ! # == WSDL Methods # ! # * searchSimple(program, database, query) # Returns a blast report in the default format. ! # * searchParam(program, database, query, param) # Blasts with param and returns a blast report. # ! # == References # # * http://xml.nig.ac.jp/doc/Blast.txt --- 46,85 ---- BASE_URI = "http://xml.nig.ac.jp/wsdl/" ! # === Description # ! # DDBJ XML BLAST Database Search # # * http://xml.nig.ac.jp/doc/Blast.txt # ! # === Examples # ! # serv = Bio::DDBJ::XML::Blast.new ! # program = 'blastp' ! # database = 'SWISS' ! # query = "MSSRIARALALVVTLLHLTRLALSTCPAACHCPLEAPKCAPGVGLVRDGCGCCKVCAKQL" ! # ! # report = serv.searchSimple(program, database, query) ! # Bio::Blast::Default::Report.new(report).each_hit do |hit| ! # hit.hsps.find_all {|x| x.evalue < 0.1 }.each do |hsp| ! # p [hsps.evalue, hsps.identity, hsps.definition] ! # end ! # end # ! # program = 'tblastn' ! # database = 'ddbjvrl' ! # param = '-m 8 -e 0.001' ! # puts serv.searchParam(program, database, query, param) # ! # === WSDL Methods # ! # ==== searchSimple(program, database, query) ! # # Returns a blast report in the default format. ! # ! # ==== searchParam(program, database, query, param) ! # # Blasts with param and returns a blast report. # ! # === References # # * http://xml.nig.ac.jp/doc/Blast.txt *************** *** 79,82 **** --- 87,92 ---- class Blast < XML SERVER_URI = BASE_URI + "Blast.wsdl" + + # returns a Bio::DDBJ::XML::Blast object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 85,89 **** ! # == ClustalW # # Multiple seaquece alignment using ClustalW. --- 95,99 ---- ! # === ClustalW # # Multiple seaquece alignment using ClustalW. *************** *** 91,95 **** # * http://xml.nig.ac.jp/doc/ClustalW.txt # ! # == Examples # # serv = Bio::DDBJ::XML::ClustalW.new --- 101,105 ---- # * http://xml.nig.ac.jp/doc/ClustalW.txt # ! # === Examples # # serv = Bio::DDBJ::XML::ClustalW.new *************** *** 112,121 **** # puts serv.analyzeParam(query, '-align -matrix=blosum') # ! # == WSDL Methods # ! # * analyzeSimple(query) ! # * analyzeParam(query, param) # ! # == References # # * http://xml.nig.ac.jp/doc/ClustalW.txt --- 122,131 ---- # puts serv.analyzeParam(query, '-align -matrix=blosum') # ! # === WSDL Methods # ! # ==== analyzeSimple(query) ! # ==== analyzeParam(query, param) # ! # === References # # * http://xml.nig.ac.jp/doc/ClustalW.txt *************** *** 123,126 **** --- 133,138 ---- class ClustalW < XML SERVER_URI = BASE_URI + "ClustalW.wsdl" + + # returns a Bio::DDBJ::XML::ClustalW object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 129,133 **** ! # = DDBJ # # Retrieves a sequence entry from the DDBJ DNA Data Bank Japan. --- 141,145 ---- ! # == DDBJ # # Retrieves a sequence entry from the DDBJ DNA Data Bank Japan. *************** *** 135,139 **** # * http://xml.nig.ac.jp/doc/DDBJ.txt # ! # == Examples # # serv = Bio::DDBJ::XML::DDBJ.new --- 147,151 ---- # * http://xml.nig.ac.jp/doc/DDBJ.txt # ! # === Examples # # serv = Bio::DDBJ::XML::DDBJ.new *************** *** 145,158 **** # puts serv.getRelatedFeaturesSeq('AL121903', '59000', '64000') # ! # == WSDL Methods # ! # * getFFEntry(accession) ! # * getXMLEntry(accession) ! # * getFeatureInfo(accession, feature) ! # * getAllFeatures(accession) ! # * getRelatedFeatures(accession, start, stop) ! # * getRelatedFeaturesSeq(accession, start, stop) # ! # == References # # * http://xml.nig.ac.jp/doc/DDBJ.txt --- 157,170 ---- # puts serv.getRelatedFeaturesSeq('AL121903', '59000', '64000') # ! # === WSDL Methods # ! # ==== getFFEntry(accession) ! # ==== getXMLEntry(accession) ! # ==== getFeatureInfo(accession, feature) ! # ==== getAllFeatures(accession) ! # ==== getRelatedFeatures(accession, start, stop) ! # ==== getRelatedFeaturesSeq(accession, start, stop) # ! # === References # # * http://xml.nig.ac.jp/doc/DDBJ.txt *************** *** 160,163 **** --- 172,177 ---- class DDBJ < XML SERVER_URI = BASE_URI + "DDBJ.wsdl" + + # returns a Bio::DDBJ::XML::DDBJ object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 166,170 **** ! # = Fasta # # Searching database using the Fasta package. --- 180,184 ---- ! # == Fasta # # Searching database using the Fasta package. *************** *** 172,176 **** # * http://xml.nig.ac.jp/doc/Fasta.txt # ! # == Examples # # serv = Bio::DDBJ::XML::Fasta.new --- 186,190 ---- # * http://xml.nig.ac.jp/doc/Fasta.txt # ! # === Examples # # serv = Bio::DDBJ::XML::Fasta.new *************** *** 181,190 **** # puts serv.searchParam('fastx34_t', 'PDB', query, '-n') # ! # == WSDL Methods # ! # * searchSimple(program, database, query) ! # * searchParam(program, database, query, param) # ! # == References # # * http://xml.nig.ac.jp/doc/Fasta.txt --- 195,204 ---- # puts serv.searchParam('fastx34_t', 'PDB', query, '-n') # ! # === WSDL Methods # ! # ==== searchSimple(program, database, query) ! # ==== searchParam(program, database, query, param) # ! # === References # # * http://xml.nig.ac.jp/doc/Fasta.txt *************** *** 192,195 **** --- 206,211 ---- class Fasta < XML SERVER_URI = BASE_URI + "Fasta.wsdl" + + # returns a Bio::DDBJ::XML::Fasta object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 198,202 **** ! # = GetEntry # # Retrieves database entries. --- 214,218 ---- ! # == GetEntry # # Retrieves database entries. *************** *** 204,208 **** # * http://xml.nig.ac.jp/doc/GetEntry.txt # ! # == Examples # # serv = Bio::DDBJ::XML::GetEntry.new --- 220,224 ---- # * http://xml.nig.ac.jp/doc/GetEntry.txt # ! # === Examples # # serv = Bio::DDBJ::XML::GetEntry.new *************** *** 210,246 **** # puts serv. getPDBEntry('1AAR') # ! # == WSDL Methods # ! # * getEntry(database, var, param1, param2) ! # * getEntry(database, var) ! # * getDDBJEntry(accession) ! # * getDDBJCONEntry(accession) ! # * getDDBJVerEntry(accession) ! # * getLocus_DDBJEntry(locus) ! # * getGene_DDBJEntry(gene) ! # * getProd_DDBJEntry(products) ! # * getPID_DDBJEntry(pid) ! # * getClone_DDBJEntry(clone) ! # * getXML_DDBJEntry(accession) ! # * getEMBLEntry(accession) ! # * getSWISSEntry(accession) ! # * getPIREntry(accession) ! # * getPRFEntry(accession) ! # * getPDBEntry(accession) ! # * getQVEntry(accession) ! # * getDADEntry(accession) ! # * getPID_DADEntry(pid) ! # * getFASTA_DDBJEntry(accession) ! # * getFASTA_DDBJCONEntry(accession) ! # * getFASTA_DDBJVerEntry(accession) ! # * getFASTA_DDBJSeqEntry(accession, start, end) ! # * getFASTA_DADEntry(accession) ! # * getFASTA_PIREntry(accession) ! # * getFASTA_SWISSEntry(accession) ! # * getFASTA_PDBEntry(accession) ! # * getFASTA_PRFEntry(accession) ! # * getFASTA_CDSEntry(accession) # ! # == References # # * http://xml.nig.ac.jp/doc/GetEntry.txt --- 226,262 ---- # puts serv. getPDBEntry('1AAR') # ! # === WSDL Methods # ! # ==== getEntry(database, var, param1, param2) ! # ==== getEntry(database, var) ! # ==== getDDBJEntry(accession) ! # ==== getDDBJCONEntry(accession) ! # ==== getDDBJVerEntry(accession) ! # ==== getLocus_DDBJEntry(locus) ! # ==== getGene_DDBJEntry(gene) ! # ==== getProd_DDBJEntry(products) ! # ==== getPID_DDBJEntry(pid) ! # ==== getClone_DDBJEntry(clone) ! # ==== getXML_DDBJEntry(accession) ! # ==== getEMBLEntry(accession) ! # ==== getSWISSEntry(accession) ! # ==== getPIREntry(accession) ! # ==== getPRFEntry(accession) ! # ==== getPDBEntry(accession) ! # ==== getQVEntry(accession) ! # ==== getDADEntry(accession) ! # ==== getPID_DADEntry(pid) ! # ==== getFASTA_DDBJEntry(accession) ! # ==== getFASTA_DDBJCONEntry(accession) ! # ==== getFASTA_DDBJVerEntry(accession) ! # ==== getFASTA_DDBJSeqEntry(accession, start, end) ! # ==== getFASTA_DADEntry(accession) ! # ==== getFASTA_PIREntry(accession) ! # ==== getFASTA_SWISSEntry(accession) ! # ==== getFASTA_PDBEntry(accession) ! # ==== getFASTA_PRFEntry(accession) ! # ==== getFASTA_CDSEntry(accession) # ! # === References # # * http://xml.nig.ac.jp/doc/GetEntry.txt *************** *** 248,251 **** --- 264,269 ---- class GetEntry < XML SERVER_URI = BASE_URI + "GetEntry.wsdl" + + # returns a Bio::DDBJ::XML::GetEntry object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 254,258 **** ! # = Gib # # Genome Information broker --- 272,276 ---- ! # === Gib # # Genome Information broker *************** *** 260,264 **** # * http://xml.nig.ac.jp/doc/Gib.txt # ! # == Examples # # serv = Bio::DDBJ::XML::Gib.new --- 278,282 ---- # * http://xml.nig.ac.jp/doc/Gib.txt # ! # === Examples # # serv = Bio::DDBJ::XML::Gib.new *************** *** 275,293 **** # puts serv.getFastaFile('Nost_PCC7120:pCC7120zeta', 'cdsaa') # ! # == WSDL Methods # ! # * getOrganismList ! # * getChIDList ! # * getOrganismNameFromChid(chid) ! # * getChIDFromOrganismName(orgName) ! # * getAccession(chid) ! # * getPieceNumber(chid) ! # * getDivision(chid) ! # * getType(chid) ! # * getFlatFile(chid) ! # * getFastaFile(chid, type) ! # * getCDS(chid) # ! # == References # # * http://xml.nig.ac.jp/doc/Gib.txt --- 293,311 ---- # puts serv.getFastaFile('Nost_PCC7120:pCC7120zeta', 'cdsaa') # ! # === WSDL Methods # ! # ==== getOrganismList ! # ==== getChIDList ! # ==== getOrganismNameFromChid(chid) ! # ==== getChIDFromOrganismName(orgName) ! # ==== getAccession(chid) ! # ==== getPieceNumber(chid) ! # ==== getDivision(chid) ! # ==== getType(chid) ! # ==== getFlatFile(chid) ! # ==== getFastaFile(chid, type) ! # ==== getCDS(chid) # ! # === References # # * http://xml.nig.ac.jp/doc/Gib.txt *************** *** 295,298 **** --- 313,318 ---- class Gib < XML SERVER_URI = BASE_URI + "Gib.wsdl" + + # returns a Bio::DDBJ::XML::Gib object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 301,305 **** ! # = Gtop # # GTOP: Gene to protein. --- 321,325 ---- ! # === Gtop # # GTOP: Gene to protein. *************** *** 307,322 **** # * http://xml.nig.ac.jp/doc/Gtop.txt # ! # == Examples # ! # serv = Bio::DDBJ::XML::Gtop.new ! # puts serv.getOrganismList ! # puts serv.getMasterInfo('thrA', 'ecol0') # ! # == WSDL Methods # ! # * getOrganismList ! # * getMasterInfo(orfID, organism) # ! # == References # # * http://xml.nig.ac.jp/doc/Gtop.txt --- 327,342 ---- # * http://xml.nig.ac.jp/doc/Gtop.txt # ! # === Examples # ! # serv = Bio::DDBJ::XML::Gtop.new ! # puts serv.getOrganismList ! # puts serv.getMasterInfo('thrA', 'ecol0') # ! # === WSDL Methods # ! # ==== getOrganismList ! # ==== getMasterInfo(orfID, organism) # ! # === References # # * http://xml.nig.ac.jp/doc/Gtop.txt *************** *** 324,327 **** --- 344,349 ---- class Gtop < XML SERVER_URI = BASE_URI + "Gtop.wsdl" + + # returns a Bio::DDBJ::XML::Gtop object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 330,334 **** ! # == PML # # Variation database --- 352,356 ---- ! # === PML # # Variation database *************** *** 336,354 **** # * http://xml.nig.ac.jp/doc/PML.txt # ! # == Examples # ! # serv = Bio::DDBJ::XML::PML.new ! # puts serv.getVariation('1') # ! # == WSDL Methods # ! # * searchVariation(field, query, order) ! # * searchVariationSimple(field, query) ! # * searchFrequency(field, query, order) ! # * searchFrequencySimple(field, query) ! # * getVariation(variation_id) ! # * getFrequency(variation_id, population_id) # ! # == References # # * http://xml.nig.ac.jp/doc/PML.txt --- 358,376 ---- # * http://xml.nig.ac.jp/doc/PML.txt # ! # === Examples # ! # serv = Bio::DDBJ::XML::PML.new ! # puts serv.getVariation('1') # ! # === WSDL Methods # ! # ==== searchVariation(field, query, order) ! # ==== searchVariationSimple(field, query) ! # ==== searchFrequency(field, query, order) ! # ==== searchFrequencySimple(field, query) ! # ==== getVariation(variation_id) ! # ==== getFrequency(variation_id, population_id) # ! # === References # # * http://xml.nig.ac.jp/doc/PML.txt *************** *** 356,359 **** --- 378,383 ---- class PML < XML SERVER_URI = BASE_URI + "PML.wsdl" + + # returns a Bio::DDBJ::XML::PML object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 362,366 **** ! # = SRS # # Sequence Retrieving System --- 386,390 ---- ! # === SRS # # Sequence Retrieving System *************** *** 368,383 **** # * http://xml.nig.ac.jp/doc/SRS.txt # ! # == Examples # ! # serv = Bio::DDBJ::XML::SRS.new ! # puts serv.searchSimple('[pathway-des:sugar]') ! # puts serv.searchParam('[swissprot-des:cohesin]', '-f seq -sf fasta') # ! # == WSDL Methods # ! # * searchSimple(query) ! # * searchParam(query, param) # ! # == Examples # # * http://xml.nig.ac.jp/doc/SRS.txt --- 392,407 ---- # * http://xml.nig.ac.jp/doc/SRS.txt # ! # === Examples # ! # serv = Bio::DDBJ::XML::SRS.new ! # puts serv.searchSimple('[pathway-des:sugar]') ! # puts serv.searchParam('[swissprot-des:cohesin]', '-f seq -sf fasta') # ! # === WSDL Methods # ! # ==== searchSimple(query) ! # ==== searchParam(query, param) # ! # === Examples # # * http://xml.nig.ac.jp/doc/SRS.txt *************** *** 385,388 **** --- 409,414 ---- class SRS < XML SERVER_URI = BASE_URI + "SRS.wsdl" + + # returns a Bio::DDBJ::XML::SRS object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 391,395 **** ! # = TxSearch # # Searching taxonomy information. --- 417,421 ---- ! # === TxSearch # # Searching taxonomy information. *************** *** 397,421 **** # * http://xml.nig.ac.jp/doc/TxSearch.txt # ! # == Examples # ! # serv = Bio::DDBJ::XML::TxSearch.new ! # puts serv.searchSimple('*coli') ! # puts serv.searchSimple('*tardigrada*') ! # puts serv.getTxId('Escherichia coli') ! # puts serv.getTxName('562') # ! # query = ["Campylobacter coli", "Escherichia coli"].join("\n") ! # rank = ["family", "genus"].join("\n") ! # puts serv.searchLineage(query, rank, 'Bacteria') # ! # == WSDL Methdos # ! # * searchSimple(tx_Name) ! # * searchParam(tx_Name, tx_Clas, tx_Rank, tx_Rmax, tx_Dcls) ! # * getTxId(tx_Name) ! # * getTxName(tx_Id) ! # * searchLineage(query, ranks, superkingdom) # ! # == References # # * http://xml.nig.ac.jp/doc/TxSearch.txt --- 423,447 ---- # * http://xml.nig.ac.jp/doc/TxSearch.txt # ! # === Examples # ! # serv = Bio::DDBJ::XML::TxSearch.new ! # puts serv.searchSimple('*coli') ! # puts serv.searchSimple('*tardigrada*') ! # puts serv.getTxId('Escherichia coli') ! # puts serv.getTxName('562') # ! # query = ["Campylobacter coli", "Escherichia coli"].join("\n") ! # rank = ["family", "genus"].join("\n") ! # puts serv.searchLineage(query, rank, 'Bacteria') # ! # === WSDL Methdos # ! # ==== searchSimple(tx_Name) ! # ==== searchParam(tx_Name, tx_Clas, tx_Rank, tx_Rmax, tx_Dcls) ! # ==== getTxId(tx_Name) ! # ==== getTxName(tx_Id) ! # ==== searchLineage(query, ranks, superkingdom) # ! # === References # # * http://xml.nig.ac.jp/doc/TxSearch.txt *************** *** 423,426 **** --- 449,454 ---- class TxSearch < XML SERVER_URI = BASE_URI + "TxSearch.wsdl" + + # returns a Bio::DDBJ::XML::TxSearch object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) From nakao at pub.open-bio.org Thu Feb 2 12:08:39 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 02 Feb 2006 17:08:39 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/hmmer report.rb,1.9,1.10 Message-ID: <200602021708.k12H8dVL001851@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/hmmer In directory pub.open-bio.org:/tmp/cvs-serv1837/lib/bio/appl/hmmer Modified Files: report.rb Log Message: * Updated RDoc. Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/hmmer/report.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** report.rb 31 Oct 2005 09:12:03 -0000 1.9 --- report.rb 2 Feb 2006 17:08:36 -0000 1.10 *************** *** 1,7 **** # ! # bio/appl/hmmer/report.rb - hmmsearch, hmmpfam parserer # ! # Copyright (C) 2002 Hiroshi Suga ! # Copyright (C) 2005 Masashi Fujita # # This library is free software; you can redistribute it and/or --- 1,43 ---- # ! # = bio/appl/hmmer/report.rb - hmmsearch, hmmpfam parserer [...999 lines suppressed...] ! --- Bio::HMMER::Report::Hsp#query_from ! --- Bio::HMMER::Report::Hsp#query_to ! --- Bio::HMMER::Report::Hsp#target_seq ! --- Bio::HMMER::Report::Hsp#target_from ! --- Bio::HMMER::Report::Hsp#target_to ! ! --- Bio::HMMER::Report::Hsp#csline ! --- Bio::HMMER::Report::Hsp#rfline - =end --- 694,701 ---- print "query_to : ".rjust(indent) p hsp.query_to # hmm_t, seq_t ! end end ! end From nakao at pub.open-bio.org Thu Feb 2 12:08:38 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 02 Feb 2006 17:08:38 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl hmmer.rb,1.4,1.5 Message-ID: <200602021708.k12H8cVL001849@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv1837/lib/bio/appl Modified Files: hmmer.rb Log Message: * Updated RDoc. Index: hmmer.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/hmmer.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** hmmer.rb 26 Sep 2005 13:00:04 -0000 1.4 --- hmmer.rb 2 Feb 2006 17:08:36 -0000 1.5 *************** *** 1,6 **** # ! # bio/appl/hmmer.rb - HMMER wrapper # ! # Copyright (C) 2002 KATAYAMA Toshiaki # # This library is free software; you can redistribute it and/or --- 1,31 ---- # ! # = bio/appl/hmmer.rb - HMMER wrapper # ! # Copyright:: Copyright (C) 2002 ! # KATAYAMA Toshiaki ! # Lisence:: LGPL ! # ! # $Id$ ! # ! # == Description ! # ! # A wrapper for the HMMER programs (hmmsearch or hmmpfam). ! # ! # == Examples ! # ! # require 'bio' ! # program = 'hmmsearch' # or 'hmmpfam' ! # hmmfile = 'test.hmm' ! # seqfile = 'test.faa' ! # ! # factory = Bio::HMMER.new(program, hmmfile, seqfile) ! # p factory.query ! # ! # == References ! # ! # * HMMER ! # http://hmmer.wustl.edu/ ! # ! #-- # # This library is free software; you can redistribute it and/or *************** *** 18,22 **** # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! # $Id$ # --- 43,47 ---- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! #++ # *************** *** 26,82 **** module Bio ! class HMMER ! ! autoload :Report, 'bio/appl/hmmer/report' ! include Bio::Command::Tools ! def initialize(program, hmmfile, seqfile, opt = []) ! @program = program ! @hmmfile = hmmfile ! @seqfile = seqfile ! @output = '' ! begin ! @options = opt.to_ary ! rescue NameError #NoMethodError ! # backward compatibility ! @options = Shellwords.shellwords(opt) ! end ! end ! attr_accessor :program, :hmmfile, :seqfile, :options ! attr_reader :output ! def option # backward compatibility ! make_command_line(@options) end - def option=(str) - # backward compatibility - @options = Shellwords.shellwords(str) - end ! def query ! cmd = [ @program, *@options ] ! cmd.concat([ @hmmfile, @seqfile ]) ! ! report = nil - @output = call_command_local(cmd, nil) - report = parse_result(@output) - - return report - end - private ! def parse_result(data) ! Report.new(data) ! end end ! end --- 51,150 ---- module Bio ! # A wapper for HMMER programs (hmmsearch or hmmpfam). ! # ! # === Examples ! # ! # require 'bio' ! # program = 'hmmsearch' # or 'hmmpfam' ! # hmmfile = 'test.hmm' ! # seqfile = 'test.faa' ! # ! # factory = Bio::HMMER.new(program, hmmfile, seqfile) ! # report = factory.query ! # report.class #=> Bio::HMMER::Report ! # ! # === References ! # ! # * HMMER ! # http://hmmer.wustl.edu/ ! # ! class HMMER ! autoload :Report, 'bio/appl/hmmer/report' ! include Bio::Command::Tools ! # Prgrams name. (hmmsearch or hmmpfam). ! attr_accessor :program ! ! # Name of hmmfile. ! attr_accessor :hmmfile ! ! # Name of seqfile. ! attr_accessor :seqfile ! ! # Command line options. ! attr_accessor :options ! ! # Shows the raw output from the hmmer search. ! attr_reader :output ! # Sets a program name, a profile hmm file name, a query sequence file name ! # and options in string. ! # ! # Program names: hmmsearch, hmmpfam ! # ! def initialize(program, hmmfile, seqfile, options = []) ! @program = program ! @hmmfile = hmmfile ! @seqfile = seqfile ! @output = '' ! ! begin ! @options = opt.to_ary ! rescue NameError #NoMethodError # backward compatibility ! @options = Shellwords.shellwords(options) end + end ! # Gets options by String. ! # backward compatibility. ! def option ! make_command_line(@options) ! end + # Sets options by String. + # backward compatibility. + def option=(str) + @options = Shellwords.shellwords(str) + end ! # Executes the hmmer search and returns the report ! # (Bio::HMMER::Report object). ! def query ! cmd = [ @program, *@options ] ! cmd.concat([ @hmmfile, @seqfile ]) ! ! report = nil ! ! @output = call_command_local(cmd, nil) ! report = parse_result(@output) ! ! return report ! end + private + + def parse_result(data) + Report.new(data) end ! ! end # class HMMER ! ! end # module Bio *************** *** 84,129 **** if __FILE__ == $0 ! begin ! require 'pp' ! alias p pp ! rescue ! end ! program = ARGV.shift # hmmsearch, hmmpfam hmmfile = ARGV.shift seqfile = ARGV.shift factory = Bio::HMMER.new(program, hmmfile, seqfile) ! p factory.query end - - - =begin - - = Bio::HMMER - - --- Bio::HMMER.new(program, hmmfile, seqfile, option = '') - --- Bio::HMMER#program - --- Bio::HMMER#hmmfile - --- Bio::HMMER#seqfile - --- Bio::HMMER#options - - Accessors for the factory. - - --- Bio::HMMER#option - --- Bio::HMMER#option=(str) - - Get/set options by string. - - --- Bio::HMMER#query - - Executes the hmmer search and returns Report object (Bio::HMMER::Report). - - --- Bio::HMMER#output - - Shows the raw output from hmmer search. - - =end - - --- 152,163 ---- if __FILE__ == $0 ! require 'pp' ! program = ARGV.shift # hmmsearch, hmmpfam hmmfile = ARGV.shift seqfile = ARGV.shift factory = Bio::HMMER.new(program, hmmfile, seqfile) ! pp factory.query end From nakao at pub.open-bio.org Thu Feb 2 12:09:22 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 02 Feb 2006 17:09:22 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl/hmmer - New directory Message-ID: <200602021709.k12H9MVL001880@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl/hmmer In directory pub.open-bio.org:/tmp/cvs-serv1870/test/unit/bio/appl/hmmer Log Message: Directory /home/repository/bioruby/bioruby/test/unit/bio/appl/hmmer added to the repository From nakao at pub.open-bio.org Thu Feb 2 12:10:10 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 02 Feb 2006 17:10:10 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl/hmmer test_report.rb, NONE, 1.1 Message-ID: <200602021710.k12HAAVL001912@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl/hmmer In directory pub.open-bio.org:/tmp/cvs-serv1897/test/unit/bio/appl/hmmer Added Files: test_report.rb Log Message: * Newly added. --- NEW FILE: test_report.rb --- # # test/unit/bio/appl/hmmer/test_report.rb - Unit test for Bio::HMMER::Report # # Copyright (C) 2006 Mitsuteru Nakao # # 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: test_report.rb,v 1.1 2006/02/02 17:10:08 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib'))).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/appl/hmmer/report' module Bio class TestHMMERReportData bioruby_root = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5)).cleanpath.to_s TestDataHMMER = Pathname.new(File.join(bioruby_root, 'test', 'data', 'HMMER')).cleanpath.to_s def self.hmmpfam File.open(File.join(TestDataHMMER, 'hmmpfam.out')).read end def self.output self.hmmpfam end def self.hmmsearch File.open(File.join(TestDataHMMER, 'hmmsearch.out')).read end end class TestHMMERReportClassMethods < Test::Unit::TestCase def test_reports_ary ary = Bio::HMMER.reports(Bio::TestHMMERReportData.output) assert_equal(Array, ary.class) end def test_reports_ary Bio::HMMER.reports(Bio::TestHMMERReportData.output).each do |report| assert_equal(Bio::HMMER::Report, report.class) end end end class TestHMMERReportConstants < Test::Unit::TestCase def test_rs assert_equal("\n//\n", Bio::HMMER::Report::RS) assert_equal("\n//\n", Bio::HMMER::Report::DELIMITER) end end class TestHMMERReportHmmpfam < Test::Unit::TestCase def setup @obj = Bio::HMMER::Report.new(Bio::TestHMMERReportData.hmmpfam) end def test_program assert_equal(Hash, @obj.program.class) assert_equal("hmmpfam - search one or more sequences against HMM database", @obj.program['name']) assert_equal("HMMER 2.3.2 (Oct 2003)", @obj.program['version']) assert_equal("Copyright (C) 1992-2003 HHMI/Washington University School of Medicine", @obj.program['copyright']) assert_equal("Freely distributed under the GNU General Public License (GPL)", @obj.program['license']) end def test_parameter assert_equal(Hash, @obj.parameter.class) assert_equal("/Users/nakao/Sites/iprscan/tmp/20050517/iprscan-20050517-16244071/chunk_1/iprscan-20050517-16244071.nocrc", @obj.parameter["Sequence file"]) assert_equal("/Users/nakao/Sites/iprscan/data/Pfam", @obj.parameter['HMM file']) end def test_query_info assert_equal(Hash, @obj.query_info.class) assert_equal("104K_THEPA", @obj.query_info["Query sequence"]) assert_equal("[none]", @obj.query_info["Accession"]) assert_equal("[none]", @obj.query_info["Description"]) end def test_hits assert_equal(Bio::HMMER::Report::Hit, @obj.hits.first.class) end def test_hsps assert_equal(Bio::HMMER::Report::Hsp, @obj.hsps.first.class) end def test_histogram assert_equal(nil, @obj.histogram) end def test_statistical_detail assert_equal(nil, @obj.statistical_detail) end def test_total_seq_searched assert_equal(nil, @obj.total_seq_searched) end def test_whole_seq_top_hits assert_equal(nil, @obj.whole_seq_top_hits) end def test_domain_top_hits assert_equal(nil, @obj.domain_top_hits) end def test_each @obj.each do |hit| assert_equal(Bio::HMMER::Report::Hit, hit.class) end end def test_each_hit @obj.each_hit do |hit| assert_equal(Bio::HMMER::Report::Hit, hit.class) end end end class TestHMMERReportHit < Test::Unit::TestCase def setup @obj = Bio::HMMER::Report.new(Bio::TestHMMERReportData.output).hits.first end def test_hit assert_equal(Bio::HMMER::Report::Hit, @obj.class) end def test_hsps assert_equal(Bio::HMMER::Report::Hsp, @obj.hsps.first.class) end def test_accession assert_equal("PF04385.4", @obj.accession) end def test_target_id assert_equal("PF04385.4", @obj.target_id) end def test_hit_id assert_equal("PF04385.4", @obj.hit_id) end def test_entry_id assert_equal("PF04385.4", @obj.entry_id) end def test_description assert_equal("Domain of unknown function, DUF529", @obj.description) end def test_definition assert_equal("Domain of unknown function, DUF529", @obj.definition) end def test_score assert_equal(259.3, @obj.score) end def test_bit_score assert_equal(259.3, @obj.bit_score) end def test_evalue assert_equal(6.6e-75, @obj.evalue) end def test_num assert_equal(4, @obj.num) end def test_each @obj.each do |hsp| assert_equal(Bio::HMMER::Report::Hsp, hsp.class) end end def test_each_hsp @obj.each_hsp do |hsp| assert_equal(Bio::HMMER::Report::Hsp, hsp.class) end end def test_target_def assert_equal("<4> Domain of unknown function, DUF529", @obj.target_def) end def test_append_hsp hsp = @obj.hsps.first assert_equal(5, @obj.append_hsp(hsp).size) end end class TestHMMERReportHsp < Test::Unit::TestCase def setup @obj = Bio::HMMER::Report.new(Bio::TestHMMERReportData.output).hits.first.hsps.first end def test_hsp assert_equal(Bio::HMMER::Report::Hsp, @obj.class) end def test_accession assert_equal("PF04385.4", @obj.accession) end def test_domain assert_equal("1/4", @obj.domain) end def test_seq_f assert_equal(36, @obj.seq_f) end def test_seq_t assert_equal(111, @obj.seq_t) end def test_seq_ft assert_equal("..", @obj.seq_ft) end def test_hmm_f assert_equal(1, @obj.hmm_f) end def test_hmm_t assert_equal(80, @obj.hmm_t) end def test_score assert_equal(65.0, @obj.score) end def test_bit_score assert_equal(65.0, @obj.bit_score) end def test_evalue assert_equal(2.0e-16, @obj.evalue) end def test_midline assert_equal("t+D+n++++ f +v+++g+++ + ++ ++v+++++++Gn+v+We++ + +l++ ++++++++++++++++ +++", @obj.midline) end def test_hmmseq assert_equal("tLDlndtgstlkqfdykvalngdivvtytpkpGvkftkitdGnevvWeseddpefglivtlsfyldsnkfLvlllintak", @obj.hmmseq) end def test_flatseq assert_equal("TFDINSNQTG-PAFLTAVEMAGVKYLQVQHGSNVNIHRLVEGNVVIWENA---STPLYTGAIVTNNDGPYMAYVEVLGDP", @obj.flatseq) end def test_query_frame assert_equal(1, @obj.query_frame) end def test_target_frame assert_equal(1, @obj.target_frame) end def test_csline assert_equal(nil, @obj.csline) end def test_rfline assert_equal(nil, @obj.rfline) end def test_set_alignment end def test_query_seq assert_equal("TFDINSNQTG-PAFLTAVEMAGVKYLQVQHGSNVNIHRLVEGNVVIWENA---STPLYTGAIVTNNDGPYMAYVEVLGDP", @obj.query_seq) end def test_target_seq assert_equal("tLDlndtgstlkqfdykvalngdivvtytpkpGvkftkitdGnevvWeseddpefglivtlsfyldsnkfLvlllintak", @obj.target_seq) end def test_target_from assert_equal(1, @obj.target_from) end def test_targat_to assert_equal(80, @obj.target_to) end def test_query_from assert_equal(36, @obj.query_from) end def test_query_to assert_equal(111, @obj.query_to) end end class TestHMMERReportHmmsearch < Test::Unit::TestCase def setup @obj = Bio::HMMER::Report.new(Bio::TestHMMERReportData.hmmsearch) end def test_histogram hist = "score obs exp (one = represents 1 sequences)\n----- --- ---\n 377 1 0|=" assert_equal(hist, @obj.histogram) end def test_statistical_detail hash = {"P(chi-square)" => 0.0, "chi-sq statistic" => 0.0, "lambda" => 0.7676, "mu" => -10.6639} assert_equal(hash, @obj.statistical_detail) hash.keys.each do |key| assert_equal(hash[key], @obj.statistical_detail[key]) end end def test_total_seq_searched assert_equal(1, @obj.total_seq_searched) end def test_whole_seq_top_hit hash = {"Total memory" => "16K", "Satisfying E cutoff" => 1, "Total hits" => 1} assert_equal(hash, @obj.whole_seq_top_hits) hash.keys.each do |key| assert_equal(hash[key], @obj.whole_seq_top_hits[key]) end end def test_domain_top_hits hash = {"Total memory" => "17K", "Satisfying E cutoff" => 1, "Total hits" => 1} assert_equal(hash, @obj.domain_top_hits) hash.keys.each do |key| assert_equal(hash[key], @obj.domain_top_hits[key]) end end end end # module Bio From nakao at pub.open-bio.org Thu Feb 2 12:10:34 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 02 Feb 2006 17:10:34 +0000 Subject: [BioRuby-cvs] bioruby/test/data/HMMER - New directory Message-ID: <200602021710.k12HAYVL001929@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/HMMER In directory pub.open-bio.org:/tmp/cvs-serv1919/test/data/HMMER Log Message: Directory /home/repository/bioruby/bioruby/test/data/HMMER added to the repository From nakao at pub.open-bio.org Thu Feb 2 12:11:25 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 02 Feb 2006 17:11:25 +0000 Subject: [BioRuby-cvs] bioruby/test/data/HMMER hmmpfam.out, NONE, 1.1 hmmsearch.out, NONE, 1.1 Message-ID: <200602021711.k12HBPVL001967@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/HMMER In directory pub.open-bio.org:/tmp/cvs-serv1957/test/data/HMMER Added Files: hmmpfam.out hmmsearch.out Log Message: * Newly added. --- NEW FILE: hmmsearch.out --- hmmsearch - search a sequence database with a profile HMM HMMER 2.2g (August 2001) Copyright (C) 1992-2001 HHMI/Washington University School of Medicine Freely distributed under the GNU General Public License (GPL) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HMM file: /sw/share/hmmer/demo/7tm_1 [7tm_1] Sequence database: /sw/share/hmmer/demo/P08908.fasta per-sequence score cutoff: [none] per-domain score cutoff: [none] per-sequence Eval cutoff: <= 10 per-domain Eval cutoff: [none] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Query HMM: 7tm_1 Accession: PF00001 Description: 7 transmembrane receptor (rhodopsin family) [HMM has been calibrated; E-values are empirical estimates] Scores for complete sequences (score includes all domains): Sequence Description Score E-value N -------- ----------- ----- ------- --- sp|P08908|5H1A_HUMAN 5-hydroxytryptamine 1A receptor 377.1 5.5e-130 1 Parsed for domains: Sequence Domain seq-f seq-t hmm-f hmm-t score E-value -------- ------- ----- ----- ----- ----- ----- ------- sp|P08908|5H1A_HUMAN 1/1 53 400 .. 1 275 [] 377.1 5.5e-130 Alignments of top-scoring domains: sp|P08908|5H1A_HUMAN: domain 1 of 1, from 53 to 400: score 377.1, E = 5.5e-130 *->GNlLVilvilrtkklrtptnifilNLAvADLLflltlppwalyylvg GN+ V+++i+++++l++++n++i++LAv+DL+++++++p+a++y v sp|P08908| 53 GNACVVAAIALERSLQNVANYLIGSLAVTDLMVSVLVLPMAALYQVL 99 gsedWpfGsalCklvtaldvvnmyaSillLtaISiDRYlAIvhPlryrrr + W++G++ C+l++aldv+++++Sil+L+aI++DRY+AI++P+ y ++ sp|P08908| 100 N--KWTLGQVTCDLFIALDVLCCTSSILHLCAIALDRYWAITDPIDYVNK 147 rtsprrAkvvillvWvlalllslPpllfswvktveegngtlnvnvtvCli rt prrA+++i+l+W++++l+s+Pp +++w++++ + +C+i sp|P08908| 148 RT-PRRAAALISLTWLIGFLISIPP-MLGWRTPEDRSD------PDACTI 189 dfpeestasvstwlvsyvllstlvgFllPllvilvcYtrIlrtlrkrark + +++ y+++st+++F++Pll++lv+Y+rI+r++r r rk sp|P08908| 190 SKDHG-----------YTIYSTFGAFYIPLLLMLVLYGRIFRAARFRIRK 228 gas............................................... + + ++++ +++++ ++ ++++++ ++++++++ + + +++ ++ + sp|P08908| 229 TVKkvektgadtrhgaspapqpkksvngesgsrnwrlgveskaggalcan 278 .................................................. + ++++++ + + ++ ++++++ + +++ ++++ + + +++++++ sp|P08908| 279 gavrqgddgaalevievhrvgnskehlplpseagptpcapasferknern 328 .....kkrsskerkaaktllvvvvvFvlCWlPyfivllldtlc.lsiims + ++k+ +erk++ktl++++++F+lCWlP+fiv+l+ ++c++s++m sp|P08908| 329 aeakrKMALARERKTVKTLGIIMGTFILCWLPFFIVALVLPFCeSSCHM- 377 stCelervlptallvtlwLayvNsclNPiIY<-* + + +++wL+y+Ns lNP+IY sp|P08908| 378 --------PTLLGAIINWLGYSNSLLNPVIY 400 Histogram of all scores: score obs exp (one = represents 1 sequences) ----- --- --- 377 1 0|= % Statistical details of theoretical EVD fit: mu = -10.6639 lambda = 0.7676 chi-sq statistic = 0.0000 P(chi-square) = 0 Total sequences searched: 1 Whole sequence top hits: tophits_s report: Total hits: 1 Satisfying E cutoff: 1 Total memory: 16K Domain top hits: tophits_s report: Total hits: 1 Satisfying E cutoff: 1 Total memory: 17K --- NEW FILE: hmmpfam.out --- hmmpfam - search one or more sequences against HMM database HMMER 2.3.2 (Oct 2003) Copyright (C) 1992-2003 HHMI/Washington University School of Medicine Freely distributed under the GNU General Public License (GPL) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HMM file: /Users/nakao/Sites/iprscan/data/Pfam Sequence file: /Users/nakao/Sites/iprscan/tmp/20050517/iprscan-20050517-16244071/chunk_1/iprscan-20050517-16244071.nocrc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Query sequence: 104K_THEPA Accession: [none] Description: [none] Scores for sequence family classification (score includes all domains): Model Description Score E-value N -------- ----------- ----- ------- --- PF04385.4 Domain of unknown function, DUF529 259.3 6.6e-75 4 Parsed for domains: Model Domain seq-f seq-t hmm-f hmm-t score E-value -------- ------- ----- ----- ----- ----- ----- ------- PF04385.4 1/4 36 111 .. 1 80 [] 65.0 2e-16 PF04385.4 2/4 149 224 .. 1 80 [] 64.7 2.5e-16 PF04385.4 3/4 265 343 .. 1 80 [] 64.6 2.7e-16 PF04385.4 4/4 379 456 .. 1 80 [] 65.0 2e-16 Alignments of top-scoring domains: PF04385.4: domain 1 of 4, from 36 to 111: score 65.0, E = 2e-16 *->tLDlndtgstlkqfdykvalngdivvtytpkpGvkftkitdGnevvW t+D+n++++ f +v+++g+++ + ++ ++v+++++++Gn+v+W 104K_THEPA 36 TFDINSNQTG-PAFLTAVEMAGVKYLQVQHGSNVNIHRLVEGNVVIW 81 eseddpefglivtlsfyldsnkfLvlllintak<-* e++ + +l++ ++++++++++++++++ +++ 104K_THEPA 82 ENA---STPLYTGAIVTNNDGPYMAYVEVLGDP 111 PF04385.4: domain 2 of 4, from 149 to 224: score 64.7, E = 2.5e-16 *->tLDlndtgstlkqfdykvalngdivvtytpkpGvkftkitdGnevvW +L++ ++ +++k+ + ++a+ng ++vt++p++G+ +++++++n++++ 104K_THEPA 149 SLNMAFQLENNKYEVETHAKNGANMVTFIPRNGHICKMVYHKNVRIY 195 eseddpefglivtlsfyldsnkfLvlllintak<-* ++ ++++vt++++++ +++L+l+++ + 104K_THEPA 196 KA----TGNDTVTSVVGFFRGLRLLLINVFSID 224 PF04385.4: domain 3 of 4, from 265 to 343: score 64.6, E = 2.7e-16 *->tLDlndtgstlkqfdykvalngdivvtytpkpGvkftkitdGnevvW +Dl+ +++ +++f+ + a+++ ++++++p++G+++tk++dG++v++ 104K_THEPA 265 PVDLDIKDIDYTMFHLADATYHEPCFKIIPNTGFCITKLFDGDQVLY 311 eseddpefglivtlsfyldsnkfLvlllintak<-* es+ + + ++i +++y+++n ++++l++n+++ 104K_THEPA 312 ESFNP-LIHCINEVHIYDRNNGSIICLHLNYSP 343 PF04385.4: domain 4 of 4, from 379 to 456: score 65.0, E = 2e-16 *->tLDlndtgstlkqfdykvalngdivvty.tpkpGvkftkitdGnevv +LD+n ++++k+ +++ +n d +t+ tp+p+ + +++dG+ev+ 104K_THEPA 379 ELDVN--FISDKDLYVAALTNADLNYTMvTPRPHRDVIRVSDGSEVL 423 WeseddpefglivtlsfyldsnkfLvlllintak<-* W++e+ ++ l++++++++d++ +Lv+l+i++ 104K_THEPA 424 WYYEGL-DNFLVCAWIYVSDGVASLVHLRIKDRI 456 // From nakao at pub.open-bio.org Fri Feb 3 12:21:54 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Fri, 03 Feb 2006 17:21:54 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl/blast test_report.rb, 1.2, 1.3 test_xmlparser.rb, 1.3, 1.4 Message-ID: <200602031721.k13HLsVL006159@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl/blast In directory pub.open-bio.org:/tmp/cvs-serv6123/test/unit/bio/appl/blast Modified Files: test_report.rb test_xmlparser.rb Log Message: * Moved test/data/blast/eco:* to test/data/blast/* to avoid file name problems in the Windows file sysmtem. Index: test_xmlparser.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/appl/blast/test_xmlparser.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_xmlparser.rb 18 Dec 2005 17:06:56 -0000 1.3 --- test_xmlparser.rb 3 Feb 2006 17:21:51 -0000 1.4 *************** *** 35,43 **** def self.input ! File.open(File.join(TestDataBlast, 'eco:b0002.faa')).read end def self.output ! File.open(File.join(TestDataBlast, 'eco:b0002.faa.m7')).read end end --- 35,43 ---- def self.input ! File.open(File.join(TestDataBlast, 'b0002.faa')).read end def self.output ! File.open(File.join(TestDataBlast, 'b0002.faa.m7')).read end end *************** *** 72,76 **** def test_db ! assert_equal("eco:b0002.faa", @report.db) end --- 72,76 ---- def test_db ! assert_equal("b0002.faa", @report.db) end Index: test_report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/appl/blast/test_report.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_report.rb 22 Nov 2005 08:31:47 -0000 1.2 --- test_report.rb 3 Feb 2006 17:21:51 -0000 1.3 *************** *** 35,39 **** def self.input ! File.open(File.join(TestDataBlast, 'eco:b0002.faa')).read end --- 35,39 ---- def self.input ! File.open(File.join(TestDataBlast, 'b0002.faa')).read end *************** *** 41,49 **** case format when 0 ! File.open(File.join(TestDataBlast, 'eco:b0002.faa.m0')).read when 7 ! File.open(File.join(TestDataBlast, 'eco:b0002.faa.m7')).read when 8 ! File.open(File.join(TestDataBlast, 'eco:b0002.faa.m8')).read end end --- 41,49 ---- case format when 0 ! File.open(File.join(TestDataBlast, 'b0002.faa.m0')).read when 7 ! File.open(File.join(TestDataBlast, 'b0002.faa.m7')).read when 8 ! File.open(File.join(TestDataBlast, 'b0002.faa.m8')).read end end *************** *** 81,90 **** xml_quoted_str = "~Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, ~Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), ~"Gapped BLAST and PSI-BLAST: a new generation of protein database search~programs", Nucleic Acids Res. 25:3389-3402." text_str = '~Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, ~Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), ~"Gapped BLAST and PSI-BLAST: a new generation of protein database search~programs", Nucleic Acids Res. 25:3389-3402.' ! assert_equal(xml_quoted_str, @report.reference) assert_equal(text_str, @report.reference) end def test_db ! assert_equal('eco:b0002.faa', @report.db) end --- 81,90 ---- xml_quoted_str = "~Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, ~Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), ~"Gapped BLAST and PSI-BLAST: a new generation of protein database search~programs", Nucleic Acids Res. 25:3389-3402." text_str = '~Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, ~Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), ~"Gapped BLAST and PSI-BLAST: a new generation of protein database search~programs", Nucleic Acids Res. 25:3389-3402.' ! # assert_equal(xml_quoted_str, @report.reference) assert_equal(text_str, @report.reference) end def test_db ! assert_equal('b0002.faa', @report.db) end *************** *** 134,142 **** def test_pattern ! assert(@report.pattern) end def test_extrez_query ! assert(@report.entrez_query) end --- 134,142 ---- def test_pattern ! assert_equal(nil, @report.pattern) end def test_extrez_query ! assert_equal(nil, @report.entrez_query) end *************** *** 186,190 **** def test_message ! assert(@report.message) end end --- 186,190 ---- def test_message ! assert_equal(nil, @report.message) end end *************** *** 202,206 **** def test_statistics ! assert(@itr.statistics) end --- 202,209 ---- def test_statistics ! stat = {"kappa" => 0.041, "eff-space" => 605284, "db-num" => 1, ! "hsp-len" => 42, "db-len" => 820, "lambda" => 0.267, ! "entropy" => 0.14} ! assert_equal(stat, @itr.statistics) end *************** *** 210,214 **** def test_message ! assert(@itr.message) end end --- 213,217 ---- def test_message ! assert_equal(nil, @itr.message) end end From nakao at pub.open-bio.org Fri Feb 3 12:21:54 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Fri, 03 Feb 2006 17:21:54 +0000 Subject: [BioRuby-cvs] bioruby/test/data/blast b0002.faa, NONE, 1.1 b0002.faa.m0, NONE, 1.1 b0002.faa.m7, NONE, 1.1 b0002.faa.m8, NONE, 1.1 eco:b0002.faa, 1.1, NONE eco:b0002.faa.m0, 1.1, NONE eco:b0002.faa.m7, 1.1, NONE eco:b0002.faa.m8, 1.1, NONE Message-ID: <200602031721.k13HLsVL006164@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/blast In directory pub.open-bio.org:/tmp/cvs-serv6123/test/data/blast Added Files: b0002.faa b0002.faa.m0 b0002.faa.m7 b0002.faa.m8 Removed Files: eco:b0002.faa eco:b0002.faa.m0 eco:b0002.faa.m7 eco:b0002.faa.m8 Log Message: * Moved test/data/blast/eco:* to test/data/blast/* to avoid file name problems in the Windows file sysmtem. --- eco:b0002.faa.m7 DELETED --- --- eco:b0002.faa.m0 DELETED --- --- NEW FILE: b0002.faa.m8 --- eco:b0002 eco:b0002 100.00 820 0 0 1 820 1 820 0.0 1567 --- NEW FILE: b0002.faa.m7 --- blastp blastp 2.2.10 [Oct-19-2004] ~Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, ~Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), ~"Gapped BLAST and PSI-BLAST: a new generation of protein database search~programs", Nucleic Acids Res. 25:3389-3402. b0002.faa lcl|QUERY eco:b0002 thrA, Hs, thrD, thrA2, thrA1; bifunctional: aspartokinase I (N-terminal); homoserine dehydrogenase I (C-terminal) [EC:2.7.2.4 1.1.1.3]; K00003 homoserine dehydrogenase; K00928 aspartate kinase (A) 820 BLOSUM62 10 11 1 S 1 1 gnl|BL_ORD_ID|0 eco:b0002 thrA, Hs, thrD, thrA2, thrA1; bifunctional: aspartokinase I (N-terminal); homoserine dehydrogenase I (C-terminal) [EC:2.7.2.4 1.1.1.3]; K00003 homoserine dehydrogenase; K00928 aspartate kinase (A) 0 820 1 1567.75 4058 0 1 820 1 820 1 1 820 820 820 MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDALPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINAALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIPADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQVPDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRDEDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISFCVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAALARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQVIEVFVIGVGGVGGALLEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRLVKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSRRKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLAREMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMANLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAFYSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDALPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINAALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIPADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQVPDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRDEDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISFCVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAALARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQVIEVFVIGVGGVGGALLEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRLVKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSRRKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLAREMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMANLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAFYSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDALPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINAALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIPADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQVPDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRDEDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISFCVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAALARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQVIEVFVIGVGGVGGALLEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRLVKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSRRKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLAREMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMANLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAFYSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV 1 820 42 605284 0.041 0.267 0.14 --- eco:b0002.faa DELETED --- --- NEW FILE: b0002.faa --- >eco:b0002 thrA, Hs, thrD, thrA2, thrA1; bifunctional: aspartokinase I (N-terminal); homoserine dehydrogenase I (C-terminal) [EC:2.7.2.4 1.1.1.3]; K00003 homoserine dehydrogenase; K00928 aspartate kinase (A) MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDA LPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINA ALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIP ADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQV PDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRD EDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISF CVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAAL ARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQVIEVFVIGVGGVGGAL LEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRL VKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSR RKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLA REMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMA NLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAF YSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV --- eco:b0002.faa.m8 DELETED --- --- NEW FILE: b0002.faa.m0 --- BLASTP 2.2.10 [Oct-19-2004] Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), "Gapped BLAST and PSI-BLAST: a new generation of protein database search programs", Nucleic Acids Res. 25:3389-3402. Query= eco:b0002 thrA, Hs, thrD, thrA2, thrA1; bifunctional: aspartokinase I (N-terminal); homoserine dehydrogenase I (C-terminal) [EC:2.7.2.4 1.1.1.3]; K00003 homoserine dehydrogenase; K00928 aspartate kinase (A) (820 letters) Database: b0002.faa 1 sequences; 820 total letters Searching.done Score E Sequences producing significant alignments: (bits) Value eco:b0002 thrA, Hs, thrD, thrA2, thrA1; bifunctional: aspartokin... 1567 0.0 >eco:b0002 thrA, Hs, thrD, thrA2, thrA1; bifunctional: aspartokinase I (N-terminal); homoserine dehydrogenase I (C-terminal) [EC:2.7.2.4 1.1.1.3]; K00003 homoserine dehydrogenase; K00928 aspartate kinase (A) Length = 820 Score = 1567 bits (4058), Expect = 0.0 Identities = 806/820 (98%), Positives = 806/820 (98%) Query: 1 MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDA 60 MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDA Sbjct: 1 MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDA 60 Query: 61 LPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINA 120 LPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINA Sbjct: 61 LPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINA 120 Query: 121 ALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIP 180 ALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIP Sbjct: 121 ALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIP 180 Query: 181 ADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQV 240 ADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQV Sbjct: 181 ADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQV 240 Query: 241 PDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRD 300 PDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRD Sbjct: 241 PDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRD 300 Query: 301 EDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISF 360 EDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISF Sbjct: 301 EDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISF 360 Query: 361 CVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAAL 420 CVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAAL Sbjct: 361 CVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAAL 420 Query: 421 ARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQXXXXXXXXXXXXXXAL 480 ARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQ AL Sbjct: 421 ARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQVIEVFVIGVGGVGGAL 480 Query: 481 LEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRL 540 LEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRL Sbjct: 481 LEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRL 540 Query: 541 VKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSR 600 VKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSR Sbjct: 541 VKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSR 600 Query: 601 RKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLA 660 RKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLA Sbjct: 601 RKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLA 660 Query: 661 REMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMA 720 REMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMA Sbjct: 661 REMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMA 720 Query: 721 NLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAF 780 NLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAF Sbjct: 721 NLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAF 780 Query: 781 YSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV 820 YSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV Sbjct: 781 YSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV 820 Database: b0002.faa Posted date: Aug 7, 2005 7:29 AM Number of letters in database: 820 Number of sequences in database: 1 Lambda K H 0.319 0.134 0.383 Gapped Lambda K H 0.267 0.0410 0.140 Matrix: BLOSUM62 Gap Penalties: Existence: 11, Extension: 1 Number of Hits to DB: 1986 Number of Sequences: 1 Number of extensions: 52 Number of successful extensions: 8 Number of sequences better than 10.0: 1 Number of HSP's better than 10.0 without gapping: 1 Number of HSP's successfully gapped in prelim test: 0 Number of HSP's that attempted gapping in prelim test: 0 Number of HSP's gapped (non-prelim): 1 length of query: 820 length of database: 820 effective HSP length: 42 effective length of query: 778 effective length of database: 778 effective search space: 605284 effective search space used: 605284 T: 11 A: 40 X1: 16 ( 7.4 bits) X2: 38 (14.6 bits) X3: 64 (24.7 bits) S1: 30 (16.7 bits) S2: 30 (16.2 bits) From nakao at pub.open-bio.org Fri Feb 3 12:39:15 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Fri, 03 Feb 2006 17:39:15 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl test_blast.rb,1.2,1.3 Message-ID: <200602031739.k13HdFVL006243@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv6233/test/unit/bio/appl Modified Files: test_blast.rb Log Message: * Tto avoid file name problems in the Windows file sysmtem. Index: test_blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/appl/test_blast.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_blast.rb 23 Nov 2005 02:47:19 -0000 1.2 --- test_blast.rb 3 Feb 2006 17:39:13 -0000 1.3 *************** *** 35,39 **** def self.input ! File.open(File.join(TestDataBlast, 'eco:b0002.faa')).read end --- 35,39 ---- def self.input ! File.open(File.join(TestDataBlast, 'b0002.faa')).read end *************** *** 41,49 **** case format when '0' ! File.open(File.join(TestDataBlast, 'eco:b0002.faa.m0')).read when '7' ! File.open(File.join(TestDataBlast, 'eco:b0002.faa.m7')).read when '8' ! File.open(File.join(TestDataBlast, 'eco:b0002.faa.m8')).read end end --- 41,49 ---- case format when '0' ! File.open(File.join(TestDataBlast, 'b0002.faa.m0')).read when '7' ! File.open(File.join(TestDataBlast, 'b0002.faa.m7')).read when '8' ! File.open(File.join(TestDataBlast, 'b0002.faa.m8')).read end end From k at pub.open-bio.org Sat Feb 4 14:12:58 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Sat, 04 Feb 2006 19:12:58 +0000 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.61,1.62 Message-ID: <200602041912.k14JCvVL018259@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv18253/lib Modified Files: bio.rb Log Message: * Bio::String is prepared for replacement of old Bio::Sequence which doesn't remove any gap chars or change up/down cases. Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** bio.rb 28 Jan 2006 08:34:25 -0000 1.61 --- bio.rb 4 Feb 2006 19:12:55 -0000 1.62 *************** *** 35,40 **** ## Sequence - autoload :Seq, 'bio/sequence' autoload :Sequence, 'bio/sequence' ## Locations/Location --- 35,40 ---- ## Sequence autoload :Sequence, 'bio/sequence' + autoload :String, 'bio/string' ## Locations/Location From k at pub.open-bio.org Sat Feb 4 14:12:58 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Sat, 04 Feb 2006 19:12:58 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio string.rb,NONE,1.1 Message-ID: <200602041912.k14JCwVL018263@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv18253/lib/bio Added Files: string.rb Log Message: * Bio::String is prepared for replacement of old Bio::Sequence which doesn't remove any gap chars or change up/down cases. --- NEW FILE: string.rb --- # # = bio/string.rb - biological string class to store an intact sequence # # Copyright:: Copyright (C) 2006 # Toshiaki Katayama # License:: Ruby's # # $Id: string.rb,v 1.1 2006/02/04 19:12:56 k Exp $ # require 'bio/sequence/common' module Bio class String include Bio::Sequence::Common end end From k at pub.open-bio.org Sat Feb 4 14:17:18 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Sat, 04 Feb 2006 19:17:18 +0000 Subject: [BioRuby-cvs] bioruby README,1.12,1.13 Message-ID: <200602041917.k14JHIVL018302@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv18298 Modified Files: README Log Message: * included announcement of changing license from LGPL to Ruby's Index: README =================================================================== RCS file: /home/repository/bioruby/bioruby/README,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** README 12 Dec 2005 02:06:35 -0000 1.12 --- README 4 Feb 2006 19:17:16 -0000 1.13 *************** *** 3,7 **** $Id$ ! Copyright (C) 2001-2005 Toshiaki Katayama = BioRuby --- 3,7 ---- $Id$ ! Copyright (C) 2001-2006 Toshiaki Katayama = BioRuby *************** *** 168,171 **** --- 168,172 ---- BioRuby can be freely distributed under the GNU LGPL license. + We are trying to change the lincense to Ruby's now. Note that, install.rb included in the BioRuby package comes from From nakao at pub.open-bio.org Sun Feb 5 12:35:13 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sun, 05 Feb 2006 17:35:13 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/sequence - New directory Message-ID: <200602051735.k15HZDVL030716@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv30706/test/unit/bio/sequence Log Message: Directory /home/repository/bioruby/bioruby/test/unit/bio/sequence added to the repository From nakao at pub.open-bio.org Sun Feb 5 12:39:29 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sun, 05 Feb 2006 17:39:29 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/sequence test_common.rb, NONE, 1.1 test_compat.rb, NONE, 1.1 Message-ID: <200602051739.k15HdTVL030749@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv30733/test/unit/bio/sequence Added Files: test_common.rb test_compat.rb Log Message: * test_common.rb: added. * test_compat.rb: added. * test_sequence.rb: moved some test codes to test_common.rb or test_compat.rb. --- NEW FILE: test_compat.rb --- # # test/unit/bio/sequence/test_compat.rb - Unit test for Bio::Sequencce::Compat # # Copyright (C) 2006 Mitsuteru C. Nakao # # 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: test_compat.rb,v 1.1 2006/02/05 17:39:27 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/sequence' require 'bio/sequence/compat' module Bio class TSequence < String include Bio::Sequence::Common end class TestSequenceCompat < Test::Unit::TestCase def setup @obj = TSequence.new('atgcatgcatgcatgcaaaa') end def test_to_s str = 'atgcatgcatgcatgcaaaa' assert_equal(str, @obj.to_s) end end class TestSequenceCommonCompat < Test::Unit::TestCase # Test Sequence#to_fasta def test_to_fasta sequence = TSequence.new("agtc" * 10) header = "the header" str = ">the header\n" + ("agtc" * 5) + "\n" + ("agtc" * 5) + "\n" assert_equal(str, sequence.to_fasta(header, 20)) end end require 'bio/sequence/na' class TestSequenceNACompat < Test::Unit::TestCase def test_na_self_randomize composition = Bio::Sequence::NA.new("acgtacgt").composition assert(Bio::Sequence::NA.randomize(composition)) end end require 'bio/sequence/aa' class TestSequenceNACompat < Test::Unit::TestCase def test_aa_self_randomize composition = Bio::Sequence::AA.new("WWDTGAK").composition assert(Bio::Sequence::AA.randomize(composition)) end end end --- NEW FILE: test_common.rb --- # # test/unit/bio/sequence/test_common.rb - Unit test for Bio::Sequencce::Common # # Copyright (C) 2006 Mitsuteru C. Nakao # # 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: test_common.rb,v 1.1 2006/02/05 17:39:27 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/sequence' require 'bio/sequence/common' module Bio class TSequence < String include Bio::Sequence::Common end class TestSequenceCommon < Test::Unit::TestCase def setup @obj = TSequence.new('atgcatgcatgcatgcaaaa') end def test_to_s assert_equal('atgcatgcatgcatgcaaaa', @obj.to_s) end def test_seq str = "atgcatgcatgcatgcaaaa" assert_equal(str, @obj.seq) end # <<(*arg) def test_push str = "atgcatgcatgcatgcaaaaA" assert_equal(str, @obj << "A") end # +(*arg) def test_sum str = "atgcatgcatgcatgcaaaaatgcatgcatgcatgcaaaa" assert_equal(str, @obj + @obj) end # window_search(window_size, step_size = 1) def test_window_search @obj.window_search(4) do |subseq| assert_equal(20, @obj.size) end end #total(hash) def test_total hash = {'a' => 1, 'c' => 2, 'g' => 4, 't' => 3} assert_equal(44.0, @obj.total(hash)) end def test_composition composition = {"a"=>8, "c"=>4, "g"=>4, "t"=>4} assert_equal(composition, @obj.composition) end def test_splicing #(position) assert_equal("atgcatgc", @obj.splicing("join(1..4, 13..16)")) end end class TestSequenceCommonNormalize < Test::Unit::TestCase def test_no_normalize str = "atgcatgcatgcatgcaaaA" obj = Bio::TSequence.new(str) assert_equal("atgcatgcatgcatgcaaaA", obj) end def test_normalize_A str = "atgcatgcatgcatgcaaaA" seq = Bio::TSequence.new(str) assert_equal("atgcatgcatgcatgcaaaA", seq) obj = seq.normalize! assert_equal("atgcatgcatgcatgcaaaA", obj) end def test_normalize_a str = "atgcatgcatgcatgcaaa" seq = Bio::TSequence.new(str) assert_equal("atgcatgcatgcatgcaaa", seq) obj = seq.normalize! assert_equal("atgcatgcatgcatgcaaa", obj) end end class TestSequenceCommonRansomize < Test::Unit::TestCase def test_self_randomize # self.randomize(*arg, &block) end def test_randomize #randomize(hash = nil) end end class TestSequenceCommonSubseq < Test::Unit::TestCase #def subseq(s = 1, e = self.length) def test_to_s_returns_self_as_string s = "abcefghijklmnop" sequence = TSequence.new(s) assert_equal(s, sequence.to_s, "wrong value") assert_instance_of(String, sequence.to_s, "not a String") end def test_subseq_returns_nil_blank_sequence_default_end sequence = TSequence.new("") assert_equal(nil, sequence.subseq(5)) end def test_subseq_returns_nil_start_less_than_one sequence = TSequence.new("blahblah") assert_nil(sequence.subseq(0)) end def test_subseq_returns_subsequence sequence = TSequence.new("hahasubhehe") assert_equal("sub", sequence.subseq(5,7)) end end # Test Sequence#window_wearch class TestSequenceCommonWindowSearch < Test::Unit::TestCase def test_window_search_with_width_3_default_step_no_residual sequence = TSequence.new("agtca") windows = [] returned_value = sequence.window_search(3) { |window| windows << window } assert_equal(["agt", "gtc", "tca"], windows, "windows wrong") assert_equal("", returned_value, "returned value wrong") end # added def test_window_search_with_width_3_step_two_with_residual sequence = TSequence.new("agtcat") windows = [] returned_value = sequence.window_search(3, 2) { |window| windows << window } assert_equal(["agt", "tca"], windows, "windows wrong") assert_equal("t", returned_value, "returned value wrong") end end end From nakao at pub.open-bio.org Sun Feb 5 12:39:29 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sun, 05 Feb 2006 17:39:29 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio test_sequence.rb,1.5,1.6 Message-ID: <200602051739.k15HdTVL030745@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio In directory pub.open-bio.org:/tmp/cvs-serv30733/test/unit/bio Modified Files: test_sequence.rb Log Message: * test_common.rb: added. * test_compat.rb: added. * test_sequence.rb: moved some test codes to test_common.rb or test_compat.rb. Index: test_sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/test_sequence.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_sequence.rb 26 Nov 2005 06:51:45 -0000 1.5 --- test_sequence.rb 5 Feb 2006 17:39:27 -0000 1.6 *************** *** 1,6 **** # ! # test/unit/bio/tc_sequence.rb - Unit test for Bio::Sequencce # # Copyright (C) 2004 Moses Hohman # # This library is free software; you can redistribute it and/or --- 1,7 ---- # ! # test/unit/bio/test_sequence.rb - Unit test for Bio::Sequencce # # Copyright (C) 2004 Moses Hohman + # Copyright (C) 2006 Mitsuteru C. Nakao # # This library is free software; you can redistribute it and/or *************** *** 30,33 **** --- 31,35 ---- module Bio class TestSequence < Test::Unit::TestCase + def setup @na = Sequence::NA.new('atgcatgcatgcatgcaaaa') *************** *** 36,61 **** end - def test_to_s_returns_self_as_string - s = "abcefghijklmnop" - sequence = Sequence.new(s) - assert_equal(s, sequence.to_s, "wrong value") - assert_instance_of(String, sequence.to_s, "not a String") - end - - def test_subseq_returns_nil_blank_sequence_default_end - sequence = Sequence.new("") - assert_nil(sequence.subseq(5)) - end - def test_subseq_returns_nil_start_less_than_one - sequence = Sequence.new("blahblah") - assert_nil(sequence.subseq(0)) - end - - def test_subseq_returns_subsequence - sequence = Sequence.new("hahasubhehe") - assert_equal("sub", sequence.subseq(5,7)) - end - # "main" method tests translated into unit tests --- 38,42 ---- *************** *** 125,154 **** end - # Test Sequence#to_fasta - - def test_to_fasta - sequence = Sequence.new("agtc"*10) - header = "the header" - assert_equal(">the header\n" + ("agtc"*5) + "\n" + ("agtc"*5) + "\n", sequence.to_fasta(header, 20)) - end - - # Test Sequence#window_wearch - - def test_window_search_with_width_3_default_step_no_residual - sequence = Sequence.new("agtca") - windows = [] - returned_value = sequence.window_search(3) { |window| windows << window } - assert_equal(["agt", "gtc", "tca"], windows, "windows wrong") - assert_equal("", returned_value, "returned value wrong") - end - - # added - def test_window_search_with_width_3_step_two_with_residual - sequence = Sequence::NA.new("agtcat") - windows = [] - returned_value = sequence.window_search(3, 2) { |window| windows << window } - assert_equal(["agt", "tca"], windows, "windows wrong") - assert_equal("t", returned_value, "returned value wrong") - end # Test Sequence#total --- 106,109 ---- From k at pub.open-bio.org Mon Feb 6 01:17:55 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 06:17:55 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin keggapi.rb,1.8,1.9 Message-ID: <200602060617.k166HtVL032574@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv32570/shell/plugin Modified Files: keggapi.rb Log Message: * improved to accept other WSDL Index: keggapi.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/keggapi.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** keggapi.rb 18 Dec 2005 15:47:33 -0000 1.8 --- keggapi.rb 6 Feb 2006 06:17:53 -0000 1.9 *************** *** 41,46 **** private ! def keggapi ! @keggapi ||= Bio::KEGG::API.new end --- 41,51 ---- private ! def keggapi(wsdl = nil) ! if wsdl ! @keggapi = Bio::KEGG::API.new(wsdl) ! else ! @keggapi ||= Bio::KEGG::API.new ! end ! return @keggapi end From k at pub.open-bio.org Mon Feb 6 09:07:14 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:07:14 +0000 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.62,1.63 Message-ID: <200602061407.k16E7EVL001842@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv1838 Modified Files: bio.rb Log Message: * Bio::String is changed to Bio::Sequence::Generic in lib/bio/sequence/generic.rb Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** bio.rb 4 Feb 2006 19:12:55 -0000 1.62 --- bio.rb 6 Feb 2006 14:07:11 -0000 1.63 *************** *** 36,40 **** autoload :Sequence, 'bio/sequence' - autoload :String, 'bio/string' ## Locations/Location --- 36,39 ---- From k at pub.open-bio.org Mon Feb 6 09:10:03 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:10:03 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio sequence.rb,0.51,0.52 Message-ID: <200602061410.k16EA3VL001874@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv1865 Modified Files: sequence.rb Log Message: * changed to use autoload * send to @seq when method_missing * format_* methods are moved under the module Bio::Sequence::Format * added skelton for output(:gff) to call Bio::Sequence::Format#format_gff Index: sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence.rb,v retrieving revision 0.51 retrieving revision 0.52 diff -C2 -d -r0.51 -r0.52 *** sequence.rb 23 Jan 2006 04:13:36 -0000 0.51 --- sequence.rb 6 Feb 2006 14:10:01 -0000 0.52 *************** *** 29,60 **** # - require 'bio/data/na' - require 'bio/data/aa' - require 'bio/data/codontable' - require 'bio/location' - - require 'bio/sequence/common' - require 'bio/sequence/na' - require 'bio/sequence/aa' - require 'bio/sequence/format' require 'bio/sequence/compat' module Bio - # Nucleic/Amino Acid sequence - class Sequence attr_accessor :entry_id, :definition, :features, :references, :comments, :date, :keywords, :dblinks, :taxonomy, :moltype, :seq ! # def method_missing(*arg) ! # @seq.send(*arg) ! # end def output(style) case style when :fasta format_fasta when :genbank format_genbank --- 29,62 ---- # require 'bio/sequence/compat' module Bio class Sequence + def initialize(str) + @seq = str + end + + def method_missing(*arg) + @seq.send(*arg) + end + attr_accessor :entry_id, :definition, :features, :references, :comments, :date, :keywords, :dblinks, :taxonomy, :moltype, :seq ! autoload :Common, 'bio/sequence/common' ! autoload :NA, 'bio/sequence/na' ! autoload :AA, 'bio/sequence/aa' ! autoload :Generic, 'bio/sequence/generic' ! autoload :Format, 'bio/sequence/format' def output(style) + extend Bio::Sequence::Format case style when :fasta format_fasta + when :gff + format_gff when :genbank format_genbank *************** *** 62,69 **** format_embl end - end - - def initialize(str) - @seq = str end --- 64,67 ---- From k at pub.open-bio.org Mon Feb 6 09:11:33 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:11:33 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence aa.rb,1.1,1.2 Message-ID: <200602061411.k16EBXVL001901@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv1897/sequence Modified Files: aa.rb Log Message: * added RDoc header with Ruby's license * changed to use autoload * use Bio::AminoAcid explicitly instead of AminoAcid Index: aa.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/aa.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** aa.rb 23 Jan 2006 04:13:36 -0000 1.1 --- aa.rb 6 Feb 2006 14:11:31 -0000 1.2 *************** *** 1,8 **** module Bio class Sequence - # Amino Acid sequence class AA < String --- 1,22 ---- + # + # = bio/sequence/aa.rb - amino acid sequence class + # + # Copyright:: Copyright (C) 2006 + # Toshiaki Katayama + # License:: Ruby's + # + # $Id$ + # + + require 'bio/sequence/common' + module Bio + autoload :AminoAcid, 'bio/data/aa' + class Sequence + # Amino Acid sequence class AA < String *************** *** 16,27 **** end # Estimate the weight of this protein. - # AminoAcid is defined in bio/data/aa.rb def molecular_weight ! AminoAcid.weight(self) end def to_re ! AminoAcid.to_re(self) end --- 30,41 ---- end + # Estimate the weight of this protein. def molecular_weight ! Bio::AminoAcid.weight(self) end def to_re ! Bio::AminoAcid.to_re(self) end *************** *** 31,35 **** array = [] self.each_byte do |x| ! array.push(AminoAcid.names[x.chr]) end return array --- 45,49 ---- array = [] self.each_byte do |x| ! array.push(Bio::AminoAcid.names[x.chr]) end return array *************** *** 39,43 **** def names self.codes.map do |x| ! AminoAcid.names[x] end end --- 53,57 ---- def names self.codes.map do |x| ! Bio::AminoAcid.names[x] end end *************** *** 48,49 **** --- 62,64 ---- end # Bio + From k at pub.open-bio.org Mon Feb 6 09:13:54 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:13:54 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence na.rb,1.1,1.2 Message-ID: <200602061413.k16EDsVL001949@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv1924/sequence Modified Files: na.rb Log Message: * added RDoc header with Ruby's license * changed to use autoload * use Bio::NucleicAcid explicitly instead of NucleicAcid * pikachu method is moved to lib/bio/sequence/compat.rb Index: na.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/na.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** na.rb 23 Jan 2006 04:13:36 -0000 1.1 --- na.rb 6 Feb 2006 14:13:52 -0000 1.2 *************** *** 1,8 **** module Bio class Sequence - # Nucleic Acid sequence class NA < String --- 1,23 ---- + # + # = bio/sequence/na.rb - nucleic acid sequence class + # + # Copyright:: Copyright (C) 2006 + # Toshiaki Katayama + # License:: Ruby's + # + # $Id$ + # + + require 'bio/sequence/common' + module Bio + autoload :NucleicAcid, 'bio/data/na' + autoload :CodonTable, 'bio/data/codontable' + class Sequence + # Nucleic Acid sequence class NA < String *************** *** 118,127 **** # Estimate the weight of this biological string molecule. - # NucleicAcid is defined in bio/data/na.rb def molecular_weight if self.rna? ! NucleicAcid.weight(self, true) else ! NucleicAcid.weight(self) end end --- 133,141 ---- # Estimate the weight of this biological string molecule. def molecular_weight if self.rna? ! Bio::NucleicAcid.weight(self, true) else ! Bio::NucleicAcid.weight(self) end end *************** *** 130,136 **** def to_re if self.rna? ! NucleicAcid.to_re(self.dna, true) else ! NucleicAcid.to_re(self) end end --- 144,150 ---- def to_re if self.rna? ! Bio::NucleicAcid.to_re(self.dna, true) else ! Bio::NucleicAcid.to_re(self) end end *************** *** 140,144 **** array = [] self.each_byte do |x| ! array.push(NucleicAcid.names[x.chr.upcase]) end return array --- 154,158 ---- array = [] self.each_byte do |x| ! array.push(Bio::NucleicAcid.names[x.chr.upcase]) end return array *************** *** 168,175 **** protected :rna? - def pikachu - self.dna.tr("atgc", "pika") # joke, of course :-) - end - end # NA --- 182,185 ---- *************** *** 177,178 **** --- 187,189 ---- end # Bio + From k at pub.open-bio.org Mon Feb 6 09:16:19 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:16:19 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence common.rb,1.1,1.2 Message-ID: <200602061416.k16EGJVL002009@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv1993/sequence Modified Files: common.rb Log Message: * added RDoc header with Ruby's license * changed to use autoload * subseq method is changed to raise exception when the start or end position is not a positive integer * splicing method is renamed to splice * splicing is made aliased to splice method Index: common.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/common.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** common.rb 23 Jan 2006 04:13:36 -0000 1.1 --- common.rb 6 Feb 2006 14:16:17 -0000 1.2 *************** *** 1,6 **** --- 1,20 ---- + # + # = bio/sequence/common.rb - common methods for biological sequence + # + # Copyright:: Copyright (C) 2006 + # Toshiaki Katayama + # License:: Ruby's + # + # $Id$ + # + module Bio + autoload :Locations, 'bio/location' + class Sequence + # This module provides common methods for biological sequence classes + # which must inherit String. module Common *************** *** 34,38 **** # Returns the subsequence of the self string. def subseq(s = 1, e = self.length) ! return nil if s < 1 or e < 1 s -= 1 e -= 1 --- 48,52 ---- # Returns the subsequence of the self string. def subseq(s = 1, e = self.length) ! raise "Error: start/end position must be a positive integer" unless s > 0 and e > 0 s -= 1 e -= 1 *************** *** 134,140 **** # Receive a GenBank style position string and convert it to the Locations # objects to splice the sequence itself. See also: bio/location.rb ! # ! # This method depends on Locations class, see bio/location.rb ! def splicing(position) unless position.is_a?(Locations) then position = Locations.new(position) --- 148,152 ---- # Receive a GenBank style position string and convert it to the Locations # objects to splice the sequence itself. See also: bio/location.rb ! def splice(position) unless position.is_a?(Locations) then position = Locations.new(position) *************** *** 155,158 **** --- 167,171 ---- return self.class.new(s) end + alias splicing splice end # Common From k at pub.open-bio.org Mon Feb 6 09:18:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:18:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence compat.rb,1.1,1.2 Message-ID: <200602061418.k16EI6VL002036@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv2032/sequence Modified Files: compat.rb Log Message: * added RDoc header with Ruby's license * changed to use autoload * pikachu method is moved from lib/bio/sequence/na.rb * changed to warn when to_fasta method is used in debug mode Index: compat.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/compat.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** compat.rb 23 Jan 2006 04:13:36 -0000 1.1 --- compat.rb 6 Feb 2006 14:18:03 -0000 1.2 *************** *** 1,3 **** ! # only for backward compatibility, use Bio::Sequence#output(:fasta) instead module Bio --- 1,12 ---- ! # ! # = bio/sequence/compat.rb - methods for backward compatibility ! # ! # Copyright:: Copyright (C) 2006 ! # Toshiaki Katayama ! # License:: Ruby's ! # ! # $Id$ ! # ! module Bio *************** *** 5,8 **** --- 14,21 ---- class Sequence + autoload :Common, 'bio/sequence/common' + autoload :NA, 'bio/sequence/na' + autoload :AA, 'bio/sequence/aa' + def to_s String.new(@seq) *************** *** 10,14 **** alias to_str to_s ! module Common # Output the FASTA format string of the sequence. The 1st argument is --- 23,28 ---- alias to_str to_s ! ! module Common # Output the FASTA format string of the sequence. The 1st argument is *************** *** 16,19 **** --- 30,34 ---- # sequence will be folded. def to_fasta(header = '', width = nil) + warn "Bio::Sequence#to_fasta is obsolete. Use Bio::Sequence#output(:fasta) instead" if $DEBUG ">#{header}\n" + if width *************** *** 26,29 **** --- 41,45 ---- end # Common + class NA *************** *** 32,37 **** --- 48,58 ---- end + def pikachu + self.dna.tr("atgc", "pika") # joke, of course :-) + end + end # NA + class AA *************** *** 41,44 **** --- 62,66 ---- end # AA + end # Sequence From k at pub.open-bio.org Mon Feb 6 09:20:37 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:20:37 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence format.rb,1.1,1.2 Message-ID: <200602061420.k16EKbVL002068@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv2059/sequence Modified Files: format.rb Log Message: * added RDoc header with Ruby's license * format_* functions are moved under the module Bio::Sequence::Format and these are extended to Bio::Sequence object when used. * format_gff method is added as a skelton (need to be implemented) Index: format.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/format.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** format.rb 23 Jan 2006 04:13:36 -0000 1.1 --- format.rb 6 Feb 2006 14:20:35 -0000 1.2 *************** *** 1,8 **** --- 1,26 ---- + # + # = bio/sequence/format.rb - various output format of the biological sequence + # + # Copyright:: Copyright (C) 2006 + # Toshiaki Katayama , + # Naohisa Goto + # License:: Ruby's + # + # = TODO + # # porting from N. Goto's feature-output.rb on BioRuby list. + # + # $Id$ + # + module Bio + autoload :Sequence, 'bio/sequence' + class Sequence + module Format + # Output the FASTA format string of the sequence. The 1st argument is # used in the comment line. If the 2nd argument (integer) is given, *************** *** 19,22 **** --- 37,44 ---- end + def format_gff + raise NotImplementedError + end + def format_genbank prefix = ' ' * 5 *************** *** 35,38 **** --- 57,61 ---- end + private *************** *** 104,108 **** --- 127,134 ---- end + end # Format + end # Sequence end # Bio + From k at pub.open-bio.org Mon Feb 6 09:22:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:22:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence generic.rb,1.1,1.2 Message-ID: <200602061422.k16EM6VL002095@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv2091/sequence Modified Files: generic.rb Log Message: * Bio::String caused various errors, so the class is changed to Bio::Sequence::Generic Index: generic.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/generic.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** generic.rb 4 Feb 2006 19:12:56 -0000 1.1 --- generic.rb 6 Feb 2006 14:22:04 -0000 1.2 *************** *** 1,4 **** # ! # = bio/string.rb - biological string class to store an intact sequence # # Copyright:: Copyright (C) 2006 --- 1,4 ---- # ! # = bio/sequence/generic.rb - generic sequence class to store an intact string # # Copyright:: Copyright (C) 2006 *************** *** 12,22 **** module Bio ! ! class String include Bio::Sequence::Common ! end ! ! end --- 12,22 ---- module Bio ! class Sequence ! class Generic include Bio::Sequence::Common ! end # Generic ! end # Sequence ! end # Bio From k at pub.open-bio.org Mon Feb 6 09:26:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:26:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence generic.rb,1.2,1.3 Message-ID: <200602061426.k16EQ6VL002145@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv2141/sequence Modified Files: generic.rb Log Message: * fixed to inherit String Index: generic.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/generic.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** generic.rb 6 Feb 2006 14:22:04 -0000 1.2 --- generic.rb 6 Feb 2006 14:26:04 -0000 1.3 *************** *** 13,21 **** module Bio class Sequence ! class Generic include Bio::Sequence::Common end # Generic end # Sequence end # Bio --- 13,23 ---- module Bio class Sequence ! ! class Generic < String include Bio::Sequence::Common end # Generic + end # Sequence end # Bio From nakao at pub.open-bio.org Tue Feb 7 11:53:10 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Tue, 07 Feb 2006 16:53:10 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/sequence test_common.rb, 1.1, 1.2 Message-ID: <200602071653.k17GrAVL005902@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv5892/test/unit/bio/sequence Modified Files: test_common.rb Log Message: * Removed test_subseq_returns_nil_blank_sequence_default_end and test_subseq_returns_nil_start_less_than_one test methods. * Added test_subseq_returns_RuntimeError_blank_sequence_default_end and test_subseq_returns_RuntimeError_start_less_than_one test methods. Index: test_common.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/sequence/test_common.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_common.rb 5 Feb 2006 17:39:27 -0000 1.1 --- test_common.rb 7 Feb 2006 16:53:08 -0000 1.2 *************** *** 136,149 **** end ! def test_subseq_returns_nil_blank_sequence_default_end sequence = TSequence.new("") ! assert_equal(nil, sequence.subseq(5)) end ! def test_subseq_returns_nil_start_less_than_one sequence = TSequence.new("blahblah") ! assert_nil(sequence.subseq(0)) end ! def test_subseq_returns_subsequence sequence = TSequence.new("hahasubhehe") --- 136,149 ---- end ! def test_subseq_returns_RuntimeError_blank_sequence_default_end sequence = TSequence.new("") ! assert_raise(RuntimeError) { sequence.subseq(5) } end ! def test_subseq_returns_RuntimeError_start_less_than_one sequence = TSequence.new("blahblah") ! assert_raise(RuntimeError) { sequence.subseq(0) } end ! def test_subseq_returns_subsequence sequence = TSequence.new("hahasubhehe") From nakao at pub.open-bio.org Wed Feb 8 02:08:24 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 08 Feb 2006 07:08:24 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/sequence test_na.rb,NONE,1.1 Message-ID: <200602080708.k1878OVL008720@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv8710/test/unit/bio/sequence Added Files: test_na.rb Log Message: * Newly added --- NEW FILE: test_na.rb --- # # = test/unit/bio/sequence/test_na.rb - Unit test for Bio::Sequencce::NA # # Copyright:: Copyright (C) 2006 # Mitsuteru C. Nakao # Lisence:: Ruby's # # $Id: test_na.rb,v 1.1 2006/02/08 07:08:22 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/sequence' require 'bio/sequence/na' module Bio class TestSequenceNANew < Test::Unit::TestCase def test_new str = 'atgcatgcatgcatgcaaaa' assert(Bio::Sequence::NA.new(str)) end def test_new_t str = "atgcatgcatgcatgcaaaa" str_t = "atgcatgcat\tgca\ttgcaaaa" assert_equal(str, Bio::Sequence::NA.new(str_t)) end def test_new_n str = "atgcatgcatgcatgcaaaa" str_n = "atgcatgcat\ngca\ntgcaaaa" assert_equal(str, Bio::Sequence::NA.new(str_n)) end def test_new_r str = "atgcatgcatgcatgcaaaa" str_r = "atgcatgcat\n\rgca\n\rtgcaaaa" assert_equal(str, Bio::Sequence::NA.new(str_r)) end end class TestSequenceNA < Test::Unit::TestCase def setup @obj = Bio::Sequence::NA.new('atgcatgcatgcatgcaaaa') end def test_splicing # 'atgcatgcatgcatgcaaaa' # 12345678901234567890 str = 'atgca catgcatg'.gsub(' ','') assert_equal(str, @obj.splicing("join(1..5,8..15)")) end def test_forward_complement str = 'atgcatgcatgcatgcaaaa' str_fcomp = 'tacgtacgtacgtacgtttt' fcomp = @obj.forward_complement assert_equal(str_fcomp, @obj.forward_complement) assert_equal(str, @obj) assert_equal(str_fcomp, @obj.forward_complement!) assert_equal(str_fcomp, @obj) end def test_reverse_complement str = 'atgcatgcatgcatgcaaaa' str_rcomp = 'tacgtacgtacgtacgtttt'.reverse rcomp = @obj.forward_complement assert_equal(str_rcomp, @obj.reverse_complement) assert_equal(str, @obj) assert_equal(str_rcomp, @obj.reverse_complement!) assert_equal(str_rcomp, @obj) end def test_complement assert(@obj.complement) assert(@obj.complement!) end def test_to_s str = 'atgcatgcatgcatgcaaaa' assert_equal(str, @obj.to_s) end def test_codon_usage usage = {"cat"=>1, "caa"=>1, "tgc"=>1, "gca"=>1, "atg"=>2} assert_equal(usage, @obj.codon_usage) end def test_gc_percent assert_equal(40, @obj.gc_percent) @obj[0, 1] = 'g' assert_equal(45, @obj.gc_percent) end def test_iliegal_bases @obj[0, 1] = 'n' @obj[1, 1] = 'y' assert_equal(['n', 'y'], @obj.illegal_bases) end def test_molecular_weight assert_in_delta(6174.3974, @obj.molecular_weight, 1e-4) end def test_to_re assert_equal(/atgcatgcatgcatgcaaaa/, @obj.to_re) @obj[1,1] = 'n' @obj[2,1] = 'r' @obj[3,1] = 's' @obj[4,1] = 'y' @obj[5,1] = 'w' assert_equal(/a[atgc][ag][gc][tc][at]gcatgcatgcaaaa/, @obj.to_re) end def test_names ary = ["Adenine", "Thymine", "Guanine"] assert_equal(ary , @obj.splice("1..3").names) end def test_dna @obj[0,1] = 'u' assert_equal('utgcatgcatgcatgcaaaa', @obj) assert_equal('ttgcatgcatgcatgcaaaa', @obj.dna) end def test_dna! @obj[0,1] = 'u' assert_equal('utgcatgcatgcatgcaaaa', @obj) @obj.dna! assert_equal('ttgcatgcatgcatgcaaaa', @obj) end def test_rna assert_equal('atgcatgcatgcatgcaaaa', @obj) assert_equal('augcaugcaugcaugcaaaa', @obj.rna) end def test_rna! assert_equal('atgcatgcatgcatgcaaaa', @obj) @obj.rna! assert_equal('augcaugcaugcaugcaaaa', @obj) end end class TestSequenceNATranslation < Test::Unit::TestCase def setup str = "aaacccgggttttaa" # K>>P>>G>>F>>*>> # N>>P>>G>>F>> # T>>R>>V>>L>> # P>>G>>F>>*>> # "tttgggcccaaaatt" # < Update of /home/repository/bioruby/bioruby/test/unit/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv8762/test/unit/bio/sequence Added Files: test_aa.rb Log Message: * ANewly added. --- NEW FILE: test_aa.rb --- # # = test/unit/bio/sequence/test_aa.rb - Unit test for Bio::Sequencce::AA # # Copyright:: Copyright (C) 2006 # Mitsuteru C. Nakao # Lisence:: Ruby's # # $Id: test_aa.rb,v 1.1 2006/02/08 07:20:24 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/sequence' require 'bio/sequence/aa' module Bio class TestSequenceAANew < Test::Unit::TestCase def test_new str = "RRLEHTFVFL RNFSLMLLRY" assert(Bio::Sequence::AA.new(str)) end def test_new_t str = "RRLEHTFVFLRNFSLMLLRY" str_t = "RRLEHTFVFL\tRNFSLMLLRY" assert_equal(str, Bio::Sequence::AA.new(str_t)) end def test_new_n str = "RRLEHTFVFLRNFSLMLLRY" str_n = "RRLEHTFVFL\nRNFSLMLLRY" assert_equal(str, Bio::Sequence::AA.new(str_n)) end def test_new_r str = "RRLEHTFVFLRNFSLMLLRY" str_r = "RRLEHTFVFL\n\rRNFSLMLLRY" assert_equal(str, Bio::Sequence::AA.new(str_r)) end end class TestSequenceAA < Test::Unit::TestCase def setup str = "RRLEHTFVFLRNFSLMLLRY" @obj = Bio::Sequence::AA.new(str) end def test_to_s str = "RRLEHTFVFLRNFSLMLLRY" assert_equal(str, @obj.to_s) end def test_molecular_weight assert_in_delta(2612.105, @obj.molecular_weight, 1e-4) end def test_to_re re = /RRLEHTFVFLRNFSLMLLRY/ assert_equal(re, @obj.to_re) @obj[1, 1] = 'B' re = /R[DN]LEHTFVFLRNFSLMLLRY/ assert_equal(re, @obj.to_re) end def test_codes ary = ["Arg", "Arg", "Leu", "Glu", "His", "Thr", "Phe", "Val", "Phe", "Leu", "Arg", "Asn", "Phe", "Ser", "Leu", "Met", "Leu", "Leu", "Arg", "Tyr"] assert_equal(ary, @obj.codes) end def test_names ary = ["arginine", "arginine", "leucine", "glutamic acid", "histidine", "threonine", "phenylalanine", "valine", "phenylalanine", "leucine", "arginine", "asparagine", "phenylalanine", "serine", "leucine", "methionine", "leucine", "leucine", "arginine", "tyrosine"] assert_equal(ary, @obj.names) end end require 'bio/sequence/aa' class TestSequenceAACompat < Test::Unit::TestCase def test_aa_self_randomize composition = Bio::Sequence::AA.new("WWDTGAK").composition assert(Bio::Sequence::AA.randomize(composition)) end end end From k at pub.open-bio.org Wed Feb 8 07:02:11 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed, 08 Feb 2006 12:02:11 +0000 Subject: [BioRuby-cvs] bioruby README.DEV,1.8,1.9 Message-ID: <200602081202.k18C2BVL009636@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv9632 Modified Files: README.DEV Log Message: * changes on license Index: README.DEV =================================================================== RCS file: /home/repository/bioruby/bioruby/README.DEV,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** README.DEV 14 Nov 2005 15:50:21 -0000 1.8 --- README.DEV 8 Feb 2006 12:02:09 -0000 1.9 *************** *** 3,7 **** $Id$ ! Copyright (C) 2005 Toshiaki Katayama = How to contribute to the BioRuby project? --- 3,7 ---- $Id$ ! Copyright (C) 2005, 2006 Toshiaki Katayama = How to contribute to the BioRuby project? *************** *** 15,19 **** * Develop code for new features, etc. ! All of these are welcome! This document describes the last option, how to contribute your code to the BioRuby distribution. --- 15,19 ---- * Develop code for new features, etc. ! All of these are welcome! However, this document describes the last option, how to contribute your code to the BioRuby distribution. *************** *** 23,29 **** == License ! If you would like your module to be included in the BioRuby ! distribution, please license your module under GNU's LGPL for ! compatibility with the BioRuby project. == Coding style --- 23,32 ---- == License ! If you would like your module to be included in the BioRuby distribution, ! you need to give us right to change the license of your module to make it ! compatible with other modules in BioRuby. ! ! BioRuby was previously distributed under the GNU GPL license, but now we ! are changing the license to Ruby's. == Coding style *************** *** 56,60 **** # Bio R. Hacker , # Chem R. Hacker ! # License:: LGPL # # $Id$ --- 59,63 ---- # Bio R. Hacker , # Chem R. Hacker ! # License:: Ruby's # # $Id$ *************** *** 73,97 **** # == References # ! # * Hoge F. et al., The Hoge database, Nucleic. Acid. Res. 123:100--123 (2030) # # * http://hoge.db/ - # - #-- - # - # 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 - # - #++ # --- 76,82 ---- # == References # ! # * Hoge F. et al., The Hoge database, Nucleic. Acid. Res. 123:100--123 (2030) # # * http://hoge.db/ # From k at pub.open-bio.org Wed Feb 8 07:15:44 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed, 08 Feb 2006 12:15:44 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/data na.rb,0.19,0.20 Message-ID: <200602081215.k18CFiVL009693@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/data In directory pub.open-bio.org:/tmp/cvs-serv9682/lib/bio/data Modified Files: na.rb Log Message: * to_re method is fixed to convert input sequence to downcase and not to change original sequence itself. Index: na.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/data/na.rb,v retrieving revision 0.19 retrieving revision 0.20 diff -C2 -d -r0.19 -r0.20 *** na.rb 10 Dec 2005 18:14:22 -0000 0.19 --- na.rb 8 Feb 2006 12:15:42 -0000 0.20 *************** *** 4,8 **** # Copyright:: Copyright (C) 2001, 2005 # Toshiaki Katayama ! # License:: LGPL # # $Id$ --- 4,8 ---- # Copyright:: Copyright (C) 2001, 2005 # Toshiaki Katayama ! # License:: Ruby's # # $Id$ *************** *** 39,60 **** # p Bio::NucleicAcid.weight('atgc') # - #-- - # - # 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 - # - #++ - # module Bio --- 39,42 ---- *************** *** 177,181 **** def to_re(seq, rna = false) ! str = seq.to_s str.gsub!(/[^atgcu]/) { |base| NAMES[base] || '.' --- 159,163 ---- def to_re(seq, rna = false) ! str = seq.to_s.downcase str.gsub!(/[^atgcu]/) { |base| NAMES[base] || '.' From nakao at pub.open-bio.org Wed Feb 8 08:57:03 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 08 Feb 2006 13:57:03 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/data test_na.rb,1.5,1.6 Message-ID: <200602081357.k18Dv3VL011351@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/data In directory pub.open-bio.org:/tmp/cvs-serv11278/test/unit/bio/data Modified Files: test_na.rb Log Message: * Changed on lisence. * test_to_re: added tests to check the Bio::NucleicAcid.to_re. Index: test_na.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/data/test_na.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_na.rb 25 Nov 2005 15:59:29 -0000 1.5 --- test_na.rb 8 Feb 2006 13:57:01 -0000 1.6 *************** *** 2,20 **** # test/unit/bio/data/test_na.rb - Unit test for Bio::NucleicAcid # ! # Copyright (C) 2005 Mitsuteru Nakao ! # ! # 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$ --- 2,7 ---- # test/unit/bio/data/test_na.rb - Unit test for Bio::NucleicAcid # ! # Copyright:: Copyright (C) 2005,2006 Mitsuteru Nakao ! # Lisence:: Ruby's # # $Id$ *************** *** 48,51 **** --- 35,39 ---- class TestNA < Test::Unit::TestCase + def setup @obj = Bio::NucleicAcid.new *************** *** 54,59 **** def test_to_re re = /[tc][ag][at][gc][tg][ac][tgc][atg][agc][atgc]atgc/ ! assert_equal(re, @obj.to_re('yrwskmbdvnatgc')) ! assert_equal(re, Bio::NucleicAcid.to_re('yrwskmbdvnatgc')) end --- 42,50 ---- def test_to_re re = /[tc][ag][at][gc][tg][ac][tgc][atg][agc][atgc]atgc/ ! str = 'yrwskmbdvnatgc' ! str0 = str.clone ! assert_equal(re, @obj.to_re(str)) ! assert_equal(str0, str) ! assert_equal(re, Bio::NucleicAcid.to_re(str)) end From nakao at pub.open-bio.org Wed Feb 8 09:39:01 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 08 Feb 2006 14:39:01 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio reference.rb,1.19,1.20 Message-ID: <200602081439.k18Ed1VL012353@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv12343/lib/bio Modified Files: reference.rb Log Message: * Bio::References#append: fixed a typo. Index: reference.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/reference.rb,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** reference.rb 29 Jan 2006 07:39:31 -0000 1.19 --- reference.rb 8 Feb 2006 14:38:59 -0000 1.20 *************** *** 366,370 **** # Append a Bio::Reference object. def append(reference) ! @references.push(reference) if a.is_a? Reference return self end --- 366,370 ---- # Append a Bio::Reference object. def append(reference) ! @references.push(reference) if reference.is_a? Reference return self end From nakao at pub.open-bio.org Wed Feb 8 10:06:28 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 08 Feb 2006 15:06:28 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio test_reference.rb,NONE,1.1 Message-ID: <200602081506.k18F6SVL012449@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio In directory pub.open-bio.org:/tmp/cvs-serv12435/test/unit/bio Added Files: test_reference.rb Log Message: * lib/bio/reference.rb: fixed a bug in the endnote method. * test/unit/bio/test_reference.rb: newly added. --- NEW FILE: test_reference.rb --- # # = test/bio/tc_pathway.rb - Unit test for Bio::Pathway # # Copyright:: Copyright (C) 2006 # Mitsuteru C. Nakao # Lisence:: Ruby's # # $Id: test_reference.rb,v 1.1 2006/02/08 15:06:26 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), [".."] * 3, "lib")).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/reference' module Bio class TestReference < Test::Unit::TestCase def setup hash = {'authors' => [ "Hoge, J.P.", "Fuga, F.B." ], 'title' => "Title of the study.", 'journal' => "Theor. J. Hoge", 'volume' => 12, 'issue' => 3, 'pages' => "123-145", 'year' => 2001, 'pubmed' => 12345678, 'medline' => 98765432, 'abstract' => "Hoge fuga. hoge fuga.", 'url' => "http://example.com", 'mesh' => ['Hoge'], 'affiliations' => ['Tokyo']} @obj = Bio::Reference.new(hash) end def test_authors ary = [ "Hoge, J.P.", "Fuga, F.B." ] assert_equal(ary, @obj.authors) end def test_journal str = 'Theor. J. Hoge' assert_equal(str, @obj.journal) end def test_volume str = 12 assert_equal(str, @obj.volume) end def test_issue str = 3 assert_equal(str, @obj.issue) end def test_pages str = '123-145' assert_equal(str, @obj.pages) end def test_year str = 2001 assert_equal(str, @obj.year) end def test_pubmed str = 12345678 assert_equal(str, @obj.pubmed) end def test_abstract str = 'Hoge fuga. hoge fuga.' assert_equal(str, @obj.abstract) end def test_url str = 'http://example.com' assert_equal(str, @obj.url) end def test_mesh str = ['Hoge'] assert_equal(str, @obj.mesh) end def test_affiliations str = ['Tokyo'] assert_equal(str, @obj.affiliations) end def test_format_general str = 'Hoge, J.P., Fuga, F.B. (2001). "Title of the study." Theor. J. Hoge 12:123-145.' assert_equal(str, @obj.format) assert_equal(str, @obj.format('general')) assert_equal(str, @obj.general) end def test_format_endnote str = "%0 Journal Article\n%A Hoge, J.P.\n%A Fuga, F.B.\n%D 2001\n%T Title of the study.\n%J Theor. J. Hoge\n%V 12\n%N 3\n%P 123-145\n%M 12345678\n%U http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&dopt=Citation&list_uids=12345678\n%X Hoge fuga. hoge fuga.\n%K Hoge\n%+ Tokyo" assert_equal(str, @obj.format('endnote')) assert_equal(str, @obj.endnote) end def test_format_bibitem str = "\\bibitem{PMID:12345678}\nHoge, J.P., Fuga, F.B.\nTitle of the study.,\n{\\em Theor. J. Hoge}, 12(3):123--145, 2001." assert_equal(str, @obj.format('bibitem')) assert_equal(str, @obj.bibitem) end def test_format_bibtex str =< Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv12435/lib/bio Modified Files: reference.rb Log Message: * lib/bio/reference.rb: fixed a bug in the endnote method. * test/unit/bio/test_reference.rb: newly added. Index: reference.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/reference.rb,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** reference.rb 8 Feb 2006 14:38:59 -0000 1.20 --- reference.rb 8 Feb 2006 15:06:26 -0000 1.21 *************** *** 43,50 **** # === Examples # ! # hash = {'authors' => [ "Hoge, J.P.", "Fuga, F.B." ], 'title' => "Title of the study.", ! # 'journal' => "Theor. J. Hoge", 'volume' => 12, 'issue' => 3, 'pages' => "123-145", ! # 'year' => 2001, 'pubmed' => 12345678, 'medline' => 98765432, 'abstract' => "...", ! # ''url' => "http://...", 'mesh' => [], 'affiliations' => []} # ref = Bio::Reference.new(hash) # --- 43,59 ---- # === Examples # ! # hash = {'authors' => [ "Hoge, J.P.", "Fuga, F.B." ], ! # 'title' => "Title of the study.", ! # 'journal' => "Theor. J. Hoge", ! # 'volume' => 12, ! # 'issue' => 3, ! # 'pages' => "123-145", ! # 'year' => 2001, ! # 'pubmed' => 12345678, ! # 'medline' => 98765432, ! # 'abstract' => "Hoge fuga. ...", ! # 'url' => "http://example.com", ! # 'mesh' => [], ! # 'affiliations' => []} # ref = Bio::Reference.new(hash) # *************** *** 171,181 **** lines << "%A #{author}" end ! lines << "%D #{@year}" unless @year.empty? lines << "%T #{@title}" unless @title.empty? lines << "%J #{@journal}" unless @journal.empty? ! lines << "%V #{@volume}" unless @volume.empty? ! lines << "%N #{@issue}" unless @issue.empty? lines << "%P #{@pages}" unless @pages.empty? ! lines << "%M #{@pubmed}" unless @pubmed.empty? if @pubmed cgi = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi" --- 180,190 ---- lines << "%A #{author}" end ! lines << "%D #{@year}" unless @year.to_s.empty? lines << "%T #{@title}" unless @title.empty? lines << "%J #{@journal}" unless @journal.empty? ! lines << "%V #{@volume}" unless @volume.to_s.empty? ! lines << "%N #{@issue}" unless @issue.to_s.empty? lines << "%P #{@pages}" unless @pages.empty? ! lines << "%M #{@pubmed}" unless @pubmed.to_s.empty? if @pubmed cgi = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi" From k at pub.open-bio.org Wed Feb 8 12:22:24 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed, 08 Feb 2006 17:22:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio sequence.rb,0.52,0.53 Message-ID: <200602081722.k18HMOVL012865@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv12861/lib/bio Modified Files: sequence.rb Log Message: * @seq extends Bio::Sequence::Common to make 'guess' method can find composition method on @seq. This fix is for the 'seq' command in BioRuby shell to work. Index: sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence.rb,v retrieving revision 0.52 retrieving revision 0.53 diff -C2 -d -r0.52 -r0.53 *** sequence.rb 6 Feb 2006 14:10:01 -0000 0.52 --- sequence.rb 8 Feb 2006 17:22:22 -0000 0.53 *************** *** 4,31 **** # Copyright:: Copyright (C) 2000-2006 # Toshiaki Katayama , ! # Yoshinori K. Okuji , # Naohisa Goto ! # License:: LGPL # # $Id$ # - #-- - # - # 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 - # - #++ - # require 'bio/sequence/compat' --- 4,13 ---- # Copyright:: Copyright (C) 2000-2006 # Toshiaki Katayama , ! # Yoshinori K. Okuji , # Naohisa Goto ! # License:: Ruby's # # $Id$ # require 'bio/sequence/compat' *************** *** 35,40 **** class Sequence def initialize(str) ! @seq = str end --- 17,29 ---- class Sequence + autoload :Common, 'bio/sequence/common' + autoload :NA, 'bio/sequence/na' + autoload :AA, 'bio/sequence/aa' + autoload :Generic, 'bio/sequence/generic' + autoload :Format, 'bio/sequence/format' + def initialize(str) ! @seq = str.dup ! @seq.extend Bio::Sequence::Common end *************** *** 46,55 **** :date, :keywords, :dblinks, :taxonomy, :moltype, :seq - autoload :Common, 'bio/sequence/common' - autoload :NA, 'bio/sequence/na' - autoload :AA, 'bio/sequence/aa' - autoload :Generic, 'bio/sequence/generic' - autoload :Format, 'bio/sequence/format' - def output(style) extend Bio::Sequence::Format --- 35,38 ---- *************** *** 67,77 **** def self.auto(str) ! moltype = self.guess(str) ! if moltype == NA @seq = NA.new(str) else @seq = AA.new(str) end - return @seq end --- 50,59 ---- def self.auto(str) ! @moltype = self.guess(str) ! if @moltype == NA @seq = NA.new(str) else @seq = AA.new(str) end return @seq end From ngoto at pub.open-bio.org Wed Feb 8 22:28:50 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Thu, 09 Feb 2006 03:28:50 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db fasta.rb,1.22,1.23 Message-ID: <200602090328.k193SoVL014503@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv14493/lib/bio/db Modified Files: fasta.rb Log Message: * changed Bio::Sequence.new to Bio::Sequence::Generic.new (temporary change) * changed Lisence to Ruby's Index: fasta.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/fasta.rb,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** fasta.rb 28 Jan 2006 10:48:59 -0000 1.22 --- fasta.rb 9 Feb 2006 03:28:48 -0000 1.23 *************** *** 5,9 **** # GOTO Naohisa , # KATAYAMA Toshiaki ! # Lisence:: LGPL # # $Id$ --- 5,9 ---- # GOTO Naohisa , # KATAYAMA Toshiaki ! # Lisence:: Ruby's # # $Id$ *************** *** 63,84 **** # http://www.ncbi.nlm.nih.gov/BLAST/fasta.shtml # - #-- - # - # 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 - # - #++ - # require 'bio/db' --- 63,66 ---- *************** *** 209,213 **** unless defined?(@seq) unless /\A\s*^\#/ =~ @data then ! @seq = Sequence.new(@data.tr(" \t\r\n0-9", '')) # lazy clean up else a = @data.split(/(^\#.*$)/) --- 191,195 ---- unless defined?(@seq) unless /\A\s*^\#/ =~ @data then ! @seq = Sequence::Generic.new(@data.tr(" \t\r\n0-9", '')) # lazy clean up else a = @data.split(/(^\#.*$)/) *************** *** 225,229 **** end @comment = cmnt ! @seq = Bio::Sequence.new(s.join('')) end end --- 207,211 ---- end @comment = cmnt ! @seq = Bio::Sequence::Generic.new(s.join('')) end end From k at pub.open-bio.org Thu Feb 9 11:21:49 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 16:21:49 +0000 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.63,1.64 Message-ID: <200602091621.k19GLnVL017624@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv17620 Modified Files: bio.rb Log Message: * license changed, prepared for 0.8.0 Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** bio.rb 6 Feb 2006 14:07:11 -0000 1.63 --- bio.rb 9 Feb 2006 16:21:47 -0000 1.64 *************** *** 4,33 **** # Copyright:: Copyright (C) 2001-2006 # Toshiaki Katayama ! # License:: LGPL # # $Id$ # - #-- - # - # 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 - # - #++ - # module Bio ! BIORUBY_VERSION = [0, 7, 2].extend(Comparable) ### Basic data types --- 4,15 ---- # Copyright:: Copyright (C) 2001-2006 # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # module Bio ! BIORUBY_VERSION = [0, 8, 0].extend(Comparable) ### Basic data types From k at pub.open-bio.org Thu Feb 9 11:29:12 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 16:29:12 +0000 Subject: [BioRuby-cvs] bioruby/bin bioruby,1.10,1.11 Message-ID: <200602091629.k19GTCVL017653@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv17647 Modified Files: bioruby Log Message: * license changed * if argument is given, 1. arg == dir : chdir to the specified working directory at start up or 2. arg == file : run the fille as a bioruby shell script or 3. arg == str : create the new directory to work on Index: bioruby =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/bioruby,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** bioruby 7 Dec 2005 05:12:06 -0000 1.10 --- bioruby 9 Feb 2006 16:29:10 -0000 1.11 *************** *** 3,32 **** # = BioRuby shell - command line interface for the BioRuby library # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ # - #-- - # - # 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 - # - #++ - # - - # $: << File.dirname(__FILE__)+'/../lib' begin --- 3,12 ---- # = BioRuby shell - command line interface for the BioRuby library # ! # Copyright:: Copyright (C) 2005, 2006 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # begin *************** *** 39,42 **** --- 19,40 ---- include Bio::Shell + + ### Command line argument + + # working directory or script file + arg = ARGV.shift + if File.directory?(arg) + # directory or symlink to directory + Dir.chdir(arg) + elsif File.exists?(arg) + # BioRuby shell script (lib/bioruby.rb can be obsolete) + load arg + exit + elsif arg + Dir.mkdir(arg) + Dir.chdir(arg) + end + + ### BioRuby shell setup # loading configuration and plugins From k at pub.open-bio.org Thu Feb 9 11:20:59 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 16:20:59 +0000 Subject: [BioRuby-cvs] bioruby/lib bioruby.rb,1.1,NONE Message-ID: <200602091620.k19GKxVL017598@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv17594 Removed Files: bioruby.rb Log Message: * This functionality will be moved to bioruby shell --- bioruby.rb DELETED --- From k at pub.open-bio.org Thu Feb 9 11:29:43 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 16:29:43 +0000 Subject: [BioRuby-cvs] bioruby/bin br_biofetch.rb, 1.2, 1.3 br_bioflat.rb, 1.14, 1.15 br_biogetseq.rb, 1.2, 1.3 br_pmfetch.rb, 1.5, 1.6 Message-ID: <200602091629.k19GThVL017680@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv17676 Modified Files: br_biofetch.rb br_bioflat.rb br_biogetseq.rb br_pmfetch.rb Log Message: * license is changed to Ruby's Index: br_pmfetch.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/br_pmfetch.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** br_pmfetch.rb 11 Jul 2005 09:31:32 -0000 1.5 --- br_pmfetch.rb 9 Feb 2006 16:29:41 -0000 1.6 *************** *** 1,21 **** #!/usr/bin/env ruby # ! # pmfetch - PubMed client ! # ! # Copyright (C) 2004, 2005 Toshiaki Katayama ! # ! # This program is free software; you can redistribute it and/or modify ! # it under the terms of the GNU General Public License as published by ! # the Free Software Foundation; either version 2 of the License, or ! # (at your option) any later version. # ! # This program 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 General Public License for more details. # ! # You should have received a copy of the GNU General Public License ! # along with this program; if not, write to the Free Software ! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # --- 1,11 ---- #!/usr/bin/env ruby # ! # = pmfetch - PubMed client # ! # Copyright:: Copyright (C) 2004, 2005 ! # Toshiaki Katayama ! # License:: Ruby's # ! # $Id$ # Index: br_biogetseq.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/br_biogetseq.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** br_biogetseq.rb 21 Feb 2003 02:44:22 -0000 1.2 --- br_biogetseq.rb 9 Feb 2006 16:29:41 -0000 1.3 *************** *** 1,23 **** #!/usr/bin/env ruby # ! # biogetseq - OBDA sequence data retrieval (executable) ! # ! # Copyright (C) 2003 KATAYAMA Toshiaki ! # ! # This program is free software; you can redistribute it and/or modify ! # it under the terms of the GNU General Public License as published by ! # the Free Software Foundation; either version 2 of the License, or ! # (at your option) any later version. ! # ! # This program 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 General Public License for more details. ! # ! # You should have received a copy of the GNU General Public License ! # along with this program; if not, write to the Free Software ! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! # $Id$ # --- 1,11 ---- #!/usr/bin/env ruby # ! # = biogetseq - OBDA sequence data retrieval (executable) # ! # Copyright:: Copyright (C) 2003 ! # Toshiaki Katayama ! # License:: Ruby's ! # ! # $Id$ # Index: br_biofetch.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/br_biofetch.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** br_biofetch.rb 3 Dec 2002 18:54:43 -0000 1.2 --- br_biofetch.rb 9 Feb 2006 16:29:41 -0000 1.3 *************** *** 1,23 **** #!/usr/bin/env ruby # ! # biofetch - BioFetch client ! # ! # Copyright (C) 2002 KATAYAMA Toshiaki ! # ! # This program is free software; you can redistribute it and/or modify ! # it under the terms of the GNU General Public License as published by ! # the Free Software Foundation; either version 2 of the License, or ! # (at your option) any later version. ! # ! # This program 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 General Public License for more details. # ! # You should have received a copy of the GNU General Public License ! # along with this program; if not, write to the Free Software ! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! # $Id$ # --- 1,11 ---- #!/usr/bin/env ruby # ! # = biofetch - BioFetch client # ! # Copyright:: Copyright (C) 2002 ! # Toshiaki Katayama ! # License:: Ruby's # ! # $Id$ # Index: br_bioflat.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/br_bioflat.rb,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** br_bioflat.rb 27 Aug 2003 17:28:30 -0000 1.14 --- br_bioflat.rb 9 Feb 2006 16:29:41 -0000 1.15 *************** *** 1,23 **** #!/usr/bin/env ruby # ! # bioflat - OBDA flat file indexer (executable) ! # ! # Copyright (C) 2002 GOTO Naohisa ! # ! # This program is free software; you can redistribute it and/or modify ! # it under the terms of the GNU General Public License as published by ! # the Free Software Foundation; either version 2 of the License, or ! # (at your option) any later version. ! # ! # This program 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 General Public License for more details. ! # ! # You should have received a copy of the GNU General Public License ! # along with this program; if not, write to the Free Software ! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! # $Id$ # --- 1,11 ---- #!/usr/bin/env ruby # ! # = bioflat - OBDA flat file indexer (executable) # ! # Copyright:: Copyright (C) 2002 ! # Naohisa Goto ! # License:: Ruby's ! # ! # $Id$ # From k at pub.open-bio.org Thu Feb 9 15:17:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 20:17:06 +0000 Subject: [BioRuby-cvs] bioruby/bin bioruby,1.11,1.12 Message-ID: <200602092017.k19KH6VL018828@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv18814/bin Modified Files: bioruby Log Message: * fixed to run without argument. if argument is not given, current directory will be used to save session Index: bioruby =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/bioruby,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** bioruby 9 Feb 2006 16:29:10 -0000 1.11 --- bioruby 9 Feb 2006 20:17:03 -0000 1.12 *************** *** 23,37 **** # working directory or script file ! arg = ARGV.shift ! if File.directory?(arg) ! # directory or symlink to directory ! Dir.chdir(arg) ! elsif File.exists?(arg) ! # BioRuby shell script (lib/bioruby.rb can be obsolete) ! load arg ! exit ! elsif arg ! Dir.mkdir(arg) ! Dir.chdir(arg) end --- 23,38 ---- # working directory or script file ! if arg = ARGV.shift ! if File.directory?(arg) ! # directory or symlink to directory ! Dir.chdir(arg) ! elsif File.exists?(arg) ! # BioRuby shell script (lib/bioruby.rb can be obsolete) ! load arg ! exit ! elsif arg ! Dir.mkdir(arg) ! Dir.chdir(arg) ! end end From k at pub.open-bio.org Thu Feb 9 15:26:10 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 20:26:10 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.16,1.17 Message-ID: <200602092026.k19KQAVL018915@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv18893/lib/bio/shell Modified Files: core.rb Log Message: * /etc/bioinformatics/bioruby and ~/.bioinformatics/bioruby directories are not used anymore. * changed to save session files (history, config, object) in the 'session' directory in the current directory (or in the directory specified in command line argument) instead of in the './.bioruby' directory. * 'session', 'plugin', and 'data' directories are created by default when user save the session (no directory is created when the session is not saved) Index: core.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** core.rb 7 Dec 2005 10:54:23 -0000 1.16 --- core.rb 9 Feb 2006 20:26:08 -0000 1.17 *************** *** 2,32 **** # = bio/shell/core.rb - internal methods for the BioRuby shell # ! # Copyright:: Copyright (C) 2005 # Toshiaki Katayama ! # License:: LGPL # # $Id$ # ! #-- ! # ! # 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 ! # ! #++ ! # module Bio::Shell::Ghost CONFIG = "config" OBJECT = "object" --- 2,16 ---- # = bio/shell/core.rb - internal methods for the BioRuby shell # ! # Copyright:: Copyright (C) 2005, 2006 # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # ! module Bio::Shell::Ghost + SAVEDIR = "session/" CONFIG = "config" OBJECT = "object" *************** *** 34,43 **** 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 ] --- 18,24 ---- SCRIPT = "script.rb" PLUGIN = "plugin/" + DATADIR = "data/" BIOFLAT = "bioflat/" MARSHAL = [ Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION ] *************** *** 136,169 **** def create_save_dir ! dir = ask_save_dir ! create_real_dir(dir) ! create_real_dir(dir + PLUGIN) ! create_real_dir(dir + BIOFLAT) ! return dir end ! # 1. ask to save in SAVEDIR directory in the current directory ! # 2. otherwise save in USERDIR directory ! # 3. remember the choice in @cache[:savedir] once per session ! def ask_save_dir ! if @cache[:savedir] ! dir = @cache[:savedir] ! else ! dir = SAVEDIR ! if ! File.directory?(dir) ! loop do ! print "Save in \"#{dir}\" directory? [y/n]: " ! answer = gets ! if /^\s*[Yy]/.match(answer) ! break ! elsif /^\s*[Nn]/.match(answer) ! dir = USERDIR ! break ! end ! end end - @cache[:savedir] = dir end - return dir end --- 117,149 ---- def create_save_dir ! if @cache[:save].nil? ! if ask_yes_or_no("Save session in '#{SAVEDIR}' directory? [y/n]: ") ! create_real_dir(SAVEDIR) ! create_real_dir(DATADIR) ! create_real_dir(PLUGIN) ! # create_real_dir(BIOFLAT) ! @cache[:save] = true ! else ! @cache[:save] = false ! end ! end ! return @cache[:save] end ! def ask_yes_or_no(message) ! loop do ! print message ! answer = gets ! if answer.nil? ! # readline support might be broken ! return false ! elsif /^\s*[Nn]/.match(answer) ! return false ! elsif /^\s*[Yy]/.match(answer) ! return true ! else ! # loop end end end *************** *** 175,179 **** puts "done" rescue ! warn "Error: Failed to create #{dir} : #{$!}" end end --- 155,159 ---- puts "done" rescue ! warn "Error: Failed to create directory (#{dir}) : #{$!}" end end *************** *** 183,196 **** def create_flat_dir(dbname) ! if prefix = create_save_dir ! return prefix + BIOFLAT + dbname.to_s.strip ! else ! return nil end end def find_flat_dir(dbname) ! dir = SAVEDIR + BIOFLAT + dbname.to_s.strip ! dir = USERDIR + BIOFLAT + dbname.to_s.strip unless File.exists?(dir) if File.exists?(dir) return dir --- 163,178 ---- def create_flat_dir(dbname) ! dir = BIOFLAT + dbname.to_s.strip ! unless File.directory?(BIOFLAT) ! Dir.mkdir(BIOFLAT) end + unless File.directory?(dir) + Dir.mkdir(dir) + end + return dir end def find_flat_dir(dbname) ! dir = BIOFLAT + dbname.to_s.strip if File.exists?(dir) return dir *************** *** 203,208 **** def load_config - load_config_file(SITEDIR + CONFIG) - load_config_file(USERDIR + CONFIG) load_config_file(SAVEDIR + CONFIG) end --- 185,188 ---- *************** *** 219,224 **** def save_config ! dir = create_save_dir ! save_config_file(dir + CONFIG) end --- 199,205 ---- def save_config ! if create_save_dir ! save_config_file(SAVEDIR + CONFIG) ! end end *************** *** 274,279 **** def load_plugin - load_plugin_dir(SITEDIR + PLUGIN) - load_plugin_dir(USERDIR + PLUGIN) load_plugin_dir(SAVEDIR + PLUGIN) end --- 255,258 ---- *************** *** 292,297 **** def load_object - load_object_file(SITEDIR + OBJECT) - load_object_file(USERDIR + OBJECT) load_object_file(SAVEDIR + OBJECT) end --- 271,274 ---- *************** *** 319,324 **** def save_object ! dir = create_save_dir ! save_object_file(dir + OBJECT) end --- 296,302 ---- def save_object ! if create_save_dir ! save_object_file(SAVEDIR + OBJECT) ! end end *************** *** 359,364 **** def load_history if @cache[:readline] - load_history_file(SITEDIR + HISTORY) - load_history_file(USERDIR + HISTORY) load_history_file(SAVEDIR + HISTORY) end --- 337,340 ---- *************** *** 377,382 **** def save_history if @cache[:readline] ! dir = create_save_dir ! save_history_file(dir + HISTORY) end end --- 353,359 ---- def save_history if @cache[:readline] ! if create_save_dir ! save_history_file(SAVEDIR + HISTORY) ! end end end *************** *** 429,434 **** def save_script if @script_begin and @script_end and @script_begin <= @script_end ! dir = create_save_dir ! save_script_file(dir + SCRIPT) else puts "Error: script range #{@script_begin}..#{@script_end} is invalid" --- 406,412 ---- def save_script if @script_begin and @script_end and @script_begin <= @script_end ! if create_save_dir ! save_script_file(SAVEDIR + SCRIPT) ! end else puts "Error: script range #{@script_begin}..#{@script_end} is invalid" From k at pub.open-bio.org Thu Feb 9 15:48:55 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 20:48:55 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb, 1.17, 1.18 session.rb, 1.11, 1.12 Message-ID: <200602092048.k19KmtVL019068@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv19056/shell Modified Files: core.rb session.rb Log Message: * license is changed to Ruby's Index: session.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/session.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** session.rb 7 Dec 2005 07:50:44 -0000 1.11 --- session.rb 9 Feb 2006 20:48:53 -0000 1.12 *************** *** 2,28 **** # = bio/shell/session.rb - core user interface of the BioRuby shell # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,10 ---- # = bio/shell/session.rb - core user interface of the BioRuby shell # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # Index: core.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** core.rb 9 Feb 2006 20:26:08 -0000 1.17 --- core.rb 9 Feb 2006 20:48:53 -0000 1.18 *************** *** 2,8 **** # = bio/shell/core.rb - internal methods for the BioRuby shell # ! # Copyright:: Copyright (C) 2005, 2006 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ --- 2,8 ---- # = bio/shell/core.rb - internal methods for the BioRuby shell # ! # Copyright:: Copyright (C) 2005, 2006 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ From k at pub.open-bio.org Thu Feb 9 15:48:55 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 20:48:55 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin codon.rb, 1.12, 1.13 emboss.rb, 1.1, 1.2 entry.rb, 1.5, 1.6 flatfile.rb, 1.11, 1.12 keggapi.rb, 1.9, 1.10 midi.rb, 1.6, 1.7 obda.rb, 1.8, 1.9 seq.rb, 1.16, 1.17 Message-ID: <200602092048.k19KmtVL019073@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv19056/shell/plugin Modified Files: codon.rb emboss.rb entry.rb flatfile.rb keggapi.rb midi.rb obda.rb seq.rb Log Message: * license is changed to Ruby's Index: midi.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/midi.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** midi.rb 28 Nov 2005 12:06:18 -0000 1.6 --- midi.rb 9 Feb 2006 20:48:53 -0000 1.7 *************** *** 2,29 **** # = bio/shell/plugin/midi.rb - Sequence to MIDI converter # ! # Copyright:: Copyright (C) 2003, 2005 ! # Natsuhiro Ichinose , ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,11 ---- # = bio/shell/plugin/midi.rb - Sequence to MIDI converter # ! # Copyright:: Copyright (C) 2003, 2005 ! # Natsuhiro Ichinose , ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # Index: emboss.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/emboss.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** emboss.rb 28 Jan 2006 07:22:14 -0000 1.1 --- emboss.rb 9 Feb 2006 20:48:53 -0000 1.2 *************** *** 2,28 **** # = bio/shell/plugin/emboss.rb - methods to use EMBOSS # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,10 ---- # = bio/shell/plugin/emboss.rb - methods to use EMBOSS # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # Index: obda.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/obda.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** obda.rb 30 Nov 2005 02:01:04 -0000 1.8 --- obda.rb 9 Feb 2006 20:48:53 -0000 1.9 *************** *** 2,28 **** # = bio/shell/plugin/obda.rb - plugin for OBDA # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,10 ---- # = bio/shell/plugin/obda.rb - plugin for OBDA # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License: Ruby's # # $Id$ # Index: flatfile.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/flatfile.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** flatfile.rb 30 Nov 2005 01:57:18 -0000 1.11 --- flatfile.rb 9 Feb 2006 20:48:53 -0000 1.12 *************** *** 2,29 **** # = bio/shell/plugin/flatfile.rb - plugin for flatfile database # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ # - #-- - # - # 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 - # - #++ - # module Bio::Shell --- 2,11 ---- # = bio/shell/plugin/flatfile.rb - plugin for flatfile database # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License: Ruby's # # $Id$ # module Bio::Shell *************** *** 87,92 **** def flatindex(dbname, *flatfiles) - dir = Bio::Shell.create_flat_dir(dbname) begin print "Creating BioFlat index (#{dir}) ... " bdb = format = options = nil --- 69,74 ---- def flatindex(dbname, *flatfiles) begin + dir = Bio::Shell.create_flat_dir(dbname) print "Creating BioFlat index (#{dir}) ... " bdb = format = options = nil Index: keggapi.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/keggapi.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** keggapi.rb 6 Feb 2006 06:17:53 -0000 1.9 --- keggapi.rb 9 Feb 2006 20:48:53 -0000 1.10 *************** *** 2,28 **** # = bio/shell/plugin/keggapi.rb - plugin for KEGG API # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,10 ---- # = bio/shell/plugin/keggapi.rb - plugin for KEGG API # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # Index: seq.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/seq.rb,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** seq.rb 19 Dec 2005 01:20:06 -0000 1.16 --- seq.rb 9 Feb 2006 20:48:53 -0000 1.17 *************** *** 2,29 **** # = bio/shell/plugin/seq.rb - plugin for biological sequence manipulations # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ # - #-- - # - # 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 - # - #++ - # module Bio::Shell --- 2,11 ---- # = bio/shell/plugin/seq.rb - plugin for biological sequence manipulations # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # module Bio::Shell *************** *** 211,215 **** pos = self[n, size].rindex(separater) ! if self[n, size].length < size # last line of the folded str pos = nil end --- 193,197 ---- pos = self[n, size].rindex(separater) ! if self[n, size].length < size # last line of the folded str pos = nil end *************** *** 218,222 **** ary << self[n, pos+separater.length] n += pos + separater.length ! else # line too long or the last line ary << self[n, size] n += size --- 200,204 ---- ary << self[n, pos+separater.length] n += pos + separater.length ! else # line too long or the last line ary << self[n, size] n += size Index: codon.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/codon.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** codon.rb 19 Dec 2005 02:34:24 -0000 1.12 --- codon.rb 9 Feb 2006 20:48:53 -0000 1.13 *************** *** 2,28 **** # = bio/shell/plugin/codon.rb - plugin for the codon table # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,10 ---- # = bio/shell/plugin/codon.rb - plugin for the codon table # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # Index: entry.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/entry.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** entry.rb 28 Jan 2006 06:46:43 -0000 1.5 --- entry.rb 9 Feb 2006 20:48:53 -0000 1.6 *************** *** 2,28 **** # = bio/shell/plugin/entry.rb - extract entry and sequence # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,10 ---- # = bio/shell/plugin/entry.rb - extract entry and sequence # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # From k at pub.open-bio.org Thu Feb 9 15:48:55 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 20:48:55 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio shell.rb,1.12,1.13 Message-ID: <200602092048.k19KmtVL019064@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv19056 Modified Files: shell.rb Log Message: * license is changed to Ruby's Index: shell.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** shell.rb 28 Jan 2006 06:46:42 -0000 1.12 --- shell.rb 9 Feb 2006 20:48:52 -0000 1.13 *************** *** 2,28 **** # = bio/shell.rb - Loading all BioRuby shell features # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,10 ---- # = bio/shell.rb - Loading all BioRuby shell features # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License: Ruby's # # $Id$ # From nakao at pub.open-bio.org Mon Feb 13 10:49:02 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Mon, 13 Feb 2006 15:49:02 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl/bl2seq - New directory Message-ID: <200602131549.k1DFn2VL013843@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl/bl2seq In directory pub.open-bio.org:/tmp/cvs-serv13833/test/unit/bio/appl/bl2seq Log Message: Directory /home/repository/bioruby/bioruby/test/unit/bio/appl/bl2seq added to the repository From nakao at pub.open-bio.org Mon Feb 13 10:49:28 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Mon, 13 Feb 2006 15:49:28 +0000 Subject: [BioRuby-cvs] bioruby/test/data/bl2seq - New directory Message-ID: <200602131549.k1DFnSVL013870@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/bl2seq In directory pub.open-bio.org:/tmp/cvs-serv13860/test/data/bl2seq Log Message: Directory /home/repository/bioruby/bioruby/test/data/bl2seq added to the repository From nakao at pub.open-bio.org Mon Feb 13 10:51:13 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Mon, 13 Feb 2006 15:51:13 +0000 Subject: [BioRuby-cvs] bioruby/test/data/bl2seq cd8a_cd8b_blastp.bl2seq, NONE, 1.1 cd8a_p53_e-5blastp.bl2seq, NONE, 1.1 Message-ID: <200602131551.k1DFpDVL013915@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/bl2seq In directory pub.open-bio.org:/tmp/cvs-serv13903/test/data/bl2seq Added Files: cd8a_cd8b_blastp.bl2seq cd8a_p53_e-5blastp.bl2seq Log Message: * Newly added. --- NEW FILE: cd8a_p53_e-5blastp.bl2seq --- Query= CD8A_HUMAN P01732 T-cell surface glycoprotein CD8 alpha chain precursor (T-lymphocyte differentiation antigen T8/Leu-2). (235 letters) Lambda K H 0.323 0.137 0.436 Gapped Lambda K H 0.267 0.0410 0.140 Matrix: BLOSUM62 Gap Penalties: Existence: 11, Extension: 1 Number of Hits to DB: 175 Number of Sequences: 0 Number of extensions: 8 Number of successful extensions: 0 Number of sequences better than 1.0e-05: 0 Number of HSP's better than 0.0 without gapping: 0 Number of HSP's successfully gapped in prelim test: 0 Number of HSP's that attempted gapping in prelim test: 0 Number of HSP's gapped (non-prelim): 0 length of query: 235 length of database: 393 effective HSP length: 27 effective length of query: 208 effective length of database: 366 effective search space: 76128 effective search space used: 76128 T: 11 A: 40 X1: 16 ( 7.5 bits) X2: 38 (14.6 bits) X3: 64 (24.7 bits) S1: 41 (22.0 bits) S2: 74 (33.1 bits) --- NEW FILE: cd8a_cd8b_blastp.bl2seq --- Query= CD8A_HUMAN P01732 T-cell surface glycoprotein CD8 alpha chain precursor (T-lymphocyte differentiation antigen T8/Leu-2). (235 letters) >CD8B_HUMAN P10966 T-cell surface glycoprotein CD8 beta chain precursor (Antigen CD8B). Length = 210 Score = 29.6 bits (65), Expect = 5e-05 Identities = 21/90 (23%), Positives = 37/90 (41%), Gaps = 3/90 (3%) Query: 39 VELKCQVLLSNPTSGCSWLFQ---PRGAAASPTFLLYLSQNKPKAAEGLDTQRFSGKRLG 95 V L C+ +S WL Q P + L+ S E ++ ++ + R Sbjct: 37 VMLSCEAKISLSNMRIYWLRQRQAPSSDSHHEFLALWDSAKGTIHGEEVEQEKIAVFRDA 96 Query: 96 DTFVLTLSDFRRENEGYYFCSALSNSIMYF 125 F+L L+ + E+ G YFC + + + F Sbjct: 97 SRFILNLTSVKPEDSGIYFCMIVGSPELTF 126 Lambda K H 0.323 0.137 0.436 Gapped Lambda K H 0.267 0.0410 0.140 Matrix: BLOSUM62 Gap Penalties: Existence: 11, Extension: 1 Number of Hits to DB: 102 Number of Sequences: 0 Number of extensions: 5 Number of successful extensions: 3 Number of sequences better than 10.0: 1 Number of HSP's better than 10.0 without gapping: 1 Number of HSP's successfully gapped in prelim test: 0 Number of HSP's that attempted gapping in prelim test: 0 Number of HSP's gapped (non-prelim): 1 length of query: 235 length of database: 210 effective HSP length: 22 effective length of query: 213 effective length of database: 188 effective search space: 40044 effective search space used: 40044 T: 11 A: 40 X1: 16 ( 7.5 bits) X2: 38 (14.6 bits) X3: 64 (24.7 bits) S1: 20 (12.2 bits) S2: 20 (12.3 bits) From nakao at pub.open-bio.org Mon Feb 13 10:51:13 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Mon, 13 Feb 2006 15:51:13 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl/bl2seq test_report.rb, NONE, 1.1 Message-ID: <200602131551.k1DFpDVL013918@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl/bl2seq In directory pub.open-bio.org:/tmp/cvs-serv13903/test/unit/bio/appl/bl2seq Added Files: test_report.rb Log Message: * Newly added. --- NEW FILE: test_report.rb --- # # test/unit/bio/appl/bl2seq/test_report.rb - Unit test for # Bio::Blast::Bl2seq::Report # # Copyright:: Copyright (C) 2006 # Mitsuteru C. Nakao # License:: Ruby's # # $Id: test_report.rb,v 1.1 2006/02/13 15:51:11 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib'))).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/appl/bl2seq/report' module Bio class TestBl2seqReportData bioruby_root = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5)).cleanpath.to_s TestDataBl2seq = Pathname.new(File.join(bioruby_root, 'test', 'data', 'bl2seq')).cleanpath.to_s def self.output(format = 7) case format when 'empty' File.open(File.join(TestDataBl2seq, 'cd8a_p53_e-5blastp.bl2seq')).read when 'blastp' File.open(File.join(TestDataBl2seq, 'cd8a_cd8b_blastp.bl2seq')).read when 'blastn' when 'blastx' when 'tblastn' when 'tblastx' end end end class TestBl2seqReportConstants < Test::Unit::TestCase def test_rs rs = nil assert_equal(nil, Bio::Blast::Bl2seq::Report::RS) assert_equal(nil, Bio::Blast::Bl2seq::Report::DELIMITER) end end class TestBl2seqReport < Test::Unit::TestCase def setup @empty = Bio::Blast::Bl2seq::Report.new(Bio::TestBl2seqReportData.output('empty')) @blastp = Bio::Blast::Bl2seq::Report.new(Bio::TestBl2seqReportData.output('blastp')) end def test_new assert(@empty) assert(@blastp) end def test_undefed_methods methods = ['format0_parse_header', 'program', 'version', 'version_number', 'version_date', 'message', 'converged?', 'reference', 'db'] methods.each do |x| assert_nil(@empty.methods.include?(x)) end methods.each do |x| assert_nil(@blastp.methods.include?(x)) end end # TestF0dbstat < Test::Unit::TestCase def test_db_num assert_equal(0, @empty.db_num) assert_equal(0, @blastp.db_num) end def test_db_len assert_equal(393, @empty.db_len) assert_equal(210, @blastp.db_len) end # TestIteration < Test::Unit::TestCase def test_undefed_methods methods = ['message', 'pattern_in_database', 'pattern', 'pattern_positions', 'hits_found_again', 'hits_newly_found', 'hits_for_pattern', 'parse_hitlist', 'converged?'] methods.each do |x| assert_equal(false, @empty.iterations.first.methods.include?(x), "undifined? : #{x}") end methods.each do |x| assert_equal(false, @blastp.iterations.first.methods.include?(x), "undefined? : #{x}") end end end class TestBlastReportHit < Test::Unit::TestCase def setup @empty = Bio::Blast::Bl2seq::Report.new(Bio::TestBl2seqReportData.output('empty')) @blastp = Bio::Blast::Bl2seq::Report.new(Bio::TestBl2seqReportData.output('blastp')) @empty_hit = @empty.hits.first @blastp_hit = @blastp.hits.first end def test_hits assert_equal(0, @empty.hits.size) assert_equal(Bio::Blast::Bl2seq::Report::Hit, @blastp.hits.first.class) assert_equal(1, @blastp.hits.size) end end end # module Bio From k at pub.open-bio.org Tue Feb 14 08:12:08 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Tue, 14 Feb 2006 13:12:08 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio sequence.rb,0.53,0.54 Message-ID: <200602141312.k1EDC8VL017416@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv17407/lib/bio Modified Files: sequence.rb Log Message: * previous change made on initialize is moved to guess method itself to avoid dup in initialize to make things simple. * guess method is extended to accept 'length' and 'index' arguments to specify what portion of the string should be used to guess the amino or nucleic acid-ness of the sequence. Index: sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence.rb,v retrieving revision 0.53 retrieving revision 0.54 diff -C2 -d -r0.53 -r0.54 *** sequence.rb 8 Feb 2006 17:22:22 -0000 0.53 --- sequence.rb 14 Feb 2006 13:12:06 -0000 0.54 *************** *** 24,29 **** def initialize(str) ! @seq = str.dup ! @seq.extend Bio::Sequence::Common end --- 24,28 ---- def initialize(str) ! @seq = str end *************** *** 59,64 **** end ! def guess(threshold = 0.9) ! cmp = @seq.composition bases = cmp['A'] + cmp['T'] + cmp['G'] + cmp['C'] + --- 58,64 ---- end ! def guess(threshold = 0.9, length = 10000, index = 0) ! str = @seq.to_s[index,length].to_s.extend Bio::Sequence::Common ! cmp = str.composition bases = cmp['A'] + cmp['T'] + cmp['G'] + cmp['C'] + From k at pub.open-bio.org Tue Feb 14 08:18:37 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Tue, 14 Feb 2006 13:18:37 +0000 Subject: [BioRuby-cvs] bioruby/bin bioruby,1.12,1.13 Message-ID: <200602141318.k1EDIbVL017468@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv17451/bin Modified Files: bioruby Log Message: * Bio::Shell::Ghost#load/save methods are renamed to load_session/save_session respectively to avoid method name collision with Kernel#load Index: bioruby =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/bioruby,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** bioruby 9 Feb 2006 20:17:03 -0000 1.12 --- bioruby 14 Feb 2006 13:18:35 -0000 1.13 *************** *** 92,96 **** # loading workspace and command history ! Bio::Shell.load Signal.trap("SIGINT") do --- 92,96 ---- # loading workspace and command history ! Bio::Shell.load_session Signal.trap("SIGINT") do *************** *** 103,106 **** # saving workspace, command history and configuration before exit ! Bio::Shell.save --- 103,106 ---- # saving workspace, command history and configuration before exit ! Bio::Shell.save_session From k at pub.open-bio.org Tue Feb 14 08:18:37 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Tue, 14 Feb 2006 13:18:37 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.18,1.19 Message-ID: <200602141318.k1EDIbVL017472@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv17451/lib/bio/shell Modified Files: core.rb Log Message: * Bio::Shell::Ghost#load/save methods are renamed to load_session/save_session respectively to avoid method name collision with Kernel#load Index: core.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** core.rb 9 Feb 2006 20:48:53 -0000 1.18 --- core.rb 14 Feb 2006 13:18:35 -0000 1.19 *************** *** 58,62 **** attr_accessor :cache ! def load load_object load_history --- 58,62 ---- attr_accessor :cache ! def load_session load_object load_history *************** *** 64,68 **** end ! def save closing_splash save_history --- 64,68 ---- end ! def save_session closing_splash save_history From ngoto at pub.open-bio.org Tue Feb 14 08:42:42 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Tue, 14 Feb 2006 13:42:42 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db fasta.rb,1.23,1.24 Message-ID: <200602141342.k1EDggVL017584@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv17574/lib/bio/db Modified Files: fasta.rb Log Message: added to_seq method which returns a Bio::Sequence object Index: fasta.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/fasta.rb,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** fasta.rb 9 Feb 2006 03:28:48 -0000 1.23 --- fasta.rb 14 Feb 2006 13:42:40 -0000 1.24 *************** *** 244,247 **** --- 244,261 ---- end + # Returns sequence as a Bio::Sequence object. + # + # Note: If you modify the returned Bio::Sequence object, + # the sequence or definition in this FastaFormat object + # might also be changed (but not always be changed) + # because of efficiency. + # + def to_seq + seq + obj = Bio::Sequence.new(@seq) + obj.definition = self.definition + obj + end + # Parsing FASTA Defline, and extract IDs. # IDs are NSIDs (NCBI standard FASTA sequence identifiers) From k at pub.open-bio.org Tue Feb 14 08:46:45 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Tue, 14 Feb 2006 13:46:45 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin entry.rb,1.6,1.7 Message-ID: <200602141346.k1EDkjVL017671@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv17649/lib/bio/shell/plugin Modified Files: entry.rb Log Message: * Bio::Sequence.auto(str) is changed to return Bio::Sequence object instead of NA or AA object * Bio::Sequence#auto is added to replace the value of @seq with guessed type of Bio::Sequence::?A object Index: entry.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/entry.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** entry.rb 9 Feb 2006 20:48:53 -0000 1.6 --- entry.rb 14 Feb 2006 13:46:43 -0000 1.7 *************** *** 41,45 **** if tmp and tmp.is_a?(String) and not tmp.empty? ! seq = Bio::Sequence.auto(tmp) end return seq --- 41,45 ---- if tmp and tmp.is_a?(String) and not tmp.empty? ! seq = Bio::Sequence.auto(tmp).seq end return seq From k at pub.open-bio.org Tue Feb 14 08:46:45 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Tue, 14 Feb 2006 13:46:45 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio sequence.rb,0.54,0.55 Message-ID: <200602141346.k1EDkjVL017667@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv17649/lib/bio Modified Files: sequence.rb Log Message: * Bio::Sequence.auto(str) is changed to return Bio::Sequence object instead of NA or AA object * Bio::Sequence#auto is added to replace the value of @seq with guessed type of Bio::Sequence::?A object Index: sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence.rb,v retrieving revision 0.54 retrieving revision 0.55 diff -C2 -d -r0.54 -r0.55 *** sequence.rb 14 Feb 2006 13:12:06 -0000 0.54 --- sequence.rb 14 Feb 2006 13:46:42 -0000 0.55 *************** *** 48,59 **** end ! def self.auto(str) ! @moltype = self.guess(str) if @moltype == NA ! @seq = NA.new(str) else ! @seq = AA.new(str) end ! return @seq end --- 48,64 ---- end ! def auto ! @moltype = guess if @moltype == NA ! @seq = NA.new(@seq) else ! @seq = AA.new(@seq) end ! end ! ! def self.auto(str) ! seq = self.new(str) ! seq.auto ! return seq end From pjotr at pub.open-bio.org Fri Feb 17 09:59:29 2006 From: pjotr at pub.open-bio.org (Pjotr Prins) Date: Fri, 17 Feb 2006 14:59:29 +0000 Subject: [BioRuby-cvs] bioruby/doc Tutorial.rd,1.11,1.12 Message-ID: <200602171459.k1HExTVL030206@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/doc In directory pub.open-bio.org:/tmp/cvs-serv30194/doc Modified Files: Tutorial.rd Log Message: Fixed tutorial on updated sequence handling (throw exception instead of return nil value) Added a FASTA output example that allows for regex filtering like any2fasta.rb "/GAT[CT]/i" *.seq > reduced.fasta Index: Tutorial.rd =================================================================== RCS file: /home/repository/bioruby/bioruby/doc/Tutorial.rd,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Tutorial.rd 31 Jan 2006 07:45:22 -0000 1.11 --- Tutorial.rd 17 Feb 2006 14:59:26 -0000 1.12 *************** *** 7,11 **** Translated into English: Naohisa Goto ! Editor: PjotrPrins Copyright (C) 2001-2003 KATAYAMA Toshiaki , 2005-2006 all --- 7,11 ---- Translated into English: Naohisa Goto ! Editor: PjotrPrins

Copyright (C) 2001-2003 KATAYAMA Toshiaki , 2005-2006 all *************** *** 128,136 **** 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".) ! ! (EDITOR'S NOTE: should 'subseq' not throw an exception instead?) The window_search(window_size, step_size) method shows a typical Ruby --- 128,134 ---- So when using String methods, you should subtract 1 from positions ! conventionally used in biology. (subseq method will throw an exception if you ! specify positions smaller than or equal to 0 for either one of the "from" or ! "to".) The window_search(window_size, step_size) method shows a typical Ruby *************** *** 402,405 **** --- 400,406 ---- p entry.seq # sequence data of the entry end + + An example that can take any input, filter using a regular expression to output + to a FASTA file can be found in sample/any2fasta.rb. Other methods to extract specific data from database objects can be From pjotr at pub.open-bio.org Fri Feb 17 09:59:29 2006 From: pjotr at pub.open-bio.org (Pjotr Prins) Date: Fri, 17 Feb 2006 14:59:29 +0000 Subject: [BioRuby-cvs] bioruby/sample any2fasta.rb,NONE,1.1 Message-ID: <200602171459.k1HExTVL030207@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/sample In directory pub.open-bio.org:/tmp/cvs-serv30194/sample Added Files: any2fasta.rb Log Message: Fixed tutorial on updated sequence handling (throw exception instead of return nil value) Added a FASTA output example that allows for regex filtering like any2fasta.rb "/GAT[CT]/i" *.seq > reduced.fasta --- NEW FILE: any2fasta.rb --- #!/usr/bin/env ruby # # any2fasta.rb - convert input file into FASTA format using a regex # filter # # Copyright (C) 2006 Pjotr Prins

# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # $Id: any2fasta.rb,v 1.1 2006/02/17 14:59:27 pjotr Exp $ # require 'bio/io/flatfile' include Bio usage = < reduced.fasta USAGE if ARGV.size == 0 print usage exit 1 end # ---- Valid regular expression - if it is not a file regex = ARGV[0] if regex=~/^\// and !File.exist?(regex) ARGV.shift else regex = nil end ARGV.each do | fn | ff = Bio::FlatFile.auto(fn) ff.each_entry do |entry| if regex != nil next if eval("entry.seq !~ #{regex}") end print entry.seq.to_fasta(entry.definition,70) end end From k at pub.open-bio.org Fri Feb 17 12:09:19 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri, 17 Feb 2006 17:09:19 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.19,1.20 Message-ID: <200602171709.k1HH9JVL031249@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv31222/lib/bio/shell Modified Files: core.rb Log Message: * splash animation is separated from color mode * @config[:splash] is added for this purpose * mono animation mode is also added * user can use 'config :color' and 'config :splash' in combination * added accessor for DATADIR * fixed plugin dir from SAVEDIR+PLUGIN to PLUGIN * script.rb is changed to be saved in current directory instead of in SAVEDIR * script.rb is checked before overwritten * script function can be aborted with message (especially when the script content is emptry) * script.rb is changed from ruby script to bioruby script as lib/bioruby.rb is removed (changed from #!/usr/bin/env ruby; require 'bioruby' to #!/usr/bin/env bioruby) * "\n" are removed to make independent from LF/CR Index: core.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** core.rb 14 Feb 2006 13:18:35 -0000 1.19 --- core.rb 17 Feb 2006 17:09:17 -0000 1.20 *************** *** 37,40 **** --- 37,44 ---- } + def datadir + DATADIR + end + def esc_seq ESC_SEQ *************** *** 243,246 **** --- 247,256 ---- end + def config_splash + flag = ! @config[:splash] + @config[:splash] = flag + puts "Splash #{flag ? 'on' : 'off'}" + end + def config_pager(cmd = nil) @config[:pager] = cmd *************** *** 255,259 **** def load_plugin ! load_plugin_dir(SAVEDIR + PLUGIN) end --- 265,269 ---- def load_plugin ! load_plugin_dir(PLUGIN) end *************** *** 406,414 **** def save_script if @script_begin and @script_end and @script_begin <= @script_end ! if create_save_dir ! save_script_file(SAVEDIR + SCRIPT) end else ! puts "Error: script range #{@script_begin}..#{@script_end} is invalid" end end --- 416,433 ---- def save_script if @script_begin and @script_end and @script_begin <= @script_end ! if File.exists?(SCRIPT) ! message = "Overwrite script file (#{SCRIPT})? [y/n]: " ! else ! message = "Save script file (#{SCRIPT})? [y/n]: " end + if ask_yes_or_no(message) + save_script_file(SCRIPT) + else + puts " ... save aborted." + end + elsif @script_begin and @script_end and @script_begin - @script_end == 1 + puts " ... script aborted." else ! puts "Error: Script range #{@script_begin}..#{@script_end} is invalid" end end *************** *** 418,425 **** print "Saving script (#{file}) ... " File.open(file, "w") do |f| ! f.print "#!/usr/bin/env ruby\n\n" ! f.print "require 'bioruby'\n\n" f.puts Readline::HISTORY.to_a[@script_begin.. at script_end] ! f.print "\n\n" end puts "done" --- 437,444 ---- print "Saving script (#{file}) ... " File.open(file, "w") do |f| ! f.puts "#!/usr/bin/env bioruby" ! f.puts f.puts Readline::HISTORY.to_a[@script_begin.. at script_end] ! f.puts end puts "done" *************** *** 447,450 **** --- 466,486 ---- s = splash_message l = s.length + x = " " + 0.step(l,2) do |i| + l1 = l-i; l2 = l1/2; l4 = l2/2 + STDERR.print "#{s[0,i]}#{x*l1}#{s[i,1]}\r" + sleep(0.001) + STDERR.print "#{s[0,i]}#{x*l2}#{s[i,1]}#{x*(l1-l2)}\r" + sleep(0.002) + STDERR.print "#{s[0,i]}#{x*l4}#{s[i,1]}#{x*(l2-l4)}\r" + sleep(0.004) + STDERR.print "#{s[0,i+1]}#{x*l4}\r" + sleep(0.008) + end + end + + def splash_message_action_color + s = splash_message + l = s.length c = ESC_SEQ x = " " *************** *** 463,469 **** def opening_splash ! print "\n" ! if @config[:color] ! splash_message_action end if @config[:color] --- 499,509 ---- def opening_splash ! puts ! if @config[:splash] ! if @config[:color] ! splash_message_action_color ! else ! splash_message_action ! end end if @config[:color] *************** *** 472,482 **** 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 @config[:color] print splash_message_color --- 512,526 ---- print splash_message end ! puts ! puts print " Version : BioRuby #{Bio::BIORUBY_VERSION.join(".")}" ! print " / Ruby #{RUBY_VERSION}" ! puts ! puts end def closing_splash ! puts ! puts if @config[:color] print splash_message_color *************** *** 484,488 **** print splash_message end ! print "\n\n" end --- 528,533 ---- print splash_message end ! puts ! puts end From k at pub.open-bio.org Fri Feb 17 12:12:01 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri, 17 Feb 2006 17:12:01 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell interface.rb,1.12,1.13 Message-ID: <200602171712.k1HHC1VL031323@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv31314/lib/bio/shell Modified Files: interface.rb Log Message: * module name is changed from session.rb to interface.rb * config :splash is added * display method is renamed to disp as it overrides Object#display * savefile command is changed to offer saving file under the DATADIR (data/) * modified to use Bio::Shell.ask_yes_or_no function Index: interface.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/interface.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** interface.rb 9 Feb 2006 20:48:53 -0000 1.12 --- interface.rb 17 Feb 2006 17:11:59 -0000 1.13 *************** *** 1,4 **** # ! # = bio/shell/session.rb - core user interface of the BioRuby shell # # Copyright:: Copyright (C) 2005 --- 1,4 ---- # ! # = bio/shell/interface.rb - core user interface of the BioRuby shell # # Copyright:: Copyright (C) 2005 *************** *** 65,68 **** --- 65,70 ---- when :color, "color" Bio::Shell.config_color + when :splash, "splash" + Bio::Shell.config_splash when :pager, "pager" Bio::Shell.config_pager(*opts) *************** *** 86,90 **** end ! def display(*obj) # The original idea is from http://sheepman.parfait.ne.jp/20050215.html if Bio::Shell.config[:pager] --- 88,92 ---- end ! def disp(*obj) # The original idea is from http://sheepman.parfait.ne.jp/20050215.html if Bio::Shell.config[:pager] *************** *** 100,103 **** --- 102,106 ---- end else + # or use Object#display ? puts(*obj) end *************** *** 132,145 **** def savefile(file, *objs) if File.exists?(file) ! loop do ! print "Overwrite existing #{file}? [y/n]: " ! answer = gets ! return if /^\s*[Nn]/.match(answer) ! break if /^\s*[Yy]/.match(answer) end end begin ! print "Saving data (#{file}) ... " File.open(file, "w") do |f| objs.each do |obj| --- 135,152 ---- def savefile(file, *objs) + datadir = Bio::Shell.datadir + message = "Save file '#{file}' in '#{datadir}' directory? [y/n]: " + if ! file[/^#{datadir}/] and Bio::Shell.ask_yes_or_no(message) + file = datadir + file + end if File.exists?(file) ! message = "Overwrite existing '#{file}' file? [y/n]: " ! if ! Bio::Shell.ask_yes_or_no(message) ! puts " ... save aborted." ! return end end begin ! print "Saving file (#{file}) ... " File.open(file, "w") do |f| objs.each do |obj| From k at pub.open-bio.org Fri Feb 17 12:12:41 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri, 17 Feb 2006 17:12:41 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio shell.rb,1.13,1.14 Message-ID: <200602171712.k1HHCfVL031350@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv31346/lib/bio Modified Files: shell.rb Log Message: * session.rb is renamed to interface.rb Index: shell.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell.rb,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** shell.rb 9 Feb 2006 20:48:52 -0000 1.13 --- shell.rb 17 Feb 2006 17:12:39 -0000 1.14 *************** *** 17,21 **** require 'bio/shell/core' ! require 'bio/shell/session' require 'bio/shell/plugin/entry' require 'bio/shell/plugin/seq' --- 17,21 ---- require 'bio/shell/core' ! require 'bio/shell/interface' require 'bio/shell/plugin/entry' require 'bio/shell/plugin/seq' From k at pub.open-bio.org Fri Feb 17 12:15:10 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri, 17 Feb 2006 17:15:10 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio sequence.rb,0.55,0.56 Message-ID: <200602171715.k1HHFAVL031442@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv31436/lib/bio Modified Files: sequence.rb Log Message: * Bio::Sequence#na and aa methods are added which force to convert @seq object to Bio::Sequence::NA and AA object respectively Index: sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence.rb,v retrieving revision 0.55 retrieving revision 0.56 diff -C2 -d -r0.55 -r0.56 *** sequence.rb 14 Feb 2006 13:46:42 -0000 0.55 --- sequence.rb 17 Feb 2006 17:15:08 -0000 0.56 *************** *** 83,86 **** --- 83,96 ---- end + def na + @seq = NA.new(@seq) + @moltype = NA + end + + def aa + @seq = AA.new(@seq) + @moltype = AA + end + end # Sequence From nakao at pub.open-bio.org Sat Feb 18 09:24:47 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 18 Feb 2006 14:24:47 +0000 Subject: [BioRuby-cvs] bioruby/test/data/aaindex - New directory Message-ID: <200602181424.k1IEOlVL001733@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/aaindex In directory pub.open-bio.org:/tmp/cvs-serv1723/test/data/aaindex Log Message: Directory /home/repository/bioruby/bioruby/test/data/aaindex added to the repository From nakao at pub.open-bio.org Sat Feb 18 09:44:42 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 18 Feb 2006 14:44:42 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio db.rb,0.32,0.33 Message-ID: <200602181444.k1IEigVL001790@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv1774/lib/bio Modified Files: db.rb Log Message: * db.rb: added '*' in the toptag. * aaindex.rb: added RDoc. added a facade method for both file formats (Bio::AAindex.auto). * test_aaindex.rb: added Index: db.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db.rb,v retrieving revision 0.32 retrieving revision 0.33 diff -C2 -d -r0.32 -r0.33 *** db.rb 12 Jan 2006 08:58:27 -0000 0.32 --- db.rb 18 Feb 2006 14:44:40 -0000 0.33 *************** *** 268,272 **** def toptag2array(str) sep = "\001" ! str.gsub(/\n([A-Za-z\/])/, "\n#{sep}\\1").split(sep) end --- 268,272 ---- def toptag2array(str) sep = "\001" ! str.gsub(/\n([A-Za-z\/\*])/, "\n#{sep}\\1").split(sep) end From nakao at pub.open-bio.org Sat Feb 18 09:44:42 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 18 Feb 2006 14:44:42 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/db test_aaindex.rb,NONE,1.1 Message-ID: <200602181444.k1IEigVL001788@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/db In directory pub.open-bio.org:/tmp/cvs-serv1774/test/unit/bio/db Added Files: test_aaindex.rb Log Message: * db.rb: added '*' in the toptag. * aaindex.rb: added RDoc. added a facade method for both file formats (Bio::AAindex.auto). * test_aaindex.rb: added --- NEW FILE: test_aaindex.rb --- # # test/unit/bio/db/test_aaindex.rb - Unit test for Bio::AAindex # # Copyright:: Copyright (C) 2006 # Mitsuteru C. Nakao # License:: Ruby's # # $Id: test_aaindex.rb,v 1.1 2006/02/18 14:44:40 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/io/fetch' require 'bio/db/aaindex' module Bio class DataAAindex bioruby_root = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4)).cleanpath.to_s TestDataAAindex = Pathname.new(File.join(bioruby_root, 'test', 'data', 'aaindex')).cleanpath.to_s def self.aax1 File.read(File.join(TestDataAAindex, "PRAM900102")) end def self.aax2 File.read(File.join(TestDataAAindex, "HENS920102")) end end # A super class for Bio::AAindex1 and Bio::AAindex2 class TestAAindexConstant < Test::Unit::TestCase def test_delimiter rs = "\n//\n" assert_equal(rs, Bio::AAindex::DELIMITER) assert_equal(rs, Bio::AAindex::RS) end def test_tagsize assert_equal(2, Bio::AAindex::TAGSIZE) end end class TestAAindex < Test::Unit::TestCase def test_api api_methods = ['entry_id', 'definition', 'dblinks', 'author', 'title', 'journal', 'comment'] api_methods.each do |m| end end def test_auto_aax1 assert_equal(Bio::AAindex1, Bio::AAindex.auto(DataAAindex.aax1).class) end def test_auto_aax2 assert_equal(Bio::AAindex2, Bio::AAindex.auto(DataAAindex.aax2).class) end end class TestAAindex1 < Test::Unit::TestCase def setup str = DataAAindex.aax1 @obj = Bio::AAindex1.new(str) end def test_entry_id assert_equal('PRAM900102', @obj.entry_id) end def test_definition assert_equal('Relative frequency in alpha-helix (Prabhakaran, 1990)', @obj.definition) end def test_dblinks assert_equal(['LIT:1614053b', 'PMID:2390062'], @obj.dblinks) end def test_author assert_equal('Prabhakaran, M.', @obj.author) end def test_title assert_equal('The distribution of physical, chemical and conformational properties in signal and nascent peptides', @obj.title) end def test_journal assert_equal('Biochem. J. 269, 691-696 (1990) Original reference of these three data: Creighton, T.E. In "Protein Structure and Melecular Properties", (Freeman, W.H., ed.), San Francisco P.235 (1983)', @obj.journal) end def test_comment assert_equal("", @obj.comment) end def test_correlation_coefficient # str = "LEVM780101 1.000 LEVM780104 0.964 PALJ810101 0.943 KANM800101 0.942 ISOY800101 0.929 MAXF760101 0.924 ROBB760101 0.916 GEIM800101 0.912 GEIM800104 0.907 RACS820108 0.904 PALJ810102 0.902 PALJ810109 0.898 NAGK730101 0.894 CRAJ730101 0.887 CHOP780201 0.873 TANS770101 0.854 KANM800103 0.850 QIAN880107 0.829 QIAN880106 0.827 BURA740101 0.805 NAGK730103 -0.809" # assert_equal(str, @obj.correlation_coefficient) # to be this ? hash = {'LEVM780101' => 1.000, 'LEVM780104' => 0.964, 'PALJ810101' => 0.943, 'KANM800101' => 0.942, 'ISOY800101' => 0.929, 'MAXF760101' => 0.924, 'ROBB760101' => 0.916, 'GEIM800101' => 0.912, 'GEIM800104' => 0.907, 'RACS820108' => 0.904, 'PALJ810102' => 0.902, 'PALJ810109' => 0.898, 'NAGK730101' => 0.894, 'CRAJ730101' => 0.887, 'CHOP780201' => 0.873, 'TANS770101' => 0.854, 'KANM800103' => 0.850, 'QIAN880107' => 0.829, 'QIAN880106' => 0.827, 'BURA740101' => 0.805, 'NAGK730103' => -0.809} assert_equal(hash, @obj.correlation_coefficient) end def test_index hash = {"V"=>0.91, "K"=>1.23, "W"=>0.99, "L"=>1.3, "A"=>1.29, "M"=>1.47, "Y"=>0.72, "C"=>1.11, "N"=>0.9, "D"=>1.04, "P"=>0.52, "E"=>1.44, "F"=>1.07, "Q"=>1.27, "G"=>0.56, "R"=>0.96, "S"=>0.82, "H"=>1.22, "T"=>0.82, "I"=>0.97} assert_equal(hash, @obj.index) end end class TestAAindex2 < Test::Unit::TestCase def setup str = DataAAindex.aax2 @obj = Bio::AAindex2.new(str) end def test_entry_id assert_equal('HENS920102', @obj.entry_id) end def test_definition assert_equal('BLOSUM62 substitution matrix (Henikoff-Henikoff, 1992)', @obj.definition) end def test_dblinks assert_equal(['LIT:1902106', 'PMID:1438297'], @obj.dblinks) end def test_author assert_equal("Henikoff, S. and Henikoff, J.G.", @obj.author) end def test_title assert_equal("Amino acid substitution matrices from protein blocks", @obj.title) end def test_journal assert_equal("Proc. Natl. Acad. Sci. USA 89, 10915-10919 (1992)", @obj.journal) end def test_comment assert_equal("matrix in 1/3 Bit Units", @obj.comment) end def test_rows ary = ["A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", "P", "S", "T", "W", "Y", "V"] assert_equal(ary, @obj.rows) end def test_cols ary = ["A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", "P", "S", "T", "W", "Y", "V"] assert_equal(ary, @obj.cols) end def test_matrix assert_equal(Matrix, @obj.matrix.class) # assert_equal('', @obj.matrix) end def test_matrix_2_2 assert_equal(8.0, @obj.matrix[2,2]) end def test_matrix_determinant assert_equal(0, @obj.matrix.determinant) end def test_matrix_rank assert_equal(1, @obj.matrix.rank) end def test_matrix_transpose ary = Matrix[[6.0, -2.0, -2.0, -3.0, -1.0, -1.0, -1.0, 0.0, -2.0, -2.0, -2.0, -1.0, -1.0, -3.0, -1.0, 2.0, 0.0, -4.0, -3.0, 0.0]] assert_equal(ary, @obj.matrix.transpose) end end end From nakao at pub.open-bio.org Sat Feb 18 09:44:43 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 18 Feb 2006 14:44:43 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db aaindex.rb,1.16,1.17 Message-ID: <200602181444.k1IEihVL001796@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv1774/lib/bio/db Modified Files: aaindex.rb Log Message: * db.rb: added '*' in the toptag. * aaindex.rb: added RDoc. added a facade method for both file formats (Bio::AAindex.auto). * test_aaindex.rb: added Index: aaindex.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/aaindex.rb,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** aaindex.rb 18 Dec 2005 15:58:41 -0000 1.16 --- aaindex.rb 18 Feb 2006 14:44:40 -0000 1.17 *************** *** 2,6 **** # = bio/db/aaindex.rb - AAindex database class # ! # Copyright:: Copyright (C) 2001 KAWASHIMA Shuichi # License:: LGPL # --- 2,9 ---- # = bio/db/aaindex.rb - AAindex database class # ! # Copyright:: Copyright (C) 2001 ! # KAWASHIMA Shuichi ! # Copyright:: Copyright (C) 2006 ! # Mitsuteru C. Nakao # License:: LGPL # *************** *** 8,15 **** --- 11,23 ---- # # == Description + # # Classes for Amino Acid Index Database (AAindex and AAindex2). # * AAindex Manual: http://www.genome.jp/dbget-bin/show_man?aaindex # # == Examples + # + # aax1 = Bio::AAindex.auto("PRAM900102.aaindex1") + # aax2 = Bio::AAindex.auto("HENS920102.aaindex2") + # # aax1 = Bio::AAindex1.new("PRAM900102.aaindex1") # aax1.entry_id *************** *** 22,25 **** --- 30,34 ---- # # == References + # # * http://www.genome.jp/aaindex/ # *************** *** 48,51 **** --- 57,61 ---- module Bio + # Super class for AAindex1 and AAindex2 class AAindex < KEGGDB *************** *** 59,118 **** TAGSIZE = 2 def initialize(entry) super(entry, TAGSIZE) end ! # Returns def entry_id field_fetch('H') end ! # Returns def definition field_fetch('D') end ! # Returns def dblinks ! field_fetch('R') end ! # Returns def author field_fetch('A') end ! # Returns def title field_fetch('T') end ! # Returns def journal field_fetch('J') end ! # Returns def comment ! get('*') end - end class AAindex1 < AAindex - def initialize(entry) super(entry) end ! # Returns def correlation_coefficient ! field_fetch('C') end ! # Returns def index(type = :float) aa = %w( A R N D C Q E G H I L K M F P S T W Y V ) --- 69,151 ---- TAGSIZE = 2 + # Auto detecter for two AAindex formats. + # returns a Bio::AAindex1 object or a Bio::AAindex2 object. + def self.auto(str) + case str + when /^I /m + Bio::AAindex1.new(str) + when /^M /m + Bio::AAindex2.new(str) + else + raise + end + end + # def initialize(entry) super(entry, TAGSIZE) end ! # Returns entry_id in the H line. def entry_id field_fetch('H') end ! # Returns definition in the D line. def definition field_fetch('D') end ! # Returns database links in the R line. ! # cf.) ['LIT:123456', 'PMID:12345678'] def dblinks ! field_fetch('R').split(' ') end ! # Returns authors in the A line. def author field_fetch('A') end ! # Returns title in the T line. def title field_fetch('T') end ! # Returns journal name in the J line. def journal field_fetch('J') end ! # Returns comment (if any). def comment ! field_fetch("*") end end + # Class for AAindex1 format. class AAindex1 < AAindex def initialize(entry) super(entry) end ! # Returns correlation_coefficient (Hash) in the C line. ! # ! # cf.) {'ABCD12010203' => 0.999, 'CDEF123456' => 0.543, ...} def correlation_coefficient ! hash = {} ! ary = field_fetch('C').split(' ') ! ary.each do |x| ! next unless x =~ /^[A-Z]/ ! hash[x] = ary[ary.index(x) + 1].to_f ! end ! hash end ! # Returns the index (Array) in the I line. ! # ! # an argument: :string, :float, :zscore or :integer def index(type = :float) aa = %w( A R N D C Q E G H I L K M F P S T W Y V ) *************** *** 163,174 **** class AAindex2 < AAindex - def initialize(entry) super(entry) end ! # Returns def rows label_data --- 196,207 ---- + # Class for AAindex2 format. class AAindex2 < AAindex def initialize(entry) super(entry) end ! # Returns row labels. def rows label_data *************** *** 176,180 **** end ! # Returns def cols label_data --- 209,213 ---- end ! # Returns col labels. def cols label_data *************** *** 182,186 **** end ! # Returns def matrix ma = Array.new --- 215,219 ---- end ! # Returns matrix in Matrix. def matrix ma = Array.new *************** *** 195,199 **** end ! # Returns def old_matrix # for AAindex <= ver 5.0 --- 228,232 ---- end ! # Returns def old_matrix # for AAindex <= ver 5.0 *************** *** 244,250 **** end ! end ! end --- 277,283 ---- end ! end # class AAindex2 ! end # module Bio *************** *** 260,263 **** --- 293,297 ---- p aax1.title p aax1.journal + p aax1.comment p aax1.correlation_coefficient p aax1.index *************** *** 270,273 **** --- 304,308 ---- p aax2.title p aax2.journal + p aax1.comment p aax2.rows p aax2.cols From nakao at pub.open-bio.org Sat Feb 18 10:03:50 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 18 Feb 2006 15:03:50 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db medline.rb,1.12,1.13 Message-ID: <200602181503.k1IF3oVL001888@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv1878/lib/bio/db Modified Files: medline.rb Log Message: * updated RDoc. Index: medline.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/medline.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** medline.rb 8 Sep 2005 01:22:11 -0000 1.12 --- medline.rb 18 Feb 2006 15:03:47 -0000 1.13 *************** *** 1,6 **** # ! # bio/db/medline.rb - NCBI PubMed/MEDLINE database class # ! # Copyright (C) 2001, 2005 KATAYAMA Toshiaki # # This library is free software; you can redistribute it and/or --- 1,25 ---- # ! # = bio/db/medline.rb - NCBI PubMed/MEDLINE database class # ! # Copyright:: Copyright (C) 2001, 2005 ! # KATAYAMA Toshiaki ! # License:: LGPL ! # ! # == Description ! # ! # NCBI PubMed/MEDLINE database class. ! # ! # == Examples ! # ! # medline = Bio::MEDLINE.new(txt) ! # medline.reference ! # medline.pmid == medline.entry_id ! # medilne.mesh ! # ! # == References ! # ! # $Id$ ! # ! #++ # # This library is free software; you can redistribute it and/or *************** *** 18,22 **** # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! # $Id$ # --- 37,41 ---- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! #-- # *************** *** 25,30 **** --- 44,51 ---- module Bio + # NCBI PubMed/MEDLINE database class. class MEDLINE < NCBIDB + # def initialize(entry) @pubmed = Hash.new('') *************** *** 40,44 **** ! # Reference object def reference hash = Hash.new('') --- 61,65 ---- ! # returns a Reference object. def reference hash = Hash.new('') From nakao at pub.open-bio.org Sat Feb 18 11:08:12 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 18 Feb 2006 16:08:12 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl blast.rb,1.27,1.28 Message-ID: <200602181608.k1IG8CVL002623@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv2613/lib/bio/appl Modified Files: blast.rb Log Message: * Added RDoc. * Changed license. Index: blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast.rb,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** blast.rb 18 Dec 2005 17:28:55 -0000 1.27 --- blast.rb 18 Feb 2006 16:08:10 -0000 1.28 *************** *** 1,23 **** # ! # bio/appl/blast.rb - BLAST wrapper # ! # Copyright (C) 2001 Mitsuteru C. Nakao ! # Copyright (C) 2002,2003 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$ # --- 1,30 ---- # ! # = bio/appl/blast.rb - BLAST wrapper # ! # Copyright:: Copyright (C) 2001 ! # Mitsuteru C. Nakao ! # Copyrigth:: Copyright (C) 2002,2003 ! # KATAYAMA Toshiaki ! # License:: Ruby's # ! # $Id$ # ! # = Description # ! # = Examples # ! # program = 'blastp' ! # database = 'SWISS' ! # options = '-e 0.0001' ! # serv = Bio::Blast.new(program, database, options) ! # server = 'genomenet' ! # genomenet = Bio::Blast.remote(program, database, options, server) ! # report = serv.query(sequence_text) ! # ! # = References ! # ! # * http://www.ncbi.nlm.nih.gov/blast/ ! # ! # * http://blast.genome.jp/ideas/ideas.html#blast # *************** *** 29,32 **** --- 36,73 ---- module Bio + # BLAST wrapper + # + # == Description + # + # A blastall program wrapper. + # + # == Examples + # + # program = 'blastp' + # database = 'SWISS' + # options = '-e 0.0001' + # serv = Bio::Blast.new(program, database, options) + # + # server = 'genomenet' + # genomenet = Bio::Blast.remote(program, database, options, server) + # + # report = serv.query(sequence_text) + # + # == Available databases for Blast.remote(@program, @db, option, 'genomenet') + # + # ----------+-------+--------------------------------------------------- + # @program | query | @db (supported in GenomeNet) + # ----------+-------+--------------------------------------------------- + # blastp | AA | nr-aa, genes, vgenes.pep, swissprot, swissprot-upd, + # ----------+-------+ pir, prf, pdbstr + # blastx | NA | + # ----------+-------+--------------------------------------------------- + # blastn | NA | nr-nt, genbank-nonst, gbnonst-upd, dbest, dbgss, + # ----------+-------+ htgs, dbsts, embl-nonst, embnonst-upd, epd, + # tblastn | AA | genes-nt, genome, vgenes.nuc + # ----------+-------+--------------------------------------------------- + # + # * See http://blast.genome.jp/ideas/ideas.html#blast for more details. + # class Blast *************** *** 39,42 **** --- 80,153 ---- include Bio::Command::Tools + # Sets up the blast program at the localhost + def self.local(program, db, option = '') + self.new(program, db, option, 'local') + end + + # Sets up the blast program at the remote host (server) + def self.remote(program, db, option = '', server = 'genomenet') + self.new(program, db, option, server) + 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 + + + # Program name for blastall -p (blastp, blastn, blastx, tblastn or tblastx). + attr_accessor :program + + # Database name for blastall -d + attr_accessor :db + + # Options for blastall + attr_accessor :options + + # + attr_accessor :server + + # Full path for blastall. (default: 'blastall'). + attr_accessor :blastall + + # Substitution matrix for blastall -M + attr_accessor :matrix + + # Filter option for blastall -F (T or F). + attr_accessor :filter + + # Returns a String containing blast execution output in as is the Bio::Blast#format. + attr_reader :output + + # Output report format for blastall -m + # + # 0, pairwise; 1; 2; 3; 4; 5; 6; 7, XML Blast outpu;, 8, tabular; + # 9, tabular with comment lines; 10, ASN text; 11, ASN binery [intege]. + attr_reader :format + + # + attr_writer :parser # to change :xmlparser, :rexml, :tab + + + # Returns a blast factory object (Bio::Blast). + # + # --- Bio::Blast.new(program, db, option = '', server = 'local') + # --- Bio::Blast.local(program, db, option = '') + # --- Bio::Blast.remote(program, db, option = '', server = 'genomenet') + # + # For the develpper, you can add server 'hoge' by adding + # exec_hoge(query) method. + # def initialize(program, db, opt = [], server = 'local') @program = program *************** *** 66,85 **** @options = [ *a ] end - attr_accessor :program, :db, :options, :server, :blastall, :matrix, :filter - attr_reader :output, :format - attr_writer :parser # to change :xmlparser, :rexml, :tab - - def self.local(program, db, option = '') - self.new(program, db, option, 'local') - end - - def self.remote(program, db, option = '', server = 'genomenet') - self.new(program, db, option, server) - end def query(query) return self.send("exec_#{@server}", query.to_s) end def option # backward compatibility --- 177,187 ---- @options = [ *a ] end + # Execute blast search and returns Report object (Bio::Blast::Report). def query(query) return self.send("exec_#{@server}", query.to_s) end + # option reader def option # backward compatibility *************** *** 87,90 **** --- 189,193 ---- end + # option setter def option=(str) # backward compatibility *************** *** 92,111 **** 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 - private --- 195,198 ---- *************** *** 190,200 **** end - def exec_ncbi(query) raise NotImplementedError end - end ! end --- 277,287 ---- end def exec_ncbi(query) raise NotImplementedError end ! end # class Blast ! ! end # module Bio *************** *** 214,269 **** end - - =begin - - = Bio::Blast - - --- Bio::Blast.new(program, db, option = '', server = 'local') - --- Bio::Blast.local(program, db, option = '') - --- Bio::Blast.remote(program, db, option = '', server = 'genomenet') - - Returns a blast factory object (Bio::Blast). - - For the develpper, you can add server 'hoge' by adding - exec_hoge(query) method. - - --- Bio::Blast#query(query) - - Execute blast search and returns Report object (Bio::Blast::Report). - - --- Bio::Blast#output - - Returns a String containing blast execution output in as is format. - - --- Bio::Blast#program - --- Bio::Blast#db - --- Bio::Blast#options - --- Bio::Blast#server - --- Bio::Blast#blastall - --- Bio::Blast#filter - - Accessors for the factory parameters. - - --- Bio::Blast#option - --- Bio::Blast#option=(str) - - Get/set options by string. - - == Available databases for Blast.remote(@program, @db, option, 'genomenet') - - # ----------+-------+--------------------------------------------------- - # @program | query | @db (supported in GenomeNet) - # ----------+-------+--------------------------------------------------- - # blastp | AA | nr-aa, genes, vgenes.pep, swissprot, swissprot-upd, - # ----------+-------+ pir, prf, pdbstr - # blastx | NA | - # ----------+-------+--------------------------------------------------- - # blastn | NA | nr-nt, genbank-nonst, gbnonst-upd, dbest, dbgss, - # ----------+-------+ htgs, dbsts, embl-nonst, embnonst-upd, epd, - # tblastn | AA | genes-nt, genome, vgenes.nuc - # ----------+-------+--------------------------------------------------- - - See http://blast.genome.jp/ideas/ideas.html#blast for more details. - - =end --- 301,303 ---- From ngoto at pub.open-bio.org Mon Feb 20 08:00:45 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Mon, 20 Feb 2006 13:00:45 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db/pdb pdb.rb,1.14,1.15 Message-ID: <200602201300.k1KD0jVL021301@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/pdb In directory pub.open-bio.org:/tmp/cvs-serv21291/lib/bio/db/pdb Modified Files: pdb.rb Log Message: added PDB#authors method. Index: pdb.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/pdb.rb,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** pdb.rb 29 Jan 2006 06:48:39 -0000 1.14 --- pdb.rb 20 Feb 2006 13:00:43 -0000 1.15 *************** *** 1808,1811 **** --- 1808,1816 ---- end + # Get authors in "AUTHOR". + def authors + self.record('AUTHOR').first.authorList + end + #-- # Bio::DB methods From nakao at pub.open-bio.org Tue Feb 21 12:38:18 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Tue, 21 Feb 2006 17:38:18 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/shell/plugin test_seq.rb, 1.5, 1.6 Message-ID: <200602211738.k1LHcIVL029014@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv29004/test/unit/bio/shell/plugin Modified Files: test_seq.rb Log Message: * Changed the library name required (bioruby -> bio/shell). Index: test_seq.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/shell/plugin/test_seq.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_seq.rb 19 Dec 2005 02:44:03 -0000 1.5 --- test_seq.rb 21 Feb 2006 17:38:15 -0000 1.6 *************** *** 26,30 **** require 'test/unit' ! require 'bioruby' module Bio --- 26,30 ---- require 'test/unit' ! require 'bio/shell' module Bio From nakao at pub.open-bio.org Tue Feb 21 12:40:39 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Tue, 21 Feb 2006 17:40:39 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio test_shell.rb,1.4,1.5 Message-ID: <200602211740.k1LHedVL029069@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio In directory pub.open-bio.org:/tmp/cvs-serv29059/test/unit/bio Modified Files: test_shell.rb Log Message: * Changed the library name required (bioruby -> bio/shell). Index: test_shell.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/test_shell.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_shell.rb 18 Dec 2005 17:00:10 -0000 1.4 --- test_shell.rb 21 Feb 2006 17:40:37 -0000 1.5 *************** *** 26,30 **** require 'test/unit' ! require 'bioruby' module Bio --- 26,30 ---- require 'test/unit' ! require 'bio/shell' module Bio From ngoto at pub.open-bio.org Tue Feb 21 13:02:01 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Tue, 21 Feb 2006 18:02:01 +0000 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.64,1.65 Message-ID: <200602211802.k1LI21VL029168@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv29148/lib Modified Files: bio.rb Log Message: added autoload for AAindex1 and AAindex2 Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** bio.rb 9 Feb 2006 16:21:47 -0000 1.64 --- bio.rb 21 Feb 2006 18:01:59 -0000 1.65 *************** *** 101,104 **** --- 101,106 ---- autoload :GFF, 'bio/db/gff' autoload :AAindex, 'bio/db/aaindex' + autoload :AAindex1, 'bio/db/aaindex' + autoload :AAindex2, 'bio/db/aaindex' autoload :TRANSFAC, 'bio/db/transfac' autoload :PROSITE, 'bio/db/prosite' From nakao at pub.open-bio.org Tue Feb 21 21:23:25 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 22 Feb 2006 02:23:25 +0000 Subject: [BioRuby-cvs] bioruby/test/data/aaindex HENS920102, NONE, 1.1 PRAM900102, NONE, 1.1 Message-ID: <200602220223.k1M2NPVL030747@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/aaindex In directory pub.open-bio.org:/tmp/cvs-serv30737/test/data/aaindex Added Files: HENS920102 PRAM900102 Log Message: * HENS920102: newly added a test data for Bio::AAindex2. * PRAM900102: newly added a test data for Bio::AAindex1. --- NEW FILE: HENS920102 --- H HENS920102 D BLOSUM62 substitution matrix (Henikoff-Henikoff, 1992) R LIT:1902106 PMID:1438297 A Henikoff, S. and Henikoff, J.G. T Amino acid substitution matrices from protein blocks J Proc. Natl. Acad. Sci. USA 89, 10915-10919 (1992) * matrix in 1/3 Bit Units M rows = ARNDCQEGHILKMFPSTWYV, cols = ARNDCQEGHILKMFPSTWYV 6. -2. 8. -2. -1. 8. -3. -2. 2. 9. -1. -5. -4. -5. 13. -1. 1. 0. 0. -4. 8. -1. 0. 0. 2. -5. 3. 7. 0. -3. -1. -2. -4. -3. -3. 8. -2. 0. 1. -2. -4. 1. 0. -3. 11. -2. -4. -5. -5. -2. -4. -5. -6. -5. 6. -2. -3. -5. -5. -2. -3. -4. -5. -4. 2. 6. -1. 3. 0. -1. -5. 2. 1. -2. -1. -4. -4. 7. -1. -2. -3. -5. -2. -1. -3. -4. -2. 2. 3. -2. 8. -3. -4. -4. -5. -4. -5. -5. -5. -2. 0. 1. -5. 0. 9. -1. -3. -3. -2. -4. -2. -2. -3. -3. -4. -4. -2. -4. -5. 11. 2. -1. 1. 0. -1. 0. 0. 0. -1. -4. -4. 0. -2. -4. -1. 6. 0. -2. 0. -2. -1. -1. -1. -2. -3. -1. -2. -1. -1. -3. -2. 2. 7. -4. -4. -6. -6. -3. -3. -4. -4. -4. -4. -2. -4. -2. 1. -5. -4. -4. 16. -3. -3. -3. -5. -4. -2. -3. -5. 3. -2. -2. -3. -1. 4. -4. -3. -2. 3. 10. 0. -4. -4. -5. -1. -3. -4. -5. -5. 4. 1. -3. 1. -1. -4. -2. 0. -4. -2. 6. // --- NEW FILE: PRAM900102 --- H PRAM900102 D Relative frequency in alpha-helix (Prabhakaran, 1990) R LIT:1614053b PMID:2390062 A Prabhakaran, M. T The distribution of physical, chemical and conformational properties in signal and nascent peptides J Biochem. J. 269, 691-696 (1990) Original reference of these three data: Creighton, T.E. In "Protein Structure and Melecular Properties", (Freeman, W.H., ed.), San Francisco P.235 (1983) C LEVM780101 1.000 LEVM780104 0.964 PALJ810101 0.943 KANM800101 0.942 ISOY800101 0.929 MAXF760101 0.924 ROBB760101 0.916 GEIM800101 0.912 GEIM800104 0.907 RACS820108 0.904 PALJ810102 0.902 PALJ810109 0.898 NAGK730101 0.894 CRAJ730101 0.887 CHOP780201 0.873 TANS770101 0.854 KANM800103 0.850 QIAN880107 0.829 QIAN880106 0.827 BURA740101 0.805 NAGK730103 -0.809 I A/L R/K N/M D/F C/P Q/S E/T G/W H/Y I/V 1.29 0.96 0.90 1.04 1.11 1.27 1.44 0.56 1.22 0.97 1.30 1.23 1.47 1.07 0.52 0.82 0.82 0.99 0.72 0.91 // From nakao at pub.open-bio.org Wed Feb 22 00:07:38 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 22 Feb 2006 05:07:38 +0000 Subject: [BioRuby-cvs] bioruby/test/data/aaindex DAYM780301, NONE, 1.1 HENS920102, 1.1, NONE Message-ID: <200602220507.k1M57cVL032222@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/aaindex In directory pub.open-bio.org:/tmp/cvs-serv32206/test/data/aaindex Added Files: DAYM780301 Removed Files: HENS920102 Log Message: * test_aaindex.rb: changed test data (HENS920102 -> DAYM780301) for Bio::AAindex2. * DAYM780301: newly added. * HENS920102: removed. --- HENS920102 DELETED --- --- NEW FILE: DAYM780301 --- H DAYM780301 D Log odds matrix for 250 PAMs (Dayhoff et al., 1978) R A Dayhoff, M.O., Schwartz, R.M. and Orcutt, B.C. T A model of evolutionary change in proteins J In "Atlas of Protein Sequence and Structure", Vol.5, Suppl.3 (Dayhoff, M.O., ed.), National Biomedical Research Foundation, Washington, D.C., p.352 (1978) M rows = ARNDCQEGHILKMFPSTWYV, cols = ARNDCQEGHILKMFPSTWYV 2. -2. 6. 0. 0. 2. 0. -1. 2. 4. -2. -4. -4. -5. 12. 0. 1. 1. 2. -5. 4. 0. -1. 1. 3. -5. 2. 4. 1. -3. 0. 1. -3. -1. 0. 5. -1. 2. 2. 1. -3. 3. 1. -2. 6. -1. -2. -2. -2. -2. -2. -2. -3. -2. 5. -2. -3. -3. -4. -6. -2. -3. -4. -2. 2. 6. -1. 3. 1. 0. -5. 1. 0. -2. 0. -2. -3. 5. -1. 0. -2. -3. -5. -1. -2. -3. -2. 2. 4. 0. 6. -4. -4. -4. -6. -4. -5. -5. -5. -2. 1. 2. -5. 0. 9. 1. 0. -1. -1. -3. 0. -1. -1. 0. -2. -3. -1. -2. -5. 6. 1. 0. 1. 0. 0. -1. 0. 1. -1. -1. -3. 0. -2. -3. 1. 2. 1. -1. 0. 0. -2. -1. 0. 0. -1. 0. -2. 0. -1. -3. 0. 1. 3. -6. 2. -4. -7. -8. -5. -7. -7. -3. -5. -2. -3. -4. 0. -6. -2. -5. 17. -3. -4. -2. -4. 0. -4. -4. -5. 0. -1. -1. -4. -2. 7. -5. -3. -3. 0. 10. 0. -2. -2. -2. -2. -2. -2. -1. -2. 4. 2. -2. 2. -1. -1. -1. 0. -6. -2. 4. // From nakao at pub.open-bio.org Wed Feb 22 00:07:38 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 22 Feb 2006 05:07:38 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/db test_aaindex.rb,1.1,1.2 Message-ID: <200602220507.k1M57cVL032218@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/db In directory pub.open-bio.org:/tmp/cvs-serv32206/test/unit/bio/db Modified Files: test_aaindex.rb Log Message: * test_aaindex.rb: changed test data (HENS920102 -> DAYM780301) for Bio::AAindex2. * DAYM780301: newly added. * HENS920102: removed. Index: test_aaindex.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/db/test_aaindex.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_aaindex.rb 18 Feb 2006 14:44:40 -0000 1.1 --- test_aaindex.rb 22 Feb 2006 05:07:36 -0000 1.2 *************** *** 27,31 **** def self.aax2 ! File.read(File.join(TestDataAAindex, "HENS920102")) end end --- 27,31 ---- def self.aax2 ! File.read(File.join(TestDataAAindex, "DAYM780301")) end end *************** *** 117,145 **** def test_entry_id ! assert_equal('HENS920102', @obj.entry_id) end def test_definition ! assert_equal('BLOSUM62 substitution matrix (Henikoff-Henikoff, 1992)', @obj.definition) end def test_dblinks ! assert_equal(['LIT:1902106', 'PMID:1438297'], @obj.dblinks) end def test_author ! assert_equal("Henikoff, S. and Henikoff, J.G.", @obj.author) end def test_title ! assert_equal("Amino acid substitution matrices from protein blocks", @obj.title) end def test_journal ! assert_equal("Proc. Natl. Acad. Sci. USA 89, 10915-10919 (1992)", @obj.journal) end def test_comment ! assert_equal("matrix in 1/3 Bit Units", @obj.comment) end --- 117,145 ---- def test_entry_id ! assert_equal('DAYM780301', @obj.entry_id) end def test_definition ! assert_equal('Log odds matrix for 250 PAMs (Dayhoff et al., 1978)', @obj.definition) end def test_dblinks ! assert_equal([], @obj.dblinks) end def test_author ! assert_equal("Dayhoff, M.O., Schwartz, R.M. and Orcutt, B.C.", @obj.author) end def test_title ! assert_equal("A model of evolutionary change in proteins", @obj.title) end def test_journal ! assert_equal('In "Atlas of Protein Sequence and Structure", Vol.5, Suppl.3 (Dayhoff, M.O., ed.), National Biomedical Research Foundation, Washington, D.C., p.352 (1978)', @obj.journal) end def test_comment ! assert_equal("", @obj.comment) end *************** *** 160,164 **** def test_matrix_2_2 ! assert_equal(8.0, @obj.matrix[2,2]) end --- 160,164 ---- def test_matrix_2_2 ! assert_equal(2.0, @obj.matrix[2,2]) end *************** *** 172,176 **** def test_matrix_transpose ! ary = Matrix[[6.0, -2.0, -2.0, -3.0, -1.0, -1.0, -1.0, 0.0, -2.0, -2.0, -2.0, -1.0, -1.0, -3.0, -1.0, 2.0, 0.0, -4.0, -3.0, 0.0]] assert_equal(ary, @obj.matrix.transpose) end --- 172,176 ---- def test_matrix_transpose ! ary = Matrix[[2.0, -2.0, 0.0, 0.0, -2.0, 0.0, 0.0, 1.0, -1.0, -1.0, -2.0, -1.0, -1.0, -4.0, 1.0, 1.0, 1.0, -6.0, -3.0, 0.0]] assert_equal(ary, @obj.matrix.transpose) end From ngoto at pub.open-bio.org Wed Feb 22 02:01:07 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 07:01:07 +0000 Subject: [BioRuby-cvs] bioruby/bin br_bioflat.rb,1.15,1.16 Message-ID: <200602220701.k1M717VL032455@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv32441/bin Modified Files: br_bioflat.rb Log Message: changed STDERR to $stderr Index: br_bioflat.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/br_bioflat.rb,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** br_bioflat.rb 9 Feb 2006 16:29:41 -0000 1.15 --- br_bioflat.rb 22 Feb 2006 07:01:05 -0000 1.16 *************** *** 140,144 **** else ! STDERR.print "Warning: ignoring invalid option #{x.inspect}\n" end end --- 140,144 ---- else ! $stderr.print "Warning: ignoring invalid option #{x.inspect}\n" end end *************** *** 180,186 **** db = Bio::FlatFileIndex.open(dbname) ARGV.each do |key| ! STDERR.print "Searching for \'#{key}\'...\n" #r = db.search(key) ! #STDERR.print "OK, #{r.size} entry found\n" #if r.size > 0 then # print r --- 180,186 ---- db = Bio::FlatFileIndex.open(dbname) ARGV.each do |key| ! $stderr.print "Searching for \'#{key}\'...\n" #r = db.search(key) ! #$stderr.print "OK, #{r.size} entry found\n" #if r.size > 0 then # print r *************** *** 193,201 **** end rescue RuntimeError ! STDERR.print "ERROR: #{$!}\n" next end r = [] unless r ! STDERR.print "OK, #{r.size} entry found\n" r.each do |i| print db.search_primary(i) --- 193,201 ---- end rescue RuntimeError ! $stderr.print "ERROR: #{$!}\n" next end r = [] unless r ! $stderr.print "OK, #{r.size} entry found\n" r.each do |i| print db.search_primary(i) *************** *** 241,252 **** end if k then ! STDERR.print "Format: #{k.to_s}\n" format = k else ! STDERR.print "ERROR: couldn't determine file format\n" return end end ! STDERR.print "Namespaces: (first line: primary namespace)\n" if format then parser = Bio::FlatFileIndex::Indexer::Parser.new(format) --- 241,252 ---- end if k then ! $stderr.print "Format: #{k.to_s}\n" format = k else ! $stderr.print "ERROR: couldn't determine file format\n" return end end ! $stderr.print "Namespaces: (first line: primary namespace)\n" if format then parser = Bio::FlatFileIndex::Indexer::Parser.new(format) From ngoto at pub.open-bio.org Wed Feb 22 02:01:07 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 07:01:07 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io/flatfile index.rb,1.16,1.17 Message-ID: <200602220701.k1M717VL032459@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io/flatfile In directory pub.open-bio.org:/tmp/cvs-serv32441/lib/bio/io/flatfile Modified Files: index.rb Log Message: changed STDERR to $stderr Index: index.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile/index.rb,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** index.rb 29 Jan 2006 10:06:43 -0000 1.16 --- index.rb 22 Feb 2006 07:01:05 -0000 1.17 *************** *** 414,425 **** # Module for output debug messages. # Default setting: If $DEBUG or $VERBOSE is true, output debug ! # messages to STDERR; Otherwise, don't output messages. # module DEBUG ! @@out = STDERR @@flag = nil # Set debug messages output destination. ! # If true is given, outputs to STDERR. # If nil is given, outputs nothing. # This method affects ALL of FlatFileIndex related objects/methods. --- 414,425 ---- # Module for output debug messages. # Default setting: If $DEBUG or $VERBOSE is true, output debug ! # messages to $stderr; Otherwise, don't output messages. # module DEBUG ! @@out = $stderr @@flag = nil # Set debug messages output destination. ! # If true is given, outputs to $stderr. # If nil is given, outputs nothing. # This method affects ALL of FlatFileIndex related objects/methods. *************** *** 428,432 **** if io then @@out = io ! @@out = STDERR if io == true @@flag = true else --- 428,432 ---- if io then @@out = io ! @@out = $stderr if io == true @@flag = true else From nakao at pub.open-bio.org Wed Feb 22 02:35:21 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 22 Feb 2006 07:35:21 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/db test_aaindex.rb,1.2,1.3 Message-ID: <200602220735.k1M7ZLVL032553@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/db In directory pub.open-bio.org:/tmp/cvs-serv32524/test/unit/bio/db Modified Files: test_aaindex.rb Log Message: * aaindex.rb: Added Bio::AAindex2#[](aa1, aa2) method for accessing the value in the matrix. Changed arguments of Bio::AAindex2#matrix(aa1 = nil, aa1 = nil) to access Bio::AAindex2#[](aa1, aa2) method. Added a lazy-parsing by using @data. * test_aaindex.rb: Changed test codes for Bio::AAindex2#[] and BioAAindex2#matrix. Index: test_aaindex.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/db/test_aaindex.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_aaindex.rb 22 Feb 2006 05:07:36 -0000 1.2 --- test_aaindex.rb 22 Feb 2006 07:35:19 -0000 1.3 *************** *** 156,164 **** def test_matrix assert_equal(Matrix, @obj.matrix.class) - # assert_equal('', @obj.matrix) end def test_matrix_2_2 ! assert_equal(2.0, @obj.matrix[2,2]) end --- 156,183 ---- def test_matrix assert_equal(Matrix, @obj.matrix.class) end def test_matrix_2_2 ! assert_equal(2.0, @obj.matrix[2, 2]) ! end ! ! def test_matrix_1_2 ! assert_equal(nil, @obj.matrix[1, 2]) ! end ! ! def test_access_A_R ! assert_equal(nil, @obj['A', 'R']) ! end ! ! def test_access_R_A ! assert_equal(-2.0, @obj['R', 'A']) ! end ! ! def test_matrix_A_R ! assert_equal(nil, @obj.matrix('A', 'R')) ! end ! ! def test_matrix_R_A ! assert_equal(-2.0, @obj.matrix('R', 'A')) end From nakao at pub.open-bio.org Wed Feb 22 02:35:22 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 22 Feb 2006 07:35:22 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db aaindex.rb,1.17,1.18 Message-ID: <200602220735.k1M7ZMVL032557@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv32524/lib/bio/db Modified Files: aaindex.rb Log Message: * aaindex.rb: Added Bio::AAindex2#[](aa1, aa2) method for accessing the value in the matrix. Changed arguments of Bio::AAindex2#matrix(aa1 = nil, aa1 = nil) to access Bio::AAindex2#[](aa1, aa2) method. Added a lazy-parsing by using @data. * test_aaindex.rb: Changed test codes for Bio::AAindex2#[] and BioAAindex2#matrix. Index: aaindex.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/aaindex.rb,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** aaindex.rb 18 Feb 2006 14:44:40 -0000 1.17 --- aaindex.rb 22 Feb 2006 07:35:19 -0000 1.18 *************** *** 18,22 **** # # aax1 = Bio::AAindex.auto("PRAM900102.aaindex1") ! # aax2 = Bio::AAindex.auto("HENS920102.aaindex2") # # aax1 = Bio::AAindex1.new("PRAM900102.aaindex1") --- 18,22 ---- # # aax1 = Bio::AAindex.auto("PRAM900102.aaindex1") ! # aax2 = Bio::AAindex.auto("DAYM780301.aaindex2") # # aax1 = Bio::AAindex1.new("PRAM900102.aaindex1") *************** *** 24,31 **** # aax1.index # ! # aax2 = Bio::AAindex2.new("HENS920102.aaindex2") # aax2.entry_id # aax2.matrix # aax2.matrix[2,2] # # == References --- 24,33 ---- # aax1.index # ! # aax2 = Bio::AAindex2.new("DAYM780301.aaindex2") # aax2.entry_id # aax2.matrix # aax2.matrix[2,2] + # aax2.matrix('R', 'A') + # aax2['R', 'A'] # # == References *************** *** 89,98 **** # Returns entry_id in the H line. def entry_id ! field_fetch('H') end # Returns definition in the D line. def definition ! field_fetch('D') end --- 91,108 ---- # Returns entry_id in the H line. def entry_id ! if @data['entry_id'] ! @data['entry_id'] ! else ! @data['entry_id'] = field_fetch('H') ! end end # Returns definition in the D line. def definition ! if @data['definition'] ! @data['definition'] ! else ! @data['definition'] = field_fetch('D') ! end end *************** *** 100,124 **** # cf.) ['LIT:123456', 'PMID:12345678'] def dblinks ! field_fetch('R').split(' ') end # Returns authors in the A line. def author ! field_fetch('A') end # Returns title in the T line. def title ! field_fetch('T') end # Returns journal name in the J line. def journal ! field_fetch('J') end # Returns comment (if any). def comment ! field_fetch("*") end end --- 110,154 ---- # cf.) ['LIT:123456', 'PMID:12345678'] def dblinks ! if @data['ref'] ! @data['ref'] ! else ! @data['ref'] = field_fetch('R').split(' ') ! end end # Returns authors in the A line. def author ! if @data['author'] ! @data['author'] ! else ! @data['author'] = field_fetch('A') ! end end # Returns title in the T line. def title ! if @data['title'] ! @data['title'] ! else ! @data['title'] = field_fetch('T') ! end end # Returns journal name in the J line. def journal ! if @data['journal'] ! @data['journal'] ! else ! @data['journal'] = field_fetch('J') ! end end # Returns comment (if any). def comment ! if @data['comment'] ! @data['comment'] ! else ! @data['comment'] = field_fetch('*') ! end end end *************** *** 136,146 **** # cf.) {'ABCD12010203' => 0.999, 'CDEF123456' => 0.543, ...} def correlation_coefficient ! hash = {} ! ary = field_fetch('C').split(' ') ! ary.each do |x| ! next unless x =~ /^[A-Z]/ ! hash[x] = ary[ary.index(x) + 1].to_f end - hash end --- 166,180 ---- # cf.) {'ABCD12010203' => 0.999, 'CDEF123456' => 0.543, ...} def correlation_coefficient ! if @data['correlation_coefficient'] ! @data['correlation_coefficient'] ! else ! hash = {} ! ary = field_fetch('C').split(' ') ! ary.each do |x| ! next unless x =~ /^[A-Z]/ ! hash[x] = ary[ary.index(x) + 1].to_f ! end ! @data['correlation_coefficient'] = hash end end *************** *** 205,236 **** # Returns row labels. def rows ! label_data ! @rows end # Returns col labels. def cols ! label_data ! @cols end ! # Returns matrix in Matrix. ! def matrix ! ma = Array.new ! data = label_data ! data.each_line do |line| ! list = line.strip.split(/\s+/).map{|x| x.to_f} ! ma.push(list) ! end ! Matrix[*ma] end ! # Returns def old_matrix # for AAindex <= ver 5.0 ! @aa = {} # used to determine row/column of the aa attr_reader :aa field = field_fetch('I') --- 239,289 ---- # Returns row labels. def rows ! if @data['rows'] ! @data['rows'] ! else ! label_data ! @rows ! end end # Returns col labels. def cols ! if @data['cols'] ! @data['cols'] ! else ! label_data ! @cols ! end end ! # Returns the value of amino acids substitution (aa1 -> aa2). ! def [](aa1 = nil, aa2 = nil) ! matrix[cols.index(aa1), rows.index(aa2)] ! end ! # Returns amino acids matrix in Matrix. ! def matrix(aa1 = nil, aa2 = nil) ! return self[aa1, aa2] if aa1 and aa2 ! if @data['matrix'] ! @data['matrix'] ! else ! ma = [] ! label_data.each_line do |line| ! ma << line.strip.split(/\s+/).map {|x| x.to_f } ! end ! @data['matrix'] = Matrix[*ma] ! end end ! # Returns amino acids matrix in Matrix for the old format (<= ver 5.0). def old_matrix # for AAindex <= ver 5.0 + return @data['matrix'] if @data['matrix'] ! @aa = {} ! # used to determine row/column of the aa attr_reader :aa + alias_method :aa, :rows + alias_method :aa, :cols field = field_fetch('I') *************** *** 256,261 **** end end ! Matrix[*ma] ! when / -ARNDCQEGHILKMFPSTWYV / # 21x20/2 matrix (with gap) raise NotImplementedError --- 309,313 ---- end end ! @data['matrix'] = Matrix[*ma] when / -ARNDCQEGHILKMFPSTWYV / # 21x20/2 matrix (with gap) raise NotImplementedError *************** *** 268,278 **** def label_data ! label, data = get('M').split("\n", 2) ! if /M rows = (\S+), cols = (\S+)/.match(label) ! rows, cols = $1, $2 ! @rows = rows.split('') ! @cols = cols.split('') end - return data end --- 320,334 ---- def label_data ! if @data['data'] ! @data['data'] ! else ! label, data = get('M').split("\n", 2) ! if /M rows = (\S+), cols = (\S+)/.match(label) ! rows, cols = $1, $2 ! @rows = rows.split('') ! @cols = cols.split('') ! end ! @data['data'] = data end end *************** *** 296,301 **** p aax1.correlation_coefficient p aax1.index ! puts "### AAindex2 (HENS920102)" ! aax2 = Bio::AAindex2.new(Bio::Fetch.query('aaindex', 'HENS920102', 'raw')) p aax2.entry_id p aax2.definition --- 352,358 ---- p aax1.correlation_coefficient p aax1.index ! p aax1 ! puts "### AAindex2 (DAYM780301)" ! aax2 = Bio::AAindex2.new(Bio::Fetch.query('aaindex', 'DAYM780301', 'raw')) p aax2.entry_id p aax2.definition *************** *** 309,315 **** --- 366,375 ---- p aax2.matrix p aax2.matrix[2,2] + p aax2.matrix[2,3] + p aax2.matrix[4,3] p aax2.matrix.determinant p aax2.matrix.rank p aax2.matrix.transpose + p aax2 end From ngoto at pub.open-bio.org Wed Feb 22 03:38:43 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 08:38:43 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io flatfile.rb,1.43,1.44 Message-ID: <200602220838.k1M8chVL032682@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory pub.open-bio.org:/tmp/cvs-serv32672/lib/bio/io Modified Files: flatfile.rb Log Message: Completely rewritten. Please see Changes-0.7.rd for incompatible changes. Index: flatfile.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile.rb,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** flatfile.rb 29 Jan 2006 06:54:14 -0000 1.43 --- flatfile.rb 22 Feb 2006 08:38:41 -0000 1.44 *************** *** 2,26 **** # = bio/io/flatfile.rb - flatfile access wrapper class # ! # Copyright:: Copyright (C) 2001, 2002 GOTO Naohisa ! # License:: LGPL ! # ! #-- ! # 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. [...1570 lines suppressed...] + #fastaformat.is_prior_to(debug_last) + + a.rehash + return a + end + + end #class AutoDetect + end #class FlatFile end #module Bio if __FILE__ == $0 if ARGV.size == 2 *************** *** 500,502 **** end end - --- 1199,1200 ---- From ngoto at pub.open-bio.org Wed Feb 22 03:40:33 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 08:40:33 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io/flatfile index.rb,1.17,1.18 Message-ID: <200602220840.k1M8eXVL032748@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io/flatfile In directory pub.open-bio.org:/tmp/cvs-serv32738/lib/bio/io/flatfile Modified Files: index.rb Log Message: changed lisence to Ruby's Index: index.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile/index.rb,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** index.rb 22 Feb 2006 07:01:05 -0000 1.17 --- index.rb 22 Feb 2006 08:40:31 -0000 1.18 *************** *** 3,27 **** # # Copyright:: Copyright (C) 2002 ! # GOTO Naohisa ! # License:: LGPL # # $Id$ # - #-- - # 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 - #++ - # # = About Bio::FlatFileIndex # --- 3,11 ---- # # Copyright:: Copyright (C) 2002 ! # GOTO Naohisa ! # License:: Ruby's # # $Id$ # # = About Bio::FlatFileIndex # From ngoto at pub.open-bio.org Wed Feb 22 03:41:05 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 08:41:05 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io/flatfile indexer.rb,1.22,1.23 Message-ID: <200602220841.k1M8f5VL032765@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io/flatfile In directory pub.open-bio.org:/tmp/cvs-serv32755/lib/bio/io/flatfile Modified Files: indexer.rb Log Message: changes were made due to the Bio::FlatFile internal change Index: indexer.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile/indexer.rb,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** indexer.rb 29 Jan 2006 06:54:14 -0000 1.22 --- indexer.rb 22 Feb 2006 08:41:03 -0000 1.23 *************** *** 1,20 **** # ! # bio/io/flatfile/indexer.rb - OBDA flatfile indexer ! # ! # Copyright (C) 2002 GOTO Naohisa ! # ! # 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$ --- 1,7 ---- # ! # = bio/io/flatfile/indexer.rb - OBDA flatfile indexer # ! # Copyright:: Copyright (C) 2002 GOTO Naohisa ! # License:: Ruby's # # $Id$ *************** *** 133,140 **** def each - pos = @flatfile.pos @flatfile.each do |x| @entry = x ! len = @flatfile.entry_raw.length begin yield pos, len --- 120,127 ---- def each @flatfile.each do |x| @entry = x ! pos = @flatfile.entry_start_pos ! len = @flatfile.entry_ended_pos - @flatfile.entry_start_pos begin yield pos, len *************** *** 153,157 **** end end #rescue - pos = @flatfile.pos end end --- 140,143 ---- *************** *** 206,218 **** end self.add_secondary_namespaces(*sec_names) - end - def open_flatfile(fileid, file) - super - @flatfile.pos = 0 - begin - pos = @flatfile.pos - line = @flatfile.gets - end until (!line or line =~ /^LOCUS /) - @flatfile.pos = pos end end #class GenBankParser --- 192,195 ---- From ngoto at pub.open-bio.org Wed Feb 22 03:43:17 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 08:43:17 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db nbrf.rb,1.7,1.8 Message-ID: <200602220843.k1M8hHVL000347@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv337/lib/bio/db Modified Files: nbrf.rb Log Message: * changed license to Ruby's. * DELIMITER is changed like Bio::FastaFormat. * Added new constant DELIMITER_OVERRUN for Bio::FlatFile. Index: nbrf.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/nbrf.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** nbrf.rb 18 Dec 2005 15:58:41 -0000 1.7 --- nbrf.rb 22 Feb 2006 08:43:15 -0000 1.8 *************** *** 2,24 **** # = bio/db/nbrf.rb - NBRF/PIR format sequence data class # ! # Copyright:: Copyright (C) 2001-2003 GOTO Naohisa # Copyright (C) 2001-2002 KATAYAMA Toshiaki ! # License:: LGPL ! # ! #-- ! # 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$ --- 2,8 ---- # = bio/db/nbrf.rb - NBRF/PIR format sequence data class # ! # Copyright:: Copyright (C) 2001-2003,2006 Naohisa Goto # Copyright (C) 2001-2002 KATAYAMA Toshiaki ! # License:: Ruby's # # $Id$ *************** *** 45,49 **** # Delimiter of each entry. Bio::FlatFile uses it. ! DELIMITER = RS = "*\n" # Creates a new NBRF object. It stores the comment and sequence --- 29,41 ---- # Delimiter of each entry. Bio::FlatFile uses it. ! DELIMITER = RS = "\n>" ! ! # (Integer) excess read size included in DELIMITER. ! DELIMITER_OVERRUN = 1 # '>' ! ! #-- ! # Note: DELIMITER is changed due to the change of Bio::FlatFile. ! # DELIMITER = RS = "*\n" ! #++ # Creates a new NBRF object. It stores the comment and sequence From ngoto at pub.open-bio.org Wed Feb 22 03:44:49 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 08:44:49 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db fasta.rb,1.24,1.25 Message-ID: <200602220844.k1M8inVL000375@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv365/lib/bio/db Modified Files: fasta.rb Log Message: added a new constant DELIMITER_OVERRUN for Bio::FlatFile. Index: fasta.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/fasta.rb,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** fasta.rb 14 Feb 2006 13:42:40 -0000 1.24 --- fasta.rb 22 Feb 2006 08:44:46 -0000 1.25 *************** *** 139,142 **** --- 139,145 ---- DELIMITER = RS = "\n>" + # (Integer) excess read size included in DELIMITER. + DELIMITER_OVERRUN = 1 # '>' + # The comment line of the FASTA formatted data. attr_accessor :definition From ngoto at pub.open-bio.org Wed Feb 22 03:46:17 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 08:46:17 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/blast format0.rb, 1.16, 1.17 wublast.rb, 1.5, 1.6 Message-ID: <200602220846.k1M8kHVL000400@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/blast In directory pub.open-bio.org:/tmp/cvs-serv384/lib/bio/appl/blast Modified Files: format0.rb wublast.rb Log Message: * changed license to Ruby's. * added a new constant DELIMITER_OVERRUN for Bio::FlatFile. Index: wublast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/wublast.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** wublast.rb 18 Dec 2005 15:58:39 -0000 1.5 --- wublast.rb 22 Feb 2006 08:46:15 -0000 1.6 *************** *** 3,23 **** # # Copyright:: Copyright (C) 2003 GOTO Naohisa ! # License:: LGPL ! # ! #-- ! # 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$ --- 3,7 ---- # # Copyright:: Copyright (C) 2003 GOTO Naohisa ! # License:: Ruby's # # $Id$ *************** *** 338,341 **** --- 322,328 ---- # Delimter of each entry for TBLAST. Bio::FlatFile uses it. DELIMITER = RS = "\nTBLAST" + + # (Integer) excess read size included in DELIMITER. + DELIMITER_OVERRUN = 6 # "TBLAST" end #class Report_TBlast Index: format0.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/format0.rb,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** format0.rb 1 Nov 2005 05:32:23 -0000 1.16 --- format0.rb 22 Feb 2006 08:46:15 -0000 1.17 *************** *** 3,24 **** # # Author:: Naohisa GOTO ! # Copyright:: Copyright (C) 2003 GOTO Naohisa ! # License:: LGPL ! # ! #-- ! # 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$ --- 3,8 ---- # # Author:: Naohisa GOTO ! # Copyright:: Copyright (C) 2003-2006 GOTO Naohisa ! # License:: Ruby's # # $Id$ *************** *** 57,60 **** --- 41,47 ---- DELIMITER = RS = "\nBLAST" + # (Integer) excess read size included in DELIMITER. + DELIMITER_OVERRUN = 5 # "BLAST" + # Opens file by using Bio::FlatFile.open. def self.open(filename, *mode) *************** *** 1202,1205 **** --- 1189,1195 ---- # Delimter of each entry for TBLAST. Bio::FlatFile uses it. DELIMITER = RS = "\nTBLAST" + + # (Integer) excess read size included in DELIMITER. + DELIMITER_OVERRUN = 6 # "TBLAST" end #class Report_TBlast From ngoto at pub.open-bio.org Wed Feb 22 03:46:17 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 08:46:17 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/spidey report.rb,1.8,1.9 Message-ID: <200602220846.k1M8kHVL000396@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/spidey In directory pub.open-bio.org:/tmp/cvs-serv384/lib/bio/appl/spidey Modified Files: report.rb Log Message: * changed license to Ruby's. * added a new constant DELIMITER_OVERRUN for Bio::FlatFile. Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/spidey/report.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** report.rb 18 Dec 2005 15:58:41 -0000 1.8 --- report.rb 22 Feb 2006 08:46:15 -0000 1.9 *************** *** 3,23 **** # # Copyright:: Copyright (C) 2004 GOTO Naohisa ! # License:: LGPL ! # ! #-- ! # 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$ --- 3,7 ---- # # Copyright:: Copyright (C) 2004 GOTO Naohisa ! # License:: Ruby's # # $Id$ *************** *** 45,48 **** --- 29,34 ---- # Spidey report parser class. + # Please see bio/appl/spidey/report.rb for details. + # # Its object may contain some Bio::Spidey::Report::Hit objects. class Report #< DB *************** *** 53,56 **** --- 39,45 ---- # Delimiter of each entry. Bio::FlatFile uses it. DELIMITER = RS = "\n--SPIDEY " + + # (Integer) excess read size included in DELIMITER. + DELIMITER_OVERRUN = 9 # "--SPIDEY ".length # Creates a new Bio::Spidey::Report object from String. From ngoto at pub.open-bio.org Wed Feb 22 04:15:24 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 09:15:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io flatfile.rb,1.44,1.45 Message-ID: <200602220915.k1M9FOVL000832@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory pub.open-bio.org:/tmp/cvs-serv822/lib/bio/io Modified Files: flatfile.rb Log Message: changed HEADER to FLATFILE_HEADER. Index: flatfile.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile.rb,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** flatfile.rb 22 Feb 2006 08:38:41 -0000 1.44 --- flatfile.rb 22 Feb 2006 09:15:22 -0000 1.45 *************** *** 273,277 **** # It sees following constants in the given class. # DELIMITER:: (String) delimiter indicates the end of a entry. ! # HEADER:: (String) start of a entry, located on head of a line. # DELIMITER_OVERRUN:: (Integer) excess read size included in DELIMITER. # --- 273,277 ---- # It sees following constants in the given class. # DELIMITER:: (String) delimiter indicates the end of a entry. ! # FLATFILE_HEADER:: (String) start of a entry, located on head of a line. # DELIMITER_OVERRUN:: (Integer) excess read size included in DELIMITER. # *************** *** 283,287 **** @stream = bstream @delimiter = klass::DELIMITER rescue nil ! @header = klass::HEADER rescue nil # for specific classes' benefit unless header --- 283,287 ---- @stream = bstream @delimiter = klass::DELIMITER rescue nil ! @header = klass::FLATFILE_HEADER rescue nil # for specific classes' benefit unless header *************** *** 306,310 **** # If @header is not nil, it reads till the contents of @header # comes at the head of a line. ! # If correct HEADER is found, returns true. # Otherwise, returns nil. def skip_leader --- 306,310 ---- # If @header is not nil, it reads till the contents of @header # comes at the head of a line. ! # If correct FLATFILE_HEADER is found, returns true. # Otherwise, returns nil. def skip_leader From ngoto at pub.open-bio.org Wed Feb 22 05:01:29 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 10:01:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io flatfile.rb,1.45,1.46 Message-ID: <200602221001.k1MA1TVL000938@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory pub.open-bio.org:/tmp/cvs-serv917/lib/bio/io Modified Files: flatfile.rb Log Message: in Bio::FlatFile::AutoDetect#autodetect_flatfile calls autodetect rules before reading the stream if meta information (file path, etc) is available. Index: flatfile.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile.rb,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** flatfile.rb 22 Feb 2006 09:15:22 -0000 1.45 --- flatfile.rb 22 Feb 2006 10:01:27 -0000 1.46 *************** *** 989,994 **** # Returns nil if failed. def autodetect_flatfile(ff, lines = 31) stream = ff.instance_eval { @stream } ! meta = { :path => stream.path } 1.upto(lines) do |x| break unless line = stream.prefetch_gets --- 989,1006 ---- # Returns nil if failed. def autodetect_flatfile(ff, lines = 31) + meta = {} stream = ff.instance_eval { @stream } ! begin ! path = stream.path ! rescue NameError ! end ! if path then ! meta[:path] = path ! # call autodetect onece with meta and without any read action ! if r = self.autodetect(stream.prefetch_buffer, meta) ! return r ! end ! end ! # reading stream 1.upto(lines) do |x| break unless line = stream.prefetch_gets From ngoto at pub.open-bio.org Wed Feb 22 10:09:47 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 15:09:47 +0000 Subject: [BioRuby-cvs] bioruby/doc Changes-0.7.rd,1.14,1.15 Message-ID: <200602221509.k1MF9lVL001795@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/doc In directory pub.open-bio.org:/tmp/cvs-serv1785/doc Modified Files: Changes-0.7.rd Log Message: added Bio::FlatFile incompatible changes. Index: Changes-0.7.rd =================================================================== RCS file: /home/repository/bioruby/bioruby/doc/Changes-0.7.rd,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Changes-0.7.rd 16 Jan 2006 15:25:43 -0000 1.14 --- Changes-0.7.rd 22 Feb 2006 15:09:45 -0000 1.15 *************** *** 227,230 **** --- 227,252 ---- * There are more and more changes to be written... + --- Bio::FlatFile + + In 0.7.2: + + * Bio::FlatFile.open, Bio::FlatFile.auto and Bio::FlatFile.new are changed + not to accept the last argument to specify raw mode, e.g. :raw => true, + :raw => false, true or false. Instead, please use Bio::FlatFile#raw= + method after creating a new object. + * Now, first argument of Bio::FlatFile.open, which shall be a database + class or nil, can be omitted, and you can do + Bio::FlatFile.open(filename, ...). Note that + Bio::FlatFile.open(dbclass, filaname, ...) is still available. + * Bio::FlatFile#io is obsoleted. Please use Bio::FlatFile#to_io instead. + * When reading GenBank or GenPept files, comments at the head of the file + before the first "LOCUS" lines are now skipped by default. + When reading other file formats, white space characters are skipped. + * File format autodetection routine is completely rewritten. + If it fails to determine data format which was previously determined, + please report us with the data. + * Internal structure is now completely changed. Codes depend on the internal + structure (which is not recommended) would not work. + === Deleted files From nakao at pub.open-bio.org Thu Feb 23 17:25:32 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 23 Feb 2006 22:25:32 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl/bl2seq test_report.rb, 1.1, 1.2 Message-ID: <200602232225.k1NMPWVL007689@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl/bl2seq In directory pub.open-bio.org:/tmp/cvs-serv7677/test/unit/bio/appl/bl2seq Modified Files: test_report.rb Log Message: * Changed class TestBlastReportHit -> class TestBl2seqReportHit. Index: test_report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/appl/bl2seq/test_report.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_report.rb 13 Feb 2006 15:51:11 -0000 1.1 --- test_report.rb 23 Feb 2006 22:25:30 -0000 1.2 *************** *** 114,118 **** ! class TestBlastReportHit < Test::Unit::TestCase def setup @empty = Bio::Blast::Bl2seq::Report.new(Bio::TestBl2seqReportData.output('empty')) --- 114,118 ---- ! class TestBl2seqReportHit < Test::Unit::TestCase def setup @empty = Bio::Blast::Bl2seq::Report.new(Bio::TestBl2seqReportData.output('empty')) *************** *** 122,128 **** end ! def test_hits assert_equal(0, @empty.hits.size) assert_equal(Bio::Blast::Bl2seq::Report::Hit, @blastp.hits.first.class) assert_equal(1, @blastp.hits.size) --- 122,130 ---- end ! def test_empty_hits assert_equal(0, @empty.hits.size) + end + def test_hits assert_equal(Bio::Blast::Bl2seq::Report::Hit, @blastp.hits.first.class) assert_equal(1, @blastp.hits.size) From k at pub.open-bio.org Mon Feb 27 04:09:59 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:09:59 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.20,1.21 Message-ID: <200602270910.k1R99xVL000442@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv424/lib/bio/shell Modified Files: core.rb Log Message: * policy of directory creation is changed - session, data, plugin directories are created at a start time without asking to incorporate rails smoothly. * functions of splash animation and color/mono mode are separated Index: core.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** core.rb 17 Feb 2006 17:09:17 -0000 1.20 --- core.rb 27 Feb 2006 09:09:57 -0000 1.21 *************** *** 37,40 **** --- 37,44 ---- } + def history + SAVEDIR + HISTORY + end + def datadir DATADIR *************** *** 70,107 **** def save_session closing_splash ! save_history ! save_object ! save_config ! end ! ! #-- ! # *TODO* How to prevent terminal collapse and suppress loading messages? ! #++ ! def load_thread ! message = '' ! begin ! t1 = Thread.new do ! require 'stringio' ! sio = StringIO.new('') ! begin ! stdout_save = STDOUT.clone ! STDOUT.reopen(sio) ! load_object ! load_history ! ensure ! STDOUT.reopen(stdout_save) ! stdout_save.close ! message = sio.read ! sio.close ! end ! end ! t2 = Thread.new do ! opening_splash ! end ! t1.join ! t2.join ! rescue end - puts message end --- 74,82 ---- def save_session closing_splash ! if create_save_dir_ask ! #save_history # changed to use our own... ! save_object ! save_config end end *************** *** 121,126 **** def create_save_dir if @cache[:save].nil? ! if ask_yes_or_no("Save session in '#{SAVEDIR}' directory? [y/n]: ") create_real_dir(SAVEDIR) create_real_dir(DATADIR) --- 96,110 ---- def create_save_dir + create_real_dir(SAVEDIR) + create_real_dir(DATADIR) + create_real_dir(PLUGIN) + end + + def create_save_dir_ask + if File.directory?(SAVEDIR) + @cache[:save] = true + end if @cache[:save].nil? ! if ask_yes_or_no("Save session in '#{SAVEDIR}' directory? [y/n] ") create_real_dir(SAVEDIR) create_real_dir(DATADIR) *************** *** 137,141 **** def ask_yes_or_no(message) loop do ! print message answer = gets if answer.nil? --- 121,125 ---- def ask_yes_or_no(message) loop do ! print "#{message}" answer = gets if answer.nil? *************** *** 203,209 **** def save_config ! if create_save_dir ! save_config_file(SAVEDIR + CONFIG) ! end end --- 187,191 ---- def save_config ! save_config_file(SAVEDIR + CONFIG) end *************** *** 247,258 **** end def config_splash flag = ! @config[:splash] @config[:splash] = flag puts "Splash #{flag ? 'on' : 'off'}" ! end ! ! def config_pager(cmd = nil) ! @config[:pager] = cmd end --- 229,241 ---- end + def config_pager(cmd = nil) + @config[:pager] = cmd + end + def config_splash flag = ! @config[:splash] @config[:splash] = flag puts "Splash #{flag ? 'on' : 'off'}" ! opening_splash end *************** *** 260,263 **** --- 243,247 ---- str ||= MESSAGE @config[:message] = str + opening_splash end *************** *** 306,312 **** def save_object ! if create_save_dir ! save_object_file(SAVEDIR + OBJECT) ! end end --- 290,294 ---- def save_object ! save_object_file(SAVEDIR + OBJECT) end *************** *** 355,359 **** print "Loading history (#{file}) ... " File.open(file).each do |line| ! Readline::HISTORY.push line.chomp end puts "done" --- 337,343 ---- print "Loading history (#{file}) ... " File.open(file).each do |line| ! #Readline::HISTORY.push line.chomp ! date, hist = line.chomp.split("\t") ! Readline::HISTORY.push hist if hist end puts "done" *************** *** 363,369 **** def save_history if @cache[:readline] ! if create_save_dir ! save_history_file(SAVEDIR + HISTORY) ! end end end --- 347,351 ---- def save_history if @cache[:readline] ! save_history_file(SAVEDIR + HISTORY) end end *************** *** 417,423 **** if @script_begin and @script_end and @script_begin <= @script_end if File.exists?(SCRIPT) ! message = "Overwrite script file (#{SCRIPT})? [y/n]: " else ! message = "Save script file (#{SCRIPT})? [y/n]: " end if ask_yes_or_no(message) --- 399,405 ---- if @script_begin and @script_end and @script_begin <= @script_end if File.exists?(SCRIPT) ! message = "Overwrite script file (#{SCRIPT})? [y/n] " else ! message = "Save script file (#{SCRIPT})? [y/n] " end if ask_yes_or_no(message) *************** *** 463,468 **** end ! def splash_message_action ! s = splash_message l = s.length x = " " --- 445,450 ---- end ! def splash_message_action(message = nil) ! s = message || splash_message l = s.length x = " " *************** *** 480,485 **** end ! def splash_message_action_color ! s = splash_message l = s.length c = ESC_SEQ --- 462,467 ---- end ! def splash_message_action_color(message = nil) ! s = message || splash_message l = s.length c = ESC_SEQ From k at pub.open-bio.org Mon Feb 27 04:11:03 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:11:03 +0000 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.65,1.66 Message-ID: <200602270911.k1R9B3VL000498@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv494/lib Modified Files: bio.rb Log Message: * prepared for 1.0.0 release Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** bio.rb 21 Feb 2006 18:01:59 -0000 1.65 --- bio.rb 27 Feb 2006 09:11:01 -0000 1.66 *************** *** 11,15 **** module Bio ! BIORUBY_VERSION = [0, 8, 0].extend(Comparable) ### Basic data types --- 11,15 ---- module Bio ! BIORUBY_VERSION = [1, 0, 0].extend(Comparable) ### Basic data types *************** *** 101,106 **** autoload :GFF, 'bio/db/gff' autoload :AAindex, 'bio/db/aaindex' ! autoload :AAindex1, 'bio/db/aaindex' ! autoload :AAindex2, 'bio/db/aaindex' autoload :TRANSFAC, 'bio/db/transfac' autoload :PROSITE, 'bio/db/prosite' --- 101,106 ---- autoload :GFF, 'bio/db/gff' autoload :AAindex, 'bio/db/aaindex' ! autoload :AAindex1, 'bio/db/aaindex' # change to AAindex::AAindex1 ? ! autoload :AAindex2, 'bio/db/aaindex' # change to AAindex::AAindex2 ? autoload :TRANSFAC, 'bio/db/transfac' autoload :PROSITE, 'bio/db/prosite' From k at pub.open-bio.org Mon Feb 27 04:13:10 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:13:10 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio db.rb,0.33,0.34 Message-ID: <200602270913.k1R9DAVL000596@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv592/lib/bio Modified Files: db.rb Log Message: * license is changed from LGPL to Ruby's Index: db.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db.rb,v retrieving revision 0.33 retrieving revision 0.34 diff -C2 -d -r0.33 -r0.34 *** db.rb 18 Feb 2006 14:44:40 -0000 0.33 --- db.rb 27 Feb 2006 09:13:08 -0000 0.34 *************** *** 4,8 **** # Copyright:: Copyright (C) 2001, 2002, 2005 # KATAYAMA Toshiaki ! # License:: LGPL # # $Id$ --- 4,8 ---- # Copyright:: Copyright (C) 2001, 2002, 2005 # KATAYAMA Toshiaki ! # License:: Ruby's # # $Id$ *************** *** 145,166 **** # The name of the organism. # - #-- - # - # 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 - # - #++ - # require 'bio/sequence' --- 145,148 ---- From k at pub.open-bio.org Mon Feb 27 04:13:48 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:13:48 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio feature.rb,1.9,1.10 Message-ID: <200602270913.k1R9DmVL000647@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv642/lib/bio Modified Files: feature.rb Log Message: * license is changed from LGPL to Ruby's Index: feature.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/feature.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** feature.rb 30 Nov 2005 01:54:38 -0000 1.9 --- feature.rb 27 Feb 2006 09:13:46 -0000 1.10 *************** *** 4,16 **** # Copyright:: Copyright (c) 2002, 2005 # Toshiaki Katayama ! # License:: LGPL # # $Id$ # - #-- - # *TODO* - # add to_gff method - #++ - # # == INSD Feature table definition # --- 4,11 ---- # Copyright:: Copyright (c) 2002, 2005 # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # # == INSD Feature table definition # *************** *** 44,65 **** # end # - #-- - # - # 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 - # - #++ - # require 'bio/location' --- 39,42 ---- *************** *** 158,167 **** # Returns an Array of Feature objects. attr_accessor :features - - def to_gff - # *TODO* - # to generate Bio::GFF object and implement Bio::GFF#to_s or - # to generate GFF string in this method? - end # Appends a Feature object to Features. --- 135,138 ---- From k at pub.open-bio.org Mon Feb 27 04:14:32 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:14:32 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl emboss.rb,1.3,1.4 Message-ID: <200602270914.k1R9EWVL000696@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv692/lib/bio/appl Modified Files: emboss.rb Log Message: * license is changed from LGPL to Ruby's Index: emboss.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/emboss.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** emboss.rb 28 Jan 2006 06:46:42 -0000 1.3 --- emboss.rb 27 Feb 2006 09:14:30 -0000 1.4 *************** *** 4,8 **** # Copyright:: Copyright (C) 2002, 2005 # KATAYAMA Toshiaki ! # License:: LGPL # # $Id$ --- 4,8 ---- # Copyright:: Copyright (C) 2002, 2005 # KATAYAMA Toshiaki ! # License:: Ruby's # # $Id$ *************** *** 11,32 **** # # * http://www.emboss.org - # - #-- - # - # 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 - # - #++ # --- 11,14 ---- From k at pub.open-bio.org Mon Feb 27 04:16:15 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:16:15 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell object.rb,NONE,1.1 Message-ID: <200602270916.k1R9GFVL000786@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv773/lib/bio/shell Added Files: object.rb Log Message: * Object extention for Rails --- NEW FILE: object.rb --- # # = bio/shell/object.rb - Object extension for the BioRuby shell # # Copyright:: Copyright (C) 2006 # Nobuya Tanaka , # Toshiaki Katayama # License:: Ruby's # # $Id: object.rb,v 1.1 2006/02/27 09:16:13 k Exp $ # require 'cgi' require 'pp' ### Object extention class Object # Couldn't work for Fixnum (Marshal) attr_accessor :memo # *TODO* def to_html if self.is_a?(String) "

" + self + "
" else str = "" PP.pp(self, str) "
" + str + "
" #"
" + CGI.escapeHTML(str) + "
" #self.inspect #"
" + self.inspect + "
" #"
" + self.to_s + "
" end end end =begin module Bio class DB def to_html html = "" html += "" @data.each do |k, v| html += "" end html += "
#{k}#{v}
" end end end =end From k at pub.open-bio.org Mon Feb 27 04:22:44 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:22:44 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell web.rb,NONE,1.1 Message-ID: <200602270922.k1R9MiVL000860@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv856/lib/bio/shell Added Files: web.rb Log Message: * 'web' command to start BioRuby shell on Rails --- NEW FILE: web.rb --- # # = bio/shell/web.rb - GUI for the BioRuby shell # # Copyright:: Copyright (C) 2006 # Nobuya Tanaka , # Toshiaki Katayama # License:: Ruby's # # $Id: web.rb,v 1.1 2006/02/27 09:22:42 k Exp $ # module Bio::Shell private def rails_directory_setup server = "script/server" unless File.exists?(server) require 'fileutils' basedir = File.dirname(__FILE__) print "Copying web server files ... " FileUtils.cp_r("#{basedir}/rails/.", ".") puts "done" end end def rails_server_setup require 'open3' $web_server = Open3.popen3(server) $web_error_log = File.open("log/web-error.log", "a") $web_server[2].reopen($web_error_log) while line = $web_server[1].gets if line[/druby:\/\/localhost/] uri = line.chomp puts uri if $DEBUG break end end $web_access_log = File.open("log/web-access.log", "a") $web_server[1].reopen($web_access_log) return uri end def web return if $web_server require 'drb/drb' # $SAFE = 1 # disable eval() and friends rails_directory_setup #uri = rails_server_setup uri = 'druby://localhost:81064' # baioroji- $drb_server = DRbObject.new_with_uri(uri) $drb_server.puts_remote("Connected") puts "Connected to server #{uri}" puts "Open http://localhost:3000/shell/" io = IRB.conf[:MAIN_CONTEXT].io io.class.class_eval do alias_method :shell_original_gets, :gets end def io.gets bind = IRB.conf[:MAIN_CONTEXT].workspace.binding vars = eval("local_variables", bind) vars.each do |var| next if var == "_" if val = eval("#{var}", bind) $drb_server[var] = val else $drb_server.delete(var) end end line = shell_original_gets line end end end From k at pub.open-bio.org Mon Feb 27 04:33:25 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:33:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell demo.rb,NONE,1.1 Message-ID: <200602270933.k1R9XPVL000936@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv932/lib/bio/shell Added Files: demo.rb Log Message: * 'demo' command for BioRuby shell --- NEW FILE: demo.rb --- # # = bio/shell/demo.rb - demo mode for the BioRuby shell # # Copyright:: Copyright (C) 2006 # Toshiaki Katayama # License:: Ruby's # # $Id: demo.rb,v 1.1 2006/02/27 09:33:22 k Exp $ # module Bio::Shell private def demo(part = nil) demo = Demo.new if part demo.send(part) else demo.all end end class Demo def initialize @bind = IRB.conf[:MAIN_CONTEXT].workspace.binding end def all sequence && entry && shell && pdb && true end def tutorial end def mito run(%q[entry = ent("data/kumamushi.gb")], "Load kumamushi gene from GenBank database entry ...", false) && run(%q[disp entry], "Check the contents ...", false) && run(%q[kuma = flatparse(entry)], "Parse the database entry ...", true) && run(%q[web], "Start BioRuby on Rails...", false) && run(%q[puts kuma.entry_id], "Extract entry ID ...", false) && run(%q[puts kuma.definition], "Extract definition ...", false) && run(%q[gene = kuma.seq], "Extract DNA sequence of the gene ...", true) && run(%q[doublehelix(gene)], "Show the sequence in ascii art ...", false) && run(%q[seqstat(gene)], "Statistics of the gene ...", false) && run(%q[config :color], "Change to color mode...", false) && run(%q[seqstat(gene)], "Statistics of the gene ...", false) && #run(%q[codontable], "Codontalble ...", false) && run(%q[protein = gene.translate], "Translate DNA into protein ...", true) && run(%q[comp = protein.composition], "Composition of the amino acids ...", false) && run(%q[pp comp], "Check the composition ...", false) && run(%q[puts protein.molecular_weight], "Molecular weight ...", false) && run(%q[midifile("data/kumamushi.mid", gene)], "Gene to music ...", false) && run(%q[`open "data/kumamushi.mid"`], "Let's listen ...", false) && true end def sequence run(%q[dna = seq("atgc" * 100)], "Generating DNA sequence ...", true) && run(%q[doublehelix dna], "Double helix representation", false) && run(%q[protein = dna.translate], "Translate DNA into Protein ...", true) && run(%q[protein.molecular_weight], "Calculating molecular weight ...", true) && run(%q[protein.composition], "Amino acid composition ...", true) && true end def entry run(%q[kuma = obj("gb:AF237819")], "Obtain an entry from GenBank database", false) && run(%q[kuma.definition], "Definition of the entry", true) && run(%q[kuma.naseq], "Sequence of the entry", true) && run(%q[kuma.naseq.translate], "Translate the sequence to protein", true) && run(%q[midifile("data/AF237819.mid", kuma.naseq)], "Generate gene music ...", false) && true end def shell run(%q[pwd], "Show current working directory ...", false) && run(%q[dir], "Show directory contents ...", false) && run(%q[dir "session"], "Show directory contents ...", false) && true end def pdb run(%q[ent_1bl8 = ent("pdb:1bl8")], "Retrieving PDB entry 1BL8 ...", false) && run(%q[head ent_1bl8], "Head part of the entry ...", false) && run(%q[savefile("1bl8.pdb", ent_1bl8)], "Saving the original entry in file ...", false) && run(%q[less "data/1bl8.pdb"], "Look through the entire entry ...", false) && run(%q[pdb_1bl8 = flatparse(ent_1bl8)], "Parsing the entry ...", false) && run(%q[pdb_1bl8.entry_id], "Showing the entry ID ...", true) && run(%q[pdb_1bl8.each_heterogen { |heterogen| p heterogen.resName }], "Showing each heterogen object ...", false) && true end def pdb_hetdic run(%q[het_dic = open("http://deposit.pdb.org/het_dictionary.txt").read], "Retrieving the het_dic database ...", false) && run(%q[savefile("data/het_dictionary.txt", het_dic)], "Saving the file ... ", false) && run(%q[het_dic.size], "Bytes of the file ...", true) && run(%q[less "data/het_dictionary.txt"], "Take a look on the contents ...", true) && run(%q[flatindex("het_dic", "data/het_dictionary.txt")], "Creating index to make the seaarchable database ...", false) && run(%q[ethanol = flatsearch("het_dic", "EOH")], "Search an ethanol entry ...", true) && run(%q[osake = flatparse(ethanol)], "Parse the entry ...", true) && run(%q[sake.conect], "Showing connect table (conect) of the molecule ...", true) && true end private def run(cmd, msg, echo) comment(msg) splash(cmd) result = eval(cmd, @bind) if echo pp result end continue? end def comment(msg) puts "### #{msg}" end def splash(msg) Bio::Shell.splash_message_action("bioruby> #{msg}") print "bioruby> #{msg}" gets end def continue? Bio::Shell.ask_yes_or_no("Continue? [y/n] ") end end end From k at pub.open-bio.org Mon Feb 27 04:34:25 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:34:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio shell.rb,1.14,1.15 Message-ID: <200602270934.k1R9YPVL000983@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv979/lib/bio Modified Files: shell.rb Log Message: * added object, web, demo modules Index: shell.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell.rb,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** shell.rb 17 Feb 2006 17:12:39 -0000 1.14 --- shell.rb 27 Feb 2006 09:34:23 -0000 1.15 *************** *** 2,6 **** # = bio/shell.rb - Loading all BioRuby shell features # ! # Copyright:: Copyright (C) 2005 # Toshiaki Katayama # License: Ruby's --- 2,6 ---- # = bio/shell.rb - Loading all BioRuby shell features # ! # Copyright:: Copyright (C) 2005, 2006 # Toshiaki Katayama # License: Ruby's *************** *** 18,21 **** --- 18,24 ---- require 'bio/shell/core' require 'bio/shell/interface' + require 'bio/shell/object' + require 'bio/shell/web' + require 'bio/shell/demo' require 'bio/shell/plugin/entry' require 'bio/shell/plugin/seq' From k at pub.open-bio.org Mon Feb 27 04:36:37 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:36:37 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell interface.rb,1.13,1.14 Message-ID: <200602270936.k1R9abVL001075@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv1071/lib/bio/shell Modified Files: interface.rb Log Message: * 'less' command is removed and merged into 'disp' command Index: interface.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/interface.rb,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** interface.rb 17 Feb 2006 17:11:59 -0000 1.13 --- interface.rb 27 Feb 2006 09:36:35 -0000 1.14 *************** *** 20,23 **** --- 20,24 ---- } puts list.inspect + return list end *************** *** 71,74 **** --- 72,77 ---- when :message, "message" Bio::Shell.config_message(*opts) + else + puts "Invalid mode (#{mode}) - :show, :echo, :color, :splash, :massage" end end *************** *** 82,86 **** def pager(cmd = nil) unless Bio::Shell.config[:pager] ! cmd = ENV['PAGER'] || cmd end Bio::Shell.config_pager(cmd) --- 85,89 ---- def pager(cmd = nil) unless Bio::Shell.config[:pager] ! cmd ||= ENV['PAGER'] end Bio::Shell.config_pager(cmd) *************** *** 88,99 **** end ! def disp(*obj) # The original idea is from http://sheepman.parfait.ne.jp/20050215.html ! if Bio::Shell.config[:pager] ! pg = IO.popen(Bio::Shell.config[:pager], "w") begin stdout_save = STDOUT.clone STDOUT.reopen(pg) ! puts(*obj) ensure STDOUT.reopen(stdout_save) --- 91,112 ---- end ! def disp(*objs) # The original idea is from http://sheepman.parfait.ne.jp/20050215.html ! if cmd = Bio::Shell.config[:pager] ! pg = IO.popen(cmd, "w") begin stdout_save = STDOUT.clone STDOUT.reopen(pg) ! objs.each do |obj| ! if obj.is_a?(String) ! if File.exists?(obj) ! system("#{cmd} #{obj}") ! else ! obj.display ! end ! else ! pp obj ! end ! end ensure STDOUT.reopen(stdout_save) *************** *** 102,115 **** end else ! # or use Object#display ? ! puts(*obj) end end - def less(file) - pager = Bio::Shell.config[:pager] || ENV['PAGER'] || "less" - system("#{pager} #{file}") - end - def head(arg, num = 10) str = "" --- 115,128 ---- end else ! objs.each do |obj| ! if obj.is_a?(String) ! obj.display ! else ! pp obj ! end ! end end end def head(arg, num = 10) str = "" *************** *** 136,145 **** def savefile(file, *objs) datadir = Bio::Shell.datadir ! message = "Save file '#{file}' in '#{datadir}' directory? [y/n]: " if ! file[/^#{datadir}/] and Bio::Shell.ask_yes_or_no(message) file = datadir + file end if File.exists?(file) ! message = "Overwrite existing '#{file}' file? [y/n]: " if ! Bio::Shell.ask_yes_or_no(message) puts " ... save aborted." --- 149,158 ---- def savefile(file, *objs) datadir = Bio::Shell.datadir ! message = "Save file '#{file}' in '#{datadir}' directory? [y/n] " if ! file[/^#{datadir}/] and Bio::Shell.ask_yes_or_no(message) file = datadir + file end if File.exists?(file) ! message = "Overwrite existing '#{file}' file? [y/n] " if ! Bio::Shell.ask_yes_or_no(message) puts " ... save aborted." From k at pub.open-bio.org Mon Feb 27 04:37:16 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:37:16 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin entry.rb,1.7,1.8 Message-ID: <200602270937.k1R9bGVL001123@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv1119/lib/bio/shell/plugin Modified Files: entry.rb Log Message: * added a tiny doc Index: entry.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/entry.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** entry.rb 14 Feb 2006 13:46:43 -0000 1.7 --- entry.rb 27 Feb 2006 09:37:14 -0000 1.8 *************** *** 86,89 **** --- 86,90 ---- end + # Obtain a parsed object from sources that ent() supports. def obj(arg) str = ent(arg) From nakao at pub.open-bio.org Mon Feb 27 04:40:15 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Mon, 27 Feb 2006 09:40:15 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/shell/plugin test_seq.rb, 1.6, 1.7 Message-ID: <200602270940.k1R9eFVL001208@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv1173/test/unit/bio/shell/plugin Modified Files: test_seq.rb Log Message: * Fixed Bio::Shell namespace for tesing.. Index: test_seq.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/shell/plugin/test_seq.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_seq.rb 21 Feb 2006 17:38:15 -0000 1.6 --- test_seq.rb 27 Feb 2006 09:40:13 -0000 1.7 *************** *** 2,22 **** # test/unit/bio/shell/plugin/test_seq.rb - Unit test for Bio::Shell plugin for biological sequence manipulations # ! # Copyright (C) 2005 Mitsuteru Nakao ! # ! # 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$ # --- 2,10 ---- # test/unit/bio/shell/plugin/test_seq.rb - Unit test for Bio::Shell plugin for biological sequence manipulations # ! # Copyright:: Copyright (C) 2005 ! # Mitsuteru Nakao ! # License:: Ruby's # ! # $Id$ # *************** *** 27,36 **** require 'test/unit' require 'bio/shell' module Bio class TestShellPluginSeq < Test::Unit::TestCase - # include Bio::Shell - # Bio::Shell.instance_variable_set :@config, {} def test_naseq --- 15,41 ---- require 'test/unit' require 'bio/shell' + require 'bio/shell/plugin/seq' module Bio + class TestShellPluginSeq < Test::Unit::TestCase + include Bio::Shell + + Bio::Shell.config = {:color => false} + + def test_htmlseq + str = 'ATGC' + html =< + a + t + g + c +
+ + END + assert_equal(html, htmlseq(str)) + end def test_naseq *************** *** 41,44 **** --- 46,50 ---- end + def test_aaseq str = 'WD' *************** *** 48,51 **** --- 54,58 ---- end + def test_na_seqstat naseq = 'atgcatgcatgc' *************** *** 113,116 **** --- 120,124 ---- end + def test_aa_seqstat aaseq = 'WD' *************** *** 139,142 **** --- 147,151 ---- end + def test_doublehelix seq = 'ACGTACGTACGTACGT' *************** *** 173,175 **** --- 182,185 ---- end + end From k at pub.open-bio.org Mon Feb 27 04:41:21 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:41:21 +0000 Subject: [BioRuby-cvs] bioruby/bin bioruby,1.13,1.14 Message-ID: <200602270941.k1R9fLVL001227@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv1204/bin Modified Files: bioruby Log Message: * history file with timestamp * rails server workaround (may not yet complete with open3) Index: bioruby =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/bioruby,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** bioruby 14 Feb 2006 13:18:35 -0000 1.13 --- bioruby 27 Feb 2006 09:41:19 -0000 1.14 *************** *** 16,26 **** end require 'bio/shell' include Bio::Shell ! ### Command line argument ! ! # working directory or script file if arg = ARGV.shift if File.directory?(arg) --- 16,28 ---- end + + ### BioRuby shell setup + require 'bio/shell' include Bio::Shell ! # command line argument (working directory or bioruby shell script file) ! script = nil if arg = ARGV.shift if File.directory?(arg) *************** *** 28,45 **** Dir.chdir(arg) elsif File.exists?(arg) ! # BioRuby shell script (lib/bioruby.rb can be obsolete) ! load arg ! exit elsif arg Dir.mkdir(arg) Dir.chdir(arg) end end - ### BioRuby shell setup - # loading configuration and plugins Bio::Shell.setup ### IRB setup --- 30,54 ---- Dir.chdir(arg) elsif File.exists?(arg) ! # BioRuby shell script (load script after the previous session is restored) ! dir = File.dirname(arg) ! script = File.basename(arg) ! Dir.chdir(dir) elsif arg Dir.mkdir(arg) Dir.chdir(arg) end + else + unless File.exists?(Bio::Shell.history) + message = "Are you sure to start new session in this directory? [y/n] " + unless Bio::Shell.ask_yes_or_no(message) + exit + end + end end # loading configuration and plugins Bio::Shell.setup + ### IRB setup *************** *** 84,88 **** #IRB.conf[:AUTO_INDENT] = true ! ### IRB main loop irb = IRB::Irb.new --- 93,98 ---- #IRB.conf[:AUTO_INDENT] = true ! ! ### Start IRB irb = IRB::Irb.new *************** *** 94,97 **** --- 104,140 ---- Bio::Shell.load_session + if script + # *TODO* - variables are seemed to exist, but couldn't access them ... + #eval("ls", irb.context.workspace.binding) + #eval("ls") + #eval("load '#{script}'", irb.context.workspace.binding) + #eval("load '#{script}'", IRB.conf[:MAIN_CONTEXT].workspace.binding) + #eval("load '#{script}'") + #eval("load '#{script}', true") + #eval("File.read('#{script}')", irb.context.workspace.binding) + #eval("File.read('#{script}')") + load script + exit + end + + Bio::Shell.create_save_dir + + $history_file = File.open(Bio::Shell.history, "a") + $history_file.sync = true + + # overwrite gets to store history with time stamp + io = IRB.conf[:MAIN_CONTEXT].io + + io.class.class_eval do + alias_method :irb_original_gets, :gets + end + + def io.gets + line = irb_original_gets + $history_file.puts "#{Time.now}\t#{line}" if line + line + end + + # main loop Signal.trap("SIGINT") do irb.signal_handle *************** *** 100,103 **** --- 143,157 ---- catch(:IRB_EXIT) do irb.eval_input + end + + $history_file.close if $history_file + + # shut down the rails server + if $web_server + $web_server.each do |io| + io.close + end + $web_access_log.close if $web_access_log + $web_error_log.close if $web_error_log end From k at pub.open-bio.org Mon Feb 27 04:41:56 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:41:56 +0000 Subject: [BioRuby-cvs] bioruby/bin bioruby,1.14,1.15 Message-ID: <200602270941.k1R9fuVL001254@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv1250/bin Modified Files: bioruby Log Message: * temporal cleanup Index: bioruby =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/bioruby,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** bioruby 27 Feb 2006 09:41:19 -0000 1.14 --- bioruby 27 Feb 2006 09:41:54 -0000 1.15 *************** *** 105,117 **** if script - # *TODO* - variables are seemed to exist, but couldn't access them ... - #eval("ls", irb.context.workspace.binding) - #eval("ls") - #eval("load '#{script}'", irb.context.workspace.binding) - #eval("load '#{script}'", IRB.conf[:MAIN_CONTEXT].workspace.binding) - #eval("load '#{script}'") - #eval("load '#{script}', true") - #eval("File.read('#{script}')", irb.context.workspace.binding) - #eval("File.read('#{script}')") load script exit --- 105,108 ---- From k at pub.open-bio.org Mon Feb 27 05:12:19 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:19 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails - New directory Message-ID: <200602271012.k1RACJVL001397@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails In directory pub.open-bio.org:/tmp/cvs-serv1393/lib/bio/shell/rails Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:29 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/log - New directory Message-ID: <200602271012.k1RACTVL001461@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/log In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/log Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/log added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:29 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public - New directory Message-ID: <200602271012.k1RACTVL001464@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/public Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:29 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/config - New directory Message-ID: <200602271012.k1RACTVL001449@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/config In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/config Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/config added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:29 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/lib - New directory Message-ID: <200602271012.k1RACTVL001458@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/lib Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:29 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/doc - New directory Message-ID: <200602271012.k1RACTVL001455@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/doc In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/doc Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/doc added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:30 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:30 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script - New directory Message-ID: <200602271012.k1RACUVL001467@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/script Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/script added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:46 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/lib/tasks - New directory Message-ID: <200602271012.k1RACkVL001542@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib/tasks In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/lib/tasks Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib/tasks added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:30 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:30 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/vendor - New directory Message-ID: <200602271012.k1RACUVL001473@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/vendor Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:48 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:48 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/unit - New directory Message-ID: <200602271012.k1RACmVL001571@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/unit In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/test/unit Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/unit added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:29 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/db - New directory Message-ID: <200602271012.k1RACTVL001452@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/db In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/db Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/db added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:47 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:47 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/stylesheets - New directory Message-ID: <200602271012.k1RAClVL001553@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/stylesheets In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/public/stylesheets Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/stylesheets added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:47 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:47 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/javascripts - New directory Message-ID: <200602271012.k1RAClVL001550@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/javascripts In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/public/javascripts Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/javascripts added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:46 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/helpers - New directory Message-ID: <200602271012.k1RACkVL001527@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/helpers In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/app/helpers Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/helpers added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:28 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:28 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app - New directory Message-ID: <200602271012.k1RACSVL001443@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/app Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:28 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:28 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/components - New directory Message-ID: <200602271012.k1RACSVL001446@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/components In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/components Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/components added to the repository From k at pub.open-bio.org Mon Feb 27 05:22:30 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:22:30 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails - New directory Message-ID: <200602271022.k1RAMUVL001703@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails In directory pub.open-bio.org:/tmp/cvs-serv1699/rails Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:04 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:04 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app - New directory Message-ID: <200602271023.k1RAN4VL001751@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app In directory pub.open-bio.org:/tmp/cvs-serv1726/app Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:04 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:04 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/controllers - New directory Message-ID: <200602271023.k1RAN4VL001760@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/controllers In directory pub.open-bio.org:/tmp/cvs-serv1726/app/controllers Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/controllers added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:05 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:05 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/views/layouts - New directory Message-ID: <200602271023.k1RAN5VL001778@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views/layouts In directory pub.open-bio.org:/tmp/cvs-serv1726/app/views/layouts Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views/layouts added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/db - New directory Message-ID: <200602271023.k1RAN6VL001806@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/db In directory pub.open-bio.org:/tmp/cvs-serv1726/db Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/db added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:05 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:05 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/views - New directory Message-ID: <200602271023.k1RAN5VL001773@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views In directory pub.open-bio.org:/tmp/cvs-serv1726/app/views Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:07 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:07 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/images - New directory Message-ID: <200602271023.k1RAN7VL001842@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/images In directory pub.open-bio.org:/tmp/cvs-serv1726/public/images Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/images added to the repository From k at pub.open-bio.org Mon Feb 27 08:24:31 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 13:24:31 +0000 Subject: [BioRuby-cvs] bioruby rdoc.zsh,NONE,1.1 Message-ID: <200602271324.k1RDOVVL003151@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv3147 Added Files: rdoc.zsh Log Message: * simple zsh script to generate rdoc --- NEW FILE: rdoc.zsh --- #!/usr/bin/env zsh #DIAGRAM='--diagram' WEBCVS='http://cvs.open-bio.org/cgi-bin/viewcvs/viewcvs.cgi' rdoc ${DIAGRAM} --op rdoc --inline-source \ --webcvs "${WEBCVS}/bioruby/\%s?cvsroot=bioruby" \ bin/*(.) lib/**/*.rb [A-Z]*(.) doc/*rd etc/bioinformatics/*(.) From k at pub.open-bio.org Mon Feb 27 05:23:09 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:09 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/unit - New directory Message-ID: <200602271023.k1RAN9VL001893@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/unit In directory pub.open-bio.org:/tmp/cvs-serv1726/test/unit Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/unit added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:10 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:10 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/vendor/plugins - New directory Message-ID: <200602271023.k1RANAVL001900@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins In directory pub.open-bio.org:/tmp/cvs-serv1726/vendor/plugins Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins added to the repository From k at pub.open-bio.org Mon Feb 27 08:22:07 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 13:22:07 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db rebase.rb,1.2,1.3 Message-ID: <200602271322.k1RDM7VL003034@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv3030/db Modified Files: rebase.rb Log Message: * autoload problem on YAML with Ruby 1.8.2 is fixed * RDoc is moved in the head Index: rebase.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/rebase.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rebase.rb 13 Dec 2005 15:02:41 -0000 1.2 --- rebase.rb 27 Feb 2006 13:22:05 -0000 1.3 *************** *** 1,7 **** - require 'bio/reference' - module Bio - # ! # bio/db/rebase.rb - Interface for EMBOSS formatted REBASE files # # Copyright:: Copyright (C) 2005 Trevor Wennblom --- 1,4 ---- # ! # = bio/db/rebase.rb - Interface for EMBOSS formatted REBASE files # # Copyright:: Copyright (C) 2005 Trevor Wennblom *************** *** 11,14 **** --- 8,98 ---- # # + # == Synopsis + # + # Bio::REBASE provides utilties for interacting with REBASE data in EMBOSS + # format. REBASE is the Restriction Enzyme Database, more information + # can be found here: + # + + # * http://rebase.neb.com + # + # EMBOSS formatted files located at: + # + # * http://rebase.neb.com/rebase/rebase.f37.html + # + # These files are the same as the "emboss_?.???" files located at: + # + # * ftp://ftp.neb.com/pub/rebase/ + # + # To easily get started with the data you can simply type this command + # at your shell prompt: + # + # % wget ftp://ftp.neb.com/pub/rebase/emboss* + # + # + # == Usage + # + # require 'bio/db/rebase' + # require 'pp' + # + # enz = File.read('emboss_e') + # ref = File.read('emboss_r') + # sup = File.read('emboss_s') + # + # # When creating a new instance of Bio::REBASE + # # the contents of the enzyme file must be passed. + # # The references and suppiers file contents + # # may also be passed. + # rebase = Bio::REBASE.new( enz ) + # rebase = Bio::REBASE.new( enz, ref ) + # rebase = Bio::REBASE.new( enz, ref, sup ) + # + # # The 'read' class method allows you to read in files + # # that are REBASE EMBOSS formatted + # rebase = Bio::REBASE.read( 'emboss_e' ) + # rebase = Bio::REBASE.read( 'emboss_e', 'emboss_r' ) + # rebase = Bio::REBASE.read( 'emboss_e', 'emboss_r', 'emboss_s' ) + # + # # The data loaded may be saved in YAML format + # rebase.save_yaml( 'enz.yaml' ) + # rebase.save_yaml( 'enz.yaml', 'ref.yaml' ) + # rebase.save_yaml( 'enz.yaml', 'ref.yaml', 'sup.yaml' ) + # + # # YAML formatted files can also be read with the + # # class method 'load_yaml' + # rebase = Bio::REBASE.load_yaml( 'enz.yaml' ) + # rebase = Bio::REBASE.load_yaml( 'enz.yaml', 'ref.yaml' ) + # rebase = Bio::REBASE.load_yaml( 'enz.yaml', 'ref.yaml', 'sup.yaml' ) + # + # pp rebase.enzymes[0..4] # ["AarI", "AasI", "AatI", "AatII", "Acc16I"] + # pp rebase['AarI'].pattern # "CACCTGC" + # pp rebase['AarI'].blunt? # false + # pp rebase['AarI'].organism # "Arthrobacter aurescens SS2-322" + # pp rebase['AarI'].source # "A. Janulaitis" + # pp rebase['AarI'].primary_strand_cut1 # 11 + # pp rebase['AarI'].primary_strand_cut2 # 0 + # pp rebase['AarI'].complementary_strand_cut1 # 15 + # pp rebase['AarI'].complementary_strand_cut2 # 0 + # pp rebase['AarI'].suppliers # ["F"] + # pp rebase['AarI'].supplier_names # ["Fermentas International Inc."] + # + # pp rebase['AarI'].isoschizomers # Currently none stored in the references file + # pp rebase['AarI'].methylation # "" + # + # pp rebase['EcoRII'].methylation # "2(5)" + # pp rebase['EcoRII'].suppliers # ["F", "J", "M", "O", "S"] + # pp rebase['EcoRII'].supplier_names # ["Fermentas International Inc.", "Nippon Gene Co., Ltd.", + # # "Roche Applied Science", "Toyobo Biochemicals", + # # "Sigma Chemical Corporation"] + # + # # Number of enzymes in the database + # pp rebase.size # 673 + # pp rebase.enzymes.size # 673 + # + # rebase.each do |name, info| + # pp "#{name}: #{info.methylation}" unless info.methylation.empty? + # end + # + # #-- # *************** *** 29,130 **** #++ # - # - - =begin rdoc - bio/db/rebase.rb - Interface for EMBOSS formatted REBASE files - - == Synopsis - - Bio::REBASE provides utilties for interacting with REBASE data in EMBOSS - format. REBASE is the Restriction Enzyme Database, more information - can be found here: - * http://rebase.neb.com - - EMBOSS formatted files located at: - * http://rebase.neb.com/rebase/rebase.f37.html - - These files are the same as the "emboss_?.???" files located at: - * ftp://ftp.neb.com/pub/rebase/ - - To easily get started with the data you can simply type this command at your shell prompt: - wget ftp://ftp.neb.com/pub/rebase/emboss* - - - == Usage - - require 'bio/db/rebase' - require 'pp' - - enz = File.read('emboss_e') - ref = File.read('emboss_r') - sup = File.read('emboss_s') - - # When creating a new instance of Bio::REBASE - # the contents of the enzyme file must be passed. - # The references and suppiers file contents - # may also be passed. - rebase = Bio::REBASE.new( enz ) - rebase = Bio::REBASE.new( enz, ref ) - rebase = Bio::REBASE.new( enz, ref, sup ) - - # The 'read' class method allows you to read in files - # that are REBASE EMBOSS formatted - rebase = Bio::REBASE.read( 'emboss_e' ) - rebase = Bio::REBASE.read( 'emboss_e', 'emboss_r' ) - rebase = Bio::REBASE.read( 'emboss_e', 'emboss_r', 'emboss_s' ) - - # The data loaded may be saved in YAML format - rebase.save_yaml( 'enz.yaml' ) - rebase.save_yaml( 'enz.yaml', 'ref.yaml' ) - rebase.save_yaml( 'enz.yaml', 'ref.yaml', 'sup.yaml' ) ! # YAML formatted files can also be read with the ! # class method 'load_yaml' ! rebase = Bio::REBASE.load_yaml( 'enz.yaml' ) ! rebase = Bio::REBASE.load_yaml( 'enz.yaml', 'ref.yaml' ) ! rebase = Bio::REBASE.load_yaml( 'enz.yaml', 'ref.yaml', 'sup.yaml' ) ! ! pp rebase.enzymes[0..4] # ["AarI", "AasI", "AatI", "AatII", "Acc16I"] ! pp rebase['AarI'].pattern # "CACCTGC" ! pp rebase['AarI'].blunt? # false ! pp rebase['AarI'].organism # "Arthrobacter aurescens SS2-322" ! pp rebase['AarI'].source # "A. Janulaitis" ! pp rebase['AarI'].primary_strand_cut1 # 11 ! pp rebase['AarI'].primary_strand_cut2 # 0 ! pp rebase['AarI'].complementary_strand_cut1 # 15 ! pp rebase['AarI'].complementary_strand_cut2 # 0 ! pp rebase['AarI'].suppliers # ["F"] ! pp rebase['AarI'].supplier_names # ["Fermentas International Inc."] ! ! pp rebase['AarI'].isoschizomers # Currently none stored in the references file ! pp rebase['AarI'].methylation # "" ! ! pp rebase['EcoRII'].methylation # "2(5)" ! pp rebase['EcoRII'].suppliers # ["F", "J", "M", "O", "S"] ! pp rebase['EcoRII'].supplier_names # ["Fermentas International Inc.", "Nippon Gene Co., Ltd.", ! # "Roche Applied Science", "Toyobo Biochemicals", ! # "Sigma Chemical Corporation"] ! ! # Number of enzymes in the database ! pp rebase.size # 673 ! pp rebase.enzymes.size # 673 ! ! rebase.each do |name, info| ! pp "#{name}: #{info.methylation}" unless info.methylation.empty? ! end ! ! ! == Author ! Trevor Wennblom ! == Copyright ! Copyright (C) 2005 Trevor Wennblom ! Licensed under the same terms as BioRuby. - =end class REBASE - autoload(:YAML, 'yaml') class DynamicMethod_Hash < Hash --- 113,125 ---- #++ # ! autoload :YAML, 'yaml' + module Bio ! autoload :Reference, 'reference' class REBASE class DynamicMethod_Hash < Hash *************** *** 415,417 **** --- 410,413 ---- end # REBASE + end # Bio From k at pub.open-bio.org Mon Feb 27 08:03:16 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 13:03:16 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util contingency_table.rb,1.2,1.3 Message-ID: <200602271303.k1RD3GVL002935@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util In directory pub.open-bio.org:/tmp/cvs-serv2931 Modified Files: contingency_table.rb Log Message: * RDoc is moved in the head and folded for readability Index: contingency_table.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/contingency_table.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** contingency_table.rb 13 Dec 2005 14:58:37 -0000 1.2 --- contingency_table.rb 27 Feb 2006 13:03:14 -0000 1.3 *************** *** 1,6 **** - module Bio # ! # bio/util/contingency_table.rb - Statistical contingency table analysis for aligned sequences # # Copyright:: Copyright (C) 2005 Trevor Wennblom --- 1,5 ---- # ! # = bio/util/contingency_table.rb - Statistical contingency table analysis for aligned sequences # # Copyright:: Copyright (C) 2005 Trevor Wennblom *************** *** 9,13 **** # $Id$ # ! # #-- # --- 8,236 ---- # $Id$ # ! # == Synopsis ! # ! # The Bio::ContingencyTable class provides basic statistical contingency table ! # analysis for two positions within aligned sequences. ! # ! # When ContingencyTable is instantiated the set of characters in the ! # aligned sequences may be passed to it as an array. This is ! # important since it uses these characters to create the table's rows ! # and columns. If this array is not passed it will use it's default ! # of an amino acid and nucleotide alphabet in lowercase along with the ! # clustal spacer '-'. ! # ! # To get data from the table the most used functions will be ! # chi_square and contingency_coefficient: ! # ! # ctable = Bio::ContingencyTable.new() ! # ctable['a']['t'] += 1 ! # # .. put more values into the table ! # puts ctable.chi_square ! # puts ctable.contingency_coefficient # between 0.0 and 1.0 ! # ! # The contingency_coefficient represents the degree of correlation of ! # change between two sequence positions in a multiple-sequence ! # alignment. 0.0 indicates no correlation, 1.0 is the maximum ! # correlation. ! # ! # ! # == Further Reading ! # ! # * http://en.wikipedia.org/wiki/Contingency_table ! # * http://www.physics.csbsju.edu/stats/exact.details.html ! # * Numerical Recipes in C by Press, Flannery, Teukolsky, and Vetterling ! # # ! # == Usage ! # ! # What follows is an example of ContingencyTable in typical usage ! # analyzing results from a clustal alignment. ! # ! # require 'bio' ! # require 'bio/contingency_table' ! # ! # seqs = {} ! # max_length = 0 ! # Bio::ClustalW::Report.new( IO.read('sample.aln') ).to_a.each do |entry| ! # data = entry.data.strip ! # seqs[entry.definition] = data.downcase ! # max_length = data.size if max_length == 0 ! # raise "Aligned sequences must be the same length!" unless data.size == max_length ! # end ! # ! # VERBOSE = true ! # puts "i\tj\tchi_square\tcontingency_coefficient" if VERBOSE ! # correlations = {} ! # ! # 0.upto(max_length - 1) do |i| ! # (i+1).upto(max_length - 1) do |j| ! # ctable = Bio::ContingencyTable.new() ! # seqs.each_value { |seq| ctable.table[ seq[i].chr ][ seq[j].chr ] += 1 } ! # ! # chi_square = ctable.chi_square ! # contingency_coefficient = ctable.contingency_coefficient ! # puts [(i+1), (j+1), chi_square, contingency_coefficient].join("\t") if VERBOSE ! # ! # correlations["#{i+1},#{j+1}"] = contingency_coefficient ! # correlations["#{j+1},#{i+1}"] = contingency_coefficient # Both ways are accurate ! # end ! # end ! # ! # require 'yaml' ! # File.new('results.yml', 'a+') { |f| f.puts correlations.to_yaml } ! # ! # ! # == Tutorial ! # ! ! # ContingencyTable returns the statistical significance of change ! # between two positions in an alignment. If you would like to see how ! # every possible combination of positions in your alignment compares ! # to one another you must set this up yourself. Hopefully the ! # provided examples will help you get started without too much ! # trouble. ! # ! # def lite_example(sequences, max_length, characters) ! # ! # %w{i j chi_square contingency_coefficient}.each { |x| print x.ljust(12) } ! # puts ! # ! # 0.upto(max_length - 1) do |i| ! # (i+1).upto(max_length - 1) do |j| ! # ctable = Bio::ContingencyTable.new( characters ) ! # sequences.each do |seq| ! # i_char = seq[i].chr ! # j_char = seq[j].chr ! # ctable.table[i_char][j_char] += 1 ! # end ! # chi_square = ctable.chi_square ! # contingency_coefficient = ctable.contingency_coefficient ! # [(i+1), (j+1), chi_square, contingency_coefficient].each { |x| print x.to_s.ljust(12) } ! # puts ! # end ! # end ! # ! # end ! # ! # allowed_letters = Array.new ! # allowed_letters = 'abcdefghijk'.split('') ! # ! # seqs = Array.new ! # seqs << 'abcde' ! # seqs << 'abcde' ! # seqs << 'aacje' ! # seqs << 'aacae' ! # ! # length_of_every_sequence = seqs[0].size # 5 letters long ! # ! # lite_example(seqs, length_of_every_sequence, allowed_letters) ! # ! # ! # Producing the following results: ! # ! # i j chi_square contingency_coefficient ! # 1 2 0.0 0.0 ! # 1 3 0.0 0.0 ! # 1 4 0.0 0.0 ! # 1 5 0.0 0.0 ! # 2 3 0.0 0.0 ! # 2 4 4.0 0.707106781186548 ! # 2 5 0.0 0.0 ! # 3 4 0.0 0.0 ! # 3 5 0.0 0.0 ! # 4 5 0.0 0.0 ! # ! # The position i=2 and j=4 has a high contingency coefficient ! # indicating that the changes at these positions are related. Note ! # that i and j are arbitrary, this could be represented as i=4 and j=2 ! # since they both refer to position two and position four in the ! # alignment. Here are some more examples: ! # ! # seqs = Array.new ! # seqs << 'abcde' ! # seqs << 'abcde' ! # seqs << 'aacje' ! # seqs << 'aacae' ! # seqs << 'akcfe' ! # seqs << 'akcfe' ! # ! # length_of_every_sequence = seqs[0].size # 5 letters long ! # ! # lite_example(seqs, length_of_every_sequence, allowed_letters) ! # ! # ! # Results: ! # ! # i j chi_square contingency_coefficient ! # 1 2 0.0 0.0 ! # 1 3 0.0 0.0 ! # 1 4 0.0 0.0 ! # 1 5 0.0 0.0 ! # 2 3 0.0 0.0 ! # 2 4 12.0 0.816496580927726 ! # 2 5 0.0 0.0 ! # 3 4 0.0 0.0 ! # 3 5 0.0 0.0 ! # 4 5 0.0 0.0 ! # ! # Here we can see that the strength of the correlation of change has ! # increased when more data is added with correlated changes at the ! # same positions. ! # ! # seqs = Array.new ! # seqs << 'abcde' ! # seqs << 'abcde' ! # seqs << 'kacje' # changed first letter ! # seqs << 'aacae' ! # seqs << 'akcfa' # changed last letter ! # seqs << 'akcfe' ! # ! # length_of_every_sequence = seqs[0].size # 5 letters long ! # ! # lite_example(seqs, length_of_every_sequence, allowed_letters) ! # ! # ! # Results: ! # ! # i j chi_square contingency_coefficient ! # 1 2 2.4 0.534522483824849 ! # 1 3 0.0 0.0 ! # 1 4 6.0 0.707106781186548 ! # 1 5 0.24 0.196116135138184 ! # 2 3 0.0 0.0 ! # 2 4 12.0 0.816496580927726 ! # 2 5 2.4 0.534522483824849 ! # 3 4 0.0 0.0 ! # 3 5 0.0 0.0 ! # 4 5 2.4 0.534522483824849 ! # ! # With random changes it becomes more difficult to identify correlated ! # changes, yet positions two and four still have the highest ! # correlation as indicated by the contingency coefficient. The best ! # way to improve the accuracy of your results, as is often the case ! # with statistics, is to increase the sample size. ! # ! # ! # == A Note on Efficiency ! # ! ! # ContingencyTable is slow. It involves many calculations for even a ! # seemingly small five-string data set. Even worse, it's very ! # dependent on matrix traversal, and this is done with two dimensional ! # hashes which dashes any hope of decent speed. ! # ! ! # Finally, half of the matrix is redundant and positions could be ! # summed with their companion position to reduce calculations. For ! # example the positions (5,2) and (2,5) could both have their values ! # added together and just stored in (2,5) while (5,2) could be an ! # illegal position. Also, positions (1,1), (2,2), (3,3), etc. will ! # never be used. ! # ! # The purpose of this package is flexibility and education. The code ! # is short and to the point in aims of achieving that purpose. If the ! # BioRuby project moves towards C extensions in the future a ! # professional caliber version will likely be created. ! # ! # #-- # *************** *** 30,252 **** # ! =begin rdoc ! bio/util/contingency_table.rb - Statistical contingency table analysis for aligned sequences ! ! == Synopsis ! ! The Bio::ContingencyTable class provides basic statistical contingency table ! analysis for two positions within aligned sequences. ! ! When ContingencyTable is instantiated the set of characters in the aligned sequences may be ! passed to it as an array. This is important since it uses these characters ! to create the table's rows and columns. If this array is not passed it will ! use it's default of an amino acid and nucleotide alphabet in lowercase along with the ! clustal spacer '-'. ! ! To get data from the table the most used functions will be chi_square and contingency_coefficient: ! ctable = Bio::ContingencyTable.new() ! ctable['a']['t'] += 1 ! # .. put more values into the table ! puts ctable.chi_square ! puts ctable.contingency_coefficient # between 0.0 and 1.0 ! ! The contingency_coefficient represents the degree of correlation of change between two ! sequence positions in a multiple-sequence alignment. 0.0 indicates no correlation, 1.0 is the ! maximum correlation. ! ! ! == Further Reading ! ! * http://en.wikipedia.org/wiki/Contingency_table ! * http://www.physics.csbsju.edu/stats/exact.details.html ! * Numerical Recipes in C by Press, Flannery, Teukolsky, and Vetterling ! ! ! == Usage ! ! What follows is an example of ContingencyTable in typical usage analyzing results from a clustal alignment. ! ! require 'bio' ! require 'bio/contingency_table' ! ! seqs = {} ! max_length = 0 ! Bio::ClustalW::Report.new( IO.read('sample.aln') ).to_a.each do |entry| ! data = entry.data.strip ! seqs[entry.definition] = data.downcase ! max_length = data.size if max_length == 0 ! raise "Aligned sequences must be the same length!" unless data.size == max_length ! end ! ! VERBOSE = true ! puts "i\tj\tchi_square\tcontingency_coefficient" if VERBOSE ! correlations = {} ! ! 0.upto(max_length - 1) do |i| ! (i+1).upto(max_length - 1) do |j| ! ctable = Bio::ContingencyTable.new() ! seqs.each_value { |seq| ctable.table[ seq[i].chr ][ seq[j].chr ] += 1 } ! ! chi_square = ctable.chi_square ! contingency_coefficient = ctable.contingency_coefficient ! puts [(i+1), (j+1), chi_square, contingency_coefficient].join("\t") if VERBOSE ! ! correlations["#{i+1},#{j+1}"] = contingency_coefficient ! correlations["#{j+1},#{i+1}"] = contingency_coefficient # Both ways are accurate ! end ! end ! ! require 'yaml' ! File.new('results.yml', 'a+') { |f| f.puts correlations.to_yaml } ! ! ! == Tutorial ! ! ContingencyTable returns the statistical significance of change between two positions in an alignment. ! If you would like to see how every possible combination of positions in your alignment compares to one another ! you must set this up yourself. Hopefully the provided examples will help you get started without ! too much trouble. ! ! def lite_example(sequences, max_length, characters) ! ! %w{i j chi_square contingency_coefficient}.each { |x| print x.ljust(12) } ! puts ! ! 0.upto(max_length - 1) do |i| ! (i+1).upto(max_length - 1) do |j| ! ctable = Bio::ContingencyTable.new( characters ) ! sequences.each do |seq| ! i_char = seq[i].chr ! j_char = seq[j].chr ! ctable.table[i_char][j_char] += 1 ! end ! chi_square = ctable.chi_square ! contingency_coefficient = ctable.contingency_coefficient ! [(i+1), (j+1), chi_square, contingency_coefficient].each { |x| print x.to_s.ljust(12) } ! puts ! end ! end ! ! end ! ! allowed_letters = Array.new ! allowed_letters = 'abcdefghijk'.split('') ! ! seqs = Array.new ! seqs << 'abcde' ! seqs << 'abcde' ! seqs << 'aacje' ! seqs << 'aacae' ! ! length_of_every_sequence = seqs[0].size # 5 letters long ! ! lite_example(seqs, length_of_every_sequence, allowed_letters) ! ! ! Producing the following results: ! ! i j chi_square contingency_coefficient ! 1 2 0.0 0.0 ! 1 3 0.0 0.0 ! 1 4 0.0 0.0 ! 1 5 0.0 0.0 ! 2 3 0.0 0.0 ! 2 4 4.0 0.707106781186548 ! 2 5 0.0 0.0 ! 3 4 0.0 0.0 ! 3 5 0.0 0.0 ! 4 5 0.0 0.0 ! ! The position i=2 and j=4 has a high contingency coefficient indicating that the changes at these ! positions are related. Note that i and j are arbitrary, this could be represented as i=4 and j=2 ! since they both refer to position two and position four in the alignment. Here are some more examples: ! ! seqs = Array.new ! seqs << 'abcde' ! seqs << 'abcde' ! seqs << 'aacje' ! seqs << 'aacae' ! seqs << 'akcfe' ! seqs << 'akcfe' ! ! length_of_every_sequence = seqs[0].size # 5 letters long ! ! lite_example(seqs, length_of_every_sequence, allowed_letters) ! ! ! Results: ! ! i j chi_square contingency_coefficient ! 1 2 0.0 0.0 ! 1 3 0.0 0.0 ! 1 4 0.0 0.0 ! 1 5 0.0 0.0 ! 2 3 0.0 0.0 ! 2 4 12.0 0.816496580927726 ! 2 5 0.0 0.0 ! 3 4 0.0 0.0 ! 3 5 0.0 0.0 ! 4 5 0.0 0.0 ! ! Here we can see that the strength of the correlation of change has increased when more data is added with correlated changes at the same positions. ! ! seqs = Array.new ! seqs << 'abcde' ! seqs << 'abcde' ! seqs << 'kacje' # changed first letter ! seqs << 'aacae' ! seqs << 'akcfa' # changed last letter ! seqs << 'akcfe' ! ! length_of_every_sequence = seqs[0].size # 5 letters long ! ! lite_example(seqs, length_of_every_sequence, allowed_letters) ! ! ! Results: ! ! i j chi_square contingency_coefficient ! 1 2 2.4 0.534522483824849 ! 1 3 0.0 0.0 ! 1 4 6.0 0.707106781186548 ! 1 5 0.24 0.196116135138184 ! 2 3 0.0 0.0 ! 2 4 12.0 0.816496580927726 ! 2 5 2.4 0.534522483824849 ! 3 4 0.0 0.0 ! 3 5 0.0 0.0 ! 4 5 2.4 0.534522483824849 ! ! With random changes it becomes more difficult to identify correlated changes, yet positions two ! and four still have the highest correlation as indicated by the contingency coefficient. The ! best way to improve the accuracy of your results, as is often the case with statistics, is to ! increase the sample size. ! ! ! == A Note on Efficiency ! ! ContingencyTable is slow. It involves many calculations for even a seemingly small five-string data set. ! Even worse, it's very dependent on matrix traversal, and this is done with two dimensional hashes which ! dashes any hope of decent speed. ! ! Finally, half of the matrix is redundant and positions could be summed with their companion position to reduce ! calculations. For example the positions (5,2) and (2,5) could both have their values added together and ! just stored in (2,5) while (5,2) could be an illegal position. Also, positions (1,1), (2,2), (3,3), etc. ! will never be used. ! ! The purpose of this package is flexibility and education. The code is short and to the point in ! aims of achieving that purpose. If the BioRuby project moves towards C extensions in the future a ! professional caliber version will likely be created. ! ! ! == Author ! Trevor Wennblom ! ! ! == Copyright ! Copyright (C) 2005 Trevor Wennblom ! Licensed under the same terms as BioRuby. ! ! =end class ContingencyTable --- 253,257 ---- # ! module Bio class ContingencyTable From k at pub.open-bio.org Mon Feb 27 08:23:03 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 13:23:03 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util contingency_table.rb,1.3,1.4 Message-ID: <200602271323.k1RDN3VL003103@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util In directory pub.open-bio.org:/tmp/cvs-serv3099/util Modified Files: contingency_table.rb Log Message: * tiny clenaup Index: contingency_table.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/contingency_table.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** contingency_table.rb 27 Feb 2006 13:03:14 -0000 1.3 --- contingency_table.rb 27 Feb 2006 13:23:01 -0000 1.4 *************** *** 1,3 **** - # # = bio/util/contingency_table.rb - Statistical contingency table analysis for aligned sequences --- 1,2 ---- *************** *** 340,342 **** end ! end --- 339,343 ---- end ! ! end # Bio ! From k at pub.open-bio.org Mon Feb 27 08:11:30 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 13:11:30 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util restriction_enzyme.rb,1.2,1.3 Message-ID: <200602271311.k1RDBUVL002969@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util In directory pub.open-bio.org:/tmp/cvs-serv2965 Modified Files: restriction_enzyme.rb Log Message: * RDoc is moved in the header and folded for readability * The data file enzymes.yaml should not be included in the library so self.rebase method is modified to require yaml file to be loaded. Index: restriction_enzyme.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** restriction_enzyme.rb 18 Feb 2006 22:00:55 -0000 1.2 --- restriction_enzyme.rb 27 Feb 2006 13:11:28 -0000 1.3 *************** *** 1,18 **** - require 'pathname' - libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3, 'lib')).cleanpath.to_s - $:.unshift(libpath) unless $:.include?(libpath) - - require 'bio' - require 'bio/db/rebase' - require 'bio/util/restriction_enzyme/double_stranded' - require 'bio/util/restriction_enzyme/single_strand' - require 'bio/util/restriction_enzyme/cut_symbol' - require 'bio/util/restriction_enzyme/analysis' - - - module Bio; end - # ! # bio/util/restriction_enzyme.rb - Digests DNA based on restriction enzyme cut patterns # # Copyright:: Copyright (C) 2006 Trevor Wennblom --- 1,4 ---- # ! # = bio/util/restriction_enzyme.rb - Digests DNA based on restriction enzyme cut patterns # # Copyright:: Copyright (C) 2006 Trevor Wennblom *************** *** 22,25 **** --- 8,174 ---- # # + # NOTE: This documentation and the module are still very much under + # development. It has been released as it is relatively stable and + # comments would be appreciated. + # + # == Synopsis + # + # Bio::RestrictionEnzyme allows you to fragment a DNA strand using one + # or more restriction enzymes. Bio::RestrictionEnzyme is aware that + # multiple enzymes may be competing for the same recognition site and + # returns the various possible fragmentation patterns that result in + # such circumstances. + # + + # Using Bio::RestrictionEnzyme you may simply use the name of common + # enzymes to cut with or you may construct your own unique enzymes to use. + # + # + # == Basic Usage + # + # # EcoRI cut pattern: + # # G|A A T T C + # # +-------+ + # # C T T A A|G + # # + # # This can also be written as: + # # G^AATTC + # + # require 'bio/restriction_enzyme' + # require 'pp' + # + # seq = Bio::Sequence::NA.new('gaattc') + # cuts = seq.cut_with_enzyme('EcoRI') + # p cuts.primary # ["aattc", "g"] + # p cuts.complement # ["g", "cttaa"] + # pp cuts # ==> + # # [#, + # # #] + # + # seq = Bio::Sequence::NA.new('gaattc') + # cuts = seq.cut_with_enzyme('g^aattc') + # p cuts.primary # ["aattc", "g"] + # p cuts.complement # ["g", "cttaa"] + # + # seq = Bio::Sequence::NA.new('gaattc') + # cuts = seq.cut_with_enzyme('g^aattc', 'gaatt^c') + # p cuts.primary # ["c", "aattc", "g", "gaatt"] + # p cuts.complement # ["g", "c", "cttaa", "ttaag"] + # + # seq = Bio::Sequence::NA.new('gaattcgaattc') + # cuts = seq.cut_with_enzyme('EcoRI') + # p cuts.primary # ["aattc", "aattcg", "g"] + # p cuts.complement # ["g", "gcttaa", "cttaa"] + # + # seq = Bio::Sequence::NA.new('gaattcgggaattc') + # cuts = seq.cut_with_enzyme('EcoRI') + # p cuts.primary # ["aattc", "aattcggg", "g"] + # p cuts.complement # ["g", "gcccttaa", "cttaa"] + # + # + # == Advanced Usage + # + # require 'bio/restriction_enzyme' + # require 'pp' + # enzyme_1 = Bio::RestrictionEnzyme.new('anna', [1,1], [3,3]) + # enzyme_2 = Bio::RestrictionEnzyme.new('gg', [1,1]) + # a = Bio::RestrictionEnzyme::Analysis.cut('agga', enzyme_1, enzyme_2) + # p a.primary # ["a", "ag", "g", "ga"] + # + # b = Bio::RestrictionEnzyme::Analysis.cut_and_return_by_permutations('agga', enzyme_1, enzyme_2) + # pp b + # + # + # Output (NOTE: to be cleaned): + # + # {[1, 0]=> + # #, + # #], + # @__fragments_current=true, + # @c_left=3, + # @c_right=3, + # @cut_ranges= + # [#], + # @left=0, + # @p_left=0, + # @p_right=0, + # @right=3, + # @size=4, + # @tags={}>, + # [0, 1]=> + # #, + # #, + # #, + # #], + # @__fragments_current=true, + # @c_left=3, + # @c_right=3, + # @cut_ranges= + # [#, + # #, + # #], + # @left=0, + # @p_left=0, + # @p_right=0, + # @right=3, + # @size=4, + # @tags={}>} + # + # + # == Todo + # + # Currently under development: + # + # * Optimizations in restriction_enzyme/analysis.rb to cut down on + # factorial growth of computation space. + # * Circular DNA cutting + # * Tagging of sequence data + # * Much more documentation + # + # #-- # *************** *** 42,215 **** # - =begin rdoc ! bio/util/restriction_enzyme.rb - Digests DNA based on restriction enzyme cut patterns ! ! NOTE: This documentation and the module are still very much under development. ! It has been released as it is relatively stable and comments would be appreciated. ! ! == Synopsis ! ! Bio::RestrictionEnzyme allows you to fragment a DNA strand using one or ! more restriction enzymes. Bio::RestrictionEnzyme is aware that multiple enzymes may ! be competing for the same recognition site and returns the various possible ! fragmentation patterns that result in such circumstances. ! ! Using Bio::RestrictionEnzyme you may simply use the name of common enzymes to ! cut with or you may construct your own unique enzymes to use. ! ! ! == Basic Usage ! ! # EcoRI cut pattern: ! # G|A A T T C ! # +-------+ ! # C T T A A|G ! # ! # This can also be written as: ! # G^AATTC ! ! require 'bio/restriction_enzyme' ! require 'pp' ! ! seq = Bio::Sequence::NA.new('gaattc') ! cuts = seq.cut_with_enzyme('EcoRI') ! p cuts.primary # ["aattc", "g"] ! p cuts.complement # ["g", "cttaa"] ! pp cuts # ==> ! # [#, ! # #] ! ! seq = Bio::Sequence::NA.new('gaattc') ! cuts = seq.cut_with_enzyme('g^aattc') ! p cuts.primary # ["aattc", "g"] ! p cuts.complement # ["g", "cttaa"] ! ! seq = Bio::Sequence::NA.new('gaattc') ! cuts = seq.cut_with_enzyme('g^aattc', 'gaatt^c') ! p cuts.primary # ["c", "aattc", "g", "gaatt"] ! p cuts.complement # ["g", "c", "cttaa", "ttaag"] ! ! seq = Bio::Sequence::NA.new('gaattcgaattc') ! cuts = seq.cut_with_enzyme('EcoRI') ! p cuts.primary # ["aattc", "aattcg", "g"] ! p cuts.complement # ["g", "gcttaa", "cttaa"] ! ! seq = Bio::Sequence::NA.new('gaattcgggaattc') ! cuts = seq.cut_with_enzyme('EcoRI') ! p cuts.primary # ["aattc", "aattcggg", "g"] ! p cuts.complement # ["g", "gcccttaa", "cttaa"] ! ! ! == Advanced Usage ! ! require 'bio/restriction_enzyme' ! require 'pp' ! enzyme_1 = Bio::RestrictionEnzyme.new('anna', [1,1], [3,3]) ! enzyme_2 = Bio::RestrictionEnzyme.new('gg', [1,1]) ! a = Bio::RestrictionEnzyme::Analysis.cut('agga', enzyme_1, enzyme_2) ! p a.primary # ["a", "ag", "g", "ga"] ! ! b = Bio::RestrictionEnzyme::Analysis.cut_and_return_by_permutations('agga', enzyme_1, enzyme_2) ! pp b ! ! ! Output (NOTE: to be cleaned): ! ! {[1, 0]=> ! #, ! #], ! @__fragments_current=true, ! @c_left=3, ! @c_right=3, ! @cut_ranges= ! [#], ! @left=0, ! @p_left=0, ! @p_right=0, ! @right=3, ! @size=4, ! @tags={}>, ! [0, 1]=> ! #, ! #, ! #, ! #], ! @__fragments_current=true, ! @c_left=3, ! @c_right=3, ! @cut_ranges= ! [#, ! #, ! #], ! @left=0, ! @p_left=0, ! @p_right=0, ! @right=3, ! @size=4, ! @tags={}>} ! ! ! == Todo ! Currently under development: ! * Optimizations in restriction_enzyme/analysis.rb to cut down on factorial growth of computation space. ! * Circular DNA cutting ! * Tagging of sequence data ! * Much more documentation ! ! ! == Author ! Trevor Wennblom ! == Copyright ! Copyright (C) 2006 Trevor Wennblom ! Licensed under the same terms as BioRuby. - =end class Bio::RestrictionEnzyme include CutSymbol --- 191,204 ---- # ! require 'bio/db/rebase' ! require 'bio/util/restriction_enzyme/double_stranded' ! require 'bio/util/restriction_enzyme/single_strand' ! require 'bio/util/restriction_enzyme/cut_symbol' ! require 'bio/util/restriction_enzyme/analysis' ! module Bio class Bio::RestrictionEnzyme include CutSymbol *************** *** 225,234 **** # Returns a Bio::REBASE object loaded with all of the enzyme data on file. # ! def self.rebase ! ! # NOTE open for debate ... maybe this should be stored somewhere else in bioruby? ! data_file_location = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3, 'lib')).cleanpath.to_s + '/bio/util/restriction_enzyme/enzymes.yaml' ! ! @@rebase_enzymes ||= Bio::REBASE.load_yaml( data_file_location ) @@rebase_enzymes end --- 214,219 ---- # Returns a Bio::REBASE object loaded with all of the enzyme data on file. # ! def self.rebase(enzymes_yaml) ! @@rebase_enzymes ||= Bio::REBASE.load_yaml(enzymes_yaml) @@rebase_enzymes end *************** *** 253,254 **** --- 238,241 ---- end + + end # Bio From k at pub.open-bio.org Mon Feb 27 07:55:02 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 12:55:02 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme README, 1.1, NONE Message-ID: <200602271255.k1RCt2VL002892@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv2886/restriction_enzyme Removed Files: README Log Message: * document should go under bioruby-x.x.x/doc/ directory (may be in the Tutorial.rd) --- README DELETED --- From k at pub.open-bio.org Mon Feb 27 07:28:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 12:28:06 +0000 Subject: [BioRuby-cvs] bioruby README,1.13,1.14 Message-ID: <200602271228.k1RCS6VL002726@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv2722 Modified Files: README Log Message: * recommendation of Ruby 1.8.4 or later is added Index: README =================================================================== RCS file: /home/repository/bioruby/bioruby/README,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** README 4 Feb 2006 19:17:16 -0000 1.13 --- README 27 Feb 2006 12:28:03 -0000 1.14 *************** *** 69,73 **** * Ruby 1.8.2 or later -- (()) ! == OPTIONAL REQUIREMENTS --- 69,73 ---- * Ruby 1.8.2 or later -- (()) ! (Ruby 1.8.4 or later is recommended) == OPTIONAL REQUIREMENTS From k at pub.open-bio.org Mon Feb 27 07:13:56 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 12:13:56 +0000 Subject: [BioRuby-cvs] bioruby gemspec.rb,1.6,1.7 Message-ID: <200602271213.k1RCDuVL002659@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv2655 Modified Files: gemspec.rb Log Message: * prepared for 1.0.0 release Index: gemspec.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/gemspec.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** gemspec.rb 24 Jan 2006 11:42:17 -0000 1.6 --- gemspec.rb 27 Feb 2006 12:13:54 -0000 1.7 *************** *** 4,8 **** spec = Gem::Specification.new do |s| s.name = 'bio' ! s.version = "0.7.1" s.author = "BioRuby project" --- 4,8 ---- spec = Gem::Specification.new do |s| s.name = 'bio' ! s.version = "1.0.0" s.author = "BioRuby project" From k at pub.open-bio.org Mon Feb 27 06:38:16 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:38:16 +0000 Subject: [BioRuby-cvs] bioruby ChangeLog,1.49,1.50 Message-ID: <200602271138.k1RBcGVL002462@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv2456 Modified Files: ChangeLog Log Message: * prepared for 1.0.0 release Index: ChangeLog =================================================================== RCS file: /home/repository/bioruby/bioruby/ChangeLog,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** ChangeLog 1 Feb 2006 07:30:19 -0000 1.49 --- ChangeLog 27 Feb 2006 11:38:14 -0000 1.50 *************** *** 1,18 **** ! 2005-02-01 Trevor Wennblom ! * Bio::RestrictionEnzyme first commit for comments. * See lib/bio/util/restriction_enzyme.rb and ! test/unit/bio/util/restriction_enzyme ! 2005-01-20 Toshiaki Katayama * BioRuby 0.7.1 is released. ! 2005-01-12 Toshiaki Katayama * lib/bio/db.ra: fixed a bug of the tag_cut method introduced in 0.7.0 (reported by Alex Gutteridge) ! 2005-01-04 Naohisa Goto * Bio::PDB is refactored. See doc/Changes-0.7 for more details. --- 1,51 ---- ! 2006-02-27 Toshiaki Katayama ! * BioRuby 1.0.0 released ! ! 2006-02-10 Toshiaki Katayama ! ! * BioRuby shell is changed to use session/ directory under the current ! or specified directory to store the session information instead of ! ./.bioruby directory. ! ! 2006-02-05 Toshiaki Katayama ! ! * License to be changed to Ruby's (not yet completed). ! ! 2006-02-01 Trevor Wennblom ! ! * Bio::RestrictionEnzyme first commit for comments. * See lib/bio/util/restriction_enzyme.rb and ! test/unit/bio/util/restriction_enzyme ! 2006-01-28 Toshiaki Katayama ! ! * lib/bio/appl/emboss.rb ! ! EMBOSS USA format is now accepted via seqret/entret commands ! and also utilized in the BioRuby shell (lib/bio/shell.rb, ! plugin/entry.rb, plugin/emboss.rb). ! ! * lib/bio/io/brdb.rb is removed - unused Bio::BRDB (BioRuby DB) ! ! 2006-01-23 Toshiaki Katayama ! ! * lib/bio/sequence.rb ! ! Bio::Sequence is refactored to be a container class for ! any sequence annotations. Functionality is separared into ! several files under the lib/bio/sequence/ direcotry as ! common.rb, compat.rb, aa.rb, na.rb, format.rb ! ! 2006-01-20 Toshiaki Katayama * BioRuby 0.7.1 is released. ! 2006-01-12 Toshiaki Katayama * lib/bio/db.ra: fixed a bug of the tag_cut method introduced in 0.7.0 (reported by Alex Gutteridge) ! 2006-01-04 Naohisa Goto * Bio::PDB is refactored. See doc/Changes-0.7 for more details. From k at pub.open-bio.org Mon Feb 27 06:38:16 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:38:16 +0000 Subject: [BioRuby-cvs] bioruby/doc Changes-0.7.rd,1.15,1.16 Message-ID: <200602271138.k1RBcGVL002464@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/doc In directory pub.open-bio.org:/tmp/cvs-serv2456/doc Modified Files: Changes-0.7.rd Log Message: * prepared for 1.0.0 release Index: Changes-0.7.rd =================================================================== RCS file: /home/repository/bioruby/bioruby/doc/Changes-0.7.rd,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Changes-0.7.rd 22 Feb 2006 15:09:45 -0000 1.15 --- Changes-0.7.rd 27 Feb 2006 11:38:14 -0000 1.16 *************** *** 50,53 **** --- 50,66 ---- --- Bio::Sequence + Bio::Sequence is completely refactored to be a container class for + any sequence annotations. Functionalities are separated into several + files under the lib/bio/sequence/ directory as + + * common.rb : module provides common methods for NA and AA sequences + * compat.rb : methods for backward compatibility + * aa.rb : Bio::Sequence::AA class + * na.rb : Bio::Sequence::NA class + * format.rb : module for format conversion + + Bio::Sequence is no longer a sub-class of String, instead, + Bio::Sequence::NA and AA inherits String directly. + * Bio::Sequence::NA#gc_percent returns integer instead of float * Bio::Sequence::NA#gc (was aliased to gc_percent) is removed From k at pub.open-bio.org Mon Feb 27 06:16:24 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/doc README_FOR_APP, NONE, 1.1 Message-ID: <200602271116.k1RBGOVL002307@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/doc In directory pub.open-bio.org:/tmp/cvs-serv2240/doc Added Files: README_FOR_APP Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: README_FOR_APP --- Use this README file to introduce your application and point to useful places in the API for learning more. Run "rake appdoc" to generate API documentation for your models and controllers. From k at pub.open-bio.org Mon Feb 27 06:16:26 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:26 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script/process reaper, NONE, 1.1 spawner, NONE, 1.1 spinner, NONE, 1.1 Message-ID: <200602271116.k1RBGQVL002329@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/process In directory pub.open-bio.org:/tmp/cvs-serv2240/script/process Added Files: reaper spawner spinner Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: spinner --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spinner' --- NEW FILE: spawner --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner' --- NEW FILE: reaper --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper' From k at pub.open-bio.org Mon Feb 27 06:16:25 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/images icon.png, NONE, 1.1 rails.png, NONE, 1.1 Message-ID: <200602271116.k1RBGPVL002313@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/images In directory pub.open-bio.org:/tmp/cvs-serv2240/public/images Added Files: icon.png rails.png Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: icon.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: rails.png --- (This appears to be a binary file; contents omitted.) From k at pub.open-bio.org Mon Feb 27 06:16:26 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:26 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script/performance benchmarker, NONE, 1.1 profiler, NONE, 1.1 Message-ID: <200602271116.k1RBGQVL002318@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/performance In directory pub.open-bio.org:/tmp/cvs-serv2240/script/performance Added Files: benchmarker profiler Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: benchmarker --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker' --- NEW FILE: profiler --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler' From k at pub.open-bio.org Mon Feb 27 06:16:24 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/config boot.rb, NONE, 1.1 database.yml, NONE, 1.1 environment.rb, NONE, 1.1 routes.rb, NONE, 1.1 Message-ID: <200602271116.k1RBGOVL002301@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/config In directory pub.open-bio.org:/tmp/cvs-serv2240/config Added Files: boot.rb database.yml environment.rb routes.rb Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: routes.rb --- ActionController::Routing::Routes.draw do |map| # Add your own custom routes here. # The priority is based upon order of creation: first created -> highest priority. # Here's a sample route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action # You can have the root of your site routed by hooking up '' # -- just remember to delete public/index.html. # map.connect '', :controller => "welcome" # Allow downloading Web Service WSDL as a file with an extension # instead of a file named 'wsdl' map.connect ':controller/service.wsdl', :action => 'wsdl' # Install the default route as the lowest priority. map.connect ':controller/:action/:id' end --- NEW FILE: database.yml --- # MySQL (default setup). Versions 4.1 and 5.0 are recommended. # # Get the fast C bindings: # gem install mysql # (on OS X: gem install mysql -- --include=/usr/local/lib) # And be sure to use new-style password hashing: # http://dev.mysql.com/doc/refman/5.0/en/old-client.html development: adapter: mysql database: kumamushi_development username: root password: socket: /tmp/mysql.sock # Connect on a TCP socket. If omitted, the adapter will connect on the # domain socket given by socket instead. #host: localhost #port: 3306 # Warning: The database defined as 'test' will be erased and # re-generated from your development database when you run 'rake'. # Do not set this db to the same as development or production. test: adapter: mysql database: kumamushi_test username: root password: socket: /tmp/mysql.sock production: adapter: mysql database: kumamushi_production username: root password: socket: /tmp/mysql.sock # PostgreSQL versions 7.4 - 8.1 # # Get the C bindings: # gem install postgres # or use the pure-Ruby bindings on Windows: # gem install postgres-pr postgresql_example: adapter: postgresql database: kumamushi_development username: kumamushi password: # Connect on a TCP socket. Omitted by default since the client uses a # domain socket that doesn't need configuration. #host: remote-database #port: 5432 # Schema search path. The server defaults to $user,public #schema_search_path: myapp,sharedapp,public # Character set encoding. The server defaults to sql_ascii. #encoding: UTF8 # Minimum log levels, in increasing order: # debug5, debug4, debug3, debug2, debug1, # info, notice, warning, error, log, fatal, or panic # The server defaults to notice. #min_messages: warning # SQLite version 2.x # gem install sqlite-ruby sqlite_example: adapter: sqlite database: db/development.sqlite2 # SQLite version 3.x # gem install sqlite3-ruby sqlite3_example: adapter: sqlite3 database: db/development.sqlite3 # In-memory SQLite 3 database. Useful for tests. sqlite3_in_memory_example: adapter: sqlite3 database: ":memory:" --- NEW FILE: boot.rb --- # Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb unless defined?(RAILS_ROOT) root_path = File.join(File.dirname(__FILE__), '..') unless RUBY_PLATFORM =~ /mswin32/ require 'pathname' root_path = Pathname.new(root_path).cleanpath(true).to_s end RAILS_ROOT = root_path end if File.directory?("#{RAILS_ROOT}/vendor/rails") require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" else require 'rubygems' require 'initializer' end Rails::Initializer.run(:set_load_path) --- NEW FILE: environment.rb --- # Be sure to restart your web server when you modify this file. # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way # ENV['RAILS_ENV'] ||= 'production' # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') Rails::Initializer.run do |config| # Settings in config/environments/* take precedence those specified here # Skip frameworks you're not going to use # config.frameworks -= [ :action_web_service, :action_mailer ] # Add additional load paths for your own custom dirs # config.load_paths += %W( #{RAILS_ROOT}/extras ) # Force all environments to use the same logger level # (by default production uses :info, the others :debug) # config.log_level = :debug # Use the database for sessions instead of the file system # (create the session table with 'rake create_sessions_table') # config.action_controller.session_store = :active_record_store # Enable page/fragment caching by setting a file-based store # (remember to create the caching directory and make it readable to the application) # config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache" # Activate observers that should always be running # config.active_record.observers = :cacher, :garbage_collector # Make Active Record use UTC-base instead of local time # config.active_record.default_timezone = :utc # Use Active Record's schema dumper instead of SQL when creating the test database # (enables use of different database adapters for development and test environments) # config.active_record.schema_format = :ruby # See Rails::Configuration for more options end # Add new inflection rules using the following format # (all these examples are active by default): # Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end # Include your application configuration below From k at pub.open-bio.org Mon Feb 27 06:16:25 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script about, NONE, 1.1 breakpointer, NONE, 1.1 console, NONE, 1.1 destroy, NONE, 1.1 generate, NONE, 1.1 plugin, NONE, 1.1 runner, NONE, 1.1 server, NONE, 1.1 Message-ID: <200602271116.k1RBGPVL002316@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script In directory pub.open-bio.org:/tmp/cvs-serv2240/script Added Files: about breakpointer console destroy generate plugin runner server Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: breakpointer --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/breakpointer' --- NEW FILE: about --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about' --- NEW FILE: console --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console' --- NEW FILE: plugin --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin' --- NEW FILE: runner --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner' --- NEW FILE: destroy --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy' --- NEW FILE: generate --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate' --- NEW FILE: server --- #!/usr/bin/env ruby # # = BioRuby shell on Rails server - GUI for the BioRuby shell # # Copyright:: Copyright (C) 2006 # Nobuya Tanaka , # Toshiaki Katayama # License:: Ruby's # # $Id: server,v 1.1 2006/02/27 11:16:23 k Exp $ # require 'bio/shell' require 'drb/drb' require './app/models/shell_connection' $drb_server = ShellConnection.new ## Access Control List # # require 'drb/acl' # # list = %w(deny all # allow 127.0.0.1 # ) # acl = ACL.new(list, ACL::DENY_ALLOW) # DRb.install_acl(acl) # STDOUT.sync = true #uri = "druby://localhost:0" uri = 'druby://localhost:81064' # baioroji- DRb.start_service(uri, $drb_server) puts DRb.uri puts "starting ..." require './config/boot' require 'commands/server' puts "exiting ..." From k at pub.open-bio.org Mon Feb 27 06:16:25 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public 404.html, NONE, 1.1 500.html, NONE, 1.1 dispatch.cgi, NONE, 1.1 dispatch.fcgi, NONE, 1.1 dispatch.rb, NONE, 1.1 favicon.ico, NONE, 1.1 index.html, NONE, 1.1 robots.txt, NONE, 1.1 Message-ID: <200602271116.k1RBGPVL002310@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public In directory pub.open-bio.org:/tmp/cvs-serv2240/public Added Files: 404.html 500.html dispatch.cgi dispatch.fcgi dispatch.rb favicon.ico index.html robots.txt Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: favicon.ico --- --- NEW FILE: dispatch.cgi --- #!/usr/bin/env ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired require "dispatcher" ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) Dispatcher.dispatch --- NEW FILE: 404.html ---

File not found

Change this error message for pages not found in public/404.html

--- NEW FILE: robots.txt --- # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file --- NEW FILE: index.html --- Ruby on Rails: Welcome aboard

Getting started

Here’s how to get rolling:

  1. Create your databases and edit config/database.yml

    Rails needs to know your login and password.

  2. Use script/generate to create your models and controllers

    To see all available options, run it without parameters.

  3. Set up a default route and remove or rename this file

    Routes are setup in config/routes.rb.

--- NEW FILE: dispatch.rb --- #!/usr/bin/env ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired require "dispatcher" ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) Dispatcher.dispatch --- NEW FILE: dispatch.fcgi --- #!/usr/bin/env ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log # and the GC period is nil (turned off). A reasonable number of requests # could range from 10-100 depending on the memory footprint of your app. # # Example: # # Default log path, normal GC behavior. # RailsFCGIHandler.process! # # # Default log path, 50 requests between GC. # RailsFCGIHandler.process! nil, 50 # # # Custom log path, normal GC behavior. # RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log' # require File.dirname(__FILE__) + "/../config/environment" require 'fcgi_handler' RailsFCGIHandler.process! --- NEW FILE: 500.html ---

Application error (Apache)

Change this error message for exceptions thrown outside of an action (like in Dispatcher setups or broken Ruby code) in public/500.html

From k at pub.open-bio.org Mon Feb 27 06:16:23 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:23 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails Rakefile,NONE,1.1 Message-ID: <200602271116.k1RBGNVL002274@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails In directory pub.open-bio.org:/tmp/cvs-serv2240 Added Files: Rakefile Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: Rakefile --- # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/switchtower.rake, and they will automatically be available to Rake. require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails' From k at pub.open-bio.org Mon Feb 27 05:23:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/lib - New directory Message-ID: <200602271023.k1RAN6VL001816@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib In directory pub.open-bio.org:/tmp/cvs-serv1726/lib Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:07 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:07 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/log - New directory Message-ID: <200602271023.k1RAN7VL001827@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/log In directory pub.open-bio.org:/tmp/cvs-serv1726/log Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/log added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:30 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:30 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test - New directory Message-ID: <200602271012.k1RACUVL001470@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/test Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:08 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:08 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test - New directory Message-ID: <200602271023.k1RAN8VL001869@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test In directory pub.open-bio.org:/tmp/cvs-serv1726/test Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:08 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:08 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script - New directory Message-ID: <200602271023.k1RAN8VL001856@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script In directory pub.open-bio.org:/tmp/cvs-serv1726/script Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/script added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:07 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:07 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public - New directory Message-ID: <200602271023.k1RAN7VL001834@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public In directory pub.open-bio.org:/tmp/cvs-serv1726/public Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:10 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:10 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/vendor - New directory Message-ID: <200602271023.k1RANAVL001896@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor In directory pub.open-bio.org:/tmp/cvs-serv1726/vendor Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:46 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/views - New directory Message-ID: <200602271012.k1RACkVL001530@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/app/views Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/lib/tasks - New directory Message-ID: <200602271023.k1RAN6VL001822@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib/tasks In directory pub.open-bio.org:/tmp/cvs-serv1726/lib/tasks Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib/tasks added to the repository From k at pub.open-bio.org Mon Feb 27 06:17:36 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:17:36 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public .htaccess, NONE, 1.1 Message-ID: <200602271117.k1RBHaVL002389@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public In directory pub.open-bio.org:/tmp/cvs-serv2375/lib/bio/shell/rails/public Added Files: .htaccess Log Message: * forgotten dot file --- NEW FILE: .htaccess --- # General Apache options AddHandler fastcgi-script .fcgi AddHandler cgi-script .cgi Options +FollowSymLinks +ExecCGI # If you don't want Rails to look in certain directories, # use the following rewrite rules so that Apache won't rewrite certain requests # # Example: # RewriteCond %{REQUEST_URI} ^/notrails.* # RewriteRule .* - [L] # Redirect all requests not available on the filesystem to Rails # By default the cgi dispatcher is used which is very slow # # For better performance replace the dispatcher with the fastcgi one # # Example: # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] RewriteEngine On # If your Rails application is accessed via an Alias directive, # then you MUST also set the RewriteBase in this htaccess file. # # Example: # Alias /myrailsapp /path/to/myrailsapp/public # RewriteBase /myrailsapp RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.cgi [QSA,L] # In case Rails experiences terminal errors # Instead of displaying this message you can supply a file here which will be rendered instead # # Example: # ErrorDocument 500 /500.html ErrorDocument 500 "

Application error

Rails application failed to start properly" From k at pub.open-bio.org Mon Feb 27 05:23:04 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:04 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/models - New directory Message-ID: <200602271023.k1RAN4VL001769@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/models In directory pub.open-bio.org:/tmp/cvs-serv1726/app/models Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/models added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:09 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:09 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/mocks - New directory Message-ID: <200602271023.k1RAN9VL001882@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks In directory pub.open-bio.org:/tmp/cvs-serv1726/test/mocks Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:05 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:05 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/components - New directory Message-ID: <200602271023.k1RAN5VL001792@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/components In directory pub.open-bio.org:/tmp/cvs-serv1726/components Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/components added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:46 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/models - New directory Message-ID: <200602271012.k1RACkVL001529@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/models In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/app/models Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/models added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:48 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:48 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/mocks - New directory Message-ID: <200602271012.k1RACmVL001568@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/test/mocks Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:04 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:04 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/helpers - New directory Message-ID: <200602271023.k1RAN4VL001765@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/helpers In directory pub.open-bio.org:/tmp/cvs-serv1726/app/helpers Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/helpers added to the repository From k at pub.open-bio.org Mon Feb 27 06:16:26 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:26 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test test_helper.rb, NONE, 1.1 Message-ID: <200602271116.k1RBGQVL002332@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test In directory pub.open-bio.org:/tmp/cvs-serv2240/test Added Files: test_helper.rb Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: test_helper.rb --- ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class Test::Unit::TestCase # Transactional fixtures accelerate your tests by wrapping each test method # in a transaction that's rolled back on completion. This ensures that the # test database remains unchanged so your fixtures don't have to be reloaded # between every test method. Fewer database queries means faster tests. # # Read Mike Clark's excellent walkthrough at # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting # # Every Active Record database supports transactions except MyISAM tables # in MySQL. Turn off transactional fixtures in this case; however, if you # don't care one way or the other, switching from MyISAM to InnoDB tables # is recommended. self.use_transactional_fixtures = true # Instantiated fixtures are slow, but give you @david where otherwise you # would need people(:david). If you don't want to migrate your existing # test cases which use the @david style and don't mind the speed hit (each # instantiated fixtures translates to a database query per test method), # then set this back to true. self.use_instantiated_fixtures = false # Add more helper methods to be used by all tests here... end From k at pub.open-bio.org Mon Feb 27 05:23:08 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:08 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/fixtures - New directory Message-ID: <200602271023.k1RAN8VL001874@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/fixtures In directory pub.open-bio.org:/tmp/cvs-serv1726/test/fixtures Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/fixtures added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:46 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/images - New directory Message-ID: <200602271012.k1RACkVL001547@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/images In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/public/images Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/images added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:47 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:47 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/fixtures - New directory Message-ID: <200602271012.k1RAClVL001562@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/fixtures In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/test/fixtures Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/fixtures added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:47 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:47 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script/process - New directory Message-ID: <200602271012.k1RAClVL001559@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/process In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/script/process Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/process added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:48 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:48 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/vendor/plugins - New directory Message-ID: <200602271012.k1RACmVL001574@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/vendor/plugins Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:08 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:08 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script/process - New directory Message-ID: <200602271023.k1RAN8VL001866@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/process In directory pub.open-bio.org:/tmp/cvs-serv1726/script/process Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/process added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:05 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:05 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/views/shell - New directory Message-ID: <200602271023.k1RAN5VL001787@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views/shell In directory pub.open-bio.org:/tmp/cvs-serv1726/app/views/shell Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views/shell added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:45 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:45 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/controllers - New directory Message-ID: <200602271012.k1RACjVL001522@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/controllers In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/app/controllers Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/controllers added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:47 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:47 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/functional - New directory Message-ID: <200602271012.k1RAClVL001565@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/functional In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/test/functional Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/functional added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:09 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:09 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/functional - New directory Message-ID: <200602271023.k1RAN9VL001879@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/functional In directory pub.open-bio.org:/tmp/cvs-serv1726/test/functional Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/functional added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:09 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:09 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/mocks/test - New directory Message-ID: <200602271023.k1RAN9VL001890@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks/test In directory pub.open-bio.org:/tmp/cvs-serv1726/test/mocks/test Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks/test added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:07 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:07 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/stylesheets - New directory Message-ID: <200602271023.k1RAN7VL001851@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/stylesheets In directory pub.open-bio.org:/tmp/cvs-serv1726/public/stylesheets Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/stylesheets added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:08 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:08 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script/performance - New directory Message-ID: <200602271023.k1RAN8VL001863@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/performance In directory pub.open-bio.org:/tmp/cvs-serv1726/script/performance Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/performance added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:47 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:47 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script/performance - New directory Message-ID: <200602271012.k1RAClVL001556@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/performance In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/script/performance Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/performance added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:07 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:07 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/javascripts - New directory Message-ID: <200602271023.k1RAN7VL001847@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/javascripts In directory pub.open-bio.org:/tmp/cvs-serv1726/public/javascripts Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/javascripts added to the repository From k at pub.open-bio.org Mon Feb 27 05:23:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/config/environments - New directory Message-ID: <200602271023.k1RAN6VL001803@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/config/environments In directory pub.open-bio.org:/tmp/cvs-serv1726/config/environments Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/config/environments added to the repository From k at pub.open-bio.org Mon Feb 27 05:12:46 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/config/environments - New directory Message-ID: <200602271012.k1RACkVL001532@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/config/environments In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/config/environments Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/config/environments added to the repository From k at pub.open-bio.org Mon Feb 27 06:16:25 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/stylesheets main.css, NONE, 1.1 Message-ID: <200602271116.k1RBGPVL002315@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/stylesheets In directory pub.open-bio.org:/tmp/cvs-serv2240/public/stylesheets Added Files: main.css Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: main.css --- body { background-color: #fff; color: #333; } body, p, td { font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; line-height: 18px; } pre { background-color: #eee; padding: 10px; font-size: 11px; } a { color: #000; } a:visited { color: #666; } a:hover { color: #fff; background-color:#000; } .fieldWithErrors { padding: 2px; background-color: red; display: table; } table { text-align: top; } #ErrorExplanation { width: 400px; border: 2px solid red; padding: 7px; padding-bottom: 12px; margin-bottom: 20px; background-color: #f0f0f0; } #ErrorExplanation h2 { text-align: left; font-weight: bold; padding: 5px 5px 5px 15px; font-size: 12px; margin: -7px; background-color: #c00; color: #fff; } #ErrorExplanation p { color: #333; margin-bottom: 0; padding: 5px; } #ErrorExplanation ul li { font-size: 12px; list-style: square; } h1{ color: #333; padding: 10px; margin: 12px; } #banner{ margin-left: 5em; margin-right: -6px; text-align: center; font-size: 30px; border-top: 1px solid silver; border-bottom: 1px solid silver; padding: 10px 0px 10px 0px; } tr{ vertical-align: top; text-align: left; } #side img{ background-color: black; width:12em; } #side{ position: absolute; margin: -13px; top: 1em; left: 1em; width: 10em; } #side ul{ font-size: 13px; margin: 0em; } #side h2{ font-size: 12px; text-align: center; width: 13em; background-color: black; color: white; } #side input{ text-align: center; } #main { margin-left: 10em; padding-top: 4x; padding-left: 2em; background: white; } .main { margin-left: 10em; padding-top: 4x; padding-left: 2em; background: white; } #menu { margin-left: 10em; padding-top: 4x; padding-left: 2em; background: white; } div.uploadStatus { margin: 5px; } div.progressBar { margin: 5px; } div.progressBar div.border { background-color: #fff; border: 1px solid grey; width: 100%; } div.progressBar div.background { background-color: #333; height: 18px; width: 0%; } .tabs { position:relative; height: 20px; margin: 0; padding: 0; background: #aaa repeat-x; overflow:hidden } .tabs li { display:inline; } .tabs a:hover, .tabs a.tab-active { color:#333; background:#fff url("bar_on.gif") repeat-x; border-right: 1px solid #fff } .tabs a { height: 27px; font:12px verdana, helvetica, sans-serif; font-weight:bold; position:relative; padding:6px 10px 10px 10px; margin: 0px -4px 0px 0px; color:#333; text-decoration:none; border-left:1px solid #fff; border-right:1px solid #333; } .tab-container { background: #fff; border:1px solid #555; } .tab-panes { margin: 3px } From k at pub.open-bio.org Mon Feb 27 05:23:09 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:09 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/mocks/development - New directory Message-ID: <200602271023.k1RAN9VL001887@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks/development In directory pub.open-bio.org:/tmp/cvs-serv1726/test/mocks/development Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks/development added to the repository From k at pub.open-bio.org Mon Feb 27 06:16:23 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:23 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/helpers application_helper.rb, NONE, 1.1 Message-ID: <200602271116.k1RBGNVL002282@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/helpers In directory pub.open-bio.org:/tmp/cvs-serv2240/app/helpers Added Files: application_helper.rb Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: application_helper.rb --- # Methods added to this helper will be available to all templates in the application. module ApplicationHelper end From k at pub.open-bio.org Mon Feb 27 06:16:24 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/views/layouts shell.rhtml, NONE, 1.1 Message-ID: <200602271116.k1RBGOVL002292@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views/layouts In directory pub.open-bio.org:/tmp/cvs-serv2240/app/views/layouts Added Files: shell.rhtml Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: shell.rhtml --- BioRuby shell on Rails

Local variables

    <% @local_vars.each do |idx, var| %>
  • <%= link_to idx, {:action => "show", :id => idx}%>
  • <% end %>
<%= @content_for_layout %>
From k at pub.open-bio.org Mon Feb 27 06:16:24 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/models shell_connection.rb, NONE, 1.1 Message-ID: <200602271116.k1RBGOVL002287@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/models In directory pub.open-bio.org:/tmp/cvs-serv2240/app/models Added Files: shell_connection.rb Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: shell_connection.rb --- # Model object for rails class ShellConnection # include DRb::DRbObservable attr_reader :registry def puts_remote(str) STDOUT.puts(str) end def initialize @connected = false @registry = {} end def [] o_id @registry[o_id] end def []=(name, obj) @registry[name] = obj end def delete(name) @registry.delete(name) end end From k at pub.open-bio.org Mon Feb 27 06:16:24 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/views/shell history.rhtml, NONE, 1.1 index.rhtml, NONE, 1.1 show.rhtml, NONE, 1.1 Message-ID: <200602271116.k1RBGOVL002297@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views/shell In directory pub.open-bio.org:/tmp/cvs-serv2240/app/views/shell Added Files: history.rhtml index.rhtml show.rhtml Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: index.rhtml ---

Connected!

--- NEW FILE: show.rhtml --- <%= @inheritance %> <%= @contents %> <%= form_tag(:action => "show")%> <%= end_form_tag %> --- NEW FILE: history.rhtml ---
<%= @history %>
From k at pub.open-bio.org Mon Feb 27 05:23:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/doc - New directory Message-ID: <200602271023.k1RAN6VL001811@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/doc In directory pub.open-bio.org:/tmp/cvs-serv1726/doc Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/doc added to the repository From k at pub.open-bio.org Mon Feb 27 06:16:23 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:23 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/controllers application.rb, NONE, 1.1 shell_controller.rb, NONE, 1.1 Message-ID: <200602271116.k1RBGNVL002278@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/controllers In directory pub.open-bio.org:/tmp/cvs-serv2240/app/controllers Added Files: application.rb shell_controller.rb Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: application.rb --- # Filters added to this controller will be run for all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base end --- NEW FILE: shell_controller.rb --- class DocumentRegistry @@registry = [] def self.[](class_name) @@registry.each do |block| url = block.call(class_name) return url if url end "" end def self.register &block @@registry.push(block) end end DocumentRegistry.register() do |class_name| if m = /Bio::(.+)/.match(class_name) "http://bioruby.org/rdoc/classes/Bio/#{m[1].split('::').join('/')}.html" else false end end DocumentRegistry.register do |class_name| if m = /Chem::(.+)/.match(class_name) "http://chemruby.org/rdoc/classes/Chem/#{m[1].split('::').join('/')}.html" else false end end DocumentRegistry.register do |class_name| "http://www.ruby-doc.org/core/classes/#{class_name.split('::').join('/')}.html" end class ShellController < ApplicationController layout 'shell' #, :except => [:rss_feed, :rss_with_content] def index setup end def show setup @obj = $drb_server[params[:id]] if @obj.nil? @inheritance = "

Unknown local variable! : #{params[:var]}

" else @inheritance = get_inheritance @obj.class if @obj.respond_to?(:to_html) @contents = @obj.to_html else @contents = "Undefined :to_html" end end @title = params[:id] end =begin def history setup @history = File.read("session/history") end =end private def setup @local_vars = $drb_server.registry end def get_inheritance obj # mods = obj.included_modules - [PP::ObjectMixin, Bio::Shell, WEBrick] mods = obj.included_modules module_links = mods.collect{|m| " [#{m.to_s}] " }.join("|") inherit = [] loop do inherit.push(" [#{obj.to_s}] ") break if obj == Object obj = obj.superclass end "" + "
Inheritance" + inherit.join(" < ") + "
Mix-in" + module_links + "
" end end From k at pub.open-bio.org Mon Feb 27 06:16:24 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/config/environments development.rb, NONE, 1.1 production.rb, NONE, 1.1 test.rb, NONE, 1.1 Message-ID: <200602271116.k1RBGOVL002304@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/config/environments In directory pub.open-bio.org:/tmp/cvs-serv2240/config/environments Added Files: development.rb production.rb test.rb Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: production.rb --- # Settings specified here will take precedence over those in config/environment.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Use a different logger for distributed setups # config.logger = SyslogLogger.new # Full error reports are disabled and caching is turned on config.action_controller.consider_all_requests_local = false config.action_controller.perform_caching = true # Enable serving of images, stylesheets, and javascripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" # Disable delivery errors if you bad email addresses should just be ignored # config.action_mailer.raise_delivery_errors = false --- NEW FILE: test.rb --- # Settings specified here will take precedence over those in config/environment.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! config.cache_classes = true # Log error messages when you accidentally call methods on nil. config.whiny_nils = true # Show full error reports and disable caching config.action_controller.consider_all_requests_local = true config.action_controller.perform_caching = false # Tell ActionMailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test --- NEW FILE: development.rb --- # Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.cache_classes = false # Log error messages when you accidentally call methods on nil. config.whiny_nils = true # Enable the breakpoint server that script/breakpointer connects to config.breakpoint_server = true # Show full error reports and disable caching config.action_controller.consider_all_requests_local = true config.action_controller.perform_caching = false # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false From k at pub.open-bio.org Mon Feb 27 05:23:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/config - New directory Message-ID: <200602271023.k1RAN6VL001797@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/config In directory pub.open-bio.org:/tmp/cvs-serv1726/config Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/config added to the repository From trevor at pub.open-bio.org Wed Feb 1 02:17:46 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:17:46 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme - New directory Message-ID: <200602010724.k117ObVL028599@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv28589/restriction_enzyme Log Message: Directory /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme added to the repository From trevor at pub.open-bio.org Wed Feb 1 02:18:46 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:18:46 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme/single_strand - New directory Message-ID: <200602010725.k117PdVL028617@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/single_strand In directory pub.open-bio.org:/tmp/cvs-serv28607/single_strand Log Message: Directory /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/single_strand added to the repository From trevor at pub.open-bio.org Wed Feb 1 02:19:05 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:19:05 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme/double_stranded - New directory Message-ID: <200602010725.k117PtVL028635@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/double_stranded In directory pub.open-bio.org:/tmp/cvs-serv28623/double_stranded Log Message: Directory /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/double_stranded added to the repository From trevor at pub.open-bio.org Wed Feb 1 02:19:10 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:19:10 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme/analysis - New directory Message-ID: <200602010725.k117PuVL028638@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/analysis In directory pub.open-bio.org:/tmp/cvs-serv28623/analysis Log Message: Directory /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/analysis added to the repository From trevor at pub.open-bio.org Wed Feb 1 02:19:38 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:19:38 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme - New directory Message-ID: <200602010726.k117QUVL028654@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv28644/restriction_enzyme Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme added to the repository From trevor at pub.open-bio.org Wed Feb 1 02:19:59 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:19:59 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/double_stranded - New directory Message-ID: <200602010726.k117QrVL028677@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/double_stranded In directory pub.open-bio.org:/tmp/cvs-serv28660/double_stranded Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/double_stranded added to the repository From trevor at pub.open-bio.org Wed Feb 1 02:19:59 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:19:59 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/single_strand - New directory Message-ID: <200602010726.k117QrVL028680@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/single_strand In directory pub.open-bio.org:/tmp/cvs-serv28660/single_strand Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/single_strand added to the repository From trevor at pub.open-bio.org Wed Feb 1 02:20:00 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:20:00 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/analysis - New directory Message-ID: <200602010726.k117QrVL028674@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis In directory pub.open-bio.org:/tmp/cvs-serv28660/analysis Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis added to the repository From trevor at pub.open-bio.org Wed Feb 1 02:23:32 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:23:32 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util restriction_enzyme.rb,NONE,1.1 Message-ID: <200602010730.k117UMVL028726@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util In directory pub.open-bio.org:/tmp/cvs-serv28712/lib/bio/util Added Files: restriction_enzyme.rb Log Message: Bio::RestrictionEnzyme inital commit. --- NEW FILE: restriction_enzyme.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio' require 'bio/db/rebase' require 'bio/util/restriction_enzyme/double_stranded' require 'bio/util/restriction_enzyme/single_strand' require 'bio/util/restriction_enzyme/cut_symbol' require 'bio/util/restriction_enzyme/analysis' module Bio; end # # bio/util/restriction_enzyme.rb - Digests DNA based on restriction enzyme cut patterns # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: restriction_enzyme.rb,v 1.1 2006/02/01 07:30:19 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme.rb - Digests DNA based on restriction enzyme cut patterns NOTE: This documentation and the module are still very much under development. It has been released as it is relatively stable and comments would be appreciated. == Synopsis Bio::RestrictionEnzyme allows you to fragment a DNA strand using one or more restriction enzymes. Bio::RestrictionEnzyme is aware that multiple enzymes may be competing for the same recognition site and returns the various possible fragmentation patterns that result in such circumstances. Using Bio::RestrictionEnzyme you may simply use the name of common enzymes to cut with or you may construct your own unique enzymes to use. == Basic Usage # EcoRI cut pattern: # G|A A T T C # +-------+ # C T T A A|G # # This can also be written as: # G^AATTC require 'bio/restriction_enzyme' require 'pp' seq = Bio::Sequence::NA.new('gaattc') cuts = seq.cut_with_enzyme('EcoRI') p cuts.primary # ["aattc", "g"] p cuts.complement # ["g", "cttaa"] pp cuts # ==> # [#, # #] seq = Bio::Sequence::NA.new('gaattc') cuts = seq.cut_with_enzyme('g^aattc') p cuts.primary # ["aattc", "g"] p cuts.complement # ["g", "cttaa"] seq = Bio::Sequence::NA.new('gaattc') cuts = seq.cut_with_enzyme('g^aattc', 'gaatt^c') p cuts.primary # ["c", "aattc", "g", "gaatt"] p cuts.complement # ["g", "c", "cttaa", "ttaag"] seq = Bio::Sequence::NA.new('gaattcgaattc') cuts = seq.cut_with_enzyme('EcoRI') p cuts.primary # ["aattc", "aattcg", "g"] p cuts.complement # ["g", "gcttaa", "cttaa"] seq = Bio::Sequence::NA.new('gaattcgggaattc') cuts = seq.cut_with_enzyme('EcoRI') p cuts.primary # ["aattc", "aattcggg", "g"] p cuts.complement # ["g", "gcccttaa", "cttaa"] == Advanced Usage require 'bio/restriction_enzyme' require 'pp' enzyme_1 = Bio::RestrictionEnzyme.new('anna', [1,1], [3,3]) enzyme_2 = Bio::RestrictionEnzyme.new('gg', [1,1]) a = Bio::RestrictionEnzyme::Analysis.cut('agga', enzyme_1, enzyme_2) p a.primary # ["a", "ag", "g", "ga"] b = Bio::RestrictionEnzyme::Analysis.cut_and_return_by_permutations('agga', enzyme_1, enzyme_2) pp b Output (NOTE: to be cleaned): {[1, 0]=> #, #], @__fragments_current=true, @c_left=3, @c_right=3, @cut_ranges= [#], @left=0, @p_left=0, @p_right=0, @right=3, @size=4, @tags={}>, [0, 1]=> #, #, #, #], @__fragments_current=true, @c_left=3, @c_right=3, @cut_ranges= [#, #, #], @left=0, @p_left=0, @p_right=0, @right=3, @size=4, @tags={}>} == Todo Currently under development: * Optimizations in restriction_enzyme/analysis.rb to cut down on factorial growth of computation space. * Circular DNA cutting * Tagging of sequence data * Much more documentation == Notes This module includes Florian Frank's permutation.rb licensed under the GPL. To prevent licensing issues the source code to Bio::RestrictionEnzyme must be included whenever Bio::RestrictionEnzyme is distributed. == Author Trevor Wennblom == Copyright Copyright (C) 2006 Trevor Wennblom Licensed under the same terms as BioRuby. =end class Bio::RestrictionEnzyme include CutSymbol extend CutSymbol # Factory for DoubleStranded def self.new(users_enzyme_or_rebase_or_pattern, *cut_locations) DoubleStranded.new(users_enzyme_or_rebase_or_pattern, *cut_locations) end # REBASE enzyme data information # # Returns a Bio::REBASE object loaded with all of the enzyme data on file. # def self.rebase # NOTE open for debate ... maybe this should be stored somewhere else in bioruby? data_file_location = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3, 'lib')).cleanpath.to_s + '/bio/util/restriction_enzyme/enzymes.yaml' @@rebase_enzymes ||= Bio::REBASE.load_yaml( data_file_location ) @@rebase_enzymes end # Primitive way of determining if a string is an enzyme name. # # Should work just fine thanks to dumb luck. A nucleotide or nucleotide # set can't ever contain an 'i'. Restriction enzymes always end in 'i'. # #-- # Could also look for cut symbols. #++ # def self.enzyme_name?( str ) str[-1].chr.downcase == 'i' end # See Bio::RestrictionEnzyme::Analysis.cut def self.cut( sequence, enzymes ) Bio::RestrictionEnzyme::Analysis.cut( sequence, enzymes ) end end From trevor at pub.open-bio.org Wed Feb 1 02:23:32 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:23:32 -0000 Subject: [BioRuby-cvs] bioruby ChangeLog,1.48,1.49 Message-ID: <200602010730.k117ULVL028724@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv28712 Modified Files: ChangeLog Log Message: Bio::RestrictionEnzyme inital commit. Index: ChangeLog =================================================================== RCS file: /home/repository/bioruby/bioruby/ChangeLog,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** ChangeLog 20 Jan 2006 14:04:47 -0000 1.48 --- ChangeLog 1 Feb 2006 07:30:19 -0000 1.49 *************** *** 1,2 **** --- 1,8 ---- + 2005-02-01 Trevor Wennblom + + * Bio::RestrictionEnzyme first commit for comments. + * See lib/bio/util/restriction_enzyme.rb and + test/unit/bio/util/restriction_enzyme + 2005-01-20 Toshiaki Katayama From trevor at pub.open-bio.org Wed Feb 1 02:27:27 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:27:27 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/analysis calculated_cuts.rb, NONE, 1.1 cut_range.rb, NONE, 1.1 cut_ranges.rb, NONE, 1.1 fragment.rb, NONE, 1.1 fragments.rb, NONE, 1.1 horizontal_cut_range.rb, NONE, 1.1 permutation.rb, NONE, 1.1 sequence_range.rb, NONE, 1.1 tags.rb, NONE, 1.1 vertical_cut_range.rb, NONE, 1.1 Message-ID: <200602010734.k117YDVL028868@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis In directory pub.open-bio.org:/tmp/cvs-serv28844/analysis Added Files: calculated_cuts.rb cut_range.rb cut_ranges.rb fragment.rb fragments.rb horizontal_cut_range.rb permutation.rb sequence_range.rb tags.rb vertical_cut_range.rb Log Message: Bio::RestrictionEnzyme --- NEW FILE: vertical_cut_range.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/analysis/cut_range' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/vertical_cut_range.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: vertical_cut_range.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/vertical_cut_range.rb - =end class VerticalCutRange < CutRange attr_reader :p_cut_left, :p_cut_right attr_reader :c_cut_left, :c_cut_right attr_reader :min, :max attr_reader :range def initialize( p_cut_left=nil, p_cut_right=nil, c_cut_left=nil, c_cut_right=nil ) @p_cut_left = p_cut_left @p_cut_right = p_cut_right @c_cut_left = c_cut_left @c_cut_right = c_cut_right a = [@p_cut_left, @c_cut_left, @p_cut_right, @c_cut_right] a.delete(nil) a.sort! @min = a.first @max = a.last @range = nil @range = (@min.. at max) unless @min == nil or @max == nil end def include?(i) return false if @range == nil @range.include?(i) end end end end --- NEW FILE: tags.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) #require 'bio/util/restriction_enzyme/analysis/shared_information' require 'bio' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/tags.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: tags.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/tags.rb - =end class Tags < Hash end end end --- NEW FILE: cut_range.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/cut_range.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_range.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/cut_range.rb - =end class CutRange end end end --- NEW FILE: permutation.rb --- # = permutation.rb - Permutation class for Ruby # # == Author # # Florian Frank mailto:flori at ping.de # # == License # # This is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License Version 2 as published by the Free # Software Foundation: www.gnu.org/copyleft/gpl.html # # == Download # # The latest version of permutation can be found at # # * http://rubyforge.org/frs/?group_id=291 # # The homepage of this library is located at # # * http://permutation.rubyforge.org # # == Description # # This class has a dual purpose: It can be used to create permutations # of a given size and to do some simple computations with/on # permutations. The instances of this class don't require much memory # because they don't include the permutation as a data structure. They # only save the information necessary to create the permutation if asked # to do so. # # To generate permutations the ranking/unranking method described in [SS97] # is used. Because of Ruby's Bignum arithmetic it is useful also # for permutations of very large size. # # == Examples # # In this section some examples show what can be done with this class. # # Creating all permutations and project them on data: # # perm = Permutation.new(3) # # => # # perm.map { |p| p.value } # # => [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]] # colors = [:r, :g, :b] # # => [:r, :g, :b] # perm.map { |p| p.project(colors) } # # => [[:r, :g, :b], [:r, :b, :g], [:g, :r, :b], [:g, :b, :r], [:b, :r, :g], # # [:b, :g, :r]] # string = "abc"# => "abc" # perm.map { |p| p.project(string) } # # => ["abc", "acb", "bac", "bca", "cab", "cba"] # # Or perhaps more convenient to use: # # perm = Permutation.for("abc") # perm.map { |p| p.project } # # => ["abc", "acb", "bac", "bca", "cab", "cba"] # # Finding the successor and predecessor of Permutations or a # certain Permutation for a given rank: # # perm = Permutation.new(7) # # => # # perm.succ! # # => # # perm.succ! # # => # # perm.succ! # # => # # perm.pred! # # => # # perm.rank = 3200 # # => 3200 # perm # # => # # perm.value # # => [4, 2, 5, 1, 3, 0, 6] # # Generating random Permutations # # perm = Permutation.new(10) # # => # # perm.random!.value # # => [6, 4, 9, 7, 3, 5, 8, 1, 2, 0] # perm.random!.value # # => [3, 7, 6, 1, 4, 8, 9, 2, 5, 0] # perm.random!.value # # => [2, 8, 4, 9, 3, 5, 6, 7, 0, 1] # perm.random!.project("ABCDEFGHIJ") # # => "DFJGAEBCIH" # perm.random!.project("ABCDEFGHIJ") # # => "BFADEGHJCI" # # Performing some mathematical operations on/with Permutations # # p1 = Permutation.from_cycles([[1, 3, 2], [5, 7]], 10) # # => # # p2 = Permutation.from_value [3, 2, 0, 5, 6, 8, 9, 1, 4, 7] # # => # # p3 = p1 * p2 # # => # # p3.value # # => [2, 1, 0, 7, 6, 8, 9, 3, 4, 5] # p3.cycles # # => [[0, 2], [3, 7], [4, 6, 9, 5, 8]] # p4 = p1 * -p2 # # => # # p4.value # # => [1, 5, 3, 0, 8, 2, 4, 9, 7, 6] # p4.cycles # # => [[0, 1, 5, 2, 3], [4, 8, 7, 9, 6]] # id = p1 * -p1 # # => # # # == References # # [SS97] The Algorithm Design Manual, Steven S. Skiena, Telos/Springer, 1997. # class Permutation include Enumerable include Comparable # Creates a new Permutation instance of size # (and ranked with rank). def initialize(size, rank = 0) @size, @rank = size, rank @last = factorial(size) - 1 end # Creates a new Permutation instance from the Array # indices, that should consist of a permutation of Fixnums # in the range of 0 and indices.size - 1. This is # for example the result of a call to the Permutation#value method. def self.from_value(indices) obj = new(indices.size) obj.instance_eval do self.rank = rank_indices(indices) end obj end # Creates a new Permutation instance from the Array of Arrays # cycles. This is for example the result of a # call to the Permutation#cycles method . def self.from_cycles(cycles, max = 0) indices = Array.new(max) cycles.each do |cycle| cycle.empty? and next for i in 0...cycle.size indices[ cycle[i - 1] ] = cycle[i] end end indices.each_with_index { |r, i| r or indices[i] = i } from_value(indices) end # A permutation instance of size collection.size is created with # collection as the default Permutation#project data object. A # collection should respond to size, [], and []=. The Permutation # instance will default to rank 0 if none is given. def self.for(collection, rank = 0) perm = new(collection.size, rank) perm.instance_variable_set(:@collection, collection) perm end # Returns the size of this permutation, a Fixnum. attr_reader :size # Returns the size of this permutation, a Fixnum in the range # of 0 and Permutation#last. attr_reader :rank # Returns the rank of the last ranked Permutation of size # Permutation#size . attr_reader :last # Assigns m to the rank attribute of this Permutation # instance. That implies that the indices produced by a call to the # Permutation#value method of this instance is the permutation ranked with # this new rank. def rank=(m) last = factorial(size) - 1 while m > last do m -= last end while m < 0 do m += last end @rank = m end # Returns the indices in the range of 0 to Permutation#size - 1 # of this permutation that is ranked with Permutation#rank. # # Example: # perm = Permutation.new(6, 312) # # => # # perm.value # # => [2, 4, 0, 1, 3, 5] def value unrank_indices(@rank) end # Returns the projection of this instance's Permutation#value # into the data object that should respond to # the #[] method. If this Permutation inbstance was created # with Permutation.for the collection used to create # it is used as a data object. # # Example: # perm = Permutation.new(6, 312) # # => # # perm.project("abcdef") # # => "ceabdf" def project(data = @collection) data or raise ArgumentError.new("a collection is required to project") raise ArgumentError.new("data size is != #{size}!") if data.size != size projection = data.clone value.each_with_index { |i, j| projection[j] = data[i] } projection end # Switches this instances to the next ranked Permutation. # If this was the Permutation#last permutation it wraps around # the first (rank == 0) permutation. def next! @rank += 1 last = factorial(size) - 1 @rank = 0 if @rank > last self end alias succ! next! # Returns the next ranked Permutation instance. # If this instance is the Permutation#last permutation it returns the first # (rank == 0) permutation. def next clone.next! end alias succ next # Switches this instances to the previously ranked Permutation. # If this was the first permutation it returns the last (rank == # Permutation#last) permutation. def pred! @rank -= 1 last = factorial(size) - 1 @rank = last if @rank < 0 self end # Returns the previously ranked Permutation. If this was the first # permutation it returns the last (rank == Permutation#last) # permutation. def pred clone.pred! end # Switches this Permutation instance to random permutation # of size Permutation#size. def random! new_rank = rand(last).to_i self.rank = new_rank self end # Returns a random Permutation instance # of size Permutation#size. def random clone.random! end # Iterates over all permutations of size Permutation#size starting with the # first (rank == 0) ranked permutation and ending with the # last (rank == Permutation#last) ranked permutation while # yielding to a freshly created Permutation instance for every iteration # step. # # The mixed in methods from the Enumerable module rely on this method. def each # :yields: perm 0.upto(last) do |r| klon = clone klon.rank = r yield klon end end # Does something similar to Permutation#each. It doesn't create new # instances (less overhead) for every iteration step, but yields to a # modified self instead. This is useful if one only wants to call a # method on the yielded value and work with the result of this call. It's # not a good idea to put the yielded values in a data structure because the # will all reference the same (this!) instance. If you want to do this # use Permutation#each. def each! old_rank = rank 0.upto(last) do |r| self.rank = r yield self end self.rank = old_rank end # Compares to Permutation instances according to their Permutation#size # and the Permutation#rank. # # The mixed in methods from the Comparable module rely on this method. def <=>(other) size <=> other.size.zero? || rank <=> other.rank end # Returns true if this Permutation instance and the other have the same # value, that is both Permutation instances have the same Permutation#size # and the same Permutation#rank. def eql?(other) self.class == other.class && size == other.size && rank == other.rank end alias == eql? # Computes a unique hash value for this Permutation instance. def hash size.hash ^ rank.hash end # Switchtes this Permutation instance to the inverted permutation. # (See Permutation#compose for an example.) def invert! indices = unrank_indices(rank) inverted = Array.new(size) for i in 0...size inverted[indices[i]] = i end self.rank = rank_indices(inverted) self end # Returns the inverted Permutation of this Permutation instance. # (See Permutation#compose for an example.) def invert clone.invert! end alias -@ invert # Compose this Permutation instance and the other to # a new Permutation. Note that a permutation # composed with it's inverted permutation yields # the identity permutation, the permutation with rank 0. # # Example: # p1 = Permutation.new(5, 42) # # => # # p2 = p1.invert # # => # # p1.compose(p2) # => # # Or a little nicer to look at: # p1 * -p1 # # => # def compose(other) size == other.size or raise ArgumentError.new( "permutations of unequal sizes cannot be composed!") indices = self.value composed = other.value.map { |i| indices[i] } klon = clone klon.rank = rank_indices(composed) klon end alias * compose # Returns the cycles representation of this Permutation instance. # The return value of this method can be used to create a # new Permutation instance with the Permutation.from_cycles method. # # Example: # perm = Permutation.new(7, 23) # # => # # perm.cycles # # => [[3, 6], [4, 5]] def cycles perm = value result = [[]] seen = {} current = nil until seen == perm.size current or current = perm.find { |x| !seen[x] } break unless current if seen[current] current = nil result << [] else seen[current] = true result[-1] << current current = perm[current] end end result.pop result.select { |c| c.size > 1 }.map do |c| min_index = c.index(c.min) c[min_index..-1] + c[0...min_index] end end # Returns the signum of this Permutation instance. # It's -1 if this permutation is odd and 1 if it's # an even permutation. # # A permutation is odd if it can be represented by an odd number of # transpositions (cycles of length 2), or even if it can be represented of # an even number of transpositions. def signum s = 1 cycles.each do |c| c.size % 2 == 0 and s *= -1 end s end alias sgn signum # Returns true if this permutation is even, false otherwise. def even? signum == 1 end # Returns true if this permutation is odd, false otherwise. def odd? signum == -1 end private @@factorial_cache = {} def factorial(n) f = @@factorial_cache[n] and return f f = 1 for i in 2..n do f *= i end @@factorial_cache[n] = f end def rank_indices(p) result = 0 for i in 0...size result += p[i] * factorial(size - i - 1) for j in (i + 1)...size p[j] -= 1 if p[j] > p[i] end end result end def unrank_indices(m) result = Array.new(size, 0) for i in 0...size f = factorial(i) x = m % (f * (i + 1)) m -= x x /= f result[size - i - 1] = x x -= 1 for j in (size - i)...size result[j] += 1 if result[j] > x end end result end end --- NEW FILE: fragment.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/analysis/tags' require 'bio/util/restriction_enzyme/analysis/cut_ranges' require 'bio/util/restriction_enzyme/analysis/horizontal_cut_range' require 'bio' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/fragment.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: fragment.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/fragment.rb - =end class Fragment attr_reader :size # attr_reader :tags def initialize( primary_bin, complement_bin ) # @tags = [] @primary_bin = primary_bin @complement_bin = complement_bin end # def add_tag( index, info=nil ) # @tags[index] = info # end DisplayFragment = Struct.new(:primary, :complement) def for_display(p_str=nil, c_str=nil) df = DisplayFragment.new df.primary = '' df.complement = '' both_bins = (@primary_bin + @complement_bin).sort.uniq both_bins.each do |item| @primary_bin.include?(item) ? df.primary << p_str[item] : df.primary << ' ' @complement_bin.include?(item) ? df.complement << c_str[item] : df.complement << ' ' end df end end end end --- NEW FILE: horizontal_cut_range.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/analysis/cut_range' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/horizontal_cut_range.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: horizontal_cut_range.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/horizontal_cut_range.rb - =end class HorizontalCutRange < CutRange attr_reader :p_cut_left, :p_cut_right attr_reader :c_cut_left, :c_cut_right attr_reader :min, :max attr_reader :hcuts def initialize( left, right=left ) raise "left > right" if left > right # The 'range' here is actually off by one on the left # side in relation to a normal CutRange, so using the normal # variables from CutRange would result in unpredictable # behavior. @p_cut_left = nil @p_cut_right = nil @c_cut_left = nil @c_cut_right = nil @min = nil @max = nil @range = nil @hcuts = (left..right) end def include?(i) @range.include?(i) end end end end --- NEW FILE: cut_ranges.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/cut_ranges.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_ranges.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/cut_ranges.rb - =end class CutRanges < Array def min; self.collect{|a| a.min}.flatten.sort.first; end def max; self.collect{|a| a.max}.flatten.sort.last; end def include?(i); self.collect{|a| a.include?(i)}.include?(true); end end end end --- NEW FILE: fragments.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/fragments.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: fragments.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/fragments.rb - =end class Fragments < Array attr_accessor :primary attr_accessor :complement def initialize(primary, complement) @primary = primary @complement = complement end DisplayFragment = Struct.new(:primary, :complement) def for_display(p_str=nil, c_str=nil) p_str ||= @primary c_str ||= @complement pretty_fragments = [] self.each { |fragment| pretty_fragments << fragment.for_display(p_str, c_str) } pretty_fragments end end end end --- NEW FILE: sequence_range.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/analysis/tags' require 'bio/util/restriction_enzyme/analysis/cut_ranges' require 'bio/util/restriction_enzyme/analysis/horizontal_cut_range' require 'bio/util/restriction_enzyme/analysis/vertical_cut_range' require 'bio/util/restriction_enzyme/analysis/calculated_cuts' require 'bio/util/restriction_enzyme/analysis/fragments' require 'bio/util/restriction_enzyme/analysis/fragment' require 'bio' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/sequence_range.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: sequence_range.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/sequence_range.rb - =end class SequenceRange attr_reader :p_left, :p_right attr_reader :c_left, :c_right attr_reader :left, :right attr_reader :size attr_reader :tags attr_reader :cut_ranges def initialize( p_left = nil, p_right = nil, c_left = nil, c_right = nil ) @__fragments_current = false raise ArgumentError if p_left == nil and c_left == nil raise ArgumentError if p_right == nil and c_right == nil (raise ArgumentError unless p_left <= p_right) unless p_left == nil or p_right == nil (raise ArgumentError unless c_left <= c_right) unless c_left == nil or c_right == nil @p_left = p_left @p_right = p_right @c_left = c_left @c_right = c_right tmp = [p_left, c_left] tmp.delete(nil) @left = tmp.sort.first tmp = [p_right, c_right] tmp.delete(nil) @right = tmp.sort.last @size = (@right - @left) + 1 unless @left == nil or @right == nil @tags = Tags.new @cut_ranges = CutRanges.new end =begin Special Case: Horizontal cuts at beginning or end of strand =end Bin = Struct.new(:c, :p) def fragments return @__fragments if @__fragments_current == true @__fragments_current = true cc = CalculatedCuts.new(@size) cc.add_cuts_from_cut_ranges(@cut_ranges) cc.remove_incomplete_cuts p_cut = cc.vc_primary c_cut = cc.vc_complement h = cc.hc_between_strands if @circular # NOTE # if it's circular we should start at the beginning of a cut for orientation # scan for it, hack off the first set of hcuts and move them to the back else # last_index = @size - 1 p_cut.unshift(-1) unless p_cut.include?(-1) # p_cut.push(last_index) unless p_cut.include?(last_index) c_cut.unshift(-1) unless c_cut.include?(-1) # c_cut.push(last_index) unless c_cut.include?(last_index) end if @circular largest_bin = 0 else largest_bin = -1 end p_bin = largest_bin c_bin = largest_bin bins = { largest_bin => Bin.new } # bin_id, bin bins[ largest_bin ].p = [] bins[ largest_bin ].c = [] x = lambda do |bin_id| largest_bin += 1 bins[ bin_id ] = Bin.new bins[ bin_id ].p = [] bins[ bin_id ].c = [] end -1.upto(@size-1) do |idx| # if bins are out of sync but the strands are attached if p_bin != c_bin and h.include?(idx) == false bins.delete( [p_bin, c_bin].sort.last ) p_bin = c_bin = [p_bin, c_bin].sort.first largest_bin -= 1 end bins[ p_bin ].p << idx bins[ c_bin ].c << idx if p_cut.include? idx p_bin = largest_bin + 1 x.call(p_bin) end if c_cut.include? idx c_bin = largest_bin + 1 x.call(c_bin) end end # Easy way to indicate the start of a strand just in case # there is a horizontal cut at position 0 bins.delete(-1) unless @circular # require 'pp' # pp bins #NOTE str1 = nil str2 = nil num_txt_repeat = lambda { num_txt = '0123456789'; (num_txt * ( @size / num_txt.size.to_f ).ceil)[0.. at size-1] } (str1 == nil) ? a = num_txt_repeat.call : a = str1.dup (str2 == nil) ? b = num_txt_repeat.call : b = str2.dup fragments = Fragments.new(a,b) bins.sort.each do |k, bin| fragment = Fragment.new( bin.p, bin.c ) @tags.each { |k,v| fragment.add_tag(k,v) if (ts.left..ts.right).include?(k) } fragments << fragment end #pp fragments.for_display # pp fragments # exit @__fragments = fragments return fragments end def add_tag( index, info=nil ) @__fragments_current = false raise IndexError unless index >= @left and index <= @right @tags[index] = info end # Cut occurs immediately after the index supplied. # For example, a cut at '0' would mean a cut occurs between 0 and 1. def add_cut_range( p_cut_left=nil, p_cut_right=nil, c_cut_left=nil, c_cut_right=nil ) @__fragments_current = false if p_cut_left.kind_of? CutRange @cut_ranges << p_cut_left else (raise IndexError unless p_cut_left >= @left and p_cut_left <= @right) unless p_cut_left == nil (raise IndexError unless p_cut_right >= @left and p_cut_right <= @right) unless p_cut_right == nil (raise IndexError unless c_cut_left >= @left and c_cut_left <= @right) unless c_cut_left == nil (raise IndexError unless c_cut_right >= @left and c_cut_right <= @right) unless c_cut_right == nil @cut_ranges << VerticalCutRange.new( p_cut_left, p_cut_right, c_cut_left, c_cut_right ) end end def add_cut_ranges(*cut_ranges) cut_ranges.flatten! cut_ranges.each do |cut_range| raise TypeError, "Not of type CutRange" unless cut_range.kind_of? CutRange self.add_cut_range( cut_range ) end end def add_horizontal_cut_range( left, right=left ) @__fragments_current = false @cut_ranges << HorizontalCutRange.new( left, right ) end end end end --- NEW FILE: calculated_cuts.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/cut_symbol' require 'bio/util/restriction_enzyme/string_formatting' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/calculated_cuts.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: calculated_cuts.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/calculated_cuts.rb - 1 2 3 4 5 6 7 G A|T T A C A +-----+ C T A A T|G T 1 2 3 4 5 6 7 Primary cut = 2 Complement cut = 5 Horizontal cuts = 3, 4, 5 =end class CalculatedCuts include CutSymbol include StringFormatting # Vertical cuts on the primary strand attr_reader :vc_primary # Vertical cuts on the complement strand attr_reader :vc_complement # Horizontal cuts attr_reader :hc_between_strands # Set to +true+ if the fragment CalculatedCuts is working on is circular attr_accessor :circular def initialize(size=nil, circular=false) @size = size @circular = circular @vc_primary = [] @vc_complement = [] @hc_between_strands = [] end def add_cuts_from_cut_ranges(cut_ranges) @strands_for_display_current = false cut_ranges.each do |cut_range| @vc_primary += [cut_range.p_cut_left, cut_range.p_cut_right] @vc_complement += [cut_range.c_cut_left, cut_range.c_cut_right] if cut_range.class == VerticalCutRange ( cut_range.min + 1 ).upto( cut_range.max ){|i| @hc_between_strands << i} if cut_range.min < cut_range.max elsif cut_range.class == HorizontalCutRange ( cut_range.hcuts.first ).upto( cut_range.hcuts.last ){|i| @hc_between_strands << i} end end clean_all end def remove_incomplete_cuts(size=nil) @strands_for_display_current = false @size = size if size raise IndexError, "Size of the strand must be provided here or during initalization." if !@size.kind_of?(Fixnum) and not @circular vcuts = (@vc_primary + @vc_complement).uniq.sort hcuts = @hc_between_strands last_index = @size - 1 good_hcuts = [] potential_hcuts = [] if @circular # NOTE # if it's circular we should start at the beginning of a cut for orientation # scan for it, hack off the first set of hcuts and move them to the back else vcuts.unshift(-1) unless vcuts.include?(-1) vcuts.push(last_index) unless vcuts.include?(last_index) end hcuts.each do |hcut| raise IndexError if hcut < -1 or hcut > last_index # skipped a nucleotide potential_hcuts.clear if !potential_hcuts.empty? and (hcut - potential_hcuts.last).abs > 1 if potential_hcuts.empty? if vcuts.include?( hcut ) and vcuts.include?( hcut - 1 ) good_hcuts += [hcut] elsif vcuts.include?( hcut - 1 ) potential_hcuts << hcut end else if vcuts.include?( hcut ) good_hcuts += potential_hcuts + [hcut] potential_hcuts.clear else potential_hcuts << hcut end end end check_vc = lambda do |vertical_cuts, opposing_vcuts| # opposing_vcuts is here only to check for blunt cuts, so there shouldn't # be any out-of-order problems with this good_vc = [] vertical_cuts.each { |vc| good_vc << vc if good_hcuts.include?( vc ) or good_hcuts.include?( vc + 1 ) or opposing_vcuts.include?( vc ) } good_vc end @vc_primary = check_vc.call(@vc_primary, @vc_complement) @vc_complement = check_vc.call(@vc_complement, @vc_primary) @hc_between_strands = good_hcuts clean_all end def strands_for_display(str1 = nil, str2 = nil, vcp=nil, vcc=nil, hc=nil) return @strands_for_display if @strands_for_display_current vcs = '|' hcs = '-' vhcs = '+' num_txt_repeat = lambda { num_txt = '0123456789'; (num_txt * ( @size / num_txt.size.to_f ).ceil)[0.. at size-1] } (str1 == nil) ? a = num_txt_repeat.call : a = str1.dup (str2 == nil) ? b = num_txt_repeat.call : b = str2.dup vcp = @vc_primary if vcp==nil vcc = @vc_complement if vcc==nil hc = @hc_between_strands if hc==nil vcuts = (vcp + vcc).uniq.sort vcp.reverse.each { |c| a.insert(c+1, vcs) } vcc.reverse.each { |c| b.insert(c+1, vcs) } between = ' ' * @size hc.each {|hcut| between[hcut,1] = hcs } s_a = add_spacing(a, vcs) s_b = add_spacing(b, vcs) s_bet = add_spacing(between) # NOTE watch this for circular i = 0 0.upto( s_a.size-1 ) do if (s_a[i,1] == vcs) or (s_b[i,1] == vcs) s_bet[i] = vhcs elsif i != 0 and s_bet[i-1,1] == hcs and s_bet[i+1,1] == hcs s_bet[i] = hcs end i+=1 end @strands_for_display_current = true @strands_for_display = [s_a, s_bet, s_b] end =begin def vc_primary_add(c) @vc_primary << c @current = false end def vc_complement_add(c) @vc_complement << c @current = false end def hc_between_strands_add(c) @hc_between_strands << c @current = false end =end ######### protected ######### def clean_all [@vc_primary, @vc_complement, @hc_between_strands].collect { |a| a.delete(nil); a.uniq!; a.sort! } end end end end From trevor at pub.open-bio.org Wed Feb 1 02:27:28 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:27:28 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme README, NONE, 1.1 analysis.rb, NONE, 1.1 cut_symbol.rb, NONE, 1.1 double_stranded.rb, NONE, 1.1 enzymes.yaml, NONE, 1.1 integer.rb, NONE, 1.1 single_strand.rb, NONE, 1.1 single_strand_complement.rb, NONE, 1.1 string_formatting.rb, NONE, 1.1 Message-ID: <200602010734.k117YDVL028860@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv28844 Added Files: README analysis.rb cut_symbol.rb double_stranded.rb enzymes.yaml integer.rb single_strand.rb single_strand_complement.rb string_formatting.rb Log Message: Bio::RestrictionEnzyme --- NEW FILE: integer.rb --- # # bio/util/restrction_enzyme/integer.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: integer.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restrction_enzyme/integer.rb - =end class Integer def negative? self < 0 end end --- NEW FILE: string_formatting.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/cut_symbol' module Bio; end class Bio::RestrictionEnzyme # # bio/util/restriction_enzyme/string_formatting.rb - Useful functions for string manipulation # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: string_formatting.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/string_formatting.rb - Useful functions for string manipulation =end module StringFormatting include CutSymbol extend CutSymbol # Return the sequence with spacing for alignment. Does not add whitespace # around cut symbols. # # Example: # pattern = 'n^ng^arraxt^n' # add_spacing( pattern ) # # Returns: # "n^n g^a r r a x t^n" # def add_spacing( seq, cs = cut_symbol ) str = '' flag = false seq.each_byte do |c| c = c.chr if c == cs str += c flag = false elsif flag str += ' ' + c else str += c flag = true end end str end # Remove extraneous nucleic acid wildcards ('n' padding) from the # left and right sides def strip_padding( s ) if s[0].chr == 'n' s =~ %r{(n+)(.+)} s = $2 end if s[-1].chr == 'n' s =~ %r{(.+?)(n+)$} s = $1 end s end # Remove extraneous nucleic acid wildcards ('n' padding) from the # left and right sides and remove cut symbols def strip_cuts_and_padding( s ) strip_padding( s.tr(cut_symbol, '') ) end # Return the 'n' padding on the left side of the strand def left_padding( s ) s =~ %r{^n+} ret = $& ret ? ret : '' # Don't pass nil values end # Return the 'n' padding on the right side of the strand def right_padding( s ) s =~ %r{n+$} ret = $& ret ? ret : '' # Don't pass nil values end end end --- NEW FILE: single_strand.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation' require 'bio/util/restriction_enzyme/cut_symbol' require 'bio/util/restriction_enzyme/string_formatting' require 'bio/sequence' class Bio::RestrictionEnzyme # # bio/util/restriction_enzyme/single_strand.rb - Single strand of a restriction enzyme sequence # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: single_strand.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/single_strand.rb - Single strand of a restriction enzyme sequence A single strand of restriction enzyme sequence pattern with a 5' to 3' orientation. DoubleStranded puts the SingleStrand and SingleStrandComplement together to create the sequence pattern with cuts on both strands. =end class SingleStrand < Bio::Sequence::NA include CutSymbol include StringFormatting # The cut locations in enzyme notation. Contains a # CutLocationsInEnzymeNotation object. attr_reader :cut_locations_in_enzyme_notation # The cut locations transformed from enzyme index notation to 0-based # array index notation. Contains an Array attr_reader :cut_locations # Orientation of the strand, 5' to 3' def orientation; [5,3]; end # +sequence+:: The enzyme sequence. # +c+:: Cut locations in enzyme notation. See CutLocationsInEnzymeNotation. # # * +sequence+ is required, +c+ is optional # * You cannot provide a sequence with cut symbols and provide cut locations. # * If +c+ is omitted, +input_pattern+ must contain a cut symbol. # * +sequence+ cannot contain adjacent cut symbols. # * +c+ is in enzyme index notation and therefore cannot contain a 0. # # +sequence+ must be a kind of: # * String # * Bio::Sequence::NA # * Bio::RestrictionEnzyme::SingleStrand # # +c+ must be a kind of: # * Integer, one or more # * Array # * CutLocationsInEnzymeNotation # def initialize( sequence, *c ) c.flatten! # if an array was supplied as an argument validate_args(sequence, c) sequence.downcase! if sequence =~ re_cut_symbol @cut_locations_in_enzyme_notation = CutLocationsInEnzymeNotation.new( strip_padding(sequence) ) else @cut_locations_in_enzyme_notation = CutLocationsInEnzymeNotation.new( c ) end @stripped = Bio::Sequence::NA.new( strip_cuts_and_padding( sequence ) ) super( pattern ) @cut_locations = @cut_locations_in_enzyme_notation.to_array_index end # Returns true if this enzyme is palindromic with its reverse complement. # Does not report if the +cut_locations+ are palindromic or not. # # Examples: # * This would be palindromic: # 5' - ATGCAT - 3' # TACGTA # # * This would not be palindromic: # 5' - ATGCGTA - 3' # TACGCAT # def palindromic? @stripped.reverse_complement == @stripped end # Pattern with no cut symbols and no 'n' padding. # * SingleStrand.new('garraxt', [-2, 1, 7]).stripped # "garraxt" attr_reader :stripped # The sequence with 'n' padding and cut symbols. # * SingleStrand.new('garraxt', [-2, 1, 7]).with_cut_symbols # => "n^ng^arraxt^n" def with_cut_symbols s = pattern @cut_locations_in_enzyme_notation.to_array_index.sort.reverse.each { |c| s.insert(c+1, cut_symbol) } s end # The sequence with 'n' padding on the left and right for cuts larger than the sequence. # * SingleStrand.new('garraxt', [-2, 1, 7]).pattern # => "nngarraxtn" def pattern return stripped if @cut_locations_in_enzyme_notation.min == nil left = (@cut_locations_in_enzyme_notation.min.negative? ? 'n' * @cut_locations_in_enzyme_notation.min.abs : '') # Add one more 'n' if a cut is at the last position right = (@cut_locations_in_enzyme_notation.max >= @stripped.length ? 'n' * (@cut_locations_in_enzyme_notation.max - @stripped.length + 1) : '') [left, stripped, right].to_s end # The sequence with 'n' pads, cut symbols, and spacing for alignment. # * SingleStrand.new('garraxt', [-2, 1, 7]).with_spaces # => "n^n g^a r r a x t^n" def with_spaces add_spacing( with_cut_symbols ) end # NOTE: BEING WORKED ON, BUG EXISTS IN Bio::NucleicAcid =begin to_re - important example z = [agc] z must match [agcz] not just [agc] =end ######### protected ######### def validate_args( input_pattern, input_cut_locations ) unless input_pattern.kind_of?(String) err = "input_pattern is not a String, Bio::Sequence::NA, or Bio::RestrictionEnzyme::SingleStrand::Sequence object\n" err += "pattern: #{input_pattern}\n" err += "class: #{input_pattern.class}" raise ArgumentError, err end if ( input_pattern =~ re_cut_symbol ) and !input_cut_locations.empty? err = "Cut symbol found in sequence, but cut locations were also supplied. Ambiguous.\n" err += "pattern: #{input_pattern}\n" err += "symbol: #{cut_symbol}\n" err += "locations: #{input_cut_locations.inspect}" raise ArgumentError, err end input_pattern.each_byte do |c| c = c.chr.downcase unless Bio::NucleicAcid::NAMES.has_key?(c) or c == 'x' or c == 'X' or c == cut_symbol err = "Invalid character in pattern.\n" err += "Not a nucleotide or representation of possible nucleotides. See Bio::NucleicAcid::NAMES for more information.\n" err += "char: #{c}\n" err += "input_pattern: #{input_pattern}" raise ArgumentError, err end end end # Tadayoshi Funaba's method as discussed in Programming Ruby 2ed, p390 def self.once(*ids) for id in ids module_eval <<-"end;" alias_method :__#{id.to_i}__, :#{id.to_s} private :__#{id.to_i}__ def #{id.to_s}(*args, &block) (@__#{id.to_i}__ ||= [__#{id.to_i}__(*args, &block)])[0] end end; end end once :pattern, :with_cut_symbols, :with_spaces, :to_re end end --- NEW FILE: README --- todo --- NEW FILE: enzymes.yaml --- --- TspRI: :c4: "0" :c1: "7" :len: "5" :c2: "-3" :c3: "0" :pattern: CASTG :name: TspRI :blunt: "0" :ncuts: "2" MvnI: :c4: "0" :c1: "2" :len: "4" :c2: "2" :c3: "0" :pattern: CGCG :name: MvnI [...6692 lines suppressed...] BseMI: :c4: "0" :c1: "8" :len: "6" :c2: "6" :c3: "0" :pattern: GCAATG :name: BseMI :blunt: "0" :ncuts: "2" EcoRII: :c4: "0" :c1: "-1" :len: "5" :c2: "5" :c3: "0" :pattern: CCWGG :name: EcoRII :blunt: "0" :ncuts: "2" --- NEW FILE: single_strand_complement.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/single_strand' module Bio; end class Bio::RestrictionEnzyme # # bio/util/restriction_enzyme/single_strand_complement.rb - Single strand restriction enzyme sequence in complement orientation # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: single_strand_complement.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/single_strand_complement.rb - Single strand restriction enzyme sequence in complement orientation A single strand of restriction enzyme sequence pattern with a 3' to 5' orientation. =end class SingleStrandComplement < SingleStrand # Orientation of the strand, 3' to 5' def orientation; [3, 5]; end end end --- NEW FILE: analysis.rb --- #if RUBY_VERSION[0..2] == '1.9' or RUBY_VERSION == '2.0' # err = "This class makes use of 'include' on ranges quite a bit. Possibly unstable in development Ruby. 2005/12/20." # err += "http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/167182?167051-169742" # raise err #end require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio' class Bio::Sequence::NA def cut_with_enzyme(*args) Bio::RestrictionEnzyme::Analysis.cut(self, *args) end alias cut_with_enzymes cut_with_enzyme end require 'pp' require 'bio/util/restriction_enzyme' require 'bio/util/restriction_enzyme/analysis/sequence_range.rb' require 'bio/util/restriction_enzyme/analysis/permutation.rb' class Bio::RestrictionEnzyme # # bio/util/restrction_enzyme/analysis.rb - Does the work of fragmenting the DNA from the enzymes # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: analysis.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restrction_enzyme/analysis.rb - Does the work of fragmenting the DNA from the enzymes =end class Analysis def self.cut( sequence, *args ) self.new.cut( sequence, *args ) end def self.cut_without_permutations( sequence, *args ) self.new.cut_without_permutations( sequence, *args ) end def self.cut_and_return_by_permutations( sequence, *args ) self.new.cut_and_return_by_permutations( sequence, *args ) end def cut_without_permutations( sequence, *args ) sequence = Bio::Sequence::NA.new( sequence ) enzyme_actions = create_enzyme_actions( sequence, *args ) sr_with_cuts = SequenceRange.new( 0, 0, sequence.size-1, sequence.size-1 ) enzyme_actions.each do |id, enzyme_action| enzyme_action.cut_ranges.each do |cut_range| sr_with_cuts.add_cut_range(cut_range) end end sr_with_cuts.fragments.primary = sequence sr_with_cuts.fragments.complement = sequence.forward_complement tmp = {} tmp[0] = sr_with_cuts unique_fragments_for_display( tmp ) end def cut_and_return_by_permutations( sequence, *args ) sequence = Bio::Sequence::NA.new( sequence ) enzyme_actions = create_enzyme_actions( sequence, *args ) permutations = Permutation.new(enzyme_actions.size).map { |p| p.value } # Indexed by permutation. hash_of_sequence_ranges_with_cuts = {} permutations.each do |permutation| previous_cut_ranges = [] sr_with_cuts = SequenceRange.new( 0, 0, sequence.size-1, sequence.size-1 ) permutation.each do |id| enzyme_action = enzyme_actions[id] # conflict is false if the current enzyme action may cut in it's range. # conflict is true if it cannot do to a previous enzyme action making # a cut where this enzyme action needs a whole recognition site. conflict = false # If current size of enzyme_action overlaps with previous cut_range, don't cut # note that the enzyme action may fall in the middle of a previous enzyme action # so all cut locations must be checked that would fall underneath. previous_cut_ranges.each do |cut_range| next unless cut_range.class == VerticalCutRange # we aren't concerned with horizontal cuts previous_cut_left = cut_range.range.first previous_cut_right = cut_range.range.last =begin puts "--- #{permutation.inspect} ---" puts "Previous cut left: #{previous_cut_left}" puts "EA.left #{enzyme_action.left}" puts "Previous cut right: #{previous_cut_right}" puts "EA.right: #{enzyme_action.right}" =end # Keep in mind: # * The cut location is to the immediate right of the base located at the index. # ex: at^gc -- the cut location is at index 1 # * The enzyme action location is located at the base of the index. # ex: atgc -- 0 => 'a', 1 => 't', 2 => 'g', 3 => 'c' if (enzyme_action.right <= previous_cut_left) or (enzyme_action.left > previous_cut_right) or (enzyme_action.left > previous_cut_left and enzyme_action.right <= previous_cut_right) # in between cuts # no conflict #puts "no conflict" else conflict = true #puts "conflict" end end next if conflict == true enzyme_action.cut_ranges.each { |cut_range| sr_with_cuts.add_cut_range(cut_range) } previous_cut_ranges += enzyme_action.cut_ranges end hash_of_sequence_ranges_with_cuts[permutation] = sr_with_cuts end hash_of_sequence_ranges_with_cuts.each do |permutation, sr_with_cuts| sr_with_cuts.fragments.primary = sequence sr_with_cuts.fragments.complement = sequence.forward_complement end #pp hash_of_sequence_ranges_with_cuts hash_of_sequence_ranges_with_cuts end def cut( sequence, *args ) hash_of_sequence_ranges_with_cuts = cut_and_return_by_permutations( sequence, *args ) unique_fragments_for_display( hash_of_sequence_ranges_with_cuts ) end ######### protected ######### UniqueFragment = Struct.new(:primary, :complement) class UniqueFragments < Array def primary tmp = [] self.each { |uf| tmp << uf.primary } tmp.sort.map { |e| e.tr(' ', '') } end def complement tmp = [] self.each { |uf| tmp << uf.complement } tmp.sort.map { |e| e.tr(' ', '') } end end def unique_fragments_for_display( hash_of_sequence_ranges_with_cuts ) uf_ary = UniqueFragments.new hash_of_sequence_ranges_with_cuts.each do |permutation, sr_with_cuts| sr_with_cuts.fragments.for_display.each do |fragment| uf = UniqueFragment.new uf.primary = fragment.primary uf.complement = fragment.complement duplicate = false uf_ary.each do |element| if (uf.primary == element.primary) and (uf.complement == element.complement) duplicate = true break end end uf_ary << uf unless duplicate end end uf_ary end =begin Strand = Struct.new(:primary, :complement, :p_left, :p_right, :c_left, :c_right) def ts_fragments_to_strands( sequence, fragments ) sequence = Bio::Sequence::NA.new( sequence ) strands = [] fragments.each do |f| p = sequence[f.p_left..f.p_right] c = sequence[f.c_left..f.c_right] strands << Strand.new(p, c, f.p_left, f.p_right, f.c_left, f.c_right) end strands end =end # Defines a single enzyme action, in this case being a range that correlates # to the DNA sequence that may contain it's own internal cuts. class EnzymeAction < SequenceRange end # Creates an array of EnzymeActions based on the DNA sequence and supplied enzymes. # # +sequence+:: The string of DNA to match the enzyme recognition sites against # +args+:: The enzymes to use. def create_enzyme_actions( sequence, *args ) id = 0 enzyme_actions = {} args.each do |enzyme| enzyme = Bio::RestrictionEnzyme.new(enzyme) unless enzyme.class == Bio::RestrictionEnzyme::DoubleStranded find_match_locations( sequence, enzyme.primary.to_re ).each do |offset| enzyme_actions[id] = enzyme_to_enzyme_action( enzyme, offset ) id += 1 end end enzyme_actions end # Returns the offsets of the match of a RegExp to a string. # # +string+:: The string to scan. # +re+:: A regexp to use. def find_match_locations( string, re ) md = string.match( re ) locations = [] location = -1 while md location += md.pre_match.size + 1 locations << location # md[0] is the same as $&, or "the match" itself md = (md[0][1..-1] + md.post_match).match( re ) end locations end # Takes a RestrictionEnzyme and a numerical offset to the sequence and # returns an EnzymeAction # # +enzyme+:: RestrictionEnzyme # +offset+:: Numerical offset of where the enzyme action occurs on the seqeunce def enzyme_to_enzyme_action( enzyme, offset ) enzyme_action = EnzymeAction.new(offset, offset + enzyme.primary.size-1, offset, offset + enzyme.complement.size-1) enzyme.cut_locations.each do |cut_pair| p = cut_pair[0] c = cut_pair[1] if c >= p enzyme_action.add_cut_range(offset+p, nil, nil, offset+c) else enzyme_action.add_cut_range(nil, offset+p, offset+c, nil) end end enzyme_action end end end --- NEW FILE: cut_symbol.rb --- module Bio; end class Bio::RestrictionEnzyme # # bio/util/restrction_enzyme/cut_symbol.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_symbol.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restrction_enzyme/cut_symbol.rb - =end module CutSymbol require 'singleton' class CutSymbol__ include Singleton attr_accessor :cut_symbol attr_accessor :escaped_cut_symbol end # NOTE verify this sometime def cut_symbol=(c) CutSymbol__.instance.cut_symbol = c end def cut_symbol CutSymbol__.instance.cut_symbol ||= '^' end def escaped_cut_symbol CutSymbol__.instance.escaped_cut_symbol ||= "\\#{cut_symbol}" # \^ end # Used to check if multiple cut symbols are next to each other def re_cut_symbol_adjacent %r"#{escaped_cut_symbol}{2}" end # A Regexp of the cut_symbol. Convenience method. def re_cut_symbol %r"#{escaped_cut_symbol}" end end end --- NEW FILE: double_stranded.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/db/rebase' require 'bio/util/restriction_enzyme' require 'bio/util/restriction_enzyme/cut_symbol' require 'bio/util/restriction_enzyme/single_strand' require 'bio/util/restriction_enzyme/single_strand_complement' require 'bio/util/restriction_enzyme/double_stranded/aligned_strands' require 'bio/util/restriction_enzyme/double_stranded/cut_locations' require 'bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation' module Bio; end class Bio::RestrictionEnzyme # # bio/util/restriction_enzyme/double_stranded.rb - DoubleStranded restriction enzyme sequence # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: double_stranded.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/double_stranded.rb - DoubleStranded restriction enzyme sequence A pair of +SingleStrand+ and +SingleStrandComplement+ objects with methods to add utility to their relation. == Notes * This is created by Bio::RestrictionEnzyme.new for convenience. * The two strands accessible are +primary+ and +complement+. * SingleStrand methods may be used on DoubleStranded and they will be passed to +primary+. =end class DoubleStranded include CutSymbol extend CutSymbol include StringFormatting extend StringFormatting # The primary strand attr_reader :primary # The complement strand attr_reader :complement # Cut locations in 0-based index format, DoubleStranded::CutLocations object attr_reader :cut_locations # Cut locations in enzyme index notation, DoubleStranded::CutLocationsInEnzymeNotation object attr_reader :cut_locations_in_enzyme_notation # +erp+:: Enzyme or Rebase or Pattern. One of three: The name of an enzyme. A REBASE::EnzymeEntry object. A nucleotide pattern. # +raw_cut_pairs+:: The cut locations in enzyme index notation. # # Enzyme index notation:: 1.._n_, value before 1 is -1 # # Examples of the allowable cut locations for +raw_cut_pairs+ follows. 'p' and # 'c' refer to a cut location on the 'p'rimary and 'c'omplement strands. # # 1, [3,2], [20,22], 57 # p, [p,c], [p, c], p # # Which is the same as: # # 1, (3..2), (20..22), 57 # p, (p..c), (p..c), p # # Examples of partial cuts: # 1, [nil,2], [20,nil], 57 # p, [p, c], [p, c], p # def initialize(erp, *raw_cut_pairs) k = erp.class if k == Bio::REBASE::EnzymeEntry # Passed a Bio::REBASE::EnzymeEntry object unless raw_cut_pairs.empty? err = "A Bio::REBASE::EnzymeEntry object was passed, however the cut locations contained values. Ambiguous or redundant.\n" err += "inspect = #{raw_cut_pairs.inspect}" raise ArgumentError, err end initialize_with_rebase( erp ) elsif erp.kind_of? String # Passed something that could be an enzyme pattern or an anzyme name # Decide if this String is an enzyme name or a pattern if Bio::RestrictionEnzyme.enzyme_name?( erp ) # Check if it's a known name known_enzyme = false known_enzyme = true if Bio::RestrictionEnzyme.rebase[ erp ] # Try harder to find the enzyme unless known_enzyme re = %r"^#{erp}$"i Bio::RestrictionEnzyme.rebase.each { |name, v| (known_enzyme = true; erp = name; break) if name =~ re } end if known_enzyme initialize_with_rebase( Bio::RestrictionEnzyme.rebase[erp] ) else raise IndexError, "No entry found for enzyme named '#{erp}'" end else # Not an enzyme name, so a pattern is assumed if erp =~ re_cut_symbol initialize_with_pattern_and_cut_symbols( erp ) else initialize_with_pattern_and_cut_locations( erp, raw_cut_pairs ) end end elsif k == NilClass err = "Passed a nil value. Perhaps you tried to pass a Bio::REBASE::EnzymeEntry that does not exist?\n" err += "inspect = #{erp.inspect}" raise ArgumentError, err else err = "I don't know what to do with class #{k} for erp.\n" err += "inspect = #{erp.inspect}" raise ArgumentError, err end end # See AlignedStrands.align def aligned_strands AlignedStrands.align(@primary.pattern, @complement.pattern) end # See AlignedStrands.align_with_cuts def aligned_strands_with_cuts AlignedStrands.align_with_cuts(@primary.pattern, @complement.pattern, @primary.cut_locations, @complement.cut_locations) end # Returns +true+ if the cut pattern creates blunt fragments def blunt? as = aligned_strands_with_cuts ary = [as.primary, as.complement] ary.collect! { |seq| seq.split( cut_symbol ) } # convert the cut sections to their lengths ary.each { |i| i.collect! { |c| c.length } } ary[0] == ary[1] end # Returns +true+ if the cut pattern creates sticky fragments def sticky? !blunt? end ######### protected ######### def initialize_with_pattern_and_cut_symbols( s ) p_cl = SingleStrand::CutLocationsInEnzymeNotation.new( strip_padding(s) ) s = Bio::Sequence::NA.new( strip_cuts_and_padding(s) ) # * Reflect cuts that are in enzyme notation # * 0 is not a valid enzyme index, decrement 0 and all negative # c_cl = p_cl.collect { |n| s.length - n }.collect { |n| n <= 0 ? n - 1 : n } #wrong. c_cl = p_cl.collect {|n| (n >= s.length or n < 1) ? ((s.length - n) - 1) : (s.length - n)} create_cut_locations( p_cl.zip(c_cl) ) create_primary_and_complement( s, p_cl, c_cl ) end def initialize_with_pattern_and_cut_locations( s, raw_cl ) create_cut_locations(raw_cl) create_primary_and_complement( Bio::Sequence::NA.new(s), @cut_locations_in_enzyme_notation.primary, @cut_locations_in_enzyme_notation.complement ) end def create_primary_and_complement(primary_seq, p_cuts, c_cuts) @primary = SingleStrand.new( primary_seq, p_cuts ) @complement = SingleStrandComplement.new( primary_seq.forward_complement, c_cuts ) end def create_cut_locations(raw_cl) @cut_locations_in_enzyme_notation = CutLocationsInEnzymeNotation.new( *raw_cl.collect {|cl| CutLocationPairInEnzymeNotation.new(cl)} ) @cut_locations = @cut_locations_in_enzyme_notation.to_array_index end def initialize_with_rebase( e ) p_cl = [e.primary_strand_cut1, e.primary_strand_cut2] c_cl = [e.complementary_strand_cut1, e.complementary_strand_cut2] # If there's no cut in REBASE it's represented as a 0. # 0 is an invalid index, it just means no cut. p_cl.delete(0) c_cl.delete(0) raise IndexError unless p_cl.size == c_cl.size initialize_with_pattern_and_cut_locations( e.pattern, p_cl.zip(c_cl) ) end end end From trevor at pub.open-bio.org Wed Feb 1 02:27:32 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:27:32 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/double_stranded aligned_strands.rb, NONE, 1.1 cut_location_pair.rb, NONE, 1.1 cut_location_pair_in_enzyme_notation.rb, NONE, 1.1 cut_locations.rb, NONE, 1.1 cut_locations_in_enzyme_notation.rb, NONE, 1.1 Message-ID: <200602010734.k117YDVL028880@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/double_stranded In directory pub.open-bio.org:/tmp/cvs-serv28844/double_stranded Added Files: aligned_strands.rb cut_location_pair.rb cut_location_pair_in_enzyme_notation.rb cut_locations.rb cut_locations_in_enzyme_notation.rb Log Message: Bio::RestrictionEnzyme --- NEW FILE: aligned_strands.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/single_strand' require 'bio/util/restriction_enzyme/cut_symbol' require 'bio/util/restriction_enzyme/string_formatting' module Bio; end class Bio::RestrictionEnzyme class DoubleStranded # # bio/util/restriction_enzyme/double_stranded/aligned_strands.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: aligned_strands.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/double_stranded/aligned_strands.rb - Align two SingleStrand::Pattern objects and return a Result object with +primary+ and +complement+ accessors. =end class AlignedStrands extend CutSymbol extend StringFormatting # The object returned for alignments Result = Struct.new(:primary, :complement) # Pad and align two String objects. # # +a+:: First String # +b+:: Second String # # Example invocation: # AlignedStrands.align('nngattacannnnn', 'nnnnnctaatgtnn') # # Example return value: # # # def self.align(a, b) a = a.to_s b = b.to_s validate_input( strip_padding(a), strip_padding(b) ) left = [left_padding(a), left_padding(b)].sort.last right = [right_padding(a), right_padding(b)].sort.last p = left + strip_padding(a) + right c = left + strip_padding(b) + right Result.new(p,c) end # Pad and align two String objects with cut symbols. # # +a+:: First String # +b+:: Second String # +a_cuts+:: First strand cut locations in 0-based index notation # +b_cuts+:: Second strand cut locations in 0-based index notation # # Example invocation: # AlignedStrands.with_cuts('nngattacannnnn', 'nnnnnctaatgtnn', [0, 10, 12], [0, 2, 12]) # # Example return value: # # # # Notes: # * To make room for the cut symbols each nucleotide is spaced out. # * This is meant to be able to handle multiple cuts and completely # unrelated cutsites on the two strands, therefore no biological # shortcuts are made. # def self.align_with_cuts(a,b,a_cuts,b_cuts) a = a.to_s b = b.to_s validate_input( strip_padding(a), strip_padding(b) ) a_left, a_right = left_padding(a), right_padding(a) b_left, b_right = left_padding(b), right_padding(b) left_diff = a_left.length - b_left.length right_diff = a_right.length - b_right.length (right_diff > 0) ? (b_right += 'n' * right_diff) : (a_right += 'n' * right_diff.abs) a_adjust = b_adjust = 0 if left_diff > 0 b_left += 'n' * left_diff b_adjust = left_diff else a_left += 'n' * left_diff.abs a_adjust = left_diff.abs end a = a_left + strip_padding(a) + a_right b = b_left + strip_padding(b) + b_right a_cuts.sort.reverse.each { |c| a.insert(c+1+a_adjust, cut_symbol) } b_cuts.sort.reverse.each { |c| b.insert(c+1+b_adjust, cut_symbol) } Result.new( add_spacing(a), add_spacing(b) ) end ######### protected ######### def self.validate_input(a,b) unless a.size == b.size err = "Result sequences are not the same size. Does not align sequences with differing lengths after strip_padding.\n" err += "#{a.size}, #{a.inspect}\n" err += "#{b.size}, #{b.inspect}" raise ArgumentError, err end end end end end --- NEW FILE: cut_locations.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/double_stranded/cut_location_pair' module Bio; end class Bio::RestrictionEnzyme class DoubleStranded # # bio/util/restriction_enzyme/double_stranded/cut_locations.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_locations.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/double_stranded/cut_locations.rb - =end class CutLocations < Array def initialize(*args) validate_args(args) super(args) end def primary self.collect {|a| a[0]} end def complement self.collect {|a| a[1]} end ######### protected ######### def validate_args(args) args.each do |a| unless a.class == Bio::RestrictionEnzyme::DoubleStranded::CutLocationPair err = "Not a CutLocationPair\n" err += "class: #{a.class}\n" err += "inspect: #{a.inspect}" raise ArgumentError, err end end end end end end --- NEW FILE: cut_locations_in_enzyme_notation.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/double_stranded/cut_locations' require 'bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation' module Bio; end class Bio::RestrictionEnzyme class DoubleStranded # # bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_locations_in_enzyme_notation.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb - =end class CutLocationsInEnzymeNotation < CutLocations def primary_to_array_index helper_for_to_array_index(self.primary) end def complement_to_array_index helper_for_to_array_index(self.complement) end def to_array_index unless self.primary_to_array_index.size == self.complement_to_array_index.size err = "Primary and complement strand cut locations are not available in equal numbers.\n" err += "primary: #{self.primary_to_array_index.inspect}\n" err += "primary.size: #{self.primary_to_array_index.size}\n" err += "complement: #{self.complement_to_array_index.inspect}\n" err += "complement.size: #{self.complement_to_array_index.size}" raise IndexError, err end a = self.primary_to_array_index.zip(self.complement_to_array_index) CutLocations.new( *a.collect {|cl| CutLocationPair.new(cl)} ) end ######### protected ######### def helper_for_to_array_index(a) minimum = (self.primary + self.complement).flatten minimum.delete(nil) minimum = minimum.sort.first return [] if minimum == nil # no elements if minimum.negative? calc = lambda do |n| unless n == nil n -= 1 unless n.negative? n += minimum.abs end n end else calc = lambda do |n| n -= 1 unless n == nil n end end a.collect(&calc) end def validate_args(args) args.each do |a| unless a.class == Bio::RestrictionEnzyme::DoubleStranded::CutLocationPairInEnzymeNotation err = "Not a CutLocationPairInEnzymeNotation\n" err += "class: #{a.class}\n" err += "inspect: #{a.inspect}" raise TypeError, err end end end end end end --- NEW FILE: cut_location_pair_in_enzyme_notation.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/double_stranded/cut_location_pair' require 'bio/util/restriction_enzyme/integer' module Bio; end class Bio::RestrictionEnzyme class DoubleStranded # # bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_location_pair_in_enzyme_notation.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb - See CutLocationPair =end class CutLocationPairInEnzymeNotation < CutLocationPair ######### protected ######### def validate_2( a, b ) if a == 0 raise ArgumentError, "Enzyme index notation only. 0 values are illegal." end if b == 0 raise ArgumentError, "Enzyme index notation only. 0 values are illegal." end if a == nil and b == nil raise ArgumentError, "Neither strand has a cut. Ambiguous." end end end end end --- NEW FILE: cut_location_pair.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/cut_symbol' require 'bio/util/restriction_enzyme/integer' module Bio; end class Bio::RestrictionEnzyme class DoubleStranded # # bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_location_pair.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb - Stores a cut location pair in 0-based index notation Input: +pair+:: May be two values represented as an Array, a Range, or a combination of Integer and nil values. The first value represents a cut on the primary strand, the second represents a cut on the complement strand. Example: clp = CutLocationPair.new(3,2) clp.primary # 3 clp.complement # 2 Notes: * a value of +nil+ is an explicit representation of 'no cut' =end class CutLocationPair < Array attr_reader :primary, :complement def initialize( *pair ) a = b = nil if pair[0].kind_of? Array a,b = init_with_array( pair[0] ) elsif pair[0].kind_of? Range a,b = init_with_array( [pair[0].first, pair[0].last] ) elsif pair[0].kind_of? Integer or pair[0].kind_of? NilClass a,b = init_with_array( [pair[0], pair[1]] ) else raise ArgumentError, "#{pair[0].class} is an invalid class type." end super( [a,b] ) @primary = a @complement = b end ######### protected ######### def init_with_array( ary ) validate_1(ary) a = ary.shift ary.empty? ? b = nil : b = ary.shift validate_2(a,b) [a,b] end def validate_1( ary ) unless ary.size == 1 or ary.size == 2 raise ArgumentError, "Must be one or two elements." end end def validate_2( a, b ) if a != nil and a.negative? raise ArgumentError, "0-based index notation only. Negative values are illegal." end if b != nil and b.negative? raise ArgumentError, "0-based index notation only. Negative values are illegal." end if a == nil and b == nil raise ArgumentError, "Neither strand has a cut. Ambiguous." end end end end end From trevor at pub.open-bio.org Wed Feb 1 02:27:39 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:27:39 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/single_strand cut_locations_in_enzyme_notation.rb, NONE, 1.1 Message-ID: <200602010734.k117YEVL028888@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/single_strand In directory pub.open-bio.org:/tmp/cvs-serv28844/single_strand Added Files: cut_locations_in_enzyme_notation.rb Log Message: Bio::RestrictionEnzyme --- NEW FILE: cut_locations_in_enzyme_notation.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/cut_symbol' require 'bio/util/restriction_enzyme/integer' require 'bio/sequence' module Bio; end class Bio::RestrictionEnzyme class SingleStrand < Bio::Sequence::NA # # bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb - The cut locations, in enzyme notation # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_locations_in_enzyme_notation.rb,v 1.1 2006/02/01 07:34:12 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb - The cut locations, in enzyme notation Stores the cut location in thier enzyme index notation May be initialized with a series of cuts or an enzyme pattern marked with cut symbols. Enzyme index notation:: 1.._n_, value before 1 is -1 Notes: * 0 is invalid as it does not refer to any index * +nil+ is not allowed here as it has no meaning * +nil+ values are kept track of in DoubleStranded::CutLocations as they need a reference point on the correlating strand. +nil+ represents no cut or a partial digestion. =end class CutLocationsInEnzymeNotation < Array include CutSymbol extend CutSymbol attr_reader :min, :max def initialize(*a) a.flatten! # in case an array was passed as an argument if a.size == 1 and a[0].kind_of? String and a[0] =~ re_cut_symbol # Initialize with a cut symbol pattern such as 'n^ng^arraxt^n' s = a[0] a = [] i = -( s.tr(cut_symbol, '') =~ %r{[^n]} ) # First character that's not 'n' s.each_byte { |c| (a << i; next) if c.chr == cut_symbol; i += 1 } a.collect! { |n| n <= 0 ? n-1 : n } # 0 is not a valid enzyme index, decrement from 0 and all negative else a.collect! { |n| n.to_i } # Cut locations are always integers end validate_cut_locations( a ) super(a) self.sort! @min = self.first @max = self.last self.freeze end # Transform the cut locations from enzyme index notation to 0-based index # notation. # # input -> output # [ 1, 2, 3 ] -> [ 0, 1, 2 ] # [ 1, 3, 5 ] -> [ 0, 2, 4 ] # [ -1, 1, 2 ] -> [ 0, 1, 2 ] # [ -2, 1, 3 ] -> [ 0, 2, 4 ] # def to_array_index return [] if @min == nil if @min.negative? calc = lambda do |n| n -= 1 unless n.negative? n + @min.abs end else calc = lambda { |n| n - 1 } end self.collect(&calc) end ######### protected ######### def validate_cut_locations( input_cut_locations ) unless input_cut_locations == input_cut_locations.uniq err = "The cut locations supplied contain duplicate values. Redundant / undefined meaning.\n" err += "cuts: #{input_cut_locations.inspect}\n" err += "unique: #{input_cut_locations.uniq.inspect}" raise ArgumentError, err end if input_cut_locations.include?(nil) err = "The cut locations supplied contained a nil. nil has no index for enzyme notation, alternative meaning is 'no cut'.\n" err += "cuts: #{input_cut_locations.inspect}" raise ArgumentError, err end if input_cut_locations.include?(0) err = "The cut locations supplied contained a '0'. '0' has no index for enzyme notation, alternative meaning is 'no cut'.\n" err += "cuts: #{input_cut_locations.inspect}" raise ArgumentError, err end end end end end From trevor at pub.open-bio.org Wed Feb 1 02:31:24 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:31:24 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme/double_stranded test_aligned_strands.rb, NONE, 1.1 test_cut_location_pair.rb, NONE, 1.1 test_cut_location_pair_in_enzyme_notation.rb, NONE, 1.1 test_cut_locations.rb, NONE, 1.1 test_cut_locations_in_enzyme_notation.rb, NONE, 1.1 Message-ID: <200602010738.k117cEVL028965@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/double_stranded In directory pub.open-bio.org:/tmp/cvs-serv28943/double_stranded Added Files: test_aligned_strands.rb test_cut_location_pair.rb test_cut_location_pair_in_enzyme_notation.rb test_cut_locations.rb test_cut_locations_in_enzyme_notation.rb Log Message: Bio::RestrictionEnzyme tests --- NEW FILE: test_cut_locations_in_enzyme_notation.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation' module Bio class TestDoubleStrandedCutLocationsInEnzymeNotation < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPairInEnzymeNotation @tt = Bio::RestrictionEnzyme::DoubleStranded::CutLocationsInEnzymeNotation @obj_1 = @t.new([3,5]) @obj_2 = @t.new(3, 5) @obj_3 = @t.new((3..5)) @obj_4 = @t.new(-3..5) @obj_5 = @t.new(3) @obj_6 = @t.new(nil,3) @obj_7 = @t.new(3,nil) @obj_8 = @t.new(-8, -7) @locations = @tt.new(@obj_1, @obj_2, @obj_3, @obj_4, @obj_5, @obj_6, @obj_7, @obj_8) @loc_2 = @tt.new(@t.new(-2,-2), @t.new(1,1)) @loc_3 = @tt.new(@t.new(1,2)) end def test_contents assert_equal([3,5], @locations[0]) assert_equal([3,nil], @locations[-2]) end def test_primary assert_equal([3, 3, 3, -3, 3, nil, 3, -8], @locations.primary) end def test_complement assert_equal([5, 5, 5, 5, nil, 3, nil, -7], @locations.complement) end def test_primary_to_array_index assert_equal([10, 10, 10, 5, 10, nil, 10, 0], @locations.primary_to_array_index) assert_equal([0,2], @loc_2.primary_to_array_index) assert_equal([0], @loc_3.primary_to_array_index) end def test_primary_to_array_index_class assert_equal(Array, @locations.primary_to_array_index.class) assert_equal(Array, @loc_2.primary_to_array_index.class) end def test_complement_to_array_index assert_equal([12, 12, 12, 12, nil, 10, nil, 1], @locations.complement_to_array_index) assert_equal([0,2], @loc_2.complement_to_array_index) assert_equal([1], @loc_3.complement_to_array_index) end def test_complement_to_array_index_class assert_equal(Array, @locations.complement_to_array_index.class) assert_equal(Array, @loc_2.complement_to_array_index.class) end def test_to_array_index assert_equal( [ [10, 12], [10, 12], [10, 12], [5, 12], [10, nil], [nil, 10], [10, nil], [0, 1] ], @locations.to_array_index) assert_equal( [ [0, 0], [2, 2], ], @loc_2.to_array_index) assert_equal([[0,1]], @loc_3.to_array_index) end def test_to_array_index_class assert_equal(Bio::RestrictionEnzyme::DoubleStranded::CutLocations, @locations.to_array_index.class) assert_equal(Bio::RestrictionEnzyme::DoubleStranded::CutLocations, @loc_2.to_array_index.class) end end end --- NEW FILE: test_aligned_strands.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/double_stranded/aligned_strands' require 'bio/util/restriction_enzyme/double_stranded' module Bio class TestDoubleStrandedAlignedStrands < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::DoubleStranded::AlignedStrands @s = Bio::Sequence::NA @ds = Bio::RestrictionEnzyme::DoubleStranded @s_1 = @s.new('gattaca') @s_2 = @s_1.forward_complement @s_3 = @s.new('tttttttnnn') @s_4 = @s.new('nnnaaaaaaa') @ds_1 = @ds.new('nnnn^ngattacann^nn^n') @obj_1 = @t.align(@s_1, @s_2) @obj_2 = @t.align(@s_1, @s_3) @obj_3 = @t.align(@s_1, @s_4) @obj_4 = @t.align(@s_3, @s_4) @obj_5 = @t.align(@ds_1.primary, @ds_1.complement) @obj_8 = @t.align_with_cuts(@ds_1.primary, @ds_1.complement, @ds_1.primary.cut_locations, @ds_1.complement.cut_locations) @obj_6 = @t.align_with_cuts(@s_1, @s_2, [1,2], [3,4]) @obj_7 = @t.align_with_cuts(@s_3, @s_4, [1,2], [3,4]) end def test_ds assert_equal('nngattacannnnn', @ds_1.primary) assert_equal('nnnnnctaatgtnn', @ds_1.complement) assert_equal( 'n^ngattacann^nn^n', @ds_1.primary.with_cut_symbols) assert_equal('n^nn^nnctaatgtn^n' , @ds_1.complement.with_cut_symbols) assert_equal([0, 10, 12], @ds_1.primary.cut_locations) assert_equal([0, 2, 12], @ds_1.complement.cut_locations) end def test_align assert_equal('gattaca', @obj_1.primary) assert_equal('ctaatgt', @obj_1.complement) assert_equal('gattacannn', @obj_2.primary) assert_equal('tttttttnnn', @obj_2.complement) assert_equal('nnngattaca', @obj_3.primary) assert_equal('nnnaaaaaaa', @obj_3.complement) assert_equal('nnntttttttnnn', @obj_4.primary) assert_equal('nnnaaaaaaannn', @obj_4.complement) assert_equal('nnnnngattacannnnn', @obj_5.primary) assert_equal('nnnnnctaatgtnnnnn', @obj_5.complement) end def test_align_with_cuts assert_equal('g a^t^t a c a', @obj_6.primary) assert_equal('c t a a^t^g t', @obj_6.complement) # Looks incorrect at first, but this is deliberate. # The correct cuts need to be supplied by the user. assert_equal('n n n t t^t^t t t t n n n', @obj_7.primary) assert_equal('n n n a^a^a a a a a n n n', @obj_7.complement) assert_equal('n n n n^n g a t t a c a n n^n n^n', @obj_8.primary) assert_equal('n^n n^n n c t a a t g t n^n n n n', @obj_8.complement) end def test_argument_error assert_raise(ArgumentError) { @t.new('arg', 'agg') } assert_raise(ArgumentError) { @t.new(@s.new('arg'), 'agg') } assert_raise(ArgumentError) { @t.new('arg', @s.new('agg')) } assert_raise(ArgumentError) { @t.new(@s.new('argg'), @s.new('agg')) } end end end --- NEW FILE: test_cut_locations.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/double_stranded/cut_locations' module Bio class TestDoubleStrandedCutLocations < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPair @tt = Bio::RestrictionEnzyme::DoubleStranded::CutLocations @obj_1 = @t.new([3,5]) @obj_2 = @t.new(3, 5) @obj_3 = @t.new((3..5)) @obj_4 = @t.new(3..5) @obj_5 = @t.new(3) @obj_6 = @t.new(nil,3) @obj_7 = @t.new(3,nil) @locations = @tt.new(@obj_1, @obj_2, @obj_3, @obj_4, @obj_5, @obj_6, @obj_7) end def test_contents assert_equal([3,5], @locations[0]) assert_equal([3,nil], @locations[-1]) end def test_primary assert_equal([3, 3, 3, 3, 3, nil, 3], @locations.primary) end def test_complement assert_equal([5, 5, 5, 5, nil, 3, nil], @locations.complement) end end end --- NEW FILE: test_cut_location_pair_in_enzyme_notation.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation' module Bio class TestDoubleStrandedCutLocationPairInEnzymeNotation < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPairInEnzymeNotation @obj_1 = @t.new([3,5]) @obj_2 = @t.new(3, 5) @obj_3 = @t.new((3..5)) @obj_4 = @t.new(-3..5) @obj_5 = @t.new(3) @obj_6 = @t.new(nil,3) @obj_7 = @t.new(3,nil) end def test_contents assert_equal([3,5], @obj_1) assert_equal([3,5], @obj_2) assert_equal([3,5], @obj_3) assert_equal([-3,5], @obj_4) assert_equal([3,nil], @obj_5) assert_equal([nil,3], @obj_6) assert_equal([3,nil], @obj_7) end def test_primary assert_equal(3, @obj_1.primary) assert_equal(3, @obj_2.primary) assert_equal(3, @obj_3.primary) assert_equal(-3, @obj_4.primary) assert_equal(3, @obj_5.primary) assert_equal(nil, @obj_6.primary) assert_equal(3, @obj_7.primary) end def test_complement assert_equal(5, @obj_1.complement) assert_equal(5, @obj_2.complement) assert_equal(5, @obj_3.complement) assert_equal(5, @obj_4.complement) assert_equal(nil, @obj_5.complement) assert_equal(3, @obj_6.complement) assert_equal(nil, @obj_7.complement) end def test_argument_error assert_raise(ArgumentError) { @t.new([3,5,6]) } assert_raise(ArgumentError) { @t.new(0,1) } assert_raise(ArgumentError) { @t.new(0,0) } assert_raise(ArgumentError) { @t.new('3',5) } end end end --- NEW FILE: test_cut_location_pair.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/double_stranded/cut_location_pair' module Bio class TestDoubleStrandedCutLocationPair < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPair @obj_1 = @t.new([3,5]) @obj_2 = @t.new(3, 5) @obj_3 = @t.new((3..5)) @obj_4 = @t.new(0..5) @obj_5 = @t.new(3) @obj_6 = @t.new(nil,3) @obj_7 = @t.new(3,nil) end def test_contents assert_equal([3,5], @obj_1) assert_equal([3,5], @obj_2) assert_equal([3,5], @obj_3) assert_equal([0,5], @obj_4) assert_equal([3,nil], @obj_5) assert_equal([nil,3], @obj_6) assert_equal([3,nil], @obj_7) end def test_primary assert_equal(3, @obj_1.primary) assert_equal(3, @obj_2.primary) assert_equal(3, @obj_3.primary) assert_equal(0, @obj_4.primary) assert_equal(3, @obj_5.primary) assert_equal(nil, @obj_6.primary) assert_equal(3, @obj_7.primary) end def test_complement assert_equal(5, @obj_1.complement) assert_equal(5, @obj_2.complement) assert_equal(5, @obj_3.complement) assert_equal(5, @obj_4.complement) assert_equal(nil, @obj_5.complement) assert_equal(3, @obj_6.complement) assert_equal(nil, @obj_7.complement) end def test_argument_error assert_raise(ArgumentError) { @t.new([3,5,6]) } assert_raise(ArgumentError) { @t.new(3,-1) } assert_raise(ArgumentError) { @t.new(-3,1) } assert_raise(ArgumentError) { @t.new(nil,nil) } assert_raise(ArgumentError) { @t.new('3',5) } end end end From trevor at pub.open-bio.org Wed Feb 1 02:31:24 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:31:24 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme/single_strand test_cut_locations_in_enzyme_notation.rb, NONE, 1.1 Message-ID: <200602010738.k117cEVL028968@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/single_strand In directory pub.open-bio.org:/tmp/cvs-serv28943/single_strand Added Files: test_cut_locations_in_enzyme_notation.rb Log Message: Bio::RestrictionEnzyme tests --- NEW FILE: test_cut_locations_in_enzyme_notation.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation' module Bio class TestSingleStrandCutLocationsInEnzymeNotation < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation @obj_1 = @t.new([-2,1,3]) @obj_2 = @t.new(-2,1,3) @obj_3 = @t.new(7,1,3) @obj_4 = @t.new(-7,-8,-2,1,3) end def test_max assert_equal(3, @obj_1.max) assert_equal(3, @obj_2.max) assert_equal(7, @obj_3.max) end def test_min assert_equal(-2, @obj_1.min) assert_equal(-2, @obj_2.min) assert_equal(1, @obj_3.min) end def test_to_array_index assert_equal([0,2,4], @obj_1.to_array_index) assert_equal([0,2,4], @obj_2.to_array_index) assert_equal([0,2,6], @obj_3.to_array_index) assert_equal([0, 1, 6, 8, 10], @obj_4.to_array_index) end def test_initialize_with_pattern @obj_5 = @t.new('n^ng^arraxt^n') @obj_6 = @t.new('g^arraxt^n') @obj_7 = @t.new('nnn^nn^nga^rraxt^nn') @obj_8 = @t.new('^g^arraxt^n') assert_equal([-2,1,7], @obj_5) assert_equal([0,2,8], @obj_5.to_array_index) assert_equal([1,7], @obj_6) assert_equal([0,6], @obj_6.to_array_index) assert_equal([-4, -2, 2, 7], @obj_7) assert_equal([0, 2, 5, 10], @obj_7.to_array_index) assert_equal([-1,1,7], @obj_8) assert_equal([0,1,7], @obj_8.to_array_index) end def test_argument_error assert_raise(ArgumentError) { @t.new([0,1,2]) } assert_raise(ArgumentError) { @t.new(0,1,2,0) } assert_raise(ArgumentError) { @t.new([nil,1,2]) } assert_raise(ArgumentError) { @t.new(nil,1,2,nil) } assert_raise(ArgumentError) { @t.new([1,1,2]) } assert_raise(ArgumentError) { @t.new(1,1,2,2) } end end end From trevor at pub.open-bio.org Wed Feb 1 02:31:24 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:31:24 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme/analysis test_calculated_cuts.rb, NONE, 1.1 test_sequence_range.rb, NONE, 1.1 Message-ID: <200602010738.k117cEVL028960@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/analysis In directory pub.open-bio.org:/tmp/cvs-serv28943/analysis Added Files: test_calculated_cuts.rb test_sequence_range.rb Log Message: Bio::RestrictionEnzyme tests --- NEW FILE: test_sequence_range.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/analysis/sequence_range' require 'bio/util/restriction_enzyme/analysis/fragments' require 'bio/util/restriction_enzyme/analysis/cut_range' require 'bio/util/restriction_enzyme/analysis/horizontal_cut_range' require 'bio/util/restriction_enzyme/analysis/vertical_cut_range' require 'bio/util/restriction_enzyme/analysis/cut_ranges' module Bio class TestAnalysisSequenceRange < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::Analysis::SequenceRange @fs = Bio::RestrictionEnzyme::Analysis::Fragments #a.add_cut_range(p_cut_left, p_cut_right, c_cut_left, c_cut_right ) @vcr = Bio::RestrictionEnzyme::Analysis::VerticalCutRange @crs = Bio::RestrictionEnzyme::Analysis::CutRanges @hcr = Bio::RestrictionEnzyme::Analysis::HorizontalCutRange @obj_1 = @t.new(0,5) @obj_1.add_cut_range(0,nil,nil,3) @obj_1.add_cut_range(nil,2,nil,nil) @obj_2 = @t.new(0,5) @obj_2.add_cut_ranges( @crs.new( [@vcr.new(0,2,nil,nil), @vcr.new(3,nil,4,nil)] )) @obj_3 = @t.new(0,5) @obj_3.add_cut_ranges( @crs.new( [@vcr.new(0,2,nil,nil), @vcr.new(3,nil,4,nil)] )) @obj_3.add_cut_ranges( @crs.new( [@hcr.new(0), @hcr.new(5)] )) @obj_4 = @t.new(0,5) @obj_4.add_cut_ranges( @crs.new( [@vcr.new(0,2,1,3)] )) @obj_5 = @t.new(0,5) @obj_5.add_cut_ranges( @crs.new( [@vcr.new(0,nil,nil,nil), @vcr.new(nil,4,3,nil), @hcr.new(1,2)] )) @obj_6 = @t.new(0,5) @obj_6.add_cut_ranges( @crs.new( [@vcr.new(nil,nil,0,nil), @hcr.new(1,2), @vcr.new(nil,4,3,nil)] )) @obj_7 = @t.new(0,5) @obj_7.add_cut_ranges( @crs.new( [@vcr.new(nil,2,nil,nil), @hcr.new(0,2)] )) @obj_8 = @t.new(0,11) @obj_8.add_cut_ranges( @crs.new( [@hcr.new(0,1), @vcr.new(nil,nil,nil,5), @hcr.new(7,8), @hcr.new(10), @vcr.new(nil,10,nil,nil)] )) @obj_9 = @t.new(0,5) @obj_9.add_cut_ranges( @crs.new( [@vcr.new(nil,3,nil,3)] )) @obj_10 = @t.new(0,5) @obj_10.add_cut_ranges( @crs.new( [@vcr.new(0,nil,nil,3), @vcr.new(nil,2,nil,2)] )) end def test_fragments assert_equal(@fs, @obj_1.fragments.class) end # '0|1 2|3 4 5' # ' +---+-+ ' # '0 1 2 3|4 5' def test_fragments_for_display_1 x = @obj_1 assert_equal(3, x.fragments.for_display.size) assert_equal('0 ', x.fragments.for_display[0].primary) assert_equal('0123', x.fragments.for_display[0].complement) assert_equal('12', x.fragments.for_display[1].primary) assert_equal(' ', x.fragments.for_display[1].complement) assert_equal('345', x.fragments.for_display[2].primary) assert_equal(' 45', x.fragments.for_display[2].complement) end # '0|1 2|3|4 5' # ' +---+ +-+ ' # '0 1 2 3 4|5' def test_fragments_for_display_2 x = @obj_2 assert_equal(3, x.fragments.for_display.size) assert_equal('0 3 ', x.fragments.for_display[0].primary) assert_equal('01234', x.fragments.for_display[0].complement) assert_equal('12', x.fragments.for_display[1].primary) assert_equal(' ', x.fragments.for_display[1].complement) assert_equal('45', x.fragments.for_display[2].primary) assert_equal(' 5', x.fragments.for_display[2].complement) end # '0|1 2|3|4 5' # '-+---+ +-+-' # '0 1 2 3 4|5' def test_fragments_for_display_3 x = @obj_3 assert_equal(5, x.fragments.for_display.size) assert_equal('0', x.fragments.for_display[0].primary) assert_equal(' ', x.fragments.for_display[0].complement) assert_equal(' 3 ', x.fragments.for_display[1].primary) assert_equal('01234', x.fragments.for_display[1].complement) assert_equal('12', x.fragments.for_display[2].primary) assert_equal(' ', x.fragments.for_display[2].complement) assert_equal('45', x.fragments.for_display[3].primary) assert_equal(' ', x.fragments.for_display[3].complement) assert_equal(' ', x.fragments.for_display[4].primary) assert_equal('5', x.fragments.for_display[4].complement) end # '0|1 2|3 4 5' # ' +-+-+-+ ' # '0 1|2 3|4 5' def test_fragments_for_display_4 x = @obj_4 assert_equal(4, x.fragments.for_display.size) assert_equal('0 ', x.fragments.for_display[0].primary) assert_equal('01', x.fragments.for_display[0].complement) assert_equal('12', x.fragments.for_display[1].primary) assert_equal(' ', x.fragments.for_display[1].complement) assert_equal(' ', x.fragments.for_display[2].primary) assert_equal('23', x.fragments.for_display[2].complement) assert_equal('345', x.fragments.for_display[3].primary) assert_equal(' 45', x.fragments.for_display[3].complement) end # '0 1 2 3 4|5' # ' +-+ ' # '0 1 2 3|4 5' def test_fragments_for_display_5 x = @obj_5 assert_equal(2, x.fragments.for_display.size) assert_equal('01234', x.fragments.for_display[0].primary) assert_equal('0123 ', x.fragments.for_display[0].complement) assert_equal(' 5', x.fragments.for_display[1].primary) assert_equal('45', x.fragments.for_display[1].complement) end # '0 1 2 3 4|5' # ' +-+ ' # '0 1 2 3|4 5' def test_fragments_for_display_6 x = @obj_6 assert_equal(2, x.fragments.for_display.size) assert_equal('01234', x.fragments.for_display[0].primary) assert_equal('0123 ', x.fragments.for_display[0].complement) assert_equal(' 5', x.fragments.for_display[1].primary) assert_equal('45', x.fragments.for_display[1].complement) end # '0 1 2|3 4 5' # '-----+ ' # '0 1 2 3 4 5' def test_fragments_for_display_7 x = @obj_7 assert_equal(2, x.fragments.for_display.size) assert_equal('012', x.fragments.for_display[0].primary) assert_equal(' ', x.fragments.for_display[0].complement) assert_equal(' 345', x.fragments.for_display[1].primary) assert_equal('012345', x.fragments.for_display[1].complement) end # '0 1 2 3 4 5 6 7 8 9 0 1' # ' ' # '0 1 2 3 4 5 6 7 8 9 0 1' def test_fragments_for_display_8 x = @obj_8 assert_equal(1, x.fragments.for_display.size) assert_equal('012345678901', x.fragments.for_display[0].primary) assert_equal('012345678901', x.fragments.for_display[0].complement) end # '0 1 2 3|4 5' # ' + ' # '0 1 2 3|4 5' def test_fragments_for_display_9 x = @obj_9 assert_equal(2, x.fragments.for_display.size) assert_equal('0123', x.fragments.for_display[0].primary) assert_equal('0123', x.fragments.for_display[0].complement) assert_equal('45', x.fragments.for_display[1].primary) assert_equal('45', x.fragments.for_display[1].complement) end # '0|1 2|3 4 5' # ' +---+-+ ' # '0 1 2|3|4 5' def test_fragments_for_display_10 x = @obj_10 assert_equal(4, x.fragments.for_display.size) assert_equal('0 ', x.fragments.for_display[0].primary) assert_equal('012', x.fragments.for_display[0].complement) assert_equal('12', x.fragments.for_display[1].primary) assert_equal(' ', x.fragments.for_display[1].complement) assert_equal('345', x.fragments.for_display[2].primary) assert_equal(' 45', x.fragments.for_display[2].complement) assert_equal(' ', x.fragments.for_display[3].primary) assert_equal('3', x.fragments.for_display[3].complement) end end end --- NEW FILE: test_calculated_cuts.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/analysis/calculated_cuts' require 'bio/util/restriction_enzyme/analysis/cut_range' require 'bio/util/restriction_enzyme/analysis/horizontal_cut_range' require 'bio/util/restriction_enzyme/analysis/vertical_cut_range' require 'bio/util/restriction_enzyme/analysis/cut_ranges' module Bio class TestAnalysisCalculatedCuts < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::Analysis::CalculatedCuts @vcr = Bio::RestrictionEnzyme::Analysis::VerticalCutRange @crs = Bio::RestrictionEnzyme::Analysis::CutRanges @hcr = Bio::RestrictionEnzyme::Analysis::HorizontalCutRange #a.add_cut_range(p_cut_left, p_cut_right, c_cut_left, c_cut_right ) @obj_1 = @t.new(6) @obj_1.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(0,nil,nil,3), @vcr.new(nil,2,nil,nil)] )) @obj_1b = @obj_1.dup @obj_1b.remove_incomplete_cuts @obj_2 = @t.new(6) @obj_2.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(0,2,nil,nil), @vcr.new(3,nil,4,nil)] )) @obj_2b = @obj_2.dup @obj_2b.remove_incomplete_cuts @obj_3 = @t.new(6) @obj_3.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(0,2,nil,nil), @vcr.new(3,nil,4,nil)] )) @obj_3.add_cuts_from_cut_ranges( @crs.new( [@hcr.new(0), @hcr.new(5)] )) @obj_3b = @obj_3.dup @obj_3b.remove_incomplete_cuts @obj_4 = @t.new(6) @obj_4.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(0,2,1,3)] )) @obj_4b = @obj_4.dup @obj_4b.remove_incomplete_cuts # Same thing, declared a different way @obj_4_c1 = @t.new(6) @obj_4_c1.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(nil,nil,1,3), @vcr.new(0,2,nil,nil)] )) @obj_4b_c1 = @obj_4_c1.dup @obj_4b_c1.remove_incomplete_cuts # Same thing, declared a different way @obj_4_c2 = @t.new(6) @obj_4_c2.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(0,nil,nil,3), @vcr.new(nil,2,1,nil)] )) @obj_4b_c2 = @obj_4_c2.dup @obj_4b_c2.remove_incomplete_cuts @obj_5 = @t.new(6) @obj_5.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(0,nil,nil,nil), @vcr.new(nil,4,3,nil), @hcr.new(1,2)] )) @obj_5b = @obj_5.dup @obj_5b.remove_incomplete_cuts @obj_6 = @t.new(6) @obj_6.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(nil,nil,0,nil), @hcr.new(1,2), @vcr.new(nil,4,3,nil)] )) @obj_6b = @obj_6.dup @obj_6b.remove_incomplete_cuts @obj_7 = @t.new(6) @obj_7.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(nil,2,nil,nil), @hcr.new(0,2)] )) @obj_7b = @obj_7.dup @obj_7b.remove_incomplete_cuts @obj_8 = @t.new(12) @obj_8.add_cuts_from_cut_ranges( @crs.new( [@hcr.new(0,1), @vcr.new(nil,nil,nil,5), @hcr.new(7,8), @hcr.new(10), @vcr.new(nil,10,nil,nil)] )) @obj_8b = @obj_8.dup @obj_8b.remove_incomplete_cuts @obj_9 = @t.new(6) @obj_9.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(nil,3,nil,3)] )) @obj_9b = @obj_9.dup @obj_9b.remove_incomplete_cuts @obj_10 = @t.new(6) @obj_10.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(0,nil,nil,3), @vcr.new(nil,2,nil,2)] )) @obj_10b = @obj_10.dup @obj_10b.remove_incomplete_cuts end def test_cuts x = @obj_1 assert_equal([0,2], x.vc_primary) assert_equal([3], x.vc_complement) assert_equal([1,2,3], x.hc_between_strands) x = @obj_2 assert_equal([0,2,3], x.vc_primary) assert_equal([4], x.vc_complement) assert_equal([1,2,4], x.hc_between_strands) x = @obj_3 assert_equal([0,2,3], x.vc_primary) assert_equal([4], x.vc_complement) assert_equal([0,1,2,4,5], x.hc_between_strands) x = @obj_4 assert_equal([0,2], x.vc_primary) assert_equal([1,3], x.vc_complement) assert_equal([1,2,3], x.hc_between_strands) x = @obj_4_c1 assert_equal([0,2], x.vc_primary) assert_equal([1,3], x.vc_complement) assert_equal([1,2,3], x.hc_between_strands) x = @obj_4_c2 assert_equal([0,2], x.vc_primary) assert_equal([1,3], x.vc_complement) assert_equal([1,2,3], x.hc_between_strands) x = @obj_5 assert_equal([0,4], x.vc_primary) assert_equal([3], x.vc_complement) assert_equal([1,2,4], x.hc_between_strands) x = @obj_6 assert_equal([4], x.vc_primary) assert_equal([0,3], x.vc_complement) assert_equal([1,2,4], x.hc_between_strands) x = @obj_7 assert_equal([2], x.vc_primary) assert_equal([], x.vc_complement) assert_equal([0,1,2], x.hc_between_strands) x = @obj_8 assert_equal([10], x.vc_primary) assert_equal([5], x.vc_complement) assert_equal([0,1,7,8,10], x.hc_between_strands) x = @obj_9 assert_equal([3], x.vc_primary) assert_equal([3], x.vc_complement) assert_equal([], x.hc_between_strands) x = @obj_10 assert_equal([0,2], x.vc_primary) assert_equal([2,3], x.vc_complement) assert_equal([1,2,3], x.hc_between_strands) end def test_cuts_after_remove_incomplete_cuts x = @obj_1b assert_equal([0,2], x.vc_primary) assert_equal([3], x.vc_complement) assert_equal([1,2,3], x.hc_between_strands) end def test_strands_for_display_current #check object_id end def test_strands_for_display x = @obj_1 assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +---+-+ ', x.strands_for_display[1]) assert_equal('0 1 2 3|4 5', x.strands_for_display[2]) x = @obj_1b assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +---+-+ ', x.strands_for_display[1]) assert_equal('0 1 2 3|4 5', x.strands_for_display[2]) x = @obj_2 assert_equal('0|1 2|3|4 5', x.strands_for_display[0]) assert_equal(' +---+ +-+ ', x.strands_for_display[1]) assert_equal('0 1 2 3 4|5', x.strands_for_display[2]) x = @obj_2b assert_equal('0|1 2|3|4 5', x.strands_for_display[0]) assert_equal(' +---+ +-+ ', x.strands_for_display[1]) assert_equal('0 1 2 3 4|5', x.strands_for_display[2]) x = @obj_3 assert_equal('0|1 2|3|4 5', x.strands_for_display[0]) assert_equal('-+---+ +-+-', x.strands_for_display[1]) assert_equal('0 1 2 3 4|5', x.strands_for_display[2]) x = @obj_3b assert_equal('0|1 2|3|4 5', x.strands_for_display[0]) assert_equal('-+---+ +-+-', x.strands_for_display[1]) assert_equal('0 1 2 3 4|5', x.strands_for_display[2]) x = @obj_4 assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +-+-+-+ ', x.strands_for_display[1]) assert_equal('0 1|2 3|4 5', x.strands_for_display[2]) x = @obj_4b assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +-+-+-+ ', x.strands_for_display[1]) assert_equal('0 1|2 3|4 5', x.strands_for_display[2]) x = @obj_4_c1 assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +-+-+-+ ', x.strands_for_display[1]) assert_equal('0 1|2 3|4 5', x.strands_for_display[2]) x = @obj_4b_c1 assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +-+-+-+ ', x.strands_for_display[1]) assert_equal('0 1|2 3|4 5', x.strands_for_display[2]) x = @obj_4_c2 assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +-+-+-+ ', x.strands_for_display[1]) assert_equal('0 1|2 3|4 5', x.strands_for_display[2]) x = @obj_4b_c2 assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +-+-+-+ ', x.strands_for_display[1]) assert_equal('0 1|2 3|4 5', x.strands_for_display[2]) x = @obj_5 assert_equal('0|1 2 3 4|5', x.strands_for_display[0]) assert_equal(' +--- +-+ ', x.strands_for_display[1]) assert_equal('0 1 2 3|4 5', x.strands_for_display[2]) x = @obj_5b assert_equal('0 1 2 3 4|5', x.strands_for_display[0]) assert_equal(' +-+ ', x.strands_for_display[1]) assert_equal('0 1 2 3|4 5', x.strands_for_display[2]) x = @obj_6 assert_equal('0 1 2 3 4|5', x.strands_for_display[0]) assert_equal(' +--- +-+ ', x.strands_for_display[1]) assert_equal('0|1 2 3|4 5', x.strands_for_display[2]) x = @obj_6b assert_equal('0 1 2 3 4|5', x.strands_for_display[0]) assert_equal(' +-+ ', x.strands_for_display[1]) assert_equal('0 1 2 3|4 5', x.strands_for_display[2]) x = @obj_7 assert_equal('0 1 2|3 4 5', x.strands_for_display[0]) assert_equal('-----+ ', x.strands_for_display[1]) assert_equal('0 1 2 3 4 5', x.strands_for_display[2]) x = @obj_7b assert_equal('0 1 2|3 4 5', x.strands_for_display[0]) assert_equal('-----+ ', x.strands_for_display[1]) assert_equal('0 1 2 3 4 5', x.strands_for_display[2]) x = @obj_8 assert_equal('0 1 2 3 4 5 6 7 8 9 0|1', x.strands_for_display[0]) assert_equal('--- + --- -+ ', x.strands_for_display[1]) assert_equal('0 1 2 3 4 5|6 7 8 9 0 1', x.strands_for_display[2]) x = @obj_8b assert_equal('0 1 2 3 4 5 6 7 8 9 0 1', x.strands_for_display[0]) assert_equal(' ', x.strands_for_display[1]) assert_equal('0 1 2 3 4 5 6 7 8 9 0 1', x.strands_for_display[2]) x = @obj_9 assert_equal('0 1 2 3|4 5', x.strands_for_display[0]) assert_equal(' + ', x.strands_for_display[1]) assert_equal('0 1 2 3|4 5', x.strands_for_display[2]) x = @obj_9b assert_equal('0 1 2 3|4 5', x.strands_for_display[0]) assert_equal(' + ', x.strands_for_display[1]) assert_equal('0 1 2 3|4 5', x.strands_for_display[2]) x = @obj_10 assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +---+-+ ', x.strands_for_display[1]) assert_equal('0 1 2|3|4 5', x.strands_for_display[2]) x = @obj_10b assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +---+-+ ', x.strands_for_display[1]) assert_equal('0 1 2|3|4 5', x.strands_for_display[2]) end end end From trevor at pub.open-bio.org Wed Feb 1 02:31:25 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:31:25 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme test_analysis.rb, NONE, 1.1 test_double_stranded.rb, NONE, 1.1 test_integer.rb, NONE, 1.1 test_single_strand.rb, NONE, 1.1 test_single_strand_complement.rb, NONE, 1.1 test_string_formatting.rb, NONE, 1.1 Message-ID: <200602010738.k117cEVL028959@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv28943 Added Files: test_analysis.rb test_double_stranded.rb test_integer.rb test_single_strand.rb test_single_strand_complement.rb test_string_formatting.rb Log Message: Bio::RestrictionEnzyme tests --- NEW FILE: test_integer.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/integer' module Bio class TestCutLocationsInEnzymeNotation < Test::Unit::TestCase def test_negative? assert_equal(false, 1.negative?) assert_equal(false, 0.negative?) assert_equal(true, -1.negative?) end end end --- NEW FILE: test_string_formatting.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/string_formatting' module Bio class TestStringFormatting < Test::Unit::TestCase include Bio::RestrictionEnzyme::StringFormatting def setup @t = String @obj_1 = @t.new('gata') @obj_2 = @t.new('garraxt') @obj_3 = @t.new('gArraXT') @obj_4 = @t.new('nnnnnnngarraxtnn') end def test_strip_padding assert_equal('gata', strip_padding(@obj_1)) assert_equal('garraxt', strip_padding(@obj_2)) assert_equal('gArraXT', strip_padding(@obj_3)) assert_equal('garraxt', strip_padding(@obj_4)) end def test_left_padding assert_equal('', left_padding(@obj_1)) assert_equal('', left_padding(@obj_2)) assert_equal('', left_padding(@obj_3)) assert_equal('nnnnnnn', left_padding(@obj_4)) end def test_right_padding assert_equal('', right_padding(@obj_1)) assert_equal('', right_padding(@obj_2)) assert_equal('', right_padding(@obj_3)) assert_equal('nn', right_padding(@obj_4)) end def test_add_spacing assert_equal('n^n g^a t^a', add_spacing('n^ng^at^a') ) assert_equal('n^n g^a r r a x t^n', add_spacing('n^ng^arraxt^n') ) end end end --- NEW FILE: test_analysis.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/analysis' module Bio class TestAnalysis < Test::Unit::TestCase def setup @enz = Bio::RestrictionEnzyme @t = Bio::RestrictionEnzyme::Analysis @obj_1 = @t.cut('cagagag', 'ag^ag') @obj_2 = @t.cut('agagag', 'ag^ag') @obj_3 = @t.cut('cagagagt', 'ag^ag') e1 = @enz.new('atgcatgc', [3,3]) @obj_4 = @t.cut('atgcatgcatgc', e1) e2 = @enz.new('atgcatgc', [3,5]) @obj_5 = @t.cut('atgcatgcatgc', e2) e3 = @enz.new('anna', [1,1], [3,3]) e4 = @enz.new('gg', [1,1]) @obj_6 = @t.cut('agga', e3, e4) @obj_7 = @t.cut('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII') @obj_8 = @t.cut('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII', 'HincII') @obj_1d = @t.cut_without_permutations('cagagag', 'ag^ag') @obj_2d = @t.cut_without_permutations('agagag', 'ag^ag') @obj_3d = @t.cut_without_permutations('cagagagt', 'ag^ag') e1 = @enz.new('atgcatgc', [3,3]) @obj_4d = @t.cut_without_permutations('atgcatgcatgc', e1) e2 = @enz.new('atgcatgc', [3,5]) @obj_5d = @t.cut_without_permutations('atgcatgcatgc', e2) e3 = @enz.new('anna', [1,1], [3,3]) e4 = @enz.new('gg', [1,1]) @obj_6d = @t.cut_without_permutations('agga', e3, e4) @obj_7d = @t.cut_without_permutations('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII') @obj_8d = @t.cut_without_permutations('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII', 'HincII') end def test_cut assert_equal(["ag", "cag"], @obj_1.primary) assert_equal(["gtc", "tc"], @obj_1.complement) assert_equal(2, @obj_1.size) assert_equal(Bio::RestrictionEnzyme::Analysis::UniqueFragments, @obj_1.class) assert_equal(Bio::RestrictionEnzyme::Analysis::UniqueFragment, @obj_1[0].class) assert_equal(["ag"], @obj_2.primary) assert_equal(["ag", "agt", "cag"], @obj_3.primary) assert_equal(["atg", "atgcatg", "catg", "catgc"], @obj_4.primary) assert_equal(["atg", "atgcatg", "catgc", "catgcatgc"], @obj_5.primary) assert_equal(["a", "ag", "g", "ga"], @obj_6.primary) assert_equal(["ccaggaaaaaga", "ccaggaaag", "cctggaaaagttaac", "ga"], @obj_7.primary) assert_equal(["aac", "ccaggaaaaaga", "ccaggaaag", "cctggaaaagtt", "ga"], @obj_8.primary) end def test_cut_without_permutations assert_equal(["ag", "cag"], @obj_1d.primary) assert_equal(["ag"], @obj_2d.primary) assert_equal(["ag", "agt", "cag"], @obj_3d.primary) assert_equal(["atg", "catg", "catgc"], @obj_4d.primary) assert_equal(["atg", "catg", "catgc"], @obj_5d.primary) assert_equal(["a", "g"], @obj_6d.primary) assert_equal(["ccaggaaaaaga", "ccaggaaag", "cctggaaaagttaac", "ga"], @obj_7d.primary) assert_equal(["aac", "ccaggaaaaaga", "ccaggaaag", "cctggaaaagtt", "ga"], @obj_8d.primary) end def test_cut_from_bio_sequence_na assert_equal(["ag", "cag"], Bio::Sequence::NA.new('cagagag').cut_with_enzyme('ag^ag').primary ) assert_equal(["ag", "cag"], Bio::Sequence::NA.new('cagagag').cut_with_enzymes('ag^ag').primary ) assert_equal(["ag", "cag"], Bio::Sequence::NA.new('cagagag').cut_with_enzymes('ag^ag', 'EcoRII').primary ) # NOTE: investigate where the '' is coming from assert_equal(["", "ag", "ag", "cag", "ccagg"], Bio::Sequence::NA.new('cagagagccagg').cut_with_enzymes('ag^ag', 'EcoRII').primary ) end end end --- NEW FILE: test_double_stranded.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/double_stranded' module Bio class TestDoubleStranded < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::DoubleStranded @cl = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPairInEnzymeNotation @s = String @obj_1 = @t.new(@s.new('gata'), [1,2]) @obj_2 = @t.new('gata', [1,2]) @obj_3 = @t.new('garraxt', [1,2]) @obj_4 = @t.new('nnnnnnngarraxtnn', [1,2]) @obj_5 = @t.new('garraxt', @cl.new(3,2), @cl.new(-2,-1), @cl.new(9,11)) @obj_6 = @t.new('garraxt', @cl.new(3,2)) @obj_7 = @t.new('garraxt', @cl.new(3,2), @cl.new(9,11)) @obj_8 = @t.new('garraxt', 3..2, 9..11) @obj_9 = @t.new('garraxt', [3,2], [9,11]) @obj_10 = @t.new('garraxt', [3,2], [9,11]) @obj_11 = @t.new('n^ngar^raxtnn^n') @obj_12 = @t.new('nnnn^ngar^raxtnn^nnnn') @obj_13 = @t.new(Bio::RestrictionEnzyme.rebase['EcoRII']) @obj_14 = @t.new('EcoRII') @obj_15 = @t.new('ecorii') end def test_primary assert_equal('nngarraxtnnn', @obj_5.primary) end def test_primary_with_cut_symbols assert_equal('n^ngar^raxtnn^n', @obj_5.primary.with_cut_symbols) assert_equal('gar^raxt', @obj_6.primary.with_cut_symbols) assert_equal('gar^raxtnn^n', @obj_7.primary.with_cut_symbols) assert_equal('gar^raxtnn^n', @obj_8.primary.with_cut_symbols) assert_equal('gar^raxtnn^n', @obj_9.primary.with_cut_symbols) assert_equal('gar^raxtnn^n', @obj_10.primary.with_cut_symbols) assert_equal('n^ngar^raxtnn^n', @obj_11.primary.with_cut_symbols) assert_equal('n^ngar^raxtnn^n', @obj_12.primary.with_cut_symbols) assert_equal('n^ccwgg', @obj_13.primary.with_cut_symbols) assert_equal('n^ccwgg', @obj_14.primary.with_cut_symbols) assert_equal('n^ccwgg', @obj_15.primary.with_cut_symbols) end def test_complement_with_cut_symbols assert_equal('n^ct^yytxannnn^n', @obj_5.complement.with_cut_symbols) assert_equal('ct^yytxa', @obj_6.complement.with_cut_symbols) assert_equal('ct^yytxannnn^n', @obj_7.complement.with_cut_symbols) assert_equal('ct^yytxannnn^n', @obj_8.complement.with_cut_symbols) assert_equal('ct^yytxannnn^n', @obj_9.complement.with_cut_symbols) assert_equal('ct^yytxannnn^n', @obj_10.complement.with_cut_symbols) assert_equal('n^nnctyy^txan^n', @obj_11.complement.with_cut_symbols) assert_equal('n^nnctyy^txan^n', @obj_12.complement.with_cut_symbols) assert_equal('ggwcc^n', @obj_13.complement.with_cut_symbols) assert_equal('ggwcc^n', @obj_14.complement.with_cut_symbols) assert_equal('ggwcc^n', @obj_15.complement.with_cut_symbols) end def test_complement assert_equal('nctyytxannnnn', @obj_5.complement) end def test_cut_locations assert_equal([[4, 3], [0, 1], [10, 12]], @obj_5.cut_locations) end def test_cut_locations_in_enzyme_notation assert_equal([[3, 2], [-2, -1], [9, 11]], @obj_5.cut_locations_in_enzyme_notation) end def test_argument_error assert_raise(ArgumentError) { @t.new('garraxt', [3,2,9,11]) } assert_raise(ArgumentError) { @t.new(Bio::RestrictionEnzyme.rebase['ecorii'] )} assert_raise(ArgumentError) { @t.new(Bio::RestrictionEnzyme.rebase['EzzRII']) } end def test_index_error assert_raise(IndexError) { @t.new('EzzRII') } end # NOTE def test_to_re end end end --- NEW FILE: test_single_strand_complement.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/single_strand_complement' module Bio class TestSingleStrandComplement < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::SingleStrandComplement @cl = Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation @s = Bio::Sequence::NA @obj_1 = @t.new(@s.new('gata'), @cl.new(-2,1,3)) @obj_2 = @t.new('gata', -2, 1, 3) @obj_3 = @t.new('garraxt', [-2, 1, 7]) @obj_4 = @t.new('nnnnnnngarraxtnn', [-2, 1, 7]) @obj_5 = @t.new('ga^rr^axt') @obj_6 = @t.new('^ga^rr^axt') @obj_7 = @t.new('n^ngar^raxtnn^n') end def test_pattern_palindromic? assert_equal(true, @t.new('atgcat', 1).palindromic?) assert_equal(false, @t.new('atgcgta', 1).palindromic?) assert_equal(false, @obj_1.palindromic?) assert_equal(false, @obj_2.palindromic?) assert_equal(false, @obj_3.palindromic?) assert_equal(false, @obj_4.palindromic?) end def test_stripped assert_equal('gata', @obj_1.stripped) assert_equal('gata', @obj_2.stripped) assert_equal('garraxt', @obj_3.stripped) assert_equal('garraxt', @obj_4.stripped) end def test_pattern assert_equal('nngata', @obj_1.pattern) assert_equal('nngata', @obj_2.pattern) assert_equal('nngarraxtn', @obj_3.pattern) assert_equal('nngarraxtn', @obj_4.pattern) assert_equal('nngata', @obj_1) assert_equal('nngata', @obj_2) assert_equal('nngarraxtn', @obj_3) assert_equal('nngarraxtn', @obj_4) end def test_with_cut_symbols assert_equal('n^ng^at^a', @obj_1.with_cut_symbols) assert_equal('n^ng^at^a', @obj_2.with_cut_symbols) assert_equal('n^ng^arraxt^n', @obj_3.with_cut_symbols) assert_equal('n^ng^arraxt^n', @obj_4.with_cut_symbols) end def test_with_spaces assert_equal('n^n g^a t^a', @obj_1.with_spaces) assert_equal('n^n g^a t^a', @obj_2.with_spaces) assert_equal('n^n g^a r r a x t^n', @obj_3.with_spaces) assert_equal('n^n g^a r r a x t^n', @obj_4.with_spaces) end def test_cut_locations_in_enzyme_notation assert_equal([-2,1,3], @obj_1.cut_locations_in_enzyme_notation) assert_equal([-2,1,3], @obj_2.cut_locations_in_enzyme_notation) assert_equal([-2,1,7], @obj_3.cut_locations_in_enzyme_notation) assert_equal([-2,1,7], @obj_4.cut_locations_in_enzyme_notation) assert_equal([2,4], @obj_5.cut_locations_in_enzyme_notation) assert_equal([-1,2,4], @obj_6.cut_locations_in_enzyme_notation) assert_equal([-2,3,9], @obj_7.cut_locations_in_enzyme_notation) end def test_cut_locations assert_equal([0,2,4], @obj_1.cut_locations) assert_equal([0,2,4], @obj_2.cut_locations) assert_equal([0,2,8], @obj_3.cut_locations) assert_equal([0,2,8], @obj_4.cut_locations) assert_equal([1,3], @obj_5.cut_locations) assert_equal([0,2,4], @obj_6.cut_locations) assert_equal([0,4,10], @obj_7.cut_locations) end def test_orientation assert_equal([3,5], @obj_1.orientation) assert_equal([3,5], @obj_2.orientation) assert_equal([3,5], @obj_3.orientation) assert_equal([3,5], @obj_4.orientation) end def test_creation_with_no_cuts @obj_8 = @t.new('garraxt') assert_equal([3,5], @obj_8.orientation) assert_equal([], @obj_8.cut_locations) assert_equal([], @obj_8.cut_locations_in_enzyme_notation) assert_equal('garraxt', @obj_8.pattern) end # NOTE def test_to_re end def test_argument_error assert_raise(ArgumentError) { @t.new('a', [0,1,2]) } assert_raise(ArgumentError) { @t.new('a', 0,1,2,0) } assert_raise(ArgumentError) { @t.new('a', [nil,1,2]) } assert_raise(ArgumentError) { @t.new('a', nil,1,2,nil) } assert_raise(ArgumentError) { @t.new('a', [1,1,2]) } assert_raise(ArgumentError) { @t.new('a', 1,1,2,2) } assert_raise(ArgumentError) { @t.new(1, [1,2,3]) } assert_raise(ArgumentError) { @t.new('gaat^aca', [1,2,3]) } assert_raise(ArgumentError) { @t.new('gaat^^aca') } assert_raise(ArgumentError) { @t.new('z', [1,2,3]) } assert_raise(ArgumentError) { @t.new('g', [0,1,2]) } assert_raise(ArgumentError) { @t.new('g', 0,1,2,0) } assert_raise(ArgumentError) { @t.new('g', [0,1,1,2]) } assert_raise(ArgumentError) { @t.new('g', 0,1,1,2,2) } assert_raise(ArgumentError) { @t.new(1,2,3) } assert_raise(ArgumentError) { @t.new(1,2,'g') } end end end --- NEW FILE: test_single_strand.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/single_strand' module Bio class TestSingleStrand < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::SingleStrand @cl = Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation @s = Bio::Sequence::NA @obj_1 = @t.new(@s.new('gata'), @cl.new(-2,1,3)) @obj_2 = @t.new('gata', -2, 1, 3) @obj_3 = @t.new('garraxt', [-2, 1, 7]) @obj_4 = @t.new('nnnnnnngarraxtnn', [-2, 1, 7]) @obj_5 = @t.new('ga^rr^axt') @obj_6 = @t.new('^ga^rr^axt') @obj_7 = @t.new('n^ngar^raxtnn^n') end def test_pattern_palindromic? assert_equal(true, @t.new('atgcat', 1).palindromic?) assert_equal(false, @t.new('atgcgta', 1).palindromic?) assert_equal(false, @obj_1.palindromic?) assert_equal(false, @obj_2.palindromic?) assert_equal(false, @obj_3.palindromic?) assert_equal(false, @obj_4.palindromic?) end def test_stripped assert_equal('gata', @obj_1.stripped) assert_equal('gata', @obj_2.stripped) assert_equal('garraxt', @obj_3.stripped) assert_equal('garraxt', @obj_4.stripped) end def test_pattern assert_equal('nngata', @obj_1.pattern) assert_equal('nngata', @obj_2.pattern) assert_equal('nngarraxtn', @obj_3.pattern) assert_equal('nngarraxtn', @obj_4.pattern) assert_equal('nngata', @obj_1) assert_equal('nngata', @obj_2) assert_equal('nngarraxtn', @obj_3) assert_equal('nngarraxtn', @obj_4) end def test_with_cut_symbols assert_equal('n^ng^at^a', @obj_1.with_cut_symbols) assert_equal('n^ng^at^a', @obj_2.with_cut_symbols) assert_equal('n^ng^arraxt^n', @obj_3.with_cut_symbols) assert_equal('n^ng^arraxt^n', @obj_4.with_cut_symbols) end def test_with_spaces assert_equal('n^n g^a t^a', @obj_1.with_spaces) assert_equal('n^n g^a t^a', @obj_2.with_spaces) assert_equal('n^n g^a r r a x t^n', @obj_3.with_spaces) assert_equal('n^n g^a r r a x t^n', @obj_4.with_spaces) end def test_cut_locations_in_enzyme_notation assert_equal([-2,1,3], @obj_1.cut_locations_in_enzyme_notation) assert_equal([-2,1,3], @obj_2.cut_locations_in_enzyme_notation) assert_equal([-2,1,7], @obj_3.cut_locations_in_enzyme_notation) assert_equal([-2,1,7], @obj_4.cut_locations_in_enzyme_notation) assert_equal([2,4], @obj_5.cut_locations_in_enzyme_notation) assert_equal([-1,2,4], @obj_6.cut_locations_in_enzyme_notation) assert_equal([-2,3,9], @obj_7.cut_locations_in_enzyme_notation) end def test_cut_locations assert_equal([0,2,4], @obj_1.cut_locations) assert_equal([0,2,4], @obj_2.cut_locations) assert_equal([0,2,8], @obj_3.cut_locations) assert_equal([0,2,8], @obj_4.cut_locations) assert_equal([1,3], @obj_5.cut_locations) assert_equal([0,2,4], @obj_6.cut_locations) assert_equal([0,4,10], @obj_7.cut_locations) end def test_orientation assert_equal([5,3], @obj_1.orientation) assert_equal([5,3], @obj_2.orientation) assert_equal([5,3], @obj_3.orientation) assert_equal([5,3], @obj_4.orientation) end def test_creation_with_no_cuts @obj_8 = @t.new('garraxt') assert_equal([5,3], @obj_8.orientation) assert_equal([], @obj_8.cut_locations) assert_equal([], @obj_8.cut_locations_in_enzyme_notation) assert_equal('garraxt', @obj_8.pattern) end # NOTE def test_to_re end def test_argument_error assert_raise(ArgumentError) { @t.new('a', [0,1,2]) } assert_raise(ArgumentError) { @t.new('a', 0,1,2,0) } assert_raise(ArgumentError) { @t.new('a', [nil,1,2]) } assert_raise(ArgumentError) { @t.new('a', nil,1,2,nil) } assert_raise(ArgumentError) { @t.new('a', [1,1,2]) } assert_raise(ArgumentError) { @t.new('a', 1,1,2,2) } assert_raise(ArgumentError) { @t.new(1, [1,2,3]) } assert_raise(ArgumentError) { @t.new('gaat^aca', [1,2,3]) } assert_raise(ArgumentError) { @t.new('gaat^^aca') } assert_raise(ArgumentError) { @t.new('z', [1,2,3]) } assert_raise(ArgumentError) { @t.new('g', [0,1,2]) } assert_raise(ArgumentError) { @t.new('g', 0,1,2,0) } assert_raise(ArgumentError) { @t.new('g', [0,1,1,2]) } assert_raise(ArgumentError) { @t.new('g', 0,1,1,2,2) } assert_raise(ArgumentError) { @t.new(1,2,3) } assert_raise(ArgumentError) { @t.new(1,2,'g') } end end end From trevor at pub.open-bio.org Sat Feb 18 17:00:57 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Sat, 18 Feb 2006 22:00:57 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme analysis.rb, 1.1, 1.2 Message-ID: <200602182200.k1IM0vVL003435@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv3419/restriction_enzyme Modified Files: analysis.rb Log Message: Removal and replacement of permutation.rb Index: analysis.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** analysis.rb 1 Feb 2006 07:34:11 -0000 1.1 --- analysis.rb 18 Feb 2006 22:00:55 -0000 1.2 *************** *** 22,26 **** require 'bio/util/restriction_enzyme' require 'bio/util/restriction_enzyme/analysis/sequence_range.rb' - require 'bio/util/restriction_enzyme/analysis/permutation.rb' class Bio::RestrictionEnzyme --- 22,25 ---- *************** *** 71,75 **** end - def cut_without_permutations( sequence, *args ) sequence = Bio::Sequence::NA.new( sequence ) --- 70,73 ---- *************** *** 93,97 **** sequence = Bio::Sequence::NA.new( sequence ) enzyme_actions = create_enzyme_actions( sequence, *args ) ! permutations = Permutation.new(enzyme_actions.size).map { |p| p.value } # Indexed by permutation. --- 91,95 ---- sequence = Bio::Sequence::NA.new( sequence ) enzyme_actions = create_enzyme_actions( sequence, *args ) ! permutations = permute(enzyme_actions.size) # Indexed by permutation. *************** *** 168,171 **** --- 166,184 ---- protected ######### + + def permute(count, permutations = [[0]]) + return permutations if count <= 1 + new_arrays = [] + new_array = [] + + (permutations[0].size + 1).times do |n| + new_array.clear + permutations.each { |a| new_array << a.dup } + new_array.each { |e| e.insert(n, permutations[0].size) } + new_arrays += new_array + end + + permute(count-1, new_arrays) + end UniqueFragment = Struct.new(:primary, :complement) From trevor at pub.open-bio.org Sat Feb 18 17:00:57 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Sat, 18 Feb 2006 22:00:57 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util restriction_enzyme.rb,1.1,1.2 Message-ID: <200602182200.k1IM0vVL003431@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util In directory pub.open-bio.org:/tmp/cvs-serv3419 Modified Files: restriction_enzyme.rb Log Message: Removal and replacement of permutation.rb Index: restriction_enzyme.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** restriction_enzyme.rb 1 Feb 2006 07:30:19 -0000 1.1 --- restriction_enzyme.rb 18 Feb 2006 22:00:55 -0000 1.2 *************** *** 203,210 **** - == Notes - This module includes Florian Frank's permutation.rb licensed under the GPL. To prevent licensing issues - the source code to Bio::RestrictionEnzyme must be included whenever Bio::RestrictionEnzyme is distributed. - == Author Trevor Wennblom --- 203,206 ---- From trevor at pub.open-bio.org Sat Feb 18 17:02:53 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Sat, 18 Feb 2006 22:02:53 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/analysis permutation.rb, 1.1, NONE Message-ID: <200602182202.k1IM2rVL003497@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis In directory pub.open-bio.org:/tmp/cvs-serv3487 Removed Files: permutation.rb Log Message: Permutation LGPL'd library removed. --- permutation.rb DELETED --- From trevor at pub.open-bio.org Sat Feb 18 17:11:07 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Sat, 18 Feb 2006 22:11:07 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme test_analysis.rb, 1.1, 1.2 Message-ID: <200602182211.k1IMB7VL003530@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv3520 Modified Files: test_analysis.rb Log Message: Check for empty strings as input. Index: test_analysis.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/test_analysis.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_analysis.rb 1 Feb 2006 07:38:12 -0000 1.1 --- test_analysis.rb 18 Feb 2006 22:11:05 -0000 1.2 *************** *** 48,51 **** --- 48,54 ---- @obj_8d = @t.cut_without_permutations('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII', 'HincII') + @obj_98 = @t.cut('', 'EcoRII', 'HincII') + @obj_99 = @t.cut_without_permutations('', 'EcoRII', 'HincII') + end From trevor at pub.open-bio.org Sat Feb 18 17:11:38 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Sat, 18 Feb 2006 22:11:38 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme analysis.rb, 1.2, 1.3 Message-ID: <200602182211.k1IMBcVL003547@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv3537 Modified Files: analysis.rb Log Message: Check for empty strings as input and return nil if found. Index: analysis.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** analysis.rb 18 Feb 2006 22:00:55 -0000 1.2 --- analysis.rb 18 Feb 2006 22:11:35 -0000 1.3 *************** *** 71,74 **** --- 71,75 ---- def cut_without_permutations( sequence, *args ) + return nil if !sequence.kind_of?(String) or sequence.empty? sequence = Bio::Sequence::NA.new( sequence ) enzyme_actions = create_enzyme_actions( sequence, *args ) *************** *** 89,92 **** --- 90,94 ---- def cut_and_return_by_permutations( sequence, *args ) + return nil if !sequence.kind_of?(String) or sequence.empty? sequence = Bio::Sequence::NA.new( sequence ) enzyme_actions = create_enzyme_actions( sequence, *args ) *************** *** 159,162 **** --- 161,165 ---- def cut( sequence, *args ) + return nil if !sequence.kind_of?(String) or sequence.empty? hash_of_sequence_ranges_with_cuts = cut_and_return_by_permutations( sequence, *args ) unique_fragments_for_display( hash_of_sequence_ranges_with_cuts ) From k at pub.open-bio.org Mon Feb 27 06:16:25 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/javascripts controls.js, NONE, 1.1 dragdrop.js, NONE, 1.1 effects.js, NONE, 1.1 prototype.js, NONE, 1.1 Message-ID: <200602271116.k1RBGPVL002314@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/javascripts In directory pub.open-bio.org:/tmp/cvs-serv2240/public/javascripts Added Files: controls.js dragdrop.js effects.js prototype.js Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: prototype.js --- /* Prototype JavaScript framework, version 1.4.0 * (c) 2005 Sam Stephenson * * THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff * against the source tree, available from the Prototype darcs repository. * * Prototype is freely distributable under the terms of an MIT-style license. * * For details, see the Prototype web site: http://prototype.conio.net/ * /*--------------------------------------------------------------------------*/ var Prototype = { Version: '1.4.0', ScriptFragment: '(?:)((\n|\r|.)*?)(?:<\/script>)', emptyFunction: function() {}, K: function(x) {return x} } [...1746 lines suppressed...] } // Safari returns margins on body which is incorrect if the child is absolutely // positioned. For performance reasons, redefine Position.cumulativeOffset for // KHTML/WebKit only. if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) { Position.cumulativeOffset = function(element) { var valueT = 0, valueL = 0; do { valueT += element.offsetTop || 0; valueL += element.offsetLeft || 0; if (element.offsetParent == document.body) if (Element.getStyle(element, 'position') == 'absolute') break; element = element.offsetParent; } while (element); return [valueL, valueT]; } } --- NEW FILE: controls.js --- // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan) // (c) 2005 Jon Tirsen (http://www.tirsen.com) // Contributors: // Richard Livsey // Rahul Bhargava // Rob Wills // // See scriptaculous.js for full license. // Autocompleter.Base handles all the autocompletion functionality // that's independent of the data source for autocompletion. This // includes drawing the autocompletion menu, observing keyboard // and mouse events, and similar. // // Specific autocompleters need to provide, at the very least, // a getUpdatedChoices function that will be invoked every time // the text inside the monitored textbox changes. This method // should get the text for which to provide autocompletion by // invoking this.getToken(), NOT by directly accessing // this.element.value. This is to allow incremental tokenized // autocompletion. Specific auto-completion logic (AJAX, etc) // belongs in getUpdatedChoices. // // Tokenized incremental autocompletion is enabled automatically // when an autocompleter is instantiated with the 'tokens' option // in the options parameter, e.g.: // new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' }); // will incrementally autocomplete with a comma as the token. // Additionally, ',' in the above example can be replaced with // a token array, e.g. { tokens: [',', '\n'] } which // enables autocompletion on multiple tokens. This is most // useful when one of the tokens is \n (a newline), as it // allows smart autocompletion after linebreaks. var Autocompleter = {} Autocompleter.Base = function() {}; Autocompleter.Base.prototype = { baseInitialize: function(element, update, options) { this.element = $(element); this.update = $(update); this.hasFocus = false; this.changed = false; this.active = false; this.index = 0; this.entryCount = 0; if (this.setOptions) this.setOptions(options); else this.options = options || {}; this.options.paramName = this.options.paramName || this.element.name; this.options.tokens = this.options.tokens || []; this.options.frequency = this.options.frequency || 0.4; this.options.minChars = this.options.minChars || 1; this.options.onShow = this.options.onShow || function(element, update){ if(!update.style.position || update.style.position=='absolute') { update.style.position = 'absolute'; Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight}); } Effect.Appear(update,{duration:0.15}); }; this.options.onHide = this.options.onHide || function(element, update){ new Effect.Fade(update,{duration:0.15}) }; if (typeof(this.options.tokens) == 'string') this.options.tokens = new Array(this.options.tokens); this.observer = null; this.element.setAttribute('autocomplete','off'); Element.hide(this.update); Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this)); Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this)); }, show: function() { if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update); if(!this.iefix && (navigator.appVersion.indexOf('MSIE')>0) && (navigator.userAgent.indexOf('Opera')<0) && (Element.getStyle(this.update, 'position')=='absolute')) { new Insertion.After(this.update, ''); this.iefix = $(this.update.id+'_iefix'); } if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50); }, fixIEOverlapping: function() { Position.clone(this.update, this.iefix); this.iefix.style.zIndex = 1; this.update.style.zIndex = 2; Element.show(this.iefix); }, hide: function() { this.stopIndicator(); if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update); if(this.iefix) Element.hide(this.iefix); }, startIndicator: function() { if(this.options.indicator) Element.show(this.options.indicator); }, stopIndicator: function() { if(this.options.indicator) Element.hide(this.options.indicator); }, onKeyPress: function(event) { if(this.active) switch(event.keyCode) { case Event.KEY_TAB: case Event.KEY_RETURN: this.selectEntry(); Event.stop(event); case Event.KEY_ESC: this.hide(); this.active = false; Event.stop(event); return; case Event.KEY_LEFT: case Event.KEY_RIGHT: return; case Event.KEY_UP: this.markPrevious(); this.render(); if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); return; case Event.KEY_DOWN: this.markNext(); this.render(); if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); return; } else if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN) return; this.changed = true; this.hasFocus = true; if(this.observer) clearTimeout(this.observer); this.observer = setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000); }, onHover: function(event) { var element = Event.findElement(event, 'LI'); if(this.index != element.autocompleteIndex) { this.index = element.autocompleteIndex; this.render(); } Event.stop(event); }, onClick: function(event) { var element = Event.findElement(event, 'LI'); this.index = element.autocompleteIndex; this.selectEntry(); this.hide(); }, onBlur: function(event) { // needed to make click events working setTimeout(this.hide.bind(this), 250); this.hasFocus = false; this.active = false; }, render: function() { if(this.entryCount > 0) { for (var i = 0; i < this.entryCount; i++) this.index==i ? Element.addClassName(this.getEntry(i),"selected") : Element.removeClassName(this.getEntry(i),"selected"); if(this.hasFocus) { this.show(); this.active = true; } } else { this.active = false; this.hide(); } }, markPrevious: function() { if(this.index > 0) this.index-- else this.index = this.entryCount-1; }, markNext: function() { if(this.index < this.entryCount-1) this.index++ else this.index = 0; }, getEntry: function(index) { return this.update.firstChild.childNodes[index]; }, getCurrentEntry: function() { return this.getEntry(this.index); }, selectEntry: function() { this.active = false; this.updateElement(this.getCurrentEntry()); }, updateElement: function(selectedElement) { if (this.options.updateElement) { this.options.updateElement(selectedElement); return; } var value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal'); var lastTokenPos = this.findLastToken(); if (lastTokenPos != -1) { var newValue = this.element.value.substr(0, lastTokenPos + 1); var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/); if (whitespace) newValue += whitespace[0]; this.element.value = newValue + value; } else { this.element.value = value; } this.element.focus(); if (this.options.afterUpdateElement) this.options.afterUpdateElement(this.element, selectedElement); }, updateChoices: function(choices) { if(!this.changed && this.hasFocus) { this.update.innerHTML = choices; Element.cleanWhitespace(this.update); Element.cleanWhitespace(this.update.firstChild); if(this.update.firstChild && this.update.firstChild.childNodes) { this.entryCount = this.update.firstChild.childNodes.length; for (var i = 0; i < this.entryCount; i++) { var entry = this.getEntry(i); entry.autocompleteIndex = i; this.addObservers(entry); } } else { this.entryCount = 0; } this.stopIndicator(); this.index = 0; this.render(); } }, addObservers: function(element) { Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this)); Event.observe(element, "click", this.onClick.bindAsEventListener(this)); }, onObserverEvent: function() { this.changed = false; if(this.getToken().length>=this.options.minChars) { this.startIndicator(); this.getUpdatedChoices(); } else { this.active = false; this.hide(); } }, getToken: function() { var tokenPos = this.findLastToken(); if (tokenPos != -1) var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/,'').replace(/\s+$/,''); else var ret = this.element.value; return /\n/.test(ret) ? '' : ret; }, findLastToken: function() { var lastTokenPos = -1; for (var i=0; i lastTokenPos) lastTokenPos = thisTokenPos; } return lastTokenPos; } } Ajax.Autocompleter = Class.create(); Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), { initialize: function(element, update, url, options) { this.baseInitialize(element, update, options); this.options.asynchronous = true; this.options.onComplete = this.onComplete.bind(this); this.options.defaultParams = this.options.parameters || null; this.url = url; }, getUpdatedChoices: function() { entry = encodeURIComponent(this.options.paramName) + '=' + encodeURIComponent(this.getToken()); this.options.parameters = this.options.callback ? this.options.callback(this.element, entry) : entry; if(this.options.defaultParams) this.options.parameters += '&' + this.options.defaultParams; new Ajax.Request(this.url, this.options); }, onComplete: function(request) { this.updateChoices(request.responseText); } }); // The local array autocompleter. Used when you'd prefer to // inject an array of autocompletion options into the page, rather // than sending out Ajax queries, which can be quite slow sometimes. // // The constructor takes four parameters. The first two are, as usual, // the id of the monitored textbox, and id of the autocompletion menu. // The third is the array you want to autocomplete from, and the fourth // is the options block. // // Extra local autocompletion options: // - choices - How many autocompletion choices to offer // // - partialSearch - If false, the autocompleter will match entered // text only at the beginning of strings in the // autocomplete array. Defaults to true, which will // match text at the beginning of any *word* in the // strings in the autocomplete array. If you want to // search anywhere in the string, additionally set // the option fullSearch to true (default: off). // // - fullSsearch - Search anywhere in autocomplete array strings. // // - partialChars - How many characters to enter before triggering // a partial match (unlike minChars, which defines // how many characters are required to do any match // at all). Defaults to 2. // // - ignoreCase - Whether to ignore case when autocompleting. // Defaults to true. // // It's possible to pass in a custom function as the 'selector' // option, if you prefer to write your own autocompletion logic. // In that case, the other options above will not apply unless // you support them. Autocompleter.Local = Class.create(); Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), { initialize: function(element, update, array, options) { this.baseInitialize(element, update, options); this.options.array = array; }, getUpdatedChoices: function() { this.updateChoices(this.options.selector(this)); }, setOptions: function(options) { this.options = Object.extend({ choices: 10, partialSearch: true, partialChars: 2, ignoreCase: true, fullSearch: false, selector: function(instance) { var ret = []; // Beginning matches var partial = []; // Inside matches var entry = instance.getToken(); var count = 0; for (var i = 0; i < instance.options.array.length && ret.length < instance.options.choices ; i++) { var elem = instance.options.array[i]; var foundPos = instance.options.ignoreCase ? elem.toLowerCase().indexOf(entry.toLowerCase()) : elem.indexOf(entry); while (foundPos != -1) { if (foundPos == 0 && elem.length != entry.length) { ret.push("
  • " + elem.substr(0, entry.length) + "" + elem.substr(entry.length) + "
  • "); break; } else if (entry.length >= instance.options.partialChars && instance.options.partialSearch && foundPos != -1) { if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) { partial.push("
  • " + elem.substr(0, foundPos) + "" + elem.substr(foundPos, entry.length) + "" + elem.substr( foundPos + entry.length) + "
  • "); break; } } foundPos = instance.options.ignoreCase ? elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) : elem.indexOf(entry, foundPos + 1); } } if (partial.length) ret = ret.concat(partial.slice(0, instance.options.choices - ret.length)) return "
      " + ret.join('') + "
    "; } }, options || {}); } }); // AJAX in-place editor // // see documentation on http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor // Use this if you notice weird scrolling problems on some browsers, // the DOM might be a bit confused when this gets called so do this // waits 1 ms (with setTimeout) until it does the activation Field.scrollFreeActivate = function(field) { setTimeout(function() { Field.activate(field); }, 1); } Ajax.InPlaceEditor = Class.create(); Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99"; Ajax.InPlaceEditor.prototype = { initialize: function(element, url, options) { this.url = url; this.element = $(element); this.options = Object.extend({ okText: "ok", cancelText: "cancel", savingText: "Saving...", clickToEditText: "Click to edit", okText: "ok", rows: 1, onComplete: function(transport, element) { new Effect.Highlight(element, {startcolor: this.options.highlightcolor}); }, onFailure: function(transport) { alert("Error communicating with the server: " + transport.responseText.stripTags()); }, callback: function(form) { return Form.serialize(form); }, handleLineBreaks: true, loadingText: 'Loading...', savingClassName: 'inplaceeditor-saving', loadingClassName: 'inplaceeditor-loading', formClassName: 'inplaceeditor-form', highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor, highlightendcolor: "#FFFFFF", externalControl: null, ajaxOptions: {} }, options || {}); if(!this.options.formId && this.element.id) { this.options.formId = this.element.id + "-inplaceeditor"; if ($(this.options.formId)) { // there's already a form with that name, don't specify an id this.options.formId = null; } } if (this.options.externalControl) { this.options.externalControl = $(this.options.externalControl); } this.originalBackground = Element.getStyle(this.element, 'background-color'); if (!this.originalBackground) { this.originalBackground = "transparent"; } this.element.title = this.options.clickToEditText; this.onclickListener = this.enterEditMode.bindAsEventListener(this); this.mouseoverListener = this.enterHover.bindAsEventListener(this); this.mouseoutListener = this.leaveHover.bindAsEventListener(this); Event.observe(this.element, 'click', this.onclickListener); Event.observe(this.element, 'mouseover', this.mouseoverListener); Event.observe(this.element, 'mouseout', this.mouseoutListener); if (this.options.externalControl) { Event.observe(this.options.externalControl, 'click', this.onclickListener); Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener); Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener); } }, enterEditMode: function(evt) { if (this.saving) return; if (this.editing) return; this.editing = true; this.onEnterEditMode(); if (this.options.externalControl) { Element.hide(this.options.externalControl); } Element.hide(this.element); this.createForm(); this.element.parentNode.insertBefore(this.form, this.element); Field.scrollFreeActivate(this.editField); // stop the event to avoid a page refresh in Safari if (evt) { Event.stop(evt); } return false; }, createForm: function() { this.form = document.createElement("form"); this.form.id = this.options.formId; Element.addClassName(this.form, this.options.formClassName) this.form.onsubmit = this.onSubmit.bind(this); this.createEditField(); if (this.options.textarea) { var br = document.createElement("br"); this.form.appendChild(br); } okButton = document.createElement("input"); okButton.type = "submit"; okButton.value = this.options.okText; this.form.appendChild(okButton); cancelLink = document.createElement("a"); cancelLink.href = "#"; cancelLink.appendChild(document.createTextNode(this.options.cancelText)); cancelLink.onclick = this.onclickCancel.bind(this); this.form.appendChild(cancelLink); }, hasHTMLLineBreaks: function(string) { if (!this.options.handleLineBreaks) return false; return string.match(/
    /i); }, convertHTMLLineBreaks: function(string) { return string.replace(/
    /gi, "\n").replace(//gi, "\n").replace(/<\/p>/gi, "\n").replace(/

    /gi, ""); }, createEditField: function() { var text; if(this.options.loadTextURL) { text = this.options.loadingText; } else { text = this.getText(); } if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) { this.options.textarea = false; var textField = document.createElement("input"); textField.type = "text"; textField.name = "value"; textField.value = text; textField.style.backgroundColor = this.options.highlightcolor; var size = this.options.size || this.options.cols || 0; if (size != 0) textField.size = size; this.editField = textField; } else { this.options.textarea = true; var textArea = document.createElement("textarea"); textArea.name = "value"; textArea.value = this.convertHTMLLineBreaks(text); textArea.rows = this.options.rows; textArea.cols = this.options.cols || 40; this.editField = textArea; } if(this.options.loadTextURL) { this.loadExternalText(); } this.form.appendChild(this.editField); }, getText: function() { return this.element.innerHTML; }, loadExternalText: function() { Element.addClassName(this.form, this.options.loadingClassName); this.editField.disabled = true; new Ajax.Request( this.options.loadTextURL, Object.extend({ asynchronous: true, onComplete: this.onLoadedExternalText.bind(this) }, this.options.ajaxOptions) ); }, onLoadedExternalText: function(transport) { Element.removeClassName(this.form, this.options.loadingClassName); this.editField.disabled = false; this.editField.value = transport.responseText.stripTags(); }, onclickCancel: function() { this.onComplete(); this.leaveEditMode(); return false; }, onFailure: function(transport) { this.options.onFailure(transport); if (this.oldInnerHTML) { this.element.innerHTML = this.oldInnerHTML; this.oldInnerHTML = null; } return false; }, onSubmit: function() { // onLoading resets these so we need to save them away for the Ajax call var form = this.form; var value = this.editField.value; // do this first, sometimes the ajax call returns before we get a chance to switch on Saving... // which means this will actually switch on Saving... *after* we've left edit mode causing Saving... // to be displayed indefinitely this.onLoading(); new Ajax.Updater( { success: this.element, // don't update on failure (this could be an option) failure: null }, this.url, Object.extend({ parameters: this.options.callback(form, value), onComplete: this.onComplete.bind(this), onFailure: this.onFailure.bind(this) }, this.options.ajaxOptions) ); // stop the event to avoid a page refresh in Safari if (arguments.length > 1) { Event.stop(arguments[0]); } return false; }, onLoading: function() { this.saving = true; this.removeForm(); this.leaveHover(); this.showSaving(); }, showSaving: function() { this.oldInnerHTML = this.element.innerHTML; this.element.innerHTML = this.options.savingText; Element.addClassName(this.element, this.options.savingClassName); this.element.style.backgroundColor = this.originalBackground; Element.show(this.element); }, removeForm: function() { if(this.form) { if (this.form.parentNode) Element.remove(this.form); this.form = null; } }, enterHover: function() { if (this.saving) return; this.element.style.backgroundColor = this.options.highlightcolor; if (this.effect) { this.effect.cancel(); } Element.addClassName(this.element, this.options.hoverClassName) }, leaveHover: function() { if (this.options.backgroundColor) { this.element.style.backgroundColor = this.oldBackground; } Element.removeClassName(this.element, this.options.hoverClassName) if (this.saving) return; this.effect = new Effect.Highlight(this.element, { startcolor: this.options.highlightcolor, endcolor: this.options.highlightendcolor, restorecolor: this.originalBackground }); }, leaveEditMode: function() { Element.removeClassName(this.element, this.options.savingClassName); this.removeForm(); this.leaveHover(); this.element.style.backgroundColor = this.originalBackground; Element.show(this.element); if (this.options.externalControl) { Element.show(this.options.externalControl); } this.editing = false; this.saving = false; this.oldInnerHTML = null; this.onLeaveEditMode(); }, onComplete: function(transport) { this.leaveEditMode(); this.options.onComplete.bind(this)(transport, this.element); }, onEnterEditMode: function() {}, onLeaveEditMode: function() {}, dispose: function() { if (this.oldInnerHTML) { this.element.innerHTML = this.oldInnerHTML; } this.leaveEditMode(); Event.stopObserving(this.element, 'click', this.onclickListener); Event.stopObserving(this.element, 'mouseover', this.mouseoverListener); Event.stopObserving(this.element, 'mouseout', this.mouseoutListener); if (this.options.externalControl) { Event.stopObserving(this.options.externalControl, 'click', this.onclickListener); Event.stopObserving(this.options.externalControl, 'mouseover', this.mouseoverListener); Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener); } } }; // Delayed observer, like Form.Element.Observer, // but waits for delay after last key input // Ideal for live-search fields Form.Element.DelayedObserver = Class.create(); Form.Element.DelayedObserver.prototype = { initialize: function(element, delay, callback) { this.delay = delay || 0.5; this.element = $(element); this.callback = callback; this.timer = null; this.lastValue = $F(this.element); Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this)); }, delayedListener: function(event) { if(this.lastValue == $F(this.element)) return; if(this.timer) clearTimeout(this.timer); this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000); this.lastValue = $F(this.element); }, onTimerEvent: function() { this.timer = null; this.callback(this.element, $F(this.element)); } }; --- NEW FILE: dragdrop.js --- // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // // See scriptaculous.js for full license. /*--------------------------------------------------------------------------*/ var Droppables = { drops: [], remove: function(element) { this.drops = this.drops.reject(function(d) { return d.element==$(element) }); }, add: function(element) { element = $(element); var options = Object.extend({ greedy: true, hoverclass: null }, arguments[1] || {}); // cache containers if(options.containment) { options._containers = []; var containment = options.containment; if((typeof containment == 'object') && (containment.constructor == Array)) { containment.each( function(c) { options._containers.push($(c)) }); } else { options._containers.push($(containment)); } } if(options.accept) options.accept = [options.accept].flatten(); Element.makePositioned(element); // fix IE options.element = element; this.drops.push(options); }, isContained: function(element, drop) { var parentNode = element.parentNode; return drop._containers.detect(function(c) { return parentNode == c }); }, isAffected: function(point, element, drop) { return ( (drop.element!=element) && ((!drop._containers) || this.isContained(element, drop)) && ((!drop.accept) || (Element.classNames(element).detect( function(v) { return drop.accept.include(v) } ) )) && Position.within(drop.element, point[0], point[1]) ); }, deactivate: function(drop) { if(drop.hoverclass) Element.removeClassName(drop.element, drop.hoverclass); this.last_active = null; }, activate: function(drop) { if(drop.hoverclass) Element.addClassName(drop.element, drop.hoverclass); this.last_active = drop; }, show: function(point, element) { if(!this.drops.length) return; if(this.last_active) this.deactivate(this.last_active); this.drops.each( function(drop) { if(Droppables.isAffected(point, element, drop)) { if(drop.onHover) drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element)); if(drop.greedy) { Droppables.activate(drop); throw $break; } } }); }, fire: function(event, element) { if(!this.last_active) return; Position.prepare(); if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active)) if (this.last_active.onDrop) this.last_active.onDrop(element, this.last_active.element, event); }, reset: function() { if(this.last_active) this.deactivate(this.last_active); } } var Draggables = { drags: [], observers: [], register: function(draggable) { if(this.drags.length == 0) { this.eventMouseUp = this.endDrag.bindAsEventListener(this); this.eventMouseMove = this.updateDrag.bindAsEventListener(this); this.eventKeypress = this.keyPress.bindAsEventListener(this); Event.observe(document, "mouseup", this.eventMouseUp); Event.observe(document, "mousemove", this.eventMouseMove); Event.observe(document, "keypress", this.eventKeypress); } this.drags.push(draggable); }, unregister: function(draggable) { this.drags = this.drags.reject(function(d) { return d==draggable }); if(this.drags.length == 0) { Event.stopObserving(document, "mouseup", this.eventMouseUp); Event.stopObserving(document, "mousemove", this.eventMouseMove); Event.stopObserving(document, "keypress", this.eventKeypress); } }, activate: function(draggable) { window.focus(); // allows keypress events if window isn't currently focused, fails for Safari this.activeDraggable = draggable; }, deactivate: function(draggbale) { this.activeDraggable = null; }, updateDrag: function(event) { if(!this.activeDraggable) return; var pointer = [Event.pointerX(event), Event.pointerY(event)]; // Mozilla-based browsers fire successive mousemove events with // the same coordinates, prevent needless redrawing (moz bug?) if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return; this._lastPointer = pointer; this.activeDraggable.updateDrag(event, pointer); }, endDrag: function(event) { if(!this.activeDraggable) return; this._lastPointer = null; this.activeDraggable.endDrag(event); }, keyPress: function(event) { if(this.activeDraggable) this.activeDraggable.keyPress(event); }, addObserver: function(observer) { this.observers.push(observer); this._cacheObserverCallbacks(); }, removeObserver: function(element) { // element instead of observer fixes mem leaks this.observers = this.observers.reject( function(o) { return o.element==element }); this._cacheObserverCallbacks(); }, notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag' if(this[eventName+'Count'] > 0) this.observers.each( function(o) { if(o[eventName]) o[eventName](eventName, draggable, event); }); }, _cacheObserverCallbacks: function() { ['onStart','onEnd','onDrag'].each( function(eventName) { Draggables[eventName+'Count'] = Draggables.observers.select( function(o) { return o[eventName]; } ).length; }); } } /*--------------------------------------------------------------------------*/ var Draggable = Class.create(); Draggable.prototype = { initialize: function(element) { var options = Object.extend({ handle: false, starteffect: function(element) { new Effect.Opacity(element, {duration:0.2, from:1.0, to:0.7}); }, reverteffect: function(element, top_offset, left_offset) { var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; element._revert = new Effect.MoveBy(element, -top_offset, -left_offset, {duration:dur}); }, endeffect: function(element) { new Effect.Opacity(element, {duration:0.2, from:0.7, to:1.0}); }, zindex: 1000, revert: false, snap: false // false, or xy or [x,y] or function(x,y){ return [x,y] } }, arguments[1] || {}); this.element = $(element); if(options.handle && (typeof options.handle == 'string')) this.handle = Element.childrenWithClassName(this.element, options.handle)[0]; if(!this.handle) this.handle = $(options.handle); if(!this.handle) this.handle = this.element; Element.makePositioned(this.element); // fix IE this.delta = this.currentDelta(); this.options = options; this.dragging = false; this.eventMouseDown = this.initDrag.bindAsEventListener(this); Event.observe(this.handle, "mousedown", this.eventMouseDown); Draggables.register(this); }, destroy: function() { Event.stopObserving(this.handle, "mousedown", this.eventMouseDown); Draggables.unregister(this); }, currentDelta: function() { return([ parseInt(this.element.style.left || '0'), parseInt(this.element.style.top || '0')]); }, initDrag: function(event) { if(Event.isLeftClick(event)) { // abort on form elements, fixes a Firefox issue var src = Event.element(event); if(src.tagName && ( src.tagName=='INPUT' || src.tagName=='SELECT' || src.tagName=='BUTTON' || src.tagName=='TEXTAREA')) return; if(this.element._revert) { this.element._revert.cancel(); this.element._revert = null; } var pointer = [Event.pointerX(event), Event.pointerY(event)]; var pos = Position.cumulativeOffset(this.element); this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) }); Draggables.activate(this); Event.stop(event); } }, startDrag: function(event) { this.dragging = true; if(this.options.zindex) { this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0); this.element.style.zIndex = this.options.zindex; } if(this.options.ghosting) { this._clone = this.element.cloneNode(true); Position.absolutize(this.element); this.element.parentNode.insertBefore(this._clone, this.element); } Draggables.notify('onStart', this, event); if(this.options.starteffect) this.options.starteffect(this.element); }, updateDrag: function(event, pointer) { if(!this.dragging) this.startDrag(event); Position.prepare(); Droppables.show(pointer, this.element); Draggables.notify('onDrag', this, event); this.draw(pointer); if(this.options.change) this.options.change(this); // fix AppleWebKit rendering if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); Event.stop(event); }, finishDrag: function(event, success) { this.dragging = false; if(this.options.ghosting) { Position.relativize(this.element); Element.remove(this._clone); this._clone = null; } if(success) Droppables.fire(event, this.element); Draggables.notify('onEnd', this, event); var revert = this.options.revert; if(revert && typeof revert == 'function') revert = revert(this.element); var d = this.currentDelta(); if(revert && this.options.reverteffect) { this.options.reverteffect(this.element, d[1]-this.delta[1], d[0]-this.delta[0]); } else { this.delta = d; } if(this.options.zindex) this.element.style.zIndex = this.originalZ; if(this.options.endeffect) this.options.endeffect(this.element); Draggables.deactivate(this); Droppables.reset(); }, keyPress: function(event) { if(!event.keyCode==Event.KEY_ESC) return; this.finishDrag(event, false); Event.stop(event); }, endDrag: function(event) { if(!this.dragging) return; this.finishDrag(event, true); Event.stop(event); }, draw: function(point) { var pos = Position.cumulativeOffset(this.element); var d = this.currentDelta(); pos[0] -= d[0]; pos[1] -= d[1]; var p = [0,1].map(function(i){ return (point[i]-pos[i]-this.offset[i]) }.bind(this)); if(this.options.snap) { if(typeof this.options.snap == 'function') { p = this.options.snap(p[0],p[1]); } else { if(this.options.snap instanceof Array) { p = p.map( function(v, i) { return Math.round(v/this.options.snap[i])*this.options.snap[i] }.bind(this)) } else { p = p.map( function(v) { return Math.round(v/this.options.snap)*this.options.snap }.bind(this)) } }} var style = this.element.style; if((!this.options.constraint) || (this.options.constraint=='horizontal')) style.left = p[0] + "px"; if((!this.options.constraint) || (this.options.constraint=='vertical')) style.top = p[1] + "px"; if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering } } /*--------------------------------------------------------------------------*/ var SortableObserver = Class.create(); SortableObserver.prototype = { initialize: function(element, observer) { this.element = $(element); this.observer = observer; this.lastValue = Sortable.serialize(this.element); }, onStart: function() { this.lastValue = Sortable.serialize(this.element); }, onEnd: function() { Sortable.unmark(); if(this.lastValue != Sortable.serialize(this.element)) this.observer(this.element) } } var Sortable = { sortables: new Array(), options: function(element){ element = $(element); return this.sortables.detect(function(s) { return s.element == element }); }, destroy: function(element){ element = $(element); this.sortables.findAll(function(s) { return s.element == element }).each(function(s){ Draggables.removeObserver(s.element); s.droppables.each(function(d){ Droppables.remove(d) }); s.draggables.invoke('destroy'); }); this.sortables = this.sortables.reject(function(s) { return s.element == element }); }, create: function(element) { element = $(element); var options = Object.extend({ element: element, tag: 'li', // assumes li children, override with tag: 'tagname' dropOnEmpty: false, tree: false, // fixme: unimplemented overlap: 'vertical', // one of 'vertical', 'horizontal' constraint: 'vertical', // one of 'vertical', 'horizontal', false containment: element, // also takes array of elements (or id's); or false handle: false, // or a CSS class only: false, hoverclass: null, ghosting: false, format: null, onChange: Prototype.emptyFunction, onUpdate: Prototype.emptyFunction }, arguments[1] || {}); // clear any old sortable with same element this.destroy(element); // build options for the draggables var options_for_draggable = { revert: true, ghosting: options.ghosting, constraint: options.constraint, handle: options.handle }; if(options.starteffect) options_for_draggable.starteffect = options.starteffect; if(options.reverteffect) options_for_draggable.reverteffect = options.reverteffect; else if(options.ghosting) options_for_draggable.reverteffect = function(element) { element.style.top = 0; element.style.left = 0; }; if(options.endeffect) options_for_draggable.endeffect = options.endeffect; if(options.zindex) options_for_draggable.zindex = options.zindex; // build options for the droppables var options_for_droppable = { overlap: options.overlap, containment: options.containment, hoverclass: options.hoverclass, onHover: Sortable.onHover, greedy: !options.dropOnEmpty } // fix for gecko engine Element.cleanWhitespace(element); options.draggables = []; options.droppables = []; // make it so // drop on empty handling if(options.dropOnEmpty) { Droppables.add(element, {containment: options.containment, onHover: Sortable.onEmptyHover, greedy: false}); options.droppables.push(element); } (this.findElements(element, options) || []).each( function(e) { // handles are per-draggable var handle = options.handle ? Element.childrenWithClassName(e, options.handle)[0] : e; options.draggables.push( new Draggable(e, Object.extend(options_for_draggable, { handle: handle }))); Droppables.add(e, options_for_droppable); options.droppables.push(e); }); // keep reference this.sortables.push(options); // for onupdate Draggables.addObserver(new SortableObserver(element, options.onUpdate)); }, // return all suitable-for-sortable elements in a guaranteed order findElements: function(element, options) { if(!element.hasChildNodes()) return null; var elements = []; $A(element.childNodes).each( function(e) { if(e.tagName && e.tagName.toUpperCase()==options.tag.toUpperCase() && (!options.only || (Element.hasClassName(e, options.only)))) elements.push(e); if(options.tree) { var grandchildren = this.findElements(e, options); if(grandchildren) elements.push(grandchildren); } }); return (elements.length>0 ? elements.flatten() : null); }, onHover: function(element, dropon, overlap) { if(overlap>0.5) { Sortable.mark(dropon, 'before'); if(dropon.previousSibling != element) { var oldParentNode = element.parentNode; element.style.visibility = "hidden"; // fix gecko rendering dropon.parentNode.insertBefore(element, dropon); if(dropon.parentNode!=oldParentNode) Sortable.options(oldParentNode).onChange(element); Sortable.options(dropon.parentNode).onChange(element); } } else { Sortable.mark(dropon, 'after'); var nextElement = dropon.nextSibling || null; if(nextElement != element) { var oldParentNode = element.parentNode; element.style.visibility = "hidden"; // fix gecko rendering dropon.parentNode.insertBefore(element, nextElement); if(dropon.parentNode!=oldParentNode) Sortable.options(oldParentNode).onChange(element); Sortable.options(dropon.parentNode).onChange(element); } } }, onEmptyHover: function(element, dropon) { if(element.parentNode!=dropon) { var oldParentNode = element.parentNode; dropon.appendChild(element); Sortable.options(oldParentNode).onChange(element); Sortable.options(dropon).onChange(element); } }, unmark: function() { if(Sortable._marker) Element.hide(Sortable._marker); }, mark: function(dropon, position) { // mark on ghosting only var sortable = Sortable.options(dropon.parentNode); if(sortable && !sortable.ghosting) return; if(!Sortable._marker) { Sortable._marker = $('dropmarker') || document.createElement('DIV'); Element.hide(Sortable._marker); Element.addClassName(Sortable._marker, 'dropmarker'); Sortable._marker.style.position = 'absolute'; document.getElementsByTagName("body").item(0).appendChild(Sortable._marker); } var offsets = Position.cumulativeOffset(dropon); Sortable._marker.style.left = offsets[0] + 'px'; Sortable._marker.style.top = offsets[1] + 'px'; if(position=='after') if(sortable.overlap == 'horizontal') Sortable._marker.style.left = (offsets[0]+dropon.clientWidth) + 'px'; else Sortable._marker.style.top = (offsets[1]+dropon.clientHeight) + 'px'; Element.show(Sortable._marker); }, serialize: function(element) { element = $(element); var sortableOptions = this.options(element); var options = Object.extend({ tag: sortableOptions.tag, only: sortableOptions.only, name: element.id, format: sortableOptions.format || /^[^_]*_(.*)$/ }, arguments[1] || {}); return $(this.findElements(element, options) || []).map( function(item) { return (encodeURIComponent(options.name) + "[]=" + encodeURIComponent(item.id.match(options.format) ? item.id.match(options.format)[1] : '')); }).join("&"); } } --- NEW FILE: effects.js --- // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Contributors: // Justin Palmer (http://encytemedia.com/) // Mark Pilgrim (http://diveintomark.org/) // Martin Bialasinki // // See scriptaculous.js for full license. /* ------------- element ext -------------- */ // converts rgb() and #xxx to #xxxxxx format, // returns self (or first argument) if not convertable String.prototype.parseColor = function() { var color = '#'; if(this.slice(0,4) == 'rgb(') { var cols = this.slice(4,this.length-1).split(','); var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3); } else { if(this.slice(0,1) == '#') { if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase(); if(this.length==7) color = this.toLowerCase(); } } return(color.length==7 ? color : (arguments[0] || this)); } Element.collectTextNodesIgnoreClass = function(element, ignoreclass) { var children = $(element).childNodes; var text = ''; var classtest = new RegExp('^([^ ]+ )*' + ignoreclass+ '( [^ ]+)*$','i'); for (var i = 0; i < children.length; i++) { if(children[i].nodeType==3) { text+=children[i].nodeValue; } else { if((!children[i].className.match(classtest)) && children[i].hasChildNodes()) text += Element.collectTextNodesIgnoreClass(children[i], ignoreclass); } } return text; } Element.setStyle = function(element, style) { element = $(element); for(k in style) element.style[k.camelize()] = style[k]; } Element.setContentZoom = function(element, percent) { Element.setStyle(element, {fontSize: (percent/100) + 'em'}); if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); } Element.getOpacity = function(element){ var opacity; if (opacity = Element.getStyle(element, 'opacity')) return parseFloat(opacity); if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/)) if(opacity[1]) return parseFloat(opacity[1]) / 100; return 1.0; } Element.setOpacity = function(element, value){ element= $(element); if (value == 1){ Element.setStyle(element, { opacity: (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 0.999999 : null }); if(/MSIE/.test(navigator.userAgent)) Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')}); } else { if(value < 0.00001) value = 0; Element.setStyle(element, {opacity: value}); if(/MSIE/.test(navigator.userAgent)) Element.setStyle(element, { filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') + 'alpha(opacity='+value*100+')' }); } } Element.getInlineOpacity = function(element){ return $(element).style.opacity || ''; } Element.childrenWithClassName = function(element, className) { return $A($(element).getElementsByTagName('*')).select( function(c) { return Element.hasClassName(c, className) }); } Array.prototype.call = function() { var args = arguments; this.each(function(f){ f.apply(this, args) }); } /*--------------------------------------------------------------------------*/ var Effect = { tagifyText: function(element) { var tagifyStyle = 'position:relative'; if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1'; element = $(element); $A(element.childNodes).each( function(child) { if(child.nodeType==3) { child.nodeValue.toArray().each( function(character) { element.insertBefore( Builder.node('span',{style: tagifyStyle}, character == ' ' ? String.fromCharCode(160) : character), child); }); Element.remove(child); } }); }, multiple: function(element, effect) { var elements; if(((typeof element == 'object') || (typeof element == 'function')) && (element.length)) elements = element; else elements = $(element).childNodes; var options = Object.extend({ speed: 0.1, delay: 0.0 }, arguments[2] || {}); var masterDelay = options.delay; $A(elements).each( function(element, index) { new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay })); }); } }; var Effect2 = Effect; // deprecated /* ------------- transitions ------------- */ Effect.Transitions = {} Effect.Transitions.linear = function(pos) { return pos; } Effect.Transitions.sinoidal = function(pos) { return (-Math.cos(pos*Math.PI)/2) + 0.5; } Effect.Transitions.reverse = function(pos) { return 1-pos; } Effect.Transitions.flicker = function(pos) { return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; } Effect.Transitions.wobble = function(pos) { return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; } Effect.Transitions.pulse = function(pos) { return (Math.floor(pos*10) % 2 == 0 ? (pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10))); } Effect.Transitions.none = function(pos) { return 0; } Effect.Transitions.full = function(pos) { return 1; } /* ------------- core effects ------------- */ Effect.Queue = { effects: [], _each: function(iterator) { this.effects._each(iterator); }, interval: null, add: function(effect) { var timestamp = new Date().getTime(); switch(effect.options.queue) { case 'front': // move unstarted effects after this effect this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) { e.startOn += effect.finishOn; e.finishOn += effect.finishOn; }); break; case 'end': // start effect after last queued effect has finished timestamp = this.effects.pluck('finishOn').max() || timestamp; break; } effect.startOn += timestamp; effect.finishOn += timestamp; this.effects.push(effect); if(!this.interval) this.interval = setInterval(this.loop.bind(this), 40); }, remove: function(effect) { this.effects = this.effects.reject(function(e) { return e==effect }); if(this.effects.length == 0) { clearInterval(this.interval); this.interval = null; } }, loop: function() { var timePos = new Date().getTime(); this.effects.invoke('loop', timePos); } } Object.extend(Effect.Queue, Enumerable); Effect.Base = function() {}; Effect.Base.prototype = { position: null, setOptions: function(options) { this.options = Object.extend({ transition: Effect.Transitions.sinoidal, duration: 1.0, // seconds fps: 25.0, // max. 25fps due to Effect.Queue implementation sync: false, // true for combining from: 0.0, to: 1.0, delay: 0.0, queue: 'parallel' }, options || {}); }, start: function(options) { this.setOptions(options || {}); this.currentFrame = 0; this.state = 'idle'; this.startOn = this.options.delay*1000; this.finishOn = this.startOn + (this.options.duration*1000); this.event('beforeStart'); if(!this.options.sync) Effect.Queue.add(this); }, loop: function(timePos) { if(timePos >= this.startOn) { if(timePos >= this.finishOn) { this.render(1.0); this.cancel(); this.event('beforeFinish'); if(this.finish) this.finish(); this.event('afterFinish'); return; } var pos = (timePos - this.startOn) / (this.finishOn - this.startOn); var frame = Math.round(pos * this.options.fps * this.options.duration); if(frame > this.currentFrame) { this.render(pos); this.currentFrame = frame; } } }, render: function(pos) { if(this.state == 'idle') { this.state = 'running'; this.event('beforeSetup'); if(this.setup) this.setup(); this.event('afterSetup'); } if(this.state == 'running') { if(this.options.transition) pos = this.options.transition(pos); pos *= (this.options.to-this.options.from); pos += this.options.from; this.position = pos; this.event('beforeUpdate'); if(this.update) this.update(pos); this.event('afterUpdate'); } }, cancel: function() { if(!this.options.sync) Effect.Queue.remove(this); this.state = 'finished'; }, event: function(eventName) { if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this); if(this.options[eventName]) this.options[eventName](this); }, inspect: function() { return '#'; } } Effect.Parallel = Class.create(); Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), { initialize: function(effects) { this.effects = effects || []; this.start(arguments[1]); }, update: function(position) { this.effects.invoke('render', position); }, finish: function(position) { this.effects.each( function(effect) { effect.render(1.0); effect.cancel(); effect.event('beforeFinish'); if(effect.finish) effect.finish(position); effect.event('afterFinish'); }); } }); Effect.Opacity = Class.create(); Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), { initialize: function(element) { this.element = $(element); // make this work on IE on elements without 'layout' if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout)) Element.setStyle(this.element, {zoom: 1}); var options = Object.extend({ from: Element.getOpacity(this.element) || 0.0, to: 1.0 }, arguments[1] || {}); this.start(options); }, update: function(position) { Element.setOpacity(this.element, position); } }); Effect.MoveBy = Class.create(); Object.extend(Object.extend(Effect.MoveBy.prototype, Effect.Base.prototype), { initialize: function(element, toTop, toLeft) { this.element = $(element); this.toTop = toTop; this.toLeft = toLeft; this.start(arguments[3]); }, setup: function() { // Bug in Opera: Opera returns the "real" position of a static element or // relative element that does not have top/left explicitly set. // ==> Always set top and left for position relative elements in your stylesheets // (to 0 if you do not need them) Element.makePositioned(this.element); this.originalTop = parseFloat(Element.getStyle(this.element,'top') || '0'); this.originalLeft = parseFloat(Element.getStyle(this.element,'left') || '0'); }, update: function(position) { Element.setStyle(this.element, { top: this.toTop * position + this.originalTop + 'px', left: this.toLeft * position + this.originalLeft + 'px' }); } }); Effect.Scale = Class.create(); Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), { initialize: function(element, percent) { this.element = $(element) var options = Object.extend({ scaleX: true, scaleY: true, scaleContent: true, scaleFromCenter: false, scaleMode: 'box', // 'box' or 'contents' or {} with provided values scaleFrom: 100.0, scaleTo: percent }, arguments[2] || {}); this.start(options); }, setup: function() { this.restoreAfterFinish = this.options.restoreAfterFinish || false; this.elementPositioning = Element.getStyle(this.element,'position'); this.originalStyle = {}; ['top','left','width','height','fontSize'].each( function(k) { this.originalStyle[k] = this.element.style[k]; }.bind(this)); this.originalTop = this.element.offsetTop; this.originalLeft = this.element.offsetLeft; var fontSize = Element.getStyle(this.element,'font-size') || '100%'; ['em','px','%'].each( function(fontSizeType) { if(fontSize.indexOf(fontSizeType)>0) { this.fontSize = parseFloat(fontSize); this.fontSizeType = fontSizeType; } }.bind(this)); this.factor = (this.options.scaleTo - this.options.scaleFrom)/100; this.dims = null; if(this.options.scaleMode=='box') this.dims = [this.element.offsetHeight, this.element.offsetWidth]; if(/^content/.test(this.options.scaleMode)) this.dims = [this.element.scrollHeight, this.element.scrollWidth]; if(!this.dims) this.dims = [this.options.scaleMode.originalHeight, this.options.scaleMode.originalWidth]; }, update: function(position) { var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position); if(this.options.scaleContent && this.fontSize) Element.setStyle(this.element, {fontSize: this.fontSize * currentScale + this.fontSizeType }); this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale); }, finish: function(position) { if (this.restoreAfterFinish) Element.setStyle(this.element, this.originalStyle); }, setDimensions: function(height, width) { var d = {}; if(this.options.scaleX) d.width = width + 'px'; if(this.options.scaleY) d.height = height + 'px'; if(this.options.scaleFromCenter) { var topd = (height - this.dims[0])/2; var leftd = (width - this.dims[1])/2; if(this.elementPositioning == 'absolute') { if(this.options.scaleY) d.top = this.originalTop-topd + 'px'; if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px'; } else { if(this.options.scaleY) d.top = -topd + 'px'; if(this.options.scaleX) d.left = -leftd + 'px'; } } Element.setStyle(this.element, d); } }); Effect.Highlight = Class.create(); Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), { initialize: function(element) { this.element = $(element); var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {}); this.start(options); }, setup: function() { // Prevent executing on elements not in the layout flow if(Element.getStyle(this.element, 'display')=='none') { this.cancel(); return; } // Disable background image during the effect this.oldStyle = { backgroundImage: Element.getStyle(this.element, 'background-image') }; Element.setStyle(this.element, {backgroundImage: 'none'}); if(!this.options.endcolor) this.options.endcolor = Element.getStyle(this.element, 'background-color').parseColor('#ffffff'); if(!this.options.restorecolor) this.options.restorecolor = Element.getStyle(this.element, 'background-color'); // init color calculations this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this)); this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this)); }, update: function(position) { Element.setStyle(this.element,{backgroundColor: $R(0,2).inject('#',function(m,v,i){ return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) }); }, finish: function() { Element.setStyle(this.element, Object.extend(this.oldStyle, { backgroundColor: this.options.restorecolor })); } }); Effect.ScrollTo = Class.create(); Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), { initialize: function(element) { this.element = $(element); this.start(arguments[1] || {}); }, setup: function() { Position.prepare(); var offsets = Position.cumulativeOffset(this.element); if(this.options.offset) offsets[1] += this.options.offset; var max = window.innerHeight ? window.height - window.innerHeight : document.body.scrollHeight - (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight); this.scrollStart = Position.deltaY; this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart; }, update: function(position) { Position.prepare(); window.scrollTo(Position.deltaX, this.scrollStart + (position*this.delta)); } }); /* ------------- combination effects ------------- */ Effect.Fade = function(element) { var oldOpacity = Element.getInlineOpacity(element); var options = Object.extend({ from: Element.getOpacity(element) || 1.0, to: 0.0, afterFinishInternal: function(effect) { with(Element) { if(effect.options.to!=0) return; hide(effect.element); setStyle(effect.element, {opacity: oldOpacity}); }} }, arguments[1] || {}); return new Effect.Opacity(element,options); } Effect.Appear = function(element) { var options = Object.extend({ from: (Element.getStyle(element, 'display') == 'none' ? 0.0 : Element.getOpacity(element) || 0.0), to: 1.0, beforeSetup: function(effect) { with(Element) { setOpacity(effect.element, effect.options.from); show(effect.element); }} }, arguments[1] || {}); return new Effect.Opacity(element,options); } Effect.Puff = function(element) { element = $(element); var oldStyle = { opacity: Element.getInlineOpacity(element), position: Element.getStyle(element, 'position') }; return new Effect.Parallel( [ new Effect.Scale(element, 200, { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], Object.extend({ duration: 1.0, beforeSetupInternal: function(effect) { with(Element) { setStyle(effect.effects[0].element, {position: 'absolute'}); }}, afterFinishInternal: function(effect) { with(Element) { hide(effect.effects[0].element); setStyle(effect.effects[0].element, oldStyle); }} }, arguments[1] || {}) ); } Effect.BlindUp = function(element) { element = $(element); Element.makeClipping(element); return new Effect.Scale(element, 0, Object.extend({ scaleContent: false, scaleX: false, restoreAfterFinish: true, afterFinishInternal: function(effect) { with(Element) { [hide, undoClipping].call(effect.element); }} }, arguments[1] || {}) ); } Effect.BlindDown = function(element) { element = $(element); var oldHeight = Element.getStyle(element, 'height'); var elementDimensions = Element.getDimensions(element); return new Effect.Scale(element, 100, Object.extend({ scaleContent: false, scaleX: false, scaleFrom: 0, scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, restoreAfterFinish: true, afterSetup: function(effect) { with(Element) { makeClipping(effect.element); setStyle(effect.element, {height: '0px'}); show(effect.element); }}, afterFinishInternal: function(effect) { with(Element) { undoClipping(effect.element); setStyle(effect.element, {height: oldHeight}); }} }, arguments[1] || {}) ); } Effect.SwitchOff = function(element) { element = $(element); var oldOpacity = Element.getInlineOpacity(element); return new Effect.Appear(element, { duration: 0.4, from: 0, transition: Effect.Transitions.flicker, afterFinishInternal: function(effect) { new Effect.Scale(effect.element, 1, { duration: 0.3, scaleFromCenter: true, scaleX: false, scaleContent: false, restoreAfterFinish: true, beforeSetup: function(effect) { with(Element) { [makePositioned,makeClipping].call(effect.element); }}, afterFinishInternal: function(effect) { with(Element) { [hide,undoClipping,undoPositioned].call(effect.element); setStyle(effect.element, {opacity: oldOpacity}); }} }) } }); } Effect.DropOut = function(element) { element = $(element); var oldStyle = { top: Element.getStyle(element, 'top'), left: Element.getStyle(element, 'left'), opacity: Element.getInlineOpacity(element) }; return new Effect.Parallel( [ new Effect.MoveBy(element, 100, 0, { sync: true }), new Effect.Opacity(element, { sync: true, to: 0.0 }) ], Object.extend( { duration: 0.5, beforeSetup: function(effect) { with(Element) { makePositioned(effect.effects[0].element); }}, afterFinishInternal: function(effect) { with(Element) { [hide, undoPositioned].call(effect.effects[0].element); setStyle(effect.effects[0].element, oldStyle); }} }, arguments[1] || {})); } Effect.Shake = function(element) { element = $(element); var oldStyle = { top: Element.getStyle(element, 'top'), left: Element.getStyle(element, 'left') }; return new Effect.MoveBy(element, 0, 20, { duration: 0.05, afterFinishInternal: function(effect) { new Effect.MoveBy(effect.element, 0, -40, { duration: 0.1, afterFinishInternal: function(effect) { new Effect.MoveBy(effect.element, 0, 40, { duration: 0.1, afterFinishInternal: function(effect) { new Effect.MoveBy(effect.element, 0, -40, { duration: 0.1, afterFinishInternal: function(effect) { new Effect.MoveBy(effect.element, 0, 40, { duration: 0.1, afterFinishInternal: function(effect) { new Effect.MoveBy(effect.element, 0, -20, { duration: 0.05, afterFinishInternal: function(effect) { with(Element) { undoPositioned(effect.element); setStyle(effect.element, oldStyle); }}}) }}) }}) }}) }}) }}); } Effect.SlideDown = function(element) { element = $(element); Element.cleanWhitespace(element); // SlideDown need to have the content of the element wrapped in a container element with fixed height! var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom'); var elementDimensions = Element.getDimensions(element); return new Effect.Scale(element, 100, Object.extend({ scaleContent: false, scaleX: false, scaleFrom: 0, scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, restoreAfterFinish: true, afterSetup: function(effect) { with(Element) { makePositioned(effect.element); makePositioned(effect.element.firstChild); if(window.opera) setStyle(effect.element, {top: ''}); makeClipping(effect.element); setStyle(effect.element, {height: '0px'}); show(element); }}, afterUpdateInternal: function(effect) { with(Element) { setStyle(effect.element.firstChild, {bottom: (effect.dims[0] - effect.element.clientHeight) + 'px' }); }}, afterFinishInternal: function(effect) { with(Element) { undoClipping(effect.element); undoPositioned(effect.element.firstChild); undoPositioned(effect.element); setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }} }, arguments[1] || {}) ); } Effect.SlideUp = function(element) { element = $(element); Element.cleanWhitespace(element); var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom'); return new Effect.Scale(element, 0, Object.extend({ scaleContent: false, scaleX: false, scaleMode: 'box', scaleFrom: 100, restoreAfterFinish: true, beforeStartInternal: function(effect) { with(Element) { makePositioned(effect.element); makePositioned(effect.element.firstChild); if(window.opera) setStyle(effect.element, {top: ''}); makeClipping(effect.element); show(element); }}, afterUpdateInternal: function(effect) { with(Element) { setStyle(effect.element.firstChild, {bottom: (effect.dims[0] - effect.element.clientHeight) + 'px' }); }}, afterFinishInternal: function(effect) { with(Element) { [hide, undoClipping].call(effect.element); undoPositioned(effect.element.firstChild); undoPositioned(effect.element); setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }} }, arguments[1] || {}) ); } // Bug in opera makes the TD containing this element expand for a instance after finish Effect.Squish = function(element) { return new Effect.Scale(element, window.opera ? 1 : 0, { restoreAfterFinish: true, beforeSetup: function(effect) { with(Element) { makeClipping(effect.element); }}, afterFinishInternal: function(effect) { with(Element) { hide(effect.element); undoClipping(effect.element); }} }); } Effect.Grow = function(element) { element = $(element); var options = Object.extend({ direction: 'center', moveTransistion: Effect.Transitions.sinoidal, scaleTransition: Effect.Transitions.sinoidal, opacityTransition: Effect.Transitions.full }, arguments[1] || {}); var oldStyle = { top: element.style.top, left: element.style.left, height: element.style.height, width: element.style.width, opacity: Element.getInlineOpacity(element) }; var dims = Element.getDimensions(element); var initialMoveX, initialMoveY; var moveX, moveY; switch (options.direction) { case 'top-left': initialMoveX = initialMoveY = moveX = moveY = 0; break; case 'top-right': initialMoveX = dims.width; initialMoveY = moveY = 0; moveX = -dims.width; break; case 'bottom-left': initialMoveX = moveX = 0; initialMoveY = dims.height; moveY = -dims.height; break; case 'bottom-right': initialMoveX = dims.width; initialMoveY = dims.height; moveX = -dims.width; moveY = -dims.height; break; case 'center': initialMoveX = dims.width / 2; initialMoveY = dims.height / 2; moveX = -dims.width / 2; moveY = -dims.height / 2; break; } return new Effect.MoveBy(element, initialMoveY, initialMoveX, { duration: 0.01, beforeSetup: function(effect) { with(Element) { hide(effect.element); makeClipping(effect.element); makePositioned(effect.element); }}, afterFinishInternal: function(effect) { new Effect.Parallel( [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }), new Effect.MoveBy(effect.element, moveY, moveX, { sync: true, transition: options.moveTransition }), new Effect.Scale(effect.element, 100, { scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true}) ], Object.extend({ beforeSetup: function(effect) { with(Element) { setStyle(effect.effects[0].element, {height: '0px'}); show(effect.effects[0].element); }}, afterFinishInternal: function(effect) { with(Element) { [undoClipping, undoPositioned].call(effect.effects[0].element); setStyle(effect.effects[0].element, oldStyle); }} }, options) ) } }); } Effect.Shrink = function(element) { element = $(element); var options = Object.extend({ direction: 'center', moveTransistion: Effect.Transitions.sinoidal, scaleTransition: Effect.Transitions.sinoidal, opacityTransition: Effect.Transitions.none }, arguments[1] || {}); var oldStyle = { top: element.style.top, left: element.style.left, height: element.style.height, width: element.style.width, opacity: Element.getInlineOpacity(element) }; var dims = Element.getDimensions(element); var moveX, moveY; switch (options.direction) { case 'top-left': moveX = moveY = 0; break; case 'top-right': moveX = dims.width; moveY = 0; break; case 'bottom-left': moveX = 0; moveY = dims.height; break; case 'bottom-right': moveX = dims.width; moveY = dims.height; break; case 'center': moveX = dims.width / 2; moveY = dims.height / 2; break; } return new Effect.Parallel( [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }), new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}), new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: options.moveTransition }) ], Object.extend({ beforeStartInternal: function(effect) { with(Element) { [makePositioned, makeClipping].call(effect.effects[0].element) }}, afterFinishInternal: function(effect) { with(Element) { [hide, undoClipping, undoPositioned].call(effect.effects[0].element); setStyle(effect.effects[0].element, oldStyle); }} }, options) ); } Effect.Pulsate = function(element) { element = $(element); var options = arguments[1] || {}; var oldOpacity = Element.getInlineOpacity(element); var transition = options.transition || Effect.Transitions.sinoidal; var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) }; reverser.bind(transition); return new Effect.Opacity(element, Object.extend(Object.extend({ duration: 3.0, from: 0, afterFinishInternal: function(effect) { Element.setStyle(effect.element, {opacity: oldOpacity}); } }, options), {transition: reverser})); } Effect.Fold = function(element) { element = $(element); var oldStyle = { top: element.style.top, left: element.style.left, width: element.style.width, height: element.style.height }; Element.makeClipping(element); return new Effect.Scale(element, 5, Object.extend({ scaleContent: false, scaleX: false, afterFinishInternal: function(effect) { new Effect.Scale(element, 1, { scaleContent: false, scaleY: false, afterFinishInternal: function(effect) { with(Element) { [hide, undoClipping].call(effect.element); setStyle(effect.element, oldStyle); }} }); }}, arguments[1] || {})); } From trevor at pub.open-bio.org Tue Feb 28 16:21:06 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Tue, 28 Feb 2006 21:21:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db rebase.rb,1.3,1.4 Message-ID: <200602282121.k1SLL6VL012447@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv12437 Modified Files: rebase.rb Log Message: Change 'reference' to 'bio/reference'. Index: rebase.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/rebase.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** rebase.rb 27 Feb 2006 13:22:05 -0000 1.3 --- rebase.rb 28 Feb 2006 21:21:03 -0000 1.4 *************** *** 118,122 **** module Bio ! autoload :Reference, 'reference' --- 118,122 ---- module Bio ! autoload :Reference, 'bio/reference' From trevor at pub.open-bio.org Tue Feb 28 16:45:58 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Tue, 28 Feb 2006 21:45:58 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util restriction_enzyme.rb,1.3,1.4 Message-ID: <200602282145.k1SLjwVL012531@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util In directory pub.open-bio.org:/tmp/cvs-serv12521 Modified Files: restriction_enzyme.rb Log Message: Fix for enzymes.yaml relative location Index: restriction_enzyme.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** restriction_enzyme.rb 27 Feb 2006 13:11:28 -0000 1.3 --- restriction_enzyme.rb 28 Feb 2006 21:45:56 -0000 1.4 *************** *** 214,218 **** # Returns a Bio::REBASE object loaded with all of the enzyme data on file. # ! def self.rebase(enzymes_yaml) @@rebase_enzymes ||= Bio::REBASE.load_yaml(enzymes_yaml) @@rebase_enzymes --- 214,219 ---- # Returns a Bio::REBASE object loaded with all of the enzyme data on file. # ! #def self.rebase(enzymes_yaml = '/home/trevor/tmp5/bioruby/lib/bio/util/restriction_enzyme/enzymes.yaml') ! def self.rebase(enzymes_yaml = File.dirname(__FILE__) + '/restriction_enzyme/enzymes.yaml') @@rebase_enzymes ||= Bio::REBASE.load_yaml(enzymes_yaml) @@rebase_enzymes From trevor at pub.open-bio.org Tue Feb 28 17:21:50 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Tue, 28 Feb 2006 22:21:50 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme analysis.rb, 1.3, 1.4 Message-ID: <200602282221.k1SMLoVL012608@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv12598 Modified Files: analysis.rb Log Message: Error handling for when a match isn't found. Index: analysis.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** analysis.rb 18 Feb 2006 22:11:35 -0000 1.3 --- analysis.rb 28 Feb 2006 22:21:48 -0000 1.4 *************** *** 93,96 **** --- 93,97 ---- sequence = Bio::Sequence::NA.new( sequence ) enzyme_actions = create_enzyme_actions( sequence, *args ) + return nil if enzyme_actions.empty? permutations = permute(enzyme_actions.size) *************** *** 201,204 **** --- 202,207 ---- def unique_fragments_for_display( hash_of_sequence_ranges_with_cuts ) uf_ary = UniqueFragments.new + return uf_ary if hash_of_sequence_ranges_with_cuts == nil or hash_of_sequence_ranges_with_cuts.empty? + hash_of_sequence_ranges_with_cuts.each do |permutation, sr_with_cuts| sr_with_cuts.fragments.for_display.each do |fragment| From trevor at pub.open-bio.org Tue Feb 28 17:22:52 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Tue, 28 Feb 2006 22:22:52 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme test_analysis.rb, 1.2, 1.3 Message-ID: <200602282222.k1SMMqVL012625@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv12615 Modified Files: test_analysis.rb Log Message: Test for case where no match is made. Index: test_analysis.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/test_analysis.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_analysis.rb 18 Feb 2006 22:11:05 -0000 1.2 --- test_analysis.rb 28 Feb 2006 22:22:50 -0000 1.3 *************** *** 31,34 **** --- 31,37 ---- @obj_8 = @t.cut('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII', 'HincII') + @obj_9 = @t.cut('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'EcoRII') + @obj_9 = @t.cut('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'EcoRII', 'HincII') + @obj_1d = @t.cut_without_permutations('cagagag', 'ag^ag') @obj_2d = @t.cut_without_permutations('agagag', 'ag^ag') From trevor at pub.open-bio.org Tue Feb 28 20:40:03 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Mar 2006 01:40:03 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme analysis.rb, 1.4, 1.5 Message-ID: <200603010140.k211e3VL013061@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv13046 Modified Files: analysis.rb Log Message: Huge optimization by getting ride of unnecessary permutations. Index: analysis.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** analysis.rb 28 Feb 2006 22:21:48 -0000 1.4 --- analysis.rb 1 Mar 2006 01:40:00 -0000 1.5 *************** *** 71,77 **** def cut_without_permutations( sequence, *args ) ! return nil if !sequence.kind_of?(String) or sequence.empty? sequence = Bio::Sequence::NA.new( sequence ) ! enzyme_actions = create_enzyme_actions( sequence, *args ) sr_with_cuts = SequenceRange.new( 0, 0, sequence.size-1, sequence.size-1 ) enzyme_actions.each do |id, enzyme_action| --- 71,81 ---- def cut_without_permutations( sequence, *args ) ! return {} if !sequence.kind_of?(String) or sequence.empty? sequence = Bio::Sequence::NA.new( sequence ) ! ! #enzyme_actions = create_enzyme_actions( sequence, *args ) ! tmp = create_enzyme_actions( sequence, *args ) ! enzyme_actions = tmp[0].merge(tmp[1]) ! sr_with_cuts = SequenceRange.new( 0, 0, sequence.size-1, sequence.size-1 ) enzyme_actions.each do |id, enzyme_action| *************** *** 90,105 **** def cut_and_return_by_permutations( sequence, *args ) ! return nil if !sequence.kind_of?(String) or sequence.empty? sequence = Bio::Sequence::NA.new( sequence ) ! enzyme_actions = create_enzyme_actions( sequence, *args ) ! return nil if enzyme_actions.empty? ! permutations = permute(enzyme_actions.size) # Indexed by permutation. hash_of_sequence_ranges_with_cuts = {} permutations.each do |permutation| previous_cut_ranges = [] sr_with_cuts = SequenceRange.new( 0, 0, sequence.size-1, sequence.size-1 ) permutation.each do |id| --- 94,121 ---- def cut_and_return_by_permutations( sequence, *args ) ! return {} if !sequence.kind_of?(String) or sequence.empty? sequence = Bio::Sequence::NA.new( sequence ) ! enzyme_actions, initial_cuts = create_enzyme_actions( sequence, *args ) ! return {} if enzyme_actions.empty? and initial_cuts.empty? ! ! if enzyme_actions.size > 1 ! permutations = permute(enzyme_actions.size) ! else ! permutations = [] ! end # Indexed by permutation. hash_of_sequence_ranges_with_cuts = {} + if permutations.empty? + sr_with_cuts = SequenceRange.new( 0, 0, sequence.size-1, sequence.size-1 ) + initial_cuts.each { |key, enzyme_action| enzyme_action.cut_ranges.each { |cut_range| sr_with_cuts.add_cut_range(cut_range) } } + hash_of_sequence_ranges_with_cuts[0] = sr_with_cuts + end + permutations.each do |permutation| previous_cut_ranges = [] sr_with_cuts = SequenceRange.new( 0, 0, sequence.size-1, sequence.size-1 ) + initial_cuts.each { |enzyme_action| enzyme_action.cut_ranges.each { |cut_range| sr_with_cuts.add_cut_range(cut_range) } } permutation.each do |id| *************** *** 251,265 **** def create_enzyme_actions( sequence, *args ) id = 0 ! enzyme_actions = {} args.each do |enzyme| enzyme = Bio::RestrictionEnzyme.new(enzyme) unless enzyme.class == Bio::RestrictionEnzyme::DoubleStranded find_match_locations( sequence, enzyme.primary.to_re ).each do |offset| ! enzyme_actions[id] = enzyme_to_enzyme_action( enzyme, offset ) id += 1 end end ! enzyme_actions end --- 267,338 ---- def create_enzyme_actions( sequence, *args ) id = 0 ! enzyme_actions_that_sometimes_cut = {} ! enzyme_actions_that_always_cut = {} ! indicies_of_sometimes_cut = [] args.each do |enzyme| enzyme = Bio::RestrictionEnzyme.new(enzyme) unless enzyme.class == Bio::RestrictionEnzyme::DoubleStranded find_match_locations( sequence, enzyme.primary.to_re ).each do |offset| ! enzyme_actions_that_always_cut[id] = enzyme_to_enzyme_action( enzyme, offset ) id += 1 end end ! # enzyme_actions_that_always_cut may lose members, the members to be lost are recorded in indicies_of_sometimes_cut ! ! max = enzyme_actions_that_always_cut.size - 1 ! 0.upto(max) do |i| ! enzyme_action = enzyme_actions_that_always_cut[i] ! conflict = false ! other_cut_ranges = {} ! #enzyme_actions.each { |key,enzyme_action| next if i == key; puts "i: #{i}, key: #{key}"; previous_cut_ranges += enzyme_action.cut_ranges } ! # enzyme_actions_that_always_cut.each { |key,i_ea| next if i == key; puts "i: #{i}, key: #{key}"; other_cut_ranges[key] = i_ea.cut_ranges } ! enzyme_actions_that_always_cut.each { |key,i_ea| next if i == key; other_cut_ranges[key] = i_ea.cut_ranges } ! # puts "Enzyme action #{i}:" ! # pp enzyme_actions[i] ! # pp enzyme_action ! # puts "Previous cut ranges:" ! # pp previous_cut_ranges ! ! other_cut_ranges.each do |key, cut_ranges| ! cut_ranges.each do |cut_range| ! next unless cut_range.class == VerticalCutRange # we aren't concerned with horizontal cuts ! previous_cut_left = cut_range.range.first ! previous_cut_right = cut_range.range.last ! ! if (enzyme_action.right <= previous_cut_left) or ! (enzyme_action.left > previous_cut_right) or ! (enzyme_action.left > previous_cut_left and enzyme_action.right <= previous_cut_right) # in between cuts ! # no conflict ! # puts "no conflict" ! ! else ! conflict = true ! # puts "conflict" ! #puts "cut range:" ! #pp cut_range ! #puts "enzyme action:" ! #pp enzyme_action ! end ! ! indicies_of_sometimes_cut += [i, key] if conflict == true ! end ! end ! ! # We don't need to make permutations with this enzyme action if it always cuts ! # indicies << i if conflict == false ! end ! # pp indicies_of_sometimes_cut ! ! indicies_of_sometimes_cut.uniq.each do |i| ! enzyme_actions_that_sometimes_cut[i] = enzyme_actions_that_always_cut[i] ! enzyme_actions_that_always_cut.delete(i) ! end ! #puts 'Always cut:' ! #pp enzyme_actions_that_always_cut ! #puts 'Permute:' ! #pp enzyme_actions_that_sometimes_cut ! ! [enzyme_actions_that_sometimes_cut, enzyme_actions_that_always_cut] end From nakao at pub.open-bio.org Thu Feb 2 16:30:32 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 02 Feb 2006 16:30:32 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io ddbjxml.rb,1.9,1.10 Message-ID: <200602021630.k12GUWVL001709@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory pub.open-bio.org:/tmp/cvs-serv1699/lib/bio/io Modified Files: ddbjxml.rb Log Message: * Updated RDoc. Index: ddbjxml.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/ddbjxml.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ddbjxml.rb 26 Nov 2005 09:37:11 -0000 1.9 --- ddbjxml.rb 2 Feb 2006 16:30:29 -0000 1.10 *************** *** 37,41 **** # = Bio::DDBJ::XML # ! # Accessing the DDBJ web services at # # * http://xml.nig.ac.jp/ --- 37,41 ---- # = Bio::DDBJ::XML # ! # Accessing the DDBJ web services. # # * http://xml.nig.ac.jp/ *************** *** 46,77 **** BASE_URI = "http://xml.nig.ac.jp/wsdl/" ! # = Blast # ! # BLAST Database Search # # * http://xml.nig.ac.jp/doc/Blast.txt # ! # == Examples # ! # serv = Bio::DDBJ::XML::Blast.new ! # query = "MSSRIARALALVVTLLHLTRLALSTCPAACHCPLEAPKCAPGVGLVRDGCGCCKVCAKQL" # ! # report = serv.searchSimple('blastp', 'SWISS', query) ! # Bio::Blast::Default::Report.new(report).each_hit do |hit| ! # hit.hsps.find_all {|x| x.evalue < 0.1 }.each do |hsp| ! # p [hsps.evalue, hsps.identity, hsps.definition] ! # end ! # end ! # ! # puts serv.searchParam('tblastn', 'ddbjvrl', query, '-m 8') # ! # == WSDL Methods # ! # * searchSimple(program, database, query) # Returns a blast report in the default format. ! # * searchParam(program, database, query, param) # Blasts with param and returns a blast report. # ! # == References # # * http://xml.nig.ac.jp/doc/Blast.txt --- 46,85 ---- BASE_URI = "http://xml.nig.ac.jp/wsdl/" ! # === Description # ! # DDBJ XML BLAST Database Search # # * http://xml.nig.ac.jp/doc/Blast.txt # ! # === Examples # ! # serv = Bio::DDBJ::XML::Blast.new ! # program = 'blastp' ! # database = 'SWISS' ! # query = "MSSRIARALALVVTLLHLTRLALSTCPAACHCPLEAPKCAPGVGLVRDGCGCCKVCAKQL" ! # ! # report = serv.searchSimple(program, database, query) ! # Bio::Blast::Default::Report.new(report).each_hit do |hit| ! # hit.hsps.find_all {|x| x.evalue < 0.1 }.each do |hsp| ! # p [hsps.evalue, hsps.identity, hsps.definition] ! # end ! # end # ! # program = 'tblastn' ! # database = 'ddbjvrl' ! # param = '-m 8 -e 0.001' ! # puts serv.searchParam(program, database, query, param) # ! # === WSDL Methods # ! # ==== searchSimple(program, database, query) ! # # Returns a blast report in the default format. ! # ! # ==== searchParam(program, database, query, param) ! # # Blasts with param and returns a blast report. # ! # === References # # * http://xml.nig.ac.jp/doc/Blast.txt *************** *** 79,82 **** --- 87,92 ---- class Blast < XML SERVER_URI = BASE_URI + "Blast.wsdl" + + # returns a Bio::DDBJ::XML::Blast object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 85,89 **** ! # == ClustalW # # Multiple seaquece alignment using ClustalW. --- 95,99 ---- ! # === ClustalW # # Multiple seaquece alignment using ClustalW. *************** *** 91,95 **** # * http://xml.nig.ac.jp/doc/ClustalW.txt # ! # == Examples # # serv = Bio::DDBJ::XML::ClustalW.new --- 101,105 ---- # * http://xml.nig.ac.jp/doc/ClustalW.txt # ! # === Examples # # serv = Bio::DDBJ::XML::ClustalW.new *************** *** 112,121 **** # puts serv.analyzeParam(query, '-align -matrix=blosum') # ! # == WSDL Methods # ! # * analyzeSimple(query) ! # * analyzeParam(query, param) # ! # == References # # * http://xml.nig.ac.jp/doc/ClustalW.txt --- 122,131 ---- # puts serv.analyzeParam(query, '-align -matrix=blosum') # ! # === WSDL Methods # ! # ==== analyzeSimple(query) ! # ==== analyzeParam(query, param) # ! # === References # # * http://xml.nig.ac.jp/doc/ClustalW.txt *************** *** 123,126 **** --- 133,138 ---- class ClustalW < XML SERVER_URI = BASE_URI + "ClustalW.wsdl" + + # returns a Bio::DDBJ::XML::ClustalW object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 129,133 **** ! # = DDBJ # # Retrieves a sequence entry from the DDBJ DNA Data Bank Japan. --- 141,145 ---- ! # == DDBJ # # Retrieves a sequence entry from the DDBJ DNA Data Bank Japan. *************** *** 135,139 **** # * http://xml.nig.ac.jp/doc/DDBJ.txt # ! # == Examples # # serv = Bio::DDBJ::XML::DDBJ.new --- 147,151 ---- # * http://xml.nig.ac.jp/doc/DDBJ.txt # ! # === Examples # # serv = Bio::DDBJ::XML::DDBJ.new *************** *** 145,158 **** # puts serv.getRelatedFeaturesSeq('AL121903', '59000', '64000') # ! # == WSDL Methods # ! # * getFFEntry(accession) ! # * getXMLEntry(accession) ! # * getFeatureInfo(accession, feature) ! # * getAllFeatures(accession) ! # * getRelatedFeatures(accession, start, stop) ! # * getRelatedFeaturesSeq(accession, start, stop) # ! # == References # # * http://xml.nig.ac.jp/doc/DDBJ.txt --- 157,170 ---- # puts serv.getRelatedFeaturesSeq('AL121903', '59000', '64000') # ! # === WSDL Methods # ! # ==== getFFEntry(accession) ! # ==== getXMLEntry(accession) ! # ==== getFeatureInfo(accession, feature) ! # ==== getAllFeatures(accession) ! # ==== getRelatedFeatures(accession, start, stop) ! # ==== getRelatedFeaturesSeq(accession, start, stop) # ! # === References # # * http://xml.nig.ac.jp/doc/DDBJ.txt *************** *** 160,163 **** --- 172,177 ---- class DDBJ < XML SERVER_URI = BASE_URI + "DDBJ.wsdl" + + # returns a Bio::DDBJ::XML::DDBJ object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 166,170 **** ! # = Fasta # # Searching database using the Fasta package. --- 180,184 ---- ! # == Fasta # # Searching database using the Fasta package. *************** *** 172,176 **** # * http://xml.nig.ac.jp/doc/Fasta.txt # ! # == Examples # # serv = Bio::DDBJ::XML::Fasta.new --- 186,190 ---- # * http://xml.nig.ac.jp/doc/Fasta.txt # ! # === Examples # # serv = Bio::DDBJ::XML::Fasta.new *************** *** 181,190 **** # puts serv.searchParam('fastx34_t', 'PDB', query, '-n') # ! # == WSDL Methods # ! # * searchSimple(program, database, query) ! # * searchParam(program, database, query, param) # ! # == References # # * http://xml.nig.ac.jp/doc/Fasta.txt --- 195,204 ---- # puts serv.searchParam('fastx34_t', 'PDB', query, '-n') # ! # === WSDL Methods # ! # ==== searchSimple(program, database, query) ! # ==== searchParam(program, database, query, param) # ! # === References # # * http://xml.nig.ac.jp/doc/Fasta.txt *************** *** 192,195 **** --- 206,211 ---- class Fasta < XML SERVER_URI = BASE_URI + "Fasta.wsdl" + + # returns a Bio::DDBJ::XML::Fasta object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 198,202 **** ! # = GetEntry # # Retrieves database entries. --- 214,218 ---- ! # == GetEntry # # Retrieves database entries. *************** *** 204,208 **** # * http://xml.nig.ac.jp/doc/GetEntry.txt # ! # == Examples # # serv = Bio::DDBJ::XML::GetEntry.new --- 220,224 ---- # * http://xml.nig.ac.jp/doc/GetEntry.txt # ! # === Examples # # serv = Bio::DDBJ::XML::GetEntry.new *************** *** 210,246 **** # puts serv. getPDBEntry('1AAR') # ! # == WSDL Methods # ! # * getEntry(database, var, param1, param2) ! # * getEntry(database, var) ! # * getDDBJEntry(accession) ! # * getDDBJCONEntry(accession) ! # * getDDBJVerEntry(accession) ! # * getLocus_DDBJEntry(locus) ! # * getGene_DDBJEntry(gene) ! # * getProd_DDBJEntry(products) ! # * getPID_DDBJEntry(pid) ! # * getClone_DDBJEntry(clone) ! # * getXML_DDBJEntry(accession) ! # * getEMBLEntry(accession) ! # * getSWISSEntry(accession) ! # * getPIREntry(accession) ! # * getPRFEntry(accession) ! # * getPDBEntry(accession) ! # * getQVEntry(accession) ! # * getDADEntry(accession) ! # * getPID_DADEntry(pid) ! # * getFASTA_DDBJEntry(accession) ! # * getFASTA_DDBJCONEntry(accession) ! # * getFASTA_DDBJVerEntry(accession) ! # * getFASTA_DDBJSeqEntry(accession, start, end) ! # * getFASTA_DADEntry(accession) ! # * getFASTA_PIREntry(accession) ! # * getFASTA_SWISSEntry(accession) ! # * getFASTA_PDBEntry(accession) ! # * getFASTA_PRFEntry(accession) ! # * getFASTA_CDSEntry(accession) # ! # == References # # * http://xml.nig.ac.jp/doc/GetEntry.txt --- 226,262 ---- # puts serv. getPDBEntry('1AAR') # ! # === WSDL Methods # ! # ==== getEntry(database, var, param1, param2) ! # ==== getEntry(database, var) ! # ==== getDDBJEntry(accession) ! # ==== getDDBJCONEntry(accession) ! # ==== getDDBJVerEntry(accession) ! # ==== getLocus_DDBJEntry(locus) ! # ==== getGene_DDBJEntry(gene) ! # ==== getProd_DDBJEntry(products) ! # ==== getPID_DDBJEntry(pid) ! # ==== getClone_DDBJEntry(clone) ! # ==== getXML_DDBJEntry(accession) ! # ==== getEMBLEntry(accession) ! # ==== getSWISSEntry(accession) ! # ==== getPIREntry(accession) ! # ==== getPRFEntry(accession) ! # ==== getPDBEntry(accession) ! # ==== getQVEntry(accession) ! # ==== getDADEntry(accession) ! # ==== getPID_DADEntry(pid) ! # ==== getFASTA_DDBJEntry(accession) ! # ==== getFASTA_DDBJCONEntry(accession) ! # ==== getFASTA_DDBJVerEntry(accession) ! # ==== getFASTA_DDBJSeqEntry(accession, start, end) ! # ==== getFASTA_DADEntry(accession) ! # ==== getFASTA_PIREntry(accession) ! # ==== getFASTA_SWISSEntry(accession) ! # ==== getFASTA_PDBEntry(accession) ! # ==== getFASTA_PRFEntry(accession) ! # ==== getFASTA_CDSEntry(accession) # ! # === References # # * http://xml.nig.ac.jp/doc/GetEntry.txt *************** *** 248,251 **** --- 264,269 ---- class GetEntry < XML SERVER_URI = BASE_URI + "GetEntry.wsdl" + + # returns a Bio::DDBJ::XML::GetEntry object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 254,258 **** ! # = Gib # # Genome Information broker --- 272,276 ---- ! # === Gib # # Genome Information broker *************** *** 260,264 **** # * http://xml.nig.ac.jp/doc/Gib.txt # ! # == Examples # # serv = Bio::DDBJ::XML::Gib.new --- 278,282 ---- # * http://xml.nig.ac.jp/doc/Gib.txt # ! # === Examples # # serv = Bio::DDBJ::XML::Gib.new *************** *** 275,293 **** # puts serv.getFastaFile('Nost_PCC7120:pCC7120zeta', 'cdsaa') # ! # == WSDL Methods # ! # * getOrganismList ! # * getChIDList ! # * getOrganismNameFromChid(chid) ! # * getChIDFromOrganismName(orgName) ! # * getAccession(chid) ! # * getPieceNumber(chid) ! # * getDivision(chid) ! # * getType(chid) ! # * getFlatFile(chid) ! # * getFastaFile(chid, type) ! # * getCDS(chid) # ! # == References # # * http://xml.nig.ac.jp/doc/Gib.txt --- 293,311 ---- # puts serv.getFastaFile('Nost_PCC7120:pCC7120zeta', 'cdsaa') # ! # === WSDL Methods # ! # ==== getOrganismList ! # ==== getChIDList ! # ==== getOrganismNameFromChid(chid) ! # ==== getChIDFromOrganismName(orgName) ! # ==== getAccession(chid) ! # ==== getPieceNumber(chid) ! # ==== getDivision(chid) ! # ==== getType(chid) ! # ==== getFlatFile(chid) ! # ==== getFastaFile(chid, type) ! # ==== getCDS(chid) # ! # === References # # * http://xml.nig.ac.jp/doc/Gib.txt *************** *** 295,298 **** --- 313,318 ---- class Gib < XML SERVER_URI = BASE_URI + "Gib.wsdl" + + # returns a Bio::DDBJ::XML::Gib object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 301,305 **** ! # = Gtop # # GTOP: Gene to protein. --- 321,325 ---- ! # === Gtop # # GTOP: Gene to protein. *************** *** 307,322 **** # * http://xml.nig.ac.jp/doc/Gtop.txt # ! # == Examples # ! # serv = Bio::DDBJ::XML::Gtop.new ! # puts serv.getOrganismList ! # puts serv.getMasterInfo('thrA', 'ecol0') # ! # == WSDL Methods # ! # * getOrganismList ! # * getMasterInfo(orfID, organism) # ! # == References # # * http://xml.nig.ac.jp/doc/Gtop.txt --- 327,342 ---- # * http://xml.nig.ac.jp/doc/Gtop.txt # ! # === Examples # ! # serv = Bio::DDBJ::XML::Gtop.new ! # puts serv.getOrganismList ! # puts serv.getMasterInfo('thrA', 'ecol0') # ! # === WSDL Methods # ! # ==== getOrganismList ! # ==== getMasterInfo(orfID, organism) # ! # === References # # * http://xml.nig.ac.jp/doc/Gtop.txt *************** *** 324,327 **** --- 344,349 ---- class Gtop < XML SERVER_URI = BASE_URI + "Gtop.wsdl" + + # returns a Bio::DDBJ::XML::Gtop object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 330,334 **** ! # == PML # # Variation database --- 352,356 ---- ! # === PML # # Variation database *************** *** 336,354 **** # * http://xml.nig.ac.jp/doc/PML.txt # ! # == Examples # ! # serv = Bio::DDBJ::XML::PML.new ! # puts serv.getVariation('1') # ! # == WSDL Methods # ! # * searchVariation(field, query, order) ! # * searchVariationSimple(field, query) ! # * searchFrequency(field, query, order) ! # * searchFrequencySimple(field, query) ! # * getVariation(variation_id) ! # * getFrequency(variation_id, population_id) # ! # == References # # * http://xml.nig.ac.jp/doc/PML.txt --- 358,376 ---- # * http://xml.nig.ac.jp/doc/PML.txt # ! # === Examples # ! # serv = Bio::DDBJ::XML::PML.new ! # puts serv.getVariation('1') # ! # === WSDL Methods # ! # ==== searchVariation(field, query, order) ! # ==== searchVariationSimple(field, query) ! # ==== searchFrequency(field, query, order) ! # ==== searchFrequencySimple(field, query) ! # ==== getVariation(variation_id) ! # ==== getFrequency(variation_id, population_id) # ! # === References # # * http://xml.nig.ac.jp/doc/PML.txt *************** *** 356,359 **** --- 378,383 ---- class PML < XML SERVER_URI = BASE_URI + "PML.wsdl" + + # returns a Bio::DDBJ::XML::PML object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 362,366 **** ! # = SRS # # Sequence Retrieving System --- 386,390 ---- ! # === SRS # # Sequence Retrieving System *************** *** 368,383 **** # * http://xml.nig.ac.jp/doc/SRS.txt # ! # == Examples # ! # serv = Bio::DDBJ::XML::SRS.new ! # puts serv.searchSimple('[pathway-des:sugar]') ! # puts serv.searchParam('[swissprot-des:cohesin]', '-f seq -sf fasta') # ! # == WSDL Methods # ! # * searchSimple(query) ! # * searchParam(query, param) # ! # == Examples # # * http://xml.nig.ac.jp/doc/SRS.txt --- 392,407 ---- # * http://xml.nig.ac.jp/doc/SRS.txt # ! # === Examples # ! # serv = Bio::DDBJ::XML::SRS.new ! # puts serv.searchSimple('[pathway-des:sugar]') ! # puts serv.searchParam('[swissprot-des:cohesin]', '-f seq -sf fasta') # ! # === WSDL Methods # ! # ==== searchSimple(query) ! # ==== searchParam(query, param) # ! # === Examples # # * http://xml.nig.ac.jp/doc/SRS.txt *************** *** 385,388 **** --- 409,414 ---- class SRS < XML SERVER_URI = BASE_URI + "SRS.wsdl" + + # returns a Bio::DDBJ::XML::SRS object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) *************** *** 391,395 **** ! # = TxSearch # # Searching taxonomy information. --- 417,421 ---- ! # === TxSearch # # Searching taxonomy information. *************** *** 397,421 **** # * http://xml.nig.ac.jp/doc/TxSearch.txt # ! # == Examples # ! # serv = Bio::DDBJ::XML::TxSearch.new ! # puts serv.searchSimple('*coli') ! # puts serv.searchSimple('*tardigrada*') ! # puts serv.getTxId('Escherichia coli') ! # puts serv.getTxName('562') # ! # query = ["Campylobacter coli", "Escherichia coli"].join("\n") ! # rank = ["family", "genus"].join("\n") ! # puts serv.searchLineage(query, rank, 'Bacteria') # ! # == WSDL Methdos # ! # * searchSimple(tx_Name) ! # * searchParam(tx_Name, tx_Clas, tx_Rank, tx_Rmax, tx_Dcls) ! # * getTxId(tx_Name) ! # * getTxName(tx_Id) ! # * searchLineage(query, ranks, superkingdom) # ! # == References # # * http://xml.nig.ac.jp/doc/TxSearch.txt --- 423,447 ---- # * http://xml.nig.ac.jp/doc/TxSearch.txt # ! # === Examples # ! # serv = Bio::DDBJ::XML::TxSearch.new ! # puts serv.searchSimple('*coli') ! # puts serv.searchSimple('*tardigrada*') ! # puts serv.getTxId('Escherichia coli') ! # puts serv.getTxName('562') # ! # query = ["Campylobacter coli", "Escherichia coli"].join("\n") ! # rank = ["family", "genus"].join("\n") ! # puts serv.searchLineage(query, rank, 'Bacteria') # ! # === WSDL Methdos # ! # ==== searchSimple(tx_Name) ! # ==== searchParam(tx_Name, tx_Clas, tx_Rank, tx_Rmax, tx_Dcls) ! # ==== getTxId(tx_Name) ! # ==== getTxName(tx_Id) ! # ==== searchLineage(query, ranks, superkingdom) # ! # === References # # * http://xml.nig.ac.jp/doc/TxSearch.txt *************** *** 423,426 **** --- 449,454 ---- class TxSearch < XML SERVER_URI = BASE_URI + "TxSearch.wsdl" + + # returns a Bio::DDBJ::XML::TxSearch object. def initialize(wsdl = nil) super(wsdl || SERVER_URI) From nakao at pub.open-bio.org Thu Feb 2 17:08:39 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 02 Feb 2006 17:08:39 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/hmmer report.rb,1.9,1.10 Message-ID: <200602021708.k12H8dVL001851@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/hmmer In directory pub.open-bio.org:/tmp/cvs-serv1837/lib/bio/appl/hmmer Modified Files: report.rb Log Message: * Updated RDoc. Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/hmmer/report.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** report.rb 31 Oct 2005 09:12:03 -0000 1.9 --- report.rb 2 Feb 2006 17:08:36 -0000 1.10 *************** *** 1,7 **** # ! # bio/appl/hmmer/report.rb - hmmsearch, hmmpfam parserer # ! # Copyright (C) 2002 Hiroshi Suga ! # Copyright (C) 2005 Masashi Fujita # # This library is free software; you can redistribute it and/or --- 1,43 ---- # ! # = bio/appl/hmmer/report.rb - hmmsearch, hmmpfam parserer [...999 lines suppressed...] ! --- Bio::HMMER::Report::Hsp#query_from ! --- Bio::HMMER::Report::Hsp#query_to ! --- Bio::HMMER::Report::Hsp#target_seq ! --- Bio::HMMER::Report::Hsp#target_from ! --- Bio::HMMER::Report::Hsp#target_to ! ! --- Bio::HMMER::Report::Hsp#csline ! --- Bio::HMMER::Report::Hsp#rfline - =end --- 694,701 ---- print "query_to : ".rjust(indent) p hsp.query_to # hmm_t, seq_t ! end end ! end From nakao at pub.open-bio.org Thu Feb 2 17:08:38 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 02 Feb 2006 17:08:38 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl hmmer.rb,1.4,1.5 Message-ID: <200602021708.k12H8cVL001849@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv1837/lib/bio/appl Modified Files: hmmer.rb Log Message: * Updated RDoc. Index: hmmer.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/hmmer.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** hmmer.rb 26 Sep 2005 13:00:04 -0000 1.4 --- hmmer.rb 2 Feb 2006 17:08:36 -0000 1.5 *************** *** 1,6 **** # ! # bio/appl/hmmer.rb - HMMER wrapper # ! # Copyright (C) 2002 KATAYAMA Toshiaki # # This library is free software; you can redistribute it and/or --- 1,31 ---- # ! # = bio/appl/hmmer.rb - HMMER wrapper # ! # Copyright:: Copyright (C) 2002 ! # KATAYAMA Toshiaki ! # Lisence:: LGPL ! # ! # $Id$ ! # ! # == Description ! # ! # A wrapper for the HMMER programs (hmmsearch or hmmpfam). ! # ! # == Examples ! # ! # require 'bio' ! # program = 'hmmsearch' # or 'hmmpfam' ! # hmmfile = 'test.hmm' ! # seqfile = 'test.faa' ! # ! # factory = Bio::HMMER.new(program, hmmfile, seqfile) ! # p factory.query ! # ! # == References ! # ! # * HMMER ! # http://hmmer.wustl.edu/ ! # ! #-- # # This library is free software; you can redistribute it and/or *************** *** 18,22 **** # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! # $Id$ # --- 43,47 ---- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! #++ # *************** *** 26,82 **** module Bio ! class HMMER ! ! autoload :Report, 'bio/appl/hmmer/report' ! include Bio::Command::Tools ! def initialize(program, hmmfile, seqfile, opt = []) ! @program = program ! @hmmfile = hmmfile ! @seqfile = seqfile ! @output = '' ! begin ! @options = opt.to_ary ! rescue NameError #NoMethodError ! # backward compatibility ! @options = Shellwords.shellwords(opt) ! end ! end ! attr_accessor :program, :hmmfile, :seqfile, :options ! attr_reader :output ! def option # backward compatibility ! make_command_line(@options) end - def option=(str) - # backward compatibility - @options = Shellwords.shellwords(str) - end ! def query ! cmd = [ @program, *@options ] ! cmd.concat([ @hmmfile, @seqfile ]) ! ! report = nil - @output = call_command_local(cmd, nil) - report = parse_result(@output) - - return report - end - private ! def parse_result(data) ! Report.new(data) ! end end ! end --- 51,150 ---- module Bio ! # A wapper for HMMER programs (hmmsearch or hmmpfam). ! # ! # === Examples ! # ! # require 'bio' ! # program = 'hmmsearch' # or 'hmmpfam' ! # hmmfile = 'test.hmm' ! # seqfile = 'test.faa' ! # ! # factory = Bio::HMMER.new(program, hmmfile, seqfile) ! # report = factory.query ! # report.class #=> Bio::HMMER::Report ! # ! # === References ! # ! # * HMMER ! # http://hmmer.wustl.edu/ ! # ! class HMMER ! autoload :Report, 'bio/appl/hmmer/report' ! include Bio::Command::Tools ! # Prgrams name. (hmmsearch or hmmpfam). ! attr_accessor :program ! ! # Name of hmmfile. ! attr_accessor :hmmfile ! ! # Name of seqfile. ! attr_accessor :seqfile ! ! # Command line options. ! attr_accessor :options ! ! # Shows the raw output from the hmmer search. ! attr_reader :output ! # Sets a program name, a profile hmm file name, a query sequence file name ! # and options in string. ! # ! # Program names: hmmsearch, hmmpfam ! # ! def initialize(program, hmmfile, seqfile, options = []) ! @program = program ! @hmmfile = hmmfile ! @seqfile = seqfile ! @output = '' ! ! begin ! @options = opt.to_ary ! rescue NameError #NoMethodError # backward compatibility ! @options = Shellwords.shellwords(options) end + end ! # Gets options by String. ! # backward compatibility. ! def option ! make_command_line(@options) ! end + # Sets options by String. + # backward compatibility. + def option=(str) + @options = Shellwords.shellwords(str) + end ! # Executes the hmmer search and returns the report ! # (Bio::HMMER::Report object). ! def query ! cmd = [ @program, *@options ] ! cmd.concat([ @hmmfile, @seqfile ]) ! ! report = nil ! ! @output = call_command_local(cmd, nil) ! report = parse_result(@output) ! ! return report ! end + private + + def parse_result(data) + Report.new(data) end ! ! end # class HMMER ! ! end # module Bio *************** *** 84,129 **** if __FILE__ == $0 ! begin ! require 'pp' ! alias p pp ! rescue ! end ! program = ARGV.shift # hmmsearch, hmmpfam hmmfile = ARGV.shift seqfile = ARGV.shift factory = Bio::HMMER.new(program, hmmfile, seqfile) ! p factory.query end - - - =begin - - = Bio::HMMER - - --- Bio::HMMER.new(program, hmmfile, seqfile, option = '') - --- Bio::HMMER#program - --- Bio::HMMER#hmmfile - --- Bio::HMMER#seqfile - --- Bio::HMMER#options - - Accessors for the factory. - - --- Bio::HMMER#option - --- Bio::HMMER#option=(str) - - Get/set options by string. - - --- Bio::HMMER#query - - Executes the hmmer search and returns Report object (Bio::HMMER::Report). - - --- Bio::HMMER#output - - Shows the raw output from hmmer search. - - =end - - --- 152,163 ---- if __FILE__ == $0 ! require 'pp' ! program = ARGV.shift # hmmsearch, hmmpfam hmmfile = ARGV.shift seqfile = ARGV.shift factory = Bio::HMMER.new(program, hmmfile, seqfile) ! pp factory.query end From nakao at pub.open-bio.org Thu Feb 2 17:09:22 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 02 Feb 2006 17:09:22 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl/hmmer - New directory Message-ID: <200602021709.k12H9MVL001880@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl/hmmer In directory pub.open-bio.org:/tmp/cvs-serv1870/test/unit/bio/appl/hmmer Log Message: Directory /home/repository/bioruby/bioruby/test/unit/bio/appl/hmmer added to the repository From nakao at pub.open-bio.org Thu Feb 2 17:10:10 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 02 Feb 2006 17:10:10 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl/hmmer test_report.rb, NONE, 1.1 Message-ID: <200602021710.k12HAAVL001912@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl/hmmer In directory pub.open-bio.org:/tmp/cvs-serv1897/test/unit/bio/appl/hmmer Added Files: test_report.rb Log Message: * Newly added. --- NEW FILE: test_report.rb --- # # test/unit/bio/appl/hmmer/test_report.rb - Unit test for Bio::HMMER::Report # # Copyright (C) 2006 Mitsuteru Nakao # # 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: test_report.rb,v 1.1 2006/02/02 17:10:08 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib'))).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/appl/hmmer/report' module Bio class TestHMMERReportData bioruby_root = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5)).cleanpath.to_s TestDataHMMER = Pathname.new(File.join(bioruby_root, 'test', 'data', 'HMMER')).cleanpath.to_s def self.hmmpfam File.open(File.join(TestDataHMMER, 'hmmpfam.out')).read end def self.output self.hmmpfam end def self.hmmsearch File.open(File.join(TestDataHMMER, 'hmmsearch.out')).read end end class TestHMMERReportClassMethods < Test::Unit::TestCase def test_reports_ary ary = Bio::HMMER.reports(Bio::TestHMMERReportData.output) assert_equal(Array, ary.class) end def test_reports_ary Bio::HMMER.reports(Bio::TestHMMERReportData.output).each do |report| assert_equal(Bio::HMMER::Report, report.class) end end end class TestHMMERReportConstants < Test::Unit::TestCase def test_rs assert_equal("\n//\n", Bio::HMMER::Report::RS) assert_equal("\n//\n", Bio::HMMER::Report::DELIMITER) end end class TestHMMERReportHmmpfam < Test::Unit::TestCase def setup @obj = Bio::HMMER::Report.new(Bio::TestHMMERReportData.hmmpfam) end def test_program assert_equal(Hash, @obj.program.class) assert_equal("hmmpfam - search one or more sequences against HMM database", @obj.program['name']) assert_equal("HMMER 2.3.2 (Oct 2003)", @obj.program['version']) assert_equal("Copyright (C) 1992-2003 HHMI/Washington University School of Medicine", @obj.program['copyright']) assert_equal("Freely distributed under the GNU General Public License (GPL)", @obj.program['license']) end def test_parameter assert_equal(Hash, @obj.parameter.class) assert_equal("/Users/nakao/Sites/iprscan/tmp/20050517/iprscan-20050517-16244071/chunk_1/iprscan-20050517-16244071.nocrc", @obj.parameter["Sequence file"]) assert_equal("/Users/nakao/Sites/iprscan/data/Pfam", @obj.parameter['HMM file']) end def test_query_info assert_equal(Hash, @obj.query_info.class) assert_equal("104K_THEPA", @obj.query_info["Query sequence"]) assert_equal("[none]", @obj.query_info["Accession"]) assert_equal("[none]", @obj.query_info["Description"]) end def test_hits assert_equal(Bio::HMMER::Report::Hit, @obj.hits.first.class) end def test_hsps assert_equal(Bio::HMMER::Report::Hsp, @obj.hsps.first.class) end def test_histogram assert_equal(nil, @obj.histogram) end def test_statistical_detail assert_equal(nil, @obj.statistical_detail) end def test_total_seq_searched assert_equal(nil, @obj.total_seq_searched) end def test_whole_seq_top_hits assert_equal(nil, @obj.whole_seq_top_hits) end def test_domain_top_hits assert_equal(nil, @obj.domain_top_hits) end def test_each @obj.each do |hit| assert_equal(Bio::HMMER::Report::Hit, hit.class) end end def test_each_hit @obj.each_hit do |hit| assert_equal(Bio::HMMER::Report::Hit, hit.class) end end end class TestHMMERReportHit < Test::Unit::TestCase def setup @obj = Bio::HMMER::Report.new(Bio::TestHMMERReportData.output).hits.first end def test_hit assert_equal(Bio::HMMER::Report::Hit, @obj.class) end def test_hsps assert_equal(Bio::HMMER::Report::Hsp, @obj.hsps.first.class) end def test_accession assert_equal("PF04385.4", @obj.accession) end def test_target_id assert_equal("PF04385.4", @obj.target_id) end def test_hit_id assert_equal("PF04385.4", @obj.hit_id) end def test_entry_id assert_equal("PF04385.4", @obj.entry_id) end def test_description assert_equal("Domain of unknown function, DUF529", @obj.description) end def test_definition assert_equal("Domain of unknown function, DUF529", @obj.definition) end def test_score assert_equal(259.3, @obj.score) end def test_bit_score assert_equal(259.3, @obj.bit_score) end def test_evalue assert_equal(6.6e-75, @obj.evalue) end def test_num assert_equal(4, @obj.num) end def test_each @obj.each do |hsp| assert_equal(Bio::HMMER::Report::Hsp, hsp.class) end end def test_each_hsp @obj.each_hsp do |hsp| assert_equal(Bio::HMMER::Report::Hsp, hsp.class) end end def test_target_def assert_equal("<4> Domain of unknown function, DUF529", @obj.target_def) end def test_append_hsp hsp = @obj.hsps.first assert_equal(5, @obj.append_hsp(hsp).size) end end class TestHMMERReportHsp < Test::Unit::TestCase def setup @obj = Bio::HMMER::Report.new(Bio::TestHMMERReportData.output).hits.first.hsps.first end def test_hsp assert_equal(Bio::HMMER::Report::Hsp, @obj.class) end def test_accession assert_equal("PF04385.4", @obj.accession) end def test_domain assert_equal("1/4", @obj.domain) end def test_seq_f assert_equal(36, @obj.seq_f) end def test_seq_t assert_equal(111, @obj.seq_t) end def test_seq_ft assert_equal("..", @obj.seq_ft) end def test_hmm_f assert_equal(1, @obj.hmm_f) end def test_hmm_t assert_equal(80, @obj.hmm_t) end def test_score assert_equal(65.0, @obj.score) end def test_bit_score assert_equal(65.0, @obj.bit_score) end def test_evalue assert_equal(2.0e-16, @obj.evalue) end def test_midline assert_equal("t+D+n++++ f +v+++g+++ + ++ ++v+++++++Gn+v+We++ + +l++ ++++++++++++++++ +++", @obj.midline) end def test_hmmseq assert_equal("tLDlndtgstlkqfdykvalngdivvtytpkpGvkftkitdGnevvWeseddpefglivtlsfyldsnkfLvlllintak", @obj.hmmseq) end def test_flatseq assert_equal("TFDINSNQTG-PAFLTAVEMAGVKYLQVQHGSNVNIHRLVEGNVVIWENA---STPLYTGAIVTNNDGPYMAYVEVLGDP", @obj.flatseq) end def test_query_frame assert_equal(1, @obj.query_frame) end def test_target_frame assert_equal(1, @obj.target_frame) end def test_csline assert_equal(nil, @obj.csline) end def test_rfline assert_equal(nil, @obj.rfline) end def test_set_alignment end def test_query_seq assert_equal("TFDINSNQTG-PAFLTAVEMAGVKYLQVQHGSNVNIHRLVEGNVVIWENA---STPLYTGAIVTNNDGPYMAYVEVLGDP", @obj.query_seq) end def test_target_seq assert_equal("tLDlndtgstlkqfdykvalngdivvtytpkpGvkftkitdGnevvWeseddpefglivtlsfyldsnkfLvlllintak", @obj.target_seq) end def test_target_from assert_equal(1, @obj.target_from) end def test_targat_to assert_equal(80, @obj.target_to) end def test_query_from assert_equal(36, @obj.query_from) end def test_query_to assert_equal(111, @obj.query_to) end end class TestHMMERReportHmmsearch < Test::Unit::TestCase def setup @obj = Bio::HMMER::Report.new(Bio::TestHMMERReportData.hmmsearch) end def test_histogram hist = "score obs exp (one = represents 1 sequences)\n----- --- ---\n 377 1 0|=" assert_equal(hist, @obj.histogram) end def test_statistical_detail hash = {"P(chi-square)" => 0.0, "chi-sq statistic" => 0.0, "lambda" => 0.7676, "mu" => -10.6639} assert_equal(hash, @obj.statistical_detail) hash.keys.each do |key| assert_equal(hash[key], @obj.statistical_detail[key]) end end def test_total_seq_searched assert_equal(1, @obj.total_seq_searched) end def test_whole_seq_top_hit hash = {"Total memory" => "16K", "Satisfying E cutoff" => 1, "Total hits" => 1} assert_equal(hash, @obj.whole_seq_top_hits) hash.keys.each do |key| assert_equal(hash[key], @obj.whole_seq_top_hits[key]) end end def test_domain_top_hits hash = {"Total memory" => "17K", "Satisfying E cutoff" => 1, "Total hits" => 1} assert_equal(hash, @obj.domain_top_hits) hash.keys.each do |key| assert_equal(hash[key], @obj.domain_top_hits[key]) end end end end # module Bio From nakao at pub.open-bio.org Thu Feb 2 17:10:34 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 02 Feb 2006 17:10:34 +0000 Subject: [BioRuby-cvs] bioruby/test/data/HMMER - New directory Message-ID: <200602021710.k12HAYVL001929@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/HMMER In directory pub.open-bio.org:/tmp/cvs-serv1919/test/data/HMMER Log Message: Directory /home/repository/bioruby/bioruby/test/data/HMMER added to the repository From nakao at pub.open-bio.org Thu Feb 2 17:11:25 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 02 Feb 2006 17:11:25 +0000 Subject: [BioRuby-cvs] bioruby/test/data/HMMER hmmpfam.out, NONE, 1.1 hmmsearch.out, NONE, 1.1 Message-ID: <200602021711.k12HBPVL001967@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/HMMER In directory pub.open-bio.org:/tmp/cvs-serv1957/test/data/HMMER Added Files: hmmpfam.out hmmsearch.out Log Message: * Newly added. --- NEW FILE: hmmsearch.out --- hmmsearch - search a sequence database with a profile HMM HMMER 2.2g (August 2001) Copyright (C) 1992-2001 HHMI/Washington University School of Medicine Freely distributed under the GNU General Public License (GPL) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HMM file: /sw/share/hmmer/demo/7tm_1 [7tm_1] Sequence database: /sw/share/hmmer/demo/P08908.fasta per-sequence score cutoff: [none] per-domain score cutoff: [none] per-sequence Eval cutoff: <= 10 per-domain Eval cutoff: [none] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Query HMM: 7tm_1 Accession: PF00001 Description: 7 transmembrane receptor (rhodopsin family) [HMM has been calibrated; E-values are empirical estimates] Scores for complete sequences (score includes all domains): Sequence Description Score E-value N -------- ----------- ----- ------- --- sp|P08908|5H1A_HUMAN 5-hydroxytryptamine 1A receptor 377.1 5.5e-130 1 Parsed for domains: Sequence Domain seq-f seq-t hmm-f hmm-t score E-value -------- ------- ----- ----- ----- ----- ----- ------- sp|P08908|5H1A_HUMAN 1/1 53 400 .. 1 275 [] 377.1 5.5e-130 Alignments of top-scoring domains: sp|P08908|5H1A_HUMAN: domain 1 of 1, from 53 to 400: score 377.1, E = 5.5e-130 *->GNlLVilvilrtkklrtptnifilNLAvADLLflltlppwalyylvg GN+ V+++i+++++l++++n++i++LAv+DL+++++++p+a++y v sp|P08908| 53 GNACVVAAIALERSLQNVANYLIGSLAVTDLMVSVLVLPMAALYQVL 99 gsedWpfGsalCklvtaldvvnmyaSillLtaISiDRYlAIvhPlryrrr + W++G++ C+l++aldv+++++Sil+L+aI++DRY+AI++P+ y ++ sp|P08908| 100 N--KWTLGQVTCDLFIALDVLCCTSSILHLCAIALDRYWAITDPIDYVNK 147 rtsprrAkvvillvWvlalllslPpllfswvktveegngtlnvnvtvCli rt prrA+++i+l+W++++l+s+Pp +++w++++ + +C+i sp|P08908| 148 RT-PRRAAALISLTWLIGFLISIPP-MLGWRTPEDRSD------PDACTI 189 dfpeestasvstwlvsyvllstlvgFllPllvilvcYtrIlrtlrkrark + +++ y+++st+++F++Pll++lv+Y+rI+r++r r rk sp|P08908| 190 SKDHG-----------YTIYSTFGAFYIPLLLMLVLYGRIFRAARFRIRK 228 gas............................................... + + ++++ +++++ ++ ++++++ ++++++++ + + +++ ++ + sp|P08908| 229 TVKkvektgadtrhgaspapqpkksvngesgsrnwrlgveskaggalcan 278 .................................................. + ++++++ + + ++ ++++++ + +++ ++++ + + +++++++ sp|P08908| 279 gavrqgddgaalevievhrvgnskehlplpseagptpcapasferknern 328 .....kkrsskerkaaktllvvvvvFvlCWlPyfivllldtlc.lsiims + ++k+ +erk++ktl++++++F+lCWlP+fiv+l+ ++c++s++m sp|P08908| 329 aeakrKMALARERKTVKTLGIIMGTFILCWLPFFIVALVLPFCeSSCHM- 377 stCelervlptallvtlwLayvNsclNPiIY<-* + + +++wL+y+Ns lNP+IY sp|P08908| 378 --------PTLLGAIINWLGYSNSLLNPVIY 400 Histogram of all scores: score obs exp (one = represents 1 sequences) ----- --- --- 377 1 0|= % Statistical details of theoretical EVD fit: mu = -10.6639 lambda = 0.7676 chi-sq statistic = 0.0000 P(chi-square) = 0 Total sequences searched: 1 Whole sequence top hits: tophits_s report: Total hits: 1 Satisfying E cutoff: 1 Total memory: 16K Domain top hits: tophits_s report: Total hits: 1 Satisfying E cutoff: 1 Total memory: 17K --- NEW FILE: hmmpfam.out --- hmmpfam - search one or more sequences against HMM database HMMER 2.3.2 (Oct 2003) Copyright (C) 1992-2003 HHMI/Washington University School of Medicine Freely distributed under the GNU General Public License (GPL) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HMM file: /Users/nakao/Sites/iprscan/data/Pfam Sequence file: /Users/nakao/Sites/iprscan/tmp/20050517/iprscan-20050517-16244071/chunk_1/iprscan-20050517-16244071.nocrc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Query sequence: 104K_THEPA Accession: [none] Description: [none] Scores for sequence family classification (score includes all domains): Model Description Score E-value N -------- ----------- ----- ------- --- PF04385.4 Domain of unknown function, DUF529 259.3 6.6e-75 4 Parsed for domains: Model Domain seq-f seq-t hmm-f hmm-t score E-value -------- ------- ----- ----- ----- ----- ----- ------- PF04385.4 1/4 36 111 .. 1 80 [] 65.0 2e-16 PF04385.4 2/4 149 224 .. 1 80 [] 64.7 2.5e-16 PF04385.4 3/4 265 343 .. 1 80 [] 64.6 2.7e-16 PF04385.4 4/4 379 456 .. 1 80 [] 65.0 2e-16 Alignments of top-scoring domains: PF04385.4: domain 1 of 4, from 36 to 111: score 65.0, E = 2e-16 *->tLDlndtgstlkqfdykvalngdivvtytpkpGvkftkitdGnevvW t+D+n++++ f +v+++g+++ + ++ ++v+++++++Gn+v+W 104K_THEPA 36 TFDINSNQTG-PAFLTAVEMAGVKYLQVQHGSNVNIHRLVEGNVVIW 81 eseddpefglivtlsfyldsnkfLvlllintak<-* e++ + +l++ ++++++++++++++++ +++ 104K_THEPA 82 ENA---STPLYTGAIVTNNDGPYMAYVEVLGDP 111 PF04385.4: domain 2 of 4, from 149 to 224: score 64.7, E = 2.5e-16 *->tLDlndtgstlkqfdykvalngdivvtytpkpGvkftkitdGnevvW +L++ ++ +++k+ + ++a+ng ++vt++p++G+ +++++++n++++ 104K_THEPA 149 SLNMAFQLENNKYEVETHAKNGANMVTFIPRNGHICKMVYHKNVRIY 195 eseddpefglivtlsfyldsnkfLvlllintak<-* ++ ++++vt++++++ +++L+l+++ + 104K_THEPA 196 KA----TGNDTVTSVVGFFRGLRLLLINVFSID 224 PF04385.4: domain 3 of 4, from 265 to 343: score 64.6, E = 2.7e-16 *->tLDlndtgstlkqfdykvalngdivvtytpkpGvkftkitdGnevvW +Dl+ +++ +++f+ + a+++ ++++++p++G+++tk++dG++v++ 104K_THEPA 265 PVDLDIKDIDYTMFHLADATYHEPCFKIIPNTGFCITKLFDGDQVLY 311 eseddpefglivtlsfyldsnkfLvlllintak<-* es+ + + ++i +++y+++n ++++l++n+++ 104K_THEPA 312 ESFNP-LIHCINEVHIYDRNNGSIICLHLNYSP 343 PF04385.4: domain 4 of 4, from 379 to 456: score 65.0, E = 2e-16 *->tLDlndtgstlkqfdykvalngdivvty.tpkpGvkftkitdGnevv +LD+n ++++k+ +++ +n d +t+ tp+p+ + +++dG+ev+ 104K_THEPA 379 ELDVN--FISDKDLYVAALTNADLNYTMvTPRPHRDVIRVSDGSEVL 423 WeseddpefglivtlsfyldsnkfLvlllintak<-* W++e+ ++ l++++++++d++ +Lv+l+i++ 104K_THEPA 424 WYYEGL-DNFLVCAWIYVSDGVASLVHLRIKDRI 456 // From nakao at pub.open-bio.org Fri Feb 3 17:21:54 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Fri, 03 Feb 2006 17:21:54 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl/blast test_report.rb, 1.2, 1.3 test_xmlparser.rb, 1.3, 1.4 Message-ID: <200602031721.k13HLsVL006159@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl/blast In directory pub.open-bio.org:/tmp/cvs-serv6123/test/unit/bio/appl/blast Modified Files: test_report.rb test_xmlparser.rb Log Message: * Moved test/data/blast/eco:* to test/data/blast/* to avoid file name problems in the Windows file sysmtem. Index: test_xmlparser.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/appl/blast/test_xmlparser.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_xmlparser.rb 18 Dec 2005 17:06:56 -0000 1.3 --- test_xmlparser.rb 3 Feb 2006 17:21:51 -0000 1.4 *************** *** 35,43 **** def self.input ! File.open(File.join(TestDataBlast, 'eco:b0002.faa')).read end def self.output ! File.open(File.join(TestDataBlast, 'eco:b0002.faa.m7')).read end end --- 35,43 ---- def self.input ! File.open(File.join(TestDataBlast, 'b0002.faa')).read end def self.output ! File.open(File.join(TestDataBlast, 'b0002.faa.m7')).read end end *************** *** 72,76 **** def test_db ! assert_equal("eco:b0002.faa", @report.db) end --- 72,76 ---- def test_db ! assert_equal("b0002.faa", @report.db) end Index: test_report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/appl/blast/test_report.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_report.rb 22 Nov 2005 08:31:47 -0000 1.2 --- test_report.rb 3 Feb 2006 17:21:51 -0000 1.3 *************** *** 35,39 **** def self.input ! File.open(File.join(TestDataBlast, 'eco:b0002.faa')).read end --- 35,39 ---- def self.input ! File.open(File.join(TestDataBlast, 'b0002.faa')).read end *************** *** 41,49 **** case format when 0 ! File.open(File.join(TestDataBlast, 'eco:b0002.faa.m0')).read when 7 ! File.open(File.join(TestDataBlast, 'eco:b0002.faa.m7')).read when 8 ! File.open(File.join(TestDataBlast, 'eco:b0002.faa.m8')).read end end --- 41,49 ---- case format when 0 ! File.open(File.join(TestDataBlast, 'b0002.faa.m0')).read when 7 ! File.open(File.join(TestDataBlast, 'b0002.faa.m7')).read when 8 ! File.open(File.join(TestDataBlast, 'b0002.faa.m8')).read end end *************** *** 81,90 **** xml_quoted_str = "~Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, ~Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), ~"Gapped BLAST and PSI-BLAST: a new generation of protein database search~programs", Nucleic Acids Res. 25:3389-3402." text_str = '~Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, ~Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), ~"Gapped BLAST and PSI-BLAST: a new generation of protein database search~programs", Nucleic Acids Res. 25:3389-3402.' ! assert_equal(xml_quoted_str, @report.reference) assert_equal(text_str, @report.reference) end def test_db ! assert_equal('eco:b0002.faa', @report.db) end --- 81,90 ---- xml_quoted_str = "~Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, ~Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), ~"Gapped BLAST and PSI-BLAST: a new generation of protein database search~programs", Nucleic Acids Res. 25:3389-3402." text_str = '~Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, ~Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), ~"Gapped BLAST and PSI-BLAST: a new generation of protein database search~programs", Nucleic Acids Res. 25:3389-3402.' ! # assert_equal(xml_quoted_str, @report.reference) assert_equal(text_str, @report.reference) end def test_db ! assert_equal('b0002.faa', @report.db) end *************** *** 134,142 **** def test_pattern ! assert(@report.pattern) end def test_extrez_query ! assert(@report.entrez_query) end --- 134,142 ---- def test_pattern ! assert_equal(nil, @report.pattern) end def test_extrez_query ! assert_equal(nil, @report.entrez_query) end *************** *** 186,190 **** def test_message ! assert(@report.message) end end --- 186,190 ---- def test_message ! assert_equal(nil, @report.message) end end *************** *** 202,206 **** def test_statistics ! assert(@itr.statistics) end --- 202,209 ---- def test_statistics ! stat = {"kappa" => 0.041, "eff-space" => 605284, "db-num" => 1, ! "hsp-len" => 42, "db-len" => 820, "lambda" => 0.267, ! "entropy" => 0.14} ! assert_equal(stat, @itr.statistics) end *************** *** 210,214 **** def test_message ! assert(@itr.message) end end --- 213,217 ---- def test_message ! assert_equal(nil, @itr.message) end end From nakao at pub.open-bio.org Fri Feb 3 17:21:54 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Fri, 03 Feb 2006 17:21:54 +0000 Subject: [BioRuby-cvs] bioruby/test/data/blast b0002.faa, NONE, 1.1 b0002.faa.m0, NONE, 1.1 b0002.faa.m7, NONE, 1.1 b0002.faa.m8, NONE, 1.1 eco:b0002.faa, 1.1, NONE eco:b0002.faa.m0, 1.1, NONE eco:b0002.faa.m7, 1.1, NONE eco:b0002.faa.m8, 1.1, NONE Message-ID: <200602031721.k13HLsVL006164@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/blast In directory pub.open-bio.org:/tmp/cvs-serv6123/test/data/blast Added Files: b0002.faa b0002.faa.m0 b0002.faa.m7 b0002.faa.m8 Removed Files: eco:b0002.faa eco:b0002.faa.m0 eco:b0002.faa.m7 eco:b0002.faa.m8 Log Message: * Moved test/data/blast/eco:* to test/data/blast/* to avoid file name problems in the Windows file sysmtem. --- eco:b0002.faa.m7 DELETED --- --- eco:b0002.faa.m0 DELETED --- --- NEW FILE: b0002.faa.m8 --- eco:b0002 eco:b0002 100.00 820 0 0 1 820 1 820 0.0 1567 --- NEW FILE: b0002.faa.m7 --- blastp blastp 2.2.10 [Oct-19-2004] ~Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, ~Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), ~"Gapped BLAST and PSI-BLAST: a new generation of protein database search~programs", Nucleic Acids Res. 25:3389-3402. b0002.faa lcl|QUERY eco:b0002 thrA, Hs, thrD, thrA2, thrA1; bifunctional: aspartokinase I (N-terminal); homoserine dehydrogenase I (C-terminal) [EC:2.7.2.4 1.1.1.3]; K00003 homoserine dehydrogenase; K00928 aspartate kinase (A) 820 BLOSUM62 10 11 1 S 1 1 gnl|BL_ORD_ID|0 eco:b0002 thrA, Hs, thrD, thrA2, thrA1; bifunctional: aspartokinase I (N-terminal); homoserine dehydrogenase I (C-terminal) [EC:2.7.2.4 1.1.1.3]; K00003 homoserine dehydrogenase; K00928 aspartate kinase (A) 0 820 1 1567.75 4058 0 1 820 1 820 1 1 820 820 820 MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDALPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINAALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIPADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQVPDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRDEDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISFCVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAALARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQVIEVFVIGVGGVGGALLEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRLVKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSRRKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLAREMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMANLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAFYSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDALPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINAALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIPADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQVPDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRDEDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISFCVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAALARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQVIEVFVIGVGGVGGALLEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRLVKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSRRKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLAREMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMANLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAFYSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDALPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINAALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIPADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQVPDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRDEDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISFCVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAALARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQVIEVFVIGVGGVGGALLEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRLVKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSRRKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLAREMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMANLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAFYSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV 1 820 42 605284 0.041 0.267 0.14 --- eco:b0002.faa DELETED --- --- NEW FILE: b0002.faa --- >eco:b0002 thrA, Hs, thrD, thrA2, thrA1; bifunctional: aspartokinase I (N-terminal); homoserine dehydrogenase I (C-terminal) [EC:2.7.2.4 1.1.1.3]; K00003 homoserine dehydrogenase; K00928 aspartate kinase (A) MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDA LPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINA ALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIP ADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQV PDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRD EDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISF CVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAAL ARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQVIEVFVIGVGGVGGAL LEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRL VKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSR RKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLA REMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMA NLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAF YSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV --- eco:b0002.faa.m8 DELETED --- --- NEW FILE: b0002.faa.m0 --- BLASTP 2.2.10 [Oct-19-2004] Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), "Gapped BLAST and PSI-BLAST: a new generation of protein database search programs", Nucleic Acids Res. 25:3389-3402. Query= eco:b0002 thrA, Hs, thrD, thrA2, thrA1; bifunctional: aspartokinase I (N-terminal); homoserine dehydrogenase I (C-terminal) [EC:2.7.2.4 1.1.1.3]; K00003 homoserine dehydrogenase; K00928 aspartate kinase (A) (820 letters) Database: b0002.faa 1 sequences; 820 total letters Searching.done Score E Sequences producing significant alignments: (bits) Value eco:b0002 thrA, Hs, thrD, thrA2, thrA1; bifunctional: aspartokin... 1567 0.0 >eco:b0002 thrA, Hs, thrD, thrA2, thrA1; bifunctional: aspartokinase I (N-terminal); homoserine dehydrogenase I (C-terminal) [EC:2.7.2.4 1.1.1.3]; K00003 homoserine dehydrogenase; K00928 aspartate kinase (A) Length = 820 Score = 1567 bits (4058), Expect = 0.0 Identities = 806/820 (98%), Positives = 806/820 (98%) Query: 1 MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDA 60 MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDA Sbjct: 1 MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDA 60 Query: 61 LPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINA 120 LPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINA Sbjct: 61 LPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINA 120 Query: 121 ALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIP 180 ALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIP Sbjct: 121 ALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIP 180 Query: 181 ADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQV 240 ADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQV Sbjct: 181 ADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQV 240 Query: 241 PDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRD 300 PDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRD Sbjct: 241 PDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRD 300 Query: 301 EDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISF 360 EDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISF Sbjct: 301 EDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISF 360 Query: 361 CVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAAL 420 CVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAAL Sbjct: 361 CVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAAL 420 Query: 421 ARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQXXXXXXXXXXXXXXAL 480 ARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQ AL Sbjct: 421 ARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQVIEVFVIGVGGVGGAL 480 Query: 481 LEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRL 540 LEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRL Sbjct: 481 LEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRL 540 Query: 541 VKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSR 600 VKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSR Sbjct: 541 VKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSR 600 Query: 601 RKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLA 660 RKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLA Sbjct: 601 RKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLA 660 Query: 661 REMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMA 720 REMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMA Sbjct: 661 REMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMA 720 Query: 721 NLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAF 780 NLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAF Sbjct: 721 NLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAF 780 Query: 781 YSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV 820 YSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV Sbjct: 781 YSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV 820 Database: b0002.faa Posted date: Aug 7, 2005 7:29 AM Number of letters in database: 820 Number of sequences in database: 1 Lambda K H 0.319 0.134 0.383 Gapped Lambda K H 0.267 0.0410 0.140 Matrix: BLOSUM62 Gap Penalties: Existence: 11, Extension: 1 Number of Hits to DB: 1986 Number of Sequences: 1 Number of extensions: 52 Number of successful extensions: 8 Number of sequences better than 10.0: 1 Number of HSP's better than 10.0 without gapping: 1 Number of HSP's successfully gapped in prelim test: 0 Number of HSP's that attempted gapping in prelim test: 0 Number of HSP's gapped (non-prelim): 1 length of query: 820 length of database: 820 effective HSP length: 42 effective length of query: 778 effective length of database: 778 effective search space: 605284 effective search space used: 605284 T: 11 A: 40 X1: 16 ( 7.4 bits) X2: 38 (14.6 bits) X3: 64 (24.7 bits) S1: 30 (16.7 bits) S2: 30 (16.2 bits) From nakao at pub.open-bio.org Fri Feb 3 17:39:15 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Fri, 03 Feb 2006 17:39:15 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl test_blast.rb,1.2,1.3 Message-ID: <200602031739.k13HdFVL006243@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv6233/test/unit/bio/appl Modified Files: test_blast.rb Log Message: * Tto avoid file name problems in the Windows file sysmtem. Index: test_blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/appl/test_blast.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_blast.rb 23 Nov 2005 02:47:19 -0000 1.2 --- test_blast.rb 3 Feb 2006 17:39:13 -0000 1.3 *************** *** 35,39 **** def self.input ! File.open(File.join(TestDataBlast, 'eco:b0002.faa')).read end --- 35,39 ---- def self.input ! File.open(File.join(TestDataBlast, 'b0002.faa')).read end *************** *** 41,49 **** case format when '0' ! File.open(File.join(TestDataBlast, 'eco:b0002.faa.m0')).read when '7' ! File.open(File.join(TestDataBlast, 'eco:b0002.faa.m7')).read when '8' ! File.open(File.join(TestDataBlast, 'eco:b0002.faa.m8')).read end end --- 41,49 ---- case format when '0' ! File.open(File.join(TestDataBlast, 'b0002.faa.m0')).read when '7' ! File.open(File.join(TestDataBlast, 'b0002.faa.m7')).read when '8' ! File.open(File.join(TestDataBlast, 'b0002.faa.m8')).read end end From k at pub.open-bio.org Sat Feb 4 19:12:58 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Sat, 04 Feb 2006 19:12:58 +0000 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.61,1.62 Message-ID: <200602041912.k14JCvVL018259@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv18253/lib Modified Files: bio.rb Log Message: * Bio::String is prepared for replacement of old Bio::Sequence which doesn't remove any gap chars or change up/down cases. Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** bio.rb 28 Jan 2006 08:34:25 -0000 1.61 --- bio.rb 4 Feb 2006 19:12:55 -0000 1.62 *************** *** 35,40 **** ## Sequence - autoload :Seq, 'bio/sequence' autoload :Sequence, 'bio/sequence' ## Locations/Location --- 35,40 ---- ## Sequence autoload :Sequence, 'bio/sequence' + autoload :String, 'bio/string' ## Locations/Location From k at pub.open-bio.org Sat Feb 4 19:12:58 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Sat, 04 Feb 2006 19:12:58 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio string.rb,NONE,1.1 Message-ID: <200602041912.k14JCwVL018263@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv18253/lib/bio Added Files: string.rb Log Message: * Bio::String is prepared for replacement of old Bio::Sequence which doesn't remove any gap chars or change up/down cases. --- NEW FILE: string.rb --- # # = bio/string.rb - biological string class to store an intact sequence # # Copyright:: Copyright (C) 2006 # Toshiaki Katayama # License:: Ruby's # # $Id: string.rb,v 1.1 2006/02/04 19:12:56 k Exp $ # require 'bio/sequence/common' module Bio class String include Bio::Sequence::Common end end From k at pub.open-bio.org Sat Feb 4 19:17:18 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Sat, 04 Feb 2006 19:17:18 +0000 Subject: [BioRuby-cvs] bioruby README,1.12,1.13 Message-ID: <200602041917.k14JHIVL018302@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv18298 Modified Files: README Log Message: * included announcement of changing license from LGPL to Ruby's Index: README =================================================================== RCS file: /home/repository/bioruby/bioruby/README,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** README 12 Dec 2005 02:06:35 -0000 1.12 --- README 4 Feb 2006 19:17:16 -0000 1.13 *************** *** 3,7 **** $Id$ ! Copyright (C) 2001-2005 Toshiaki Katayama = BioRuby --- 3,7 ---- $Id$ ! Copyright (C) 2001-2006 Toshiaki Katayama = BioRuby *************** *** 168,171 **** --- 168,172 ---- BioRuby can be freely distributed under the GNU LGPL license. + We are trying to change the lincense to Ruby's now. Note that, install.rb included in the BioRuby package comes from From nakao at pub.open-bio.org Sun Feb 5 17:35:13 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sun, 05 Feb 2006 17:35:13 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/sequence - New directory Message-ID: <200602051735.k15HZDVL030716@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv30706/test/unit/bio/sequence Log Message: Directory /home/repository/bioruby/bioruby/test/unit/bio/sequence added to the repository From nakao at pub.open-bio.org Sun Feb 5 17:39:29 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sun, 05 Feb 2006 17:39:29 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/sequence test_common.rb, NONE, 1.1 test_compat.rb, NONE, 1.1 Message-ID: <200602051739.k15HdTVL030749@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv30733/test/unit/bio/sequence Added Files: test_common.rb test_compat.rb Log Message: * test_common.rb: added. * test_compat.rb: added. * test_sequence.rb: moved some test codes to test_common.rb or test_compat.rb. --- NEW FILE: test_compat.rb --- # # test/unit/bio/sequence/test_compat.rb - Unit test for Bio::Sequencce::Compat # # Copyright (C) 2006 Mitsuteru C. Nakao # # 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: test_compat.rb,v 1.1 2006/02/05 17:39:27 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/sequence' require 'bio/sequence/compat' module Bio class TSequence < String include Bio::Sequence::Common end class TestSequenceCompat < Test::Unit::TestCase def setup @obj = TSequence.new('atgcatgcatgcatgcaaaa') end def test_to_s str = 'atgcatgcatgcatgcaaaa' assert_equal(str, @obj.to_s) end end class TestSequenceCommonCompat < Test::Unit::TestCase # Test Sequence#to_fasta def test_to_fasta sequence = TSequence.new("agtc" * 10) header = "the header" str = ">the header\n" + ("agtc" * 5) + "\n" + ("agtc" * 5) + "\n" assert_equal(str, sequence.to_fasta(header, 20)) end end require 'bio/sequence/na' class TestSequenceNACompat < Test::Unit::TestCase def test_na_self_randomize composition = Bio::Sequence::NA.new("acgtacgt").composition assert(Bio::Sequence::NA.randomize(composition)) end end require 'bio/sequence/aa' class TestSequenceNACompat < Test::Unit::TestCase def test_aa_self_randomize composition = Bio::Sequence::AA.new("WWDTGAK").composition assert(Bio::Sequence::AA.randomize(composition)) end end end --- NEW FILE: test_common.rb --- # # test/unit/bio/sequence/test_common.rb - Unit test for Bio::Sequencce::Common # # Copyright (C) 2006 Mitsuteru C. Nakao # # 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: test_common.rb,v 1.1 2006/02/05 17:39:27 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/sequence' require 'bio/sequence/common' module Bio class TSequence < String include Bio::Sequence::Common end class TestSequenceCommon < Test::Unit::TestCase def setup @obj = TSequence.new('atgcatgcatgcatgcaaaa') end def test_to_s assert_equal('atgcatgcatgcatgcaaaa', @obj.to_s) end def test_seq str = "atgcatgcatgcatgcaaaa" assert_equal(str, @obj.seq) end # <<(*arg) def test_push str = "atgcatgcatgcatgcaaaaA" assert_equal(str, @obj << "A") end # +(*arg) def test_sum str = "atgcatgcatgcatgcaaaaatgcatgcatgcatgcaaaa" assert_equal(str, @obj + @obj) end # window_search(window_size, step_size = 1) def test_window_search @obj.window_search(4) do |subseq| assert_equal(20, @obj.size) end end #total(hash) def test_total hash = {'a' => 1, 'c' => 2, 'g' => 4, 't' => 3} assert_equal(44.0, @obj.total(hash)) end def test_composition composition = {"a"=>8, "c"=>4, "g"=>4, "t"=>4} assert_equal(composition, @obj.composition) end def test_splicing #(position) assert_equal("atgcatgc", @obj.splicing("join(1..4, 13..16)")) end end class TestSequenceCommonNormalize < Test::Unit::TestCase def test_no_normalize str = "atgcatgcatgcatgcaaaA" obj = Bio::TSequence.new(str) assert_equal("atgcatgcatgcatgcaaaA", obj) end def test_normalize_A str = "atgcatgcatgcatgcaaaA" seq = Bio::TSequence.new(str) assert_equal("atgcatgcatgcatgcaaaA", seq) obj = seq.normalize! assert_equal("atgcatgcatgcatgcaaaA", obj) end def test_normalize_a str = "atgcatgcatgcatgcaaa" seq = Bio::TSequence.new(str) assert_equal("atgcatgcatgcatgcaaa", seq) obj = seq.normalize! assert_equal("atgcatgcatgcatgcaaa", obj) end end class TestSequenceCommonRansomize < Test::Unit::TestCase def test_self_randomize # self.randomize(*arg, &block) end def test_randomize #randomize(hash = nil) end end class TestSequenceCommonSubseq < Test::Unit::TestCase #def subseq(s = 1, e = self.length) def test_to_s_returns_self_as_string s = "abcefghijklmnop" sequence = TSequence.new(s) assert_equal(s, sequence.to_s, "wrong value") assert_instance_of(String, sequence.to_s, "not a String") end def test_subseq_returns_nil_blank_sequence_default_end sequence = TSequence.new("") assert_equal(nil, sequence.subseq(5)) end def test_subseq_returns_nil_start_less_than_one sequence = TSequence.new("blahblah") assert_nil(sequence.subseq(0)) end def test_subseq_returns_subsequence sequence = TSequence.new("hahasubhehe") assert_equal("sub", sequence.subseq(5,7)) end end # Test Sequence#window_wearch class TestSequenceCommonWindowSearch < Test::Unit::TestCase def test_window_search_with_width_3_default_step_no_residual sequence = TSequence.new("agtca") windows = [] returned_value = sequence.window_search(3) { |window| windows << window } assert_equal(["agt", "gtc", "tca"], windows, "windows wrong") assert_equal("", returned_value, "returned value wrong") end # added def test_window_search_with_width_3_step_two_with_residual sequence = TSequence.new("agtcat") windows = [] returned_value = sequence.window_search(3, 2) { |window| windows << window } assert_equal(["agt", "tca"], windows, "windows wrong") assert_equal("t", returned_value, "returned value wrong") end end end From nakao at pub.open-bio.org Sun Feb 5 17:39:29 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sun, 05 Feb 2006 17:39:29 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio test_sequence.rb,1.5,1.6 Message-ID: <200602051739.k15HdTVL030745@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio In directory pub.open-bio.org:/tmp/cvs-serv30733/test/unit/bio Modified Files: test_sequence.rb Log Message: * test_common.rb: added. * test_compat.rb: added. * test_sequence.rb: moved some test codes to test_common.rb or test_compat.rb. Index: test_sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/test_sequence.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_sequence.rb 26 Nov 2005 06:51:45 -0000 1.5 --- test_sequence.rb 5 Feb 2006 17:39:27 -0000 1.6 *************** *** 1,6 **** # ! # test/unit/bio/tc_sequence.rb - Unit test for Bio::Sequencce # # Copyright (C) 2004 Moses Hohman # # This library is free software; you can redistribute it and/or --- 1,7 ---- # ! # test/unit/bio/test_sequence.rb - Unit test for Bio::Sequencce # # Copyright (C) 2004 Moses Hohman + # Copyright (C) 2006 Mitsuteru C. Nakao # # This library is free software; you can redistribute it and/or *************** *** 30,33 **** --- 31,35 ---- module Bio class TestSequence < Test::Unit::TestCase + def setup @na = Sequence::NA.new('atgcatgcatgcatgcaaaa') *************** *** 36,61 **** end - def test_to_s_returns_self_as_string - s = "abcefghijklmnop" - sequence = Sequence.new(s) - assert_equal(s, sequence.to_s, "wrong value") - assert_instance_of(String, sequence.to_s, "not a String") - end - - def test_subseq_returns_nil_blank_sequence_default_end - sequence = Sequence.new("") - assert_nil(sequence.subseq(5)) - end - def test_subseq_returns_nil_start_less_than_one - sequence = Sequence.new("blahblah") - assert_nil(sequence.subseq(0)) - end - - def test_subseq_returns_subsequence - sequence = Sequence.new("hahasubhehe") - assert_equal("sub", sequence.subseq(5,7)) - end - # "main" method tests translated into unit tests --- 38,42 ---- *************** *** 125,154 **** end - # Test Sequence#to_fasta - - def test_to_fasta - sequence = Sequence.new("agtc"*10) - header = "the header" - assert_equal(">the header\n" + ("agtc"*5) + "\n" + ("agtc"*5) + "\n", sequence.to_fasta(header, 20)) - end - - # Test Sequence#window_wearch - - def test_window_search_with_width_3_default_step_no_residual - sequence = Sequence.new("agtca") - windows = [] - returned_value = sequence.window_search(3) { |window| windows << window } - assert_equal(["agt", "gtc", "tca"], windows, "windows wrong") - assert_equal("", returned_value, "returned value wrong") - end - - # added - def test_window_search_with_width_3_step_two_with_residual - sequence = Sequence::NA.new("agtcat") - windows = [] - returned_value = sequence.window_search(3, 2) { |window| windows << window } - assert_equal(["agt", "tca"], windows, "windows wrong") - assert_equal("t", returned_value, "returned value wrong") - end # Test Sequence#total --- 106,109 ---- From k at pub.open-bio.org Mon Feb 6 06:17:55 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 06:17:55 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin keggapi.rb,1.8,1.9 Message-ID: <200602060617.k166HtVL032574@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv32570/shell/plugin Modified Files: keggapi.rb Log Message: * improved to accept other WSDL Index: keggapi.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/keggapi.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** keggapi.rb 18 Dec 2005 15:47:33 -0000 1.8 --- keggapi.rb 6 Feb 2006 06:17:53 -0000 1.9 *************** *** 41,46 **** private ! def keggapi ! @keggapi ||= Bio::KEGG::API.new end --- 41,51 ---- private ! def keggapi(wsdl = nil) ! if wsdl ! @keggapi = Bio::KEGG::API.new(wsdl) ! else ! @keggapi ||= Bio::KEGG::API.new ! end ! return @keggapi end From k at pub.open-bio.org Mon Feb 6 14:07:14 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:07:14 +0000 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.62,1.63 Message-ID: <200602061407.k16E7EVL001842@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv1838 Modified Files: bio.rb Log Message: * Bio::String is changed to Bio::Sequence::Generic in lib/bio/sequence/generic.rb Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** bio.rb 4 Feb 2006 19:12:55 -0000 1.62 --- bio.rb 6 Feb 2006 14:07:11 -0000 1.63 *************** *** 36,40 **** autoload :Sequence, 'bio/sequence' - autoload :String, 'bio/string' ## Locations/Location --- 36,39 ---- From k at pub.open-bio.org Mon Feb 6 14:10:03 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:10:03 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio sequence.rb,0.51,0.52 Message-ID: <200602061410.k16EA3VL001874@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv1865 Modified Files: sequence.rb Log Message: * changed to use autoload * send to @seq when method_missing * format_* methods are moved under the module Bio::Sequence::Format * added skelton for output(:gff) to call Bio::Sequence::Format#format_gff Index: sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence.rb,v retrieving revision 0.51 retrieving revision 0.52 diff -C2 -d -r0.51 -r0.52 *** sequence.rb 23 Jan 2006 04:13:36 -0000 0.51 --- sequence.rb 6 Feb 2006 14:10:01 -0000 0.52 *************** *** 29,60 **** # - require 'bio/data/na' - require 'bio/data/aa' - require 'bio/data/codontable' - require 'bio/location' - - require 'bio/sequence/common' - require 'bio/sequence/na' - require 'bio/sequence/aa' - require 'bio/sequence/format' require 'bio/sequence/compat' module Bio - # Nucleic/Amino Acid sequence - class Sequence attr_accessor :entry_id, :definition, :features, :references, :comments, :date, :keywords, :dblinks, :taxonomy, :moltype, :seq ! # def method_missing(*arg) ! # @seq.send(*arg) ! # end def output(style) case style when :fasta format_fasta when :genbank format_genbank --- 29,62 ---- # require 'bio/sequence/compat' module Bio class Sequence + def initialize(str) + @seq = str + end + + def method_missing(*arg) + @seq.send(*arg) + end + attr_accessor :entry_id, :definition, :features, :references, :comments, :date, :keywords, :dblinks, :taxonomy, :moltype, :seq ! autoload :Common, 'bio/sequence/common' ! autoload :NA, 'bio/sequence/na' ! autoload :AA, 'bio/sequence/aa' ! autoload :Generic, 'bio/sequence/generic' ! autoload :Format, 'bio/sequence/format' def output(style) + extend Bio::Sequence::Format case style when :fasta format_fasta + when :gff + format_gff when :genbank format_genbank *************** *** 62,69 **** format_embl end - end - - def initialize(str) - @seq = str end --- 64,67 ---- From k at pub.open-bio.org Mon Feb 6 14:11:33 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:11:33 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence aa.rb,1.1,1.2 Message-ID: <200602061411.k16EBXVL001901@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv1897/sequence Modified Files: aa.rb Log Message: * added RDoc header with Ruby's license * changed to use autoload * use Bio::AminoAcid explicitly instead of AminoAcid Index: aa.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/aa.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** aa.rb 23 Jan 2006 04:13:36 -0000 1.1 --- aa.rb 6 Feb 2006 14:11:31 -0000 1.2 *************** *** 1,8 **** module Bio class Sequence - # Amino Acid sequence class AA < String --- 1,22 ---- + # + # = bio/sequence/aa.rb - amino acid sequence class + # + # Copyright:: Copyright (C) 2006 + # Toshiaki Katayama + # License:: Ruby's + # + # $Id$ + # + + require 'bio/sequence/common' + module Bio + autoload :AminoAcid, 'bio/data/aa' + class Sequence + # Amino Acid sequence class AA < String *************** *** 16,27 **** end # Estimate the weight of this protein. - # AminoAcid is defined in bio/data/aa.rb def molecular_weight ! AminoAcid.weight(self) end def to_re ! AminoAcid.to_re(self) end --- 30,41 ---- end + # Estimate the weight of this protein. def molecular_weight ! Bio::AminoAcid.weight(self) end def to_re ! Bio::AminoAcid.to_re(self) end *************** *** 31,35 **** array = [] self.each_byte do |x| ! array.push(AminoAcid.names[x.chr]) end return array --- 45,49 ---- array = [] self.each_byte do |x| ! array.push(Bio::AminoAcid.names[x.chr]) end return array *************** *** 39,43 **** def names self.codes.map do |x| ! AminoAcid.names[x] end end --- 53,57 ---- def names self.codes.map do |x| ! Bio::AminoAcid.names[x] end end *************** *** 48,49 **** --- 62,64 ---- end # Bio + From k at pub.open-bio.org Mon Feb 6 14:13:54 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:13:54 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence na.rb,1.1,1.2 Message-ID: <200602061413.k16EDsVL001949@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv1924/sequence Modified Files: na.rb Log Message: * added RDoc header with Ruby's license * changed to use autoload * use Bio::NucleicAcid explicitly instead of NucleicAcid * pikachu method is moved to lib/bio/sequence/compat.rb Index: na.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/na.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** na.rb 23 Jan 2006 04:13:36 -0000 1.1 --- na.rb 6 Feb 2006 14:13:52 -0000 1.2 *************** *** 1,8 **** module Bio class Sequence - # Nucleic Acid sequence class NA < String --- 1,23 ---- + # + # = bio/sequence/na.rb - nucleic acid sequence class + # + # Copyright:: Copyright (C) 2006 + # Toshiaki Katayama + # License:: Ruby's + # + # $Id$ + # + + require 'bio/sequence/common' + module Bio + autoload :NucleicAcid, 'bio/data/na' + autoload :CodonTable, 'bio/data/codontable' + class Sequence + # Nucleic Acid sequence class NA < String *************** *** 118,127 **** # Estimate the weight of this biological string molecule. - # NucleicAcid is defined in bio/data/na.rb def molecular_weight if self.rna? ! NucleicAcid.weight(self, true) else ! NucleicAcid.weight(self) end end --- 133,141 ---- # Estimate the weight of this biological string molecule. def molecular_weight if self.rna? ! Bio::NucleicAcid.weight(self, true) else ! Bio::NucleicAcid.weight(self) end end *************** *** 130,136 **** def to_re if self.rna? ! NucleicAcid.to_re(self.dna, true) else ! NucleicAcid.to_re(self) end end --- 144,150 ---- def to_re if self.rna? ! Bio::NucleicAcid.to_re(self.dna, true) else ! Bio::NucleicAcid.to_re(self) end end *************** *** 140,144 **** array = [] self.each_byte do |x| ! array.push(NucleicAcid.names[x.chr.upcase]) end return array --- 154,158 ---- array = [] self.each_byte do |x| ! array.push(Bio::NucleicAcid.names[x.chr.upcase]) end return array *************** *** 168,175 **** protected :rna? - def pikachu - self.dna.tr("atgc", "pika") # joke, of course :-) - end - end # NA --- 182,185 ---- *************** *** 177,178 **** --- 187,189 ---- end # Bio + From k at pub.open-bio.org Mon Feb 6 14:16:19 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:16:19 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence common.rb,1.1,1.2 Message-ID: <200602061416.k16EGJVL002009@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv1993/sequence Modified Files: common.rb Log Message: * added RDoc header with Ruby's license * changed to use autoload * subseq method is changed to raise exception when the start or end position is not a positive integer * splicing method is renamed to splice * splicing is made aliased to splice method Index: common.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/common.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** common.rb 23 Jan 2006 04:13:36 -0000 1.1 --- common.rb 6 Feb 2006 14:16:17 -0000 1.2 *************** *** 1,6 **** --- 1,20 ---- + # + # = bio/sequence/common.rb - common methods for biological sequence + # + # Copyright:: Copyright (C) 2006 + # Toshiaki Katayama + # License:: Ruby's + # + # $Id$ + # + module Bio + autoload :Locations, 'bio/location' + class Sequence + # This module provides common methods for biological sequence classes + # which must inherit String. module Common *************** *** 34,38 **** # Returns the subsequence of the self string. def subseq(s = 1, e = self.length) ! return nil if s < 1 or e < 1 s -= 1 e -= 1 --- 48,52 ---- # Returns the subsequence of the self string. def subseq(s = 1, e = self.length) ! raise "Error: start/end position must be a positive integer" unless s > 0 and e > 0 s -= 1 e -= 1 *************** *** 134,140 **** # Receive a GenBank style position string and convert it to the Locations # objects to splice the sequence itself. See also: bio/location.rb ! # ! # This method depends on Locations class, see bio/location.rb ! def splicing(position) unless position.is_a?(Locations) then position = Locations.new(position) --- 148,152 ---- # Receive a GenBank style position string and convert it to the Locations # objects to splice the sequence itself. See also: bio/location.rb ! def splice(position) unless position.is_a?(Locations) then position = Locations.new(position) *************** *** 155,158 **** --- 167,171 ---- return self.class.new(s) end + alias splicing splice end # Common From k at pub.open-bio.org Mon Feb 6 14:18:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:18:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence compat.rb,1.1,1.2 Message-ID: <200602061418.k16EI6VL002036@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv2032/sequence Modified Files: compat.rb Log Message: * added RDoc header with Ruby's license * changed to use autoload * pikachu method is moved from lib/bio/sequence/na.rb * changed to warn when to_fasta method is used in debug mode Index: compat.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/compat.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** compat.rb 23 Jan 2006 04:13:36 -0000 1.1 --- compat.rb 6 Feb 2006 14:18:03 -0000 1.2 *************** *** 1,3 **** ! # only for backward compatibility, use Bio::Sequence#output(:fasta) instead module Bio --- 1,12 ---- ! # ! # = bio/sequence/compat.rb - methods for backward compatibility ! # ! # Copyright:: Copyright (C) 2006 ! # Toshiaki Katayama ! # License:: Ruby's ! # ! # $Id$ ! # ! module Bio *************** *** 5,8 **** --- 14,21 ---- class Sequence + autoload :Common, 'bio/sequence/common' + autoload :NA, 'bio/sequence/na' + autoload :AA, 'bio/sequence/aa' + def to_s String.new(@seq) *************** *** 10,14 **** alias to_str to_s ! module Common # Output the FASTA format string of the sequence. The 1st argument is --- 23,28 ---- alias to_str to_s ! ! module Common # Output the FASTA format string of the sequence. The 1st argument is *************** *** 16,19 **** --- 30,34 ---- # sequence will be folded. def to_fasta(header = '', width = nil) + warn "Bio::Sequence#to_fasta is obsolete. Use Bio::Sequence#output(:fasta) instead" if $DEBUG ">#{header}\n" + if width *************** *** 26,29 **** --- 41,45 ---- end # Common + class NA *************** *** 32,37 **** --- 48,58 ---- end + def pikachu + self.dna.tr("atgc", "pika") # joke, of course :-) + end + end # NA + class AA *************** *** 41,44 **** --- 62,66 ---- end # AA + end # Sequence From k at pub.open-bio.org Mon Feb 6 14:20:37 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:20:37 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence format.rb,1.1,1.2 Message-ID: <200602061420.k16EKbVL002068@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv2059/sequence Modified Files: format.rb Log Message: * added RDoc header with Ruby's license * format_* functions are moved under the module Bio::Sequence::Format and these are extended to Bio::Sequence object when used. * format_gff method is added as a skelton (need to be implemented) Index: format.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/format.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** format.rb 23 Jan 2006 04:13:36 -0000 1.1 --- format.rb 6 Feb 2006 14:20:35 -0000 1.2 *************** *** 1,8 **** --- 1,26 ---- + # + # = bio/sequence/format.rb - various output format of the biological sequence + # + # Copyright:: Copyright (C) 2006 + # Toshiaki Katayama , + # Naohisa Goto + # License:: Ruby's + # + # = TODO + # # porting from N. Goto's feature-output.rb on BioRuby list. + # + # $Id$ + # + module Bio + autoload :Sequence, 'bio/sequence' + class Sequence + module Format + # Output the FASTA format string of the sequence. The 1st argument is # used in the comment line. If the 2nd argument (integer) is given, *************** *** 19,22 **** --- 37,44 ---- end + def format_gff + raise NotImplementedError + end + def format_genbank prefix = ' ' * 5 *************** *** 35,38 **** --- 57,61 ---- end + private *************** *** 104,108 **** --- 127,134 ---- end + end # Format + end # Sequence end # Bio + From k at pub.open-bio.org Mon Feb 6 14:22:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:22:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence generic.rb,1.1,1.2 Message-ID: <200602061422.k16EM6VL002095@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv2091/sequence Modified Files: generic.rb Log Message: * Bio::String caused various errors, so the class is changed to Bio::Sequence::Generic Index: generic.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/generic.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** generic.rb 4 Feb 2006 19:12:56 -0000 1.1 --- generic.rb 6 Feb 2006 14:22:04 -0000 1.2 *************** *** 1,4 **** # ! # = bio/string.rb - biological string class to store an intact sequence # # Copyright:: Copyright (C) 2006 --- 1,4 ---- # ! # = bio/sequence/generic.rb - generic sequence class to store an intact string # # Copyright:: Copyright (C) 2006 *************** *** 12,22 **** module Bio ! ! class String include Bio::Sequence::Common ! end ! ! end --- 12,22 ---- module Bio ! class Sequence ! class Generic include Bio::Sequence::Common ! end # Generic ! end # Sequence ! end # Bio From k at pub.open-bio.org Mon Feb 6 14:26:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 06 Feb 2006 14:26:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence generic.rb,1.2,1.3 Message-ID: <200602061426.k16EQ6VL002145@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv2141/sequence Modified Files: generic.rb Log Message: * fixed to inherit String Index: generic.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/generic.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** generic.rb 6 Feb 2006 14:22:04 -0000 1.2 --- generic.rb 6 Feb 2006 14:26:04 -0000 1.3 *************** *** 13,21 **** module Bio class Sequence ! class Generic include Bio::Sequence::Common end # Generic end # Sequence end # Bio --- 13,23 ---- module Bio class Sequence ! ! class Generic < String include Bio::Sequence::Common end # Generic + end # Sequence end # Bio From nakao at pub.open-bio.org Tue Feb 7 16:53:10 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Tue, 07 Feb 2006 16:53:10 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/sequence test_common.rb, 1.1, 1.2 Message-ID: <200602071653.k17GrAVL005902@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv5892/test/unit/bio/sequence Modified Files: test_common.rb Log Message: * Removed test_subseq_returns_nil_blank_sequence_default_end and test_subseq_returns_nil_start_less_than_one test methods. * Added test_subseq_returns_RuntimeError_blank_sequence_default_end and test_subseq_returns_RuntimeError_start_less_than_one test methods. Index: test_common.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/sequence/test_common.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_common.rb 5 Feb 2006 17:39:27 -0000 1.1 --- test_common.rb 7 Feb 2006 16:53:08 -0000 1.2 *************** *** 136,149 **** end ! def test_subseq_returns_nil_blank_sequence_default_end sequence = TSequence.new("") ! assert_equal(nil, sequence.subseq(5)) end ! def test_subseq_returns_nil_start_less_than_one sequence = TSequence.new("blahblah") ! assert_nil(sequence.subseq(0)) end ! def test_subseq_returns_subsequence sequence = TSequence.new("hahasubhehe") --- 136,149 ---- end ! def test_subseq_returns_RuntimeError_blank_sequence_default_end sequence = TSequence.new("") ! assert_raise(RuntimeError) { sequence.subseq(5) } end ! def test_subseq_returns_RuntimeError_start_less_than_one sequence = TSequence.new("blahblah") ! assert_raise(RuntimeError) { sequence.subseq(0) } end ! def test_subseq_returns_subsequence sequence = TSequence.new("hahasubhehe") From nakao at pub.open-bio.org Wed Feb 8 07:08:24 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 08 Feb 2006 07:08:24 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/sequence test_na.rb,NONE,1.1 Message-ID: <200602080708.k1878OVL008720@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv8710/test/unit/bio/sequence Added Files: test_na.rb Log Message: * Newly added --- NEW FILE: test_na.rb --- # # = test/unit/bio/sequence/test_na.rb - Unit test for Bio::Sequencce::NA # # Copyright:: Copyright (C) 2006 # Mitsuteru C. Nakao # Lisence:: Ruby's # # $Id: test_na.rb,v 1.1 2006/02/08 07:08:22 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/sequence' require 'bio/sequence/na' module Bio class TestSequenceNANew < Test::Unit::TestCase def test_new str = 'atgcatgcatgcatgcaaaa' assert(Bio::Sequence::NA.new(str)) end def test_new_t str = "atgcatgcatgcatgcaaaa" str_t = "atgcatgcat\tgca\ttgcaaaa" assert_equal(str, Bio::Sequence::NA.new(str_t)) end def test_new_n str = "atgcatgcatgcatgcaaaa" str_n = "atgcatgcat\ngca\ntgcaaaa" assert_equal(str, Bio::Sequence::NA.new(str_n)) end def test_new_r str = "atgcatgcatgcatgcaaaa" str_r = "atgcatgcat\n\rgca\n\rtgcaaaa" assert_equal(str, Bio::Sequence::NA.new(str_r)) end end class TestSequenceNA < Test::Unit::TestCase def setup @obj = Bio::Sequence::NA.new('atgcatgcatgcatgcaaaa') end def test_splicing # 'atgcatgcatgcatgcaaaa' # 12345678901234567890 str = 'atgca catgcatg'.gsub(' ','') assert_equal(str, @obj.splicing("join(1..5,8..15)")) end def test_forward_complement str = 'atgcatgcatgcatgcaaaa' str_fcomp = 'tacgtacgtacgtacgtttt' fcomp = @obj.forward_complement assert_equal(str_fcomp, @obj.forward_complement) assert_equal(str, @obj) assert_equal(str_fcomp, @obj.forward_complement!) assert_equal(str_fcomp, @obj) end def test_reverse_complement str = 'atgcatgcatgcatgcaaaa' str_rcomp = 'tacgtacgtacgtacgtttt'.reverse rcomp = @obj.forward_complement assert_equal(str_rcomp, @obj.reverse_complement) assert_equal(str, @obj) assert_equal(str_rcomp, @obj.reverse_complement!) assert_equal(str_rcomp, @obj) end def test_complement assert(@obj.complement) assert(@obj.complement!) end def test_to_s str = 'atgcatgcatgcatgcaaaa' assert_equal(str, @obj.to_s) end def test_codon_usage usage = {"cat"=>1, "caa"=>1, "tgc"=>1, "gca"=>1, "atg"=>2} assert_equal(usage, @obj.codon_usage) end def test_gc_percent assert_equal(40, @obj.gc_percent) @obj[0, 1] = 'g' assert_equal(45, @obj.gc_percent) end def test_iliegal_bases @obj[0, 1] = 'n' @obj[1, 1] = 'y' assert_equal(['n', 'y'], @obj.illegal_bases) end def test_molecular_weight assert_in_delta(6174.3974, @obj.molecular_weight, 1e-4) end def test_to_re assert_equal(/atgcatgcatgcatgcaaaa/, @obj.to_re) @obj[1,1] = 'n' @obj[2,1] = 'r' @obj[3,1] = 's' @obj[4,1] = 'y' @obj[5,1] = 'w' assert_equal(/a[atgc][ag][gc][tc][at]gcatgcatgcaaaa/, @obj.to_re) end def test_names ary = ["Adenine", "Thymine", "Guanine"] assert_equal(ary , @obj.splice("1..3").names) end def test_dna @obj[0,1] = 'u' assert_equal('utgcatgcatgcatgcaaaa', @obj) assert_equal('ttgcatgcatgcatgcaaaa', @obj.dna) end def test_dna! @obj[0,1] = 'u' assert_equal('utgcatgcatgcatgcaaaa', @obj) @obj.dna! assert_equal('ttgcatgcatgcatgcaaaa', @obj) end def test_rna assert_equal('atgcatgcatgcatgcaaaa', @obj) assert_equal('augcaugcaugcaugcaaaa', @obj.rna) end def test_rna! assert_equal('atgcatgcatgcatgcaaaa', @obj) @obj.rna! assert_equal('augcaugcaugcaugcaaaa', @obj) end end class TestSequenceNATranslation < Test::Unit::TestCase def setup str = "aaacccgggttttaa" # K>>P>>G>>F>>*>> # N>>P>>G>>F>> # T>>R>>V>>L>> # P>>G>>F>>*>> # "tttgggcccaaaatt" # < Update of /home/repository/bioruby/bioruby/test/unit/bio/sequence In directory pub.open-bio.org:/tmp/cvs-serv8762/test/unit/bio/sequence Added Files: test_aa.rb Log Message: * ANewly added. --- NEW FILE: test_aa.rb --- # # = test/unit/bio/sequence/test_aa.rb - Unit test for Bio::Sequencce::AA # # Copyright:: Copyright (C) 2006 # Mitsuteru C. Nakao # Lisence:: Ruby's # # $Id: test_aa.rb,v 1.1 2006/02/08 07:20:24 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/sequence' require 'bio/sequence/aa' module Bio class TestSequenceAANew < Test::Unit::TestCase def test_new str = "RRLEHTFVFL RNFSLMLLRY" assert(Bio::Sequence::AA.new(str)) end def test_new_t str = "RRLEHTFVFLRNFSLMLLRY" str_t = "RRLEHTFVFL\tRNFSLMLLRY" assert_equal(str, Bio::Sequence::AA.new(str_t)) end def test_new_n str = "RRLEHTFVFLRNFSLMLLRY" str_n = "RRLEHTFVFL\nRNFSLMLLRY" assert_equal(str, Bio::Sequence::AA.new(str_n)) end def test_new_r str = "RRLEHTFVFLRNFSLMLLRY" str_r = "RRLEHTFVFL\n\rRNFSLMLLRY" assert_equal(str, Bio::Sequence::AA.new(str_r)) end end class TestSequenceAA < Test::Unit::TestCase def setup str = "RRLEHTFVFLRNFSLMLLRY" @obj = Bio::Sequence::AA.new(str) end def test_to_s str = "RRLEHTFVFLRNFSLMLLRY" assert_equal(str, @obj.to_s) end def test_molecular_weight assert_in_delta(2612.105, @obj.molecular_weight, 1e-4) end def test_to_re re = /RRLEHTFVFLRNFSLMLLRY/ assert_equal(re, @obj.to_re) @obj[1, 1] = 'B' re = /R[DN]LEHTFVFLRNFSLMLLRY/ assert_equal(re, @obj.to_re) end def test_codes ary = ["Arg", "Arg", "Leu", "Glu", "His", "Thr", "Phe", "Val", "Phe", "Leu", "Arg", "Asn", "Phe", "Ser", "Leu", "Met", "Leu", "Leu", "Arg", "Tyr"] assert_equal(ary, @obj.codes) end def test_names ary = ["arginine", "arginine", "leucine", "glutamic acid", "histidine", "threonine", "phenylalanine", "valine", "phenylalanine", "leucine", "arginine", "asparagine", "phenylalanine", "serine", "leucine", "methionine", "leucine", "leucine", "arginine", "tyrosine"] assert_equal(ary, @obj.names) end end require 'bio/sequence/aa' class TestSequenceAACompat < Test::Unit::TestCase def test_aa_self_randomize composition = Bio::Sequence::AA.new("WWDTGAK").composition assert(Bio::Sequence::AA.randomize(composition)) end end end From k at pub.open-bio.org Wed Feb 8 12:02:11 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed, 08 Feb 2006 12:02:11 +0000 Subject: [BioRuby-cvs] bioruby README.DEV,1.8,1.9 Message-ID: <200602081202.k18C2BVL009636@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv9632 Modified Files: README.DEV Log Message: * changes on license Index: README.DEV =================================================================== RCS file: /home/repository/bioruby/bioruby/README.DEV,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** README.DEV 14 Nov 2005 15:50:21 -0000 1.8 --- README.DEV 8 Feb 2006 12:02:09 -0000 1.9 *************** *** 3,7 **** $Id$ ! Copyright (C) 2005 Toshiaki Katayama = How to contribute to the BioRuby project? --- 3,7 ---- $Id$ ! Copyright (C) 2005, 2006 Toshiaki Katayama = How to contribute to the BioRuby project? *************** *** 15,19 **** * Develop code for new features, etc. ! All of these are welcome! This document describes the last option, how to contribute your code to the BioRuby distribution. --- 15,19 ---- * Develop code for new features, etc. ! All of these are welcome! However, this document describes the last option, how to contribute your code to the BioRuby distribution. *************** *** 23,29 **** == License ! If you would like your module to be included in the BioRuby ! distribution, please license your module under GNU's LGPL for ! compatibility with the BioRuby project. == Coding style --- 23,32 ---- == License ! If you would like your module to be included in the BioRuby distribution, ! you need to give us right to change the license of your module to make it ! compatible with other modules in BioRuby. ! ! BioRuby was previously distributed under the GNU GPL license, but now we ! are changing the license to Ruby's. == Coding style *************** *** 56,60 **** # Bio R. Hacker , # Chem R. Hacker ! # License:: LGPL # # $Id$ --- 59,63 ---- # Bio R. Hacker , # Chem R. Hacker ! # License:: Ruby's # # $Id$ *************** *** 73,97 **** # == References # ! # * Hoge F. et al., The Hoge database, Nucleic. Acid. Res. 123:100--123 (2030) # # * http://hoge.db/ - # - #-- - # - # 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 - # - #++ # --- 76,82 ---- # == References # ! # * Hoge F. et al., The Hoge database, Nucleic. Acid. Res. 123:100--123 (2030) # # * http://hoge.db/ # From k at pub.open-bio.org Wed Feb 8 12:15:44 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed, 08 Feb 2006 12:15:44 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/data na.rb,0.19,0.20 Message-ID: <200602081215.k18CFiVL009693@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/data In directory pub.open-bio.org:/tmp/cvs-serv9682/lib/bio/data Modified Files: na.rb Log Message: * to_re method is fixed to convert input sequence to downcase and not to change original sequence itself. Index: na.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/data/na.rb,v retrieving revision 0.19 retrieving revision 0.20 diff -C2 -d -r0.19 -r0.20 *** na.rb 10 Dec 2005 18:14:22 -0000 0.19 --- na.rb 8 Feb 2006 12:15:42 -0000 0.20 *************** *** 4,8 **** # Copyright:: Copyright (C) 2001, 2005 # Toshiaki Katayama ! # License:: LGPL # # $Id$ --- 4,8 ---- # Copyright:: Copyright (C) 2001, 2005 # Toshiaki Katayama ! # License:: Ruby's # # $Id$ *************** *** 39,60 **** # p Bio::NucleicAcid.weight('atgc') # - #-- - # - # 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 - # - #++ - # module Bio --- 39,42 ---- *************** *** 177,181 **** def to_re(seq, rna = false) ! str = seq.to_s str.gsub!(/[^atgcu]/) { |base| NAMES[base] || '.' --- 159,163 ---- def to_re(seq, rna = false) ! str = seq.to_s.downcase str.gsub!(/[^atgcu]/) { |base| NAMES[base] || '.' From nakao at pub.open-bio.org Wed Feb 8 13:57:03 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 08 Feb 2006 13:57:03 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/data test_na.rb,1.5,1.6 Message-ID: <200602081357.k18Dv3VL011351@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/data In directory pub.open-bio.org:/tmp/cvs-serv11278/test/unit/bio/data Modified Files: test_na.rb Log Message: * Changed on lisence. * test_to_re: added tests to check the Bio::NucleicAcid.to_re. Index: test_na.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/data/test_na.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_na.rb 25 Nov 2005 15:59:29 -0000 1.5 --- test_na.rb 8 Feb 2006 13:57:01 -0000 1.6 *************** *** 2,20 **** # test/unit/bio/data/test_na.rb - Unit test for Bio::NucleicAcid # ! # Copyright (C) 2005 Mitsuteru Nakao ! # ! # 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$ --- 2,7 ---- # test/unit/bio/data/test_na.rb - Unit test for Bio::NucleicAcid # ! # Copyright:: Copyright (C) 2005,2006 Mitsuteru Nakao ! # Lisence:: Ruby's # # $Id$ *************** *** 48,51 **** --- 35,39 ---- class TestNA < Test::Unit::TestCase + def setup @obj = Bio::NucleicAcid.new *************** *** 54,59 **** def test_to_re re = /[tc][ag][at][gc][tg][ac][tgc][atg][agc][atgc]atgc/ ! assert_equal(re, @obj.to_re('yrwskmbdvnatgc')) ! assert_equal(re, Bio::NucleicAcid.to_re('yrwskmbdvnatgc')) end --- 42,50 ---- def test_to_re re = /[tc][ag][at][gc][tg][ac][tgc][atg][agc][atgc]atgc/ ! str = 'yrwskmbdvnatgc' ! str0 = str.clone ! assert_equal(re, @obj.to_re(str)) ! assert_equal(str0, str) ! assert_equal(re, Bio::NucleicAcid.to_re(str)) end From nakao at pub.open-bio.org Wed Feb 8 14:39:01 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 08 Feb 2006 14:39:01 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio reference.rb,1.19,1.20 Message-ID: <200602081439.k18Ed1VL012353@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv12343/lib/bio Modified Files: reference.rb Log Message: * Bio::References#append: fixed a typo. Index: reference.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/reference.rb,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** reference.rb 29 Jan 2006 07:39:31 -0000 1.19 --- reference.rb 8 Feb 2006 14:38:59 -0000 1.20 *************** *** 366,370 **** # Append a Bio::Reference object. def append(reference) ! @references.push(reference) if a.is_a? Reference return self end --- 366,370 ---- # Append a Bio::Reference object. def append(reference) ! @references.push(reference) if reference.is_a? Reference return self end From nakao at pub.open-bio.org Wed Feb 8 15:06:28 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 08 Feb 2006 15:06:28 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio test_reference.rb,NONE,1.1 Message-ID: <200602081506.k18F6SVL012449@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio In directory pub.open-bio.org:/tmp/cvs-serv12435/test/unit/bio Added Files: test_reference.rb Log Message: * lib/bio/reference.rb: fixed a bug in the endnote method. * test/unit/bio/test_reference.rb: newly added. --- NEW FILE: test_reference.rb --- # # = test/bio/tc_pathway.rb - Unit test for Bio::Pathway # # Copyright:: Copyright (C) 2006 # Mitsuteru C. Nakao # Lisence:: Ruby's # # $Id: test_reference.rb,v 1.1 2006/02/08 15:06:26 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), [".."] * 3, "lib")).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/reference' module Bio class TestReference < Test::Unit::TestCase def setup hash = {'authors' => [ "Hoge, J.P.", "Fuga, F.B." ], 'title' => "Title of the study.", 'journal' => "Theor. J. Hoge", 'volume' => 12, 'issue' => 3, 'pages' => "123-145", 'year' => 2001, 'pubmed' => 12345678, 'medline' => 98765432, 'abstract' => "Hoge fuga. hoge fuga.", 'url' => "http://example.com", 'mesh' => ['Hoge'], 'affiliations' => ['Tokyo']} @obj = Bio::Reference.new(hash) end def test_authors ary = [ "Hoge, J.P.", "Fuga, F.B." ] assert_equal(ary, @obj.authors) end def test_journal str = 'Theor. J. Hoge' assert_equal(str, @obj.journal) end def test_volume str = 12 assert_equal(str, @obj.volume) end def test_issue str = 3 assert_equal(str, @obj.issue) end def test_pages str = '123-145' assert_equal(str, @obj.pages) end def test_year str = 2001 assert_equal(str, @obj.year) end def test_pubmed str = 12345678 assert_equal(str, @obj.pubmed) end def test_abstract str = 'Hoge fuga. hoge fuga.' assert_equal(str, @obj.abstract) end def test_url str = 'http://example.com' assert_equal(str, @obj.url) end def test_mesh str = ['Hoge'] assert_equal(str, @obj.mesh) end def test_affiliations str = ['Tokyo'] assert_equal(str, @obj.affiliations) end def test_format_general str = 'Hoge, J.P., Fuga, F.B. (2001). "Title of the study." Theor. J. Hoge 12:123-145.' assert_equal(str, @obj.format) assert_equal(str, @obj.format('general')) assert_equal(str, @obj.general) end def test_format_endnote str = "%0 Journal Article\n%A Hoge, J.P.\n%A Fuga, F.B.\n%D 2001\n%T Title of the study.\n%J Theor. J. Hoge\n%V 12\n%N 3\n%P 123-145\n%M 12345678\n%U http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&dopt=Citation&list_uids=12345678\n%X Hoge fuga. hoge fuga.\n%K Hoge\n%+ Tokyo" assert_equal(str, @obj.format('endnote')) assert_equal(str, @obj.endnote) end def test_format_bibitem str = "\\bibitem{PMID:12345678}\nHoge, J.P., Fuga, F.B.\nTitle of the study.,\n{\\em Theor. J. Hoge}, 12(3):123--145, 2001." assert_equal(str, @obj.format('bibitem')) assert_equal(str, @obj.bibitem) end def test_format_bibtex str =< Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv12435/lib/bio Modified Files: reference.rb Log Message: * lib/bio/reference.rb: fixed a bug in the endnote method. * test/unit/bio/test_reference.rb: newly added. Index: reference.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/reference.rb,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** reference.rb 8 Feb 2006 14:38:59 -0000 1.20 --- reference.rb 8 Feb 2006 15:06:26 -0000 1.21 *************** *** 43,50 **** # === Examples # ! # hash = {'authors' => [ "Hoge, J.P.", "Fuga, F.B." ], 'title' => "Title of the study.", ! # 'journal' => "Theor. J. Hoge", 'volume' => 12, 'issue' => 3, 'pages' => "123-145", ! # 'year' => 2001, 'pubmed' => 12345678, 'medline' => 98765432, 'abstract' => "...", ! # ''url' => "http://...", 'mesh' => [], 'affiliations' => []} # ref = Bio::Reference.new(hash) # --- 43,59 ---- # === Examples # ! # hash = {'authors' => [ "Hoge, J.P.", "Fuga, F.B." ], ! # 'title' => "Title of the study.", ! # 'journal' => "Theor. J. Hoge", ! # 'volume' => 12, ! # 'issue' => 3, ! # 'pages' => "123-145", ! # 'year' => 2001, ! # 'pubmed' => 12345678, ! # 'medline' => 98765432, ! # 'abstract' => "Hoge fuga. ...", ! # 'url' => "http://example.com", ! # 'mesh' => [], ! # 'affiliations' => []} # ref = Bio::Reference.new(hash) # *************** *** 171,181 **** lines << "%A #{author}" end ! lines << "%D #{@year}" unless @year.empty? lines << "%T #{@title}" unless @title.empty? lines << "%J #{@journal}" unless @journal.empty? ! lines << "%V #{@volume}" unless @volume.empty? ! lines << "%N #{@issue}" unless @issue.empty? lines << "%P #{@pages}" unless @pages.empty? ! lines << "%M #{@pubmed}" unless @pubmed.empty? if @pubmed cgi = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi" --- 180,190 ---- lines << "%A #{author}" end ! lines << "%D #{@year}" unless @year.to_s.empty? lines << "%T #{@title}" unless @title.empty? lines << "%J #{@journal}" unless @journal.empty? ! lines << "%V #{@volume}" unless @volume.to_s.empty? ! lines << "%N #{@issue}" unless @issue.to_s.empty? lines << "%P #{@pages}" unless @pages.empty? ! lines << "%M #{@pubmed}" unless @pubmed.to_s.empty? if @pubmed cgi = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi" From k at pub.open-bio.org Wed Feb 8 17:22:24 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Wed, 08 Feb 2006 17:22:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio sequence.rb,0.52,0.53 Message-ID: <200602081722.k18HMOVL012865@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv12861/lib/bio Modified Files: sequence.rb Log Message: * @seq extends Bio::Sequence::Common to make 'guess' method can find composition method on @seq. This fix is for the 'seq' command in BioRuby shell to work. Index: sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence.rb,v retrieving revision 0.52 retrieving revision 0.53 diff -C2 -d -r0.52 -r0.53 *** sequence.rb 6 Feb 2006 14:10:01 -0000 0.52 --- sequence.rb 8 Feb 2006 17:22:22 -0000 0.53 *************** *** 4,31 **** # Copyright:: Copyright (C) 2000-2006 # Toshiaki Katayama , ! # Yoshinori K. Okuji , # Naohisa Goto ! # License:: LGPL # # $Id$ # - #-- - # - # 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 - # - #++ - # require 'bio/sequence/compat' --- 4,13 ---- # Copyright:: Copyright (C) 2000-2006 # Toshiaki Katayama , ! # Yoshinori K. Okuji , # Naohisa Goto ! # License:: Ruby's # # $Id$ # require 'bio/sequence/compat' *************** *** 35,40 **** class Sequence def initialize(str) ! @seq = str end --- 17,29 ---- class Sequence + autoload :Common, 'bio/sequence/common' + autoload :NA, 'bio/sequence/na' + autoload :AA, 'bio/sequence/aa' + autoload :Generic, 'bio/sequence/generic' + autoload :Format, 'bio/sequence/format' + def initialize(str) ! @seq = str.dup ! @seq.extend Bio::Sequence::Common end *************** *** 46,55 **** :date, :keywords, :dblinks, :taxonomy, :moltype, :seq - autoload :Common, 'bio/sequence/common' - autoload :NA, 'bio/sequence/na' - autoload :AA, 'bio/sequence/aa' - autoload :Generic, 'bio/sequence/generic' - autoload :Format, 'bio/sequence/format' - def output(style) extend Bio::Sequence::Format --- 35,38 ---- *************** *** 67,77 **** def self.auto(str) ! moltype = self.guess(str) ! if moltype == NA @seq = NA.new(str) else @seq = AA.new(str) end - return @seq end --- 50,59 ---- def self.auto(str) ! @moltype = self.guess(str) ! if @moltype == NA @seq = NA.new(str) else @seq = AA.new(str) end return @seq end From ngoto at pub.open-bio.org Thu Feb 9 03:28:50 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Thu, 09 Feb 2006 03:28:50 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db fasta.rb,1.22,1.23 Message-ID: <200602090328.k193SoVL014503@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv14493/lib/bio/db Modified Files: fasta.rb Log Message: * changed Bio::Sequence.new to Bio::Sequence::Generic.new (temporary change) * changed Lisence to Ruby's Index: fasta.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/fasta.rb,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** fasta.rb 28 Jan 2006 10:48:59 -0000 1.22 --- fasta.rb 9 Feb 2006 03:28:48 -0000 1.23 *************** *** 5,9 **** # GOTO Naohisa , # KATAYAMA Toshiaki ! # Lisence:: LGPL # # $Id$ --- 5,9 ---- # GOTO Naohisa , # KATAYAMA Toshiaki ! # Lisence:: Ruby's # # $Id$ *************** *** 63,84 **** # http://www.ncbi.nlm.nih.gov/BLAST/fasta.shtml # - #-- - # - # 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 - # - #++ - # require 'bio/db' --- 63,66 ---- *************** *** 209,213 **** unless defined?(@seq) unless /\A\s*^\#/ =~ @data then ! @seq = Sequence.new(@data.tr(" \t\r\n0-9", '')) # lazy clean up else a = @data.split(/(^\#.*$)/) --- 191,195 ---- unless defined?(@seq) unless /\A\s*^\#/ =~ @data then ! @seq = Sequence::Generic.new(@data.tr(" \t\r\n0-9", '')) # lazy clean up else a = @data.split(/(^\#.*$)/) *************** *** 225,229 **** end @comment = cmnt ! @seq = Bio::Sequence.new(s.join('')) end end --- 207,211 ---- end @comment = cmnt ! @seq = Bio::Sequence::Generic.new(s.join('')) end end From k at pub.open-bio.org Thu Feb 9 16:21:49 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 16:21:49 +0000 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.63,1.64 Message-ID: <200602091621.k19GLnVL017624@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv17620 Modified Files: bio.rb Log Message: * license changed, prepared for 0.8.0 Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** bio.rb 6 Feb 2006 14:07:11 -0000 1.63 --- bio.rb 9 Feb 2006 16:21:47 -0000 1.64 *************** *** 4,33 **** # Copyright:: Copyright (C) 2001-2006 # Toshiaki Katayama ! # License:: LGPL # # $Id$ # - #-- - # - # 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 - # - #++ - # module Bio ! BIORUBY_VERSION = [0, 7, 2].extend(Comparable) ### Basic data types --- 4,15 ---- # Copyright:: Copyright (C) 2001-2006 # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # module Bio ! BIORUBY_VERSION = [0, 8, 0].extend(Comparable) ### Basic data types From k at pub.open-bio.org Thu Feb 9 16:29:12 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 16:29:12 +0000 Subject: [BioRuby-cvs] bioruby/bin bioruby,1.10,1.11 Message-ID: <200602091629.k19GTCVL017653@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv17647 Modified Files: bioruby Log Message: * license changed * if argument is given, 1. arg == dir : chdir to the specified working directory at start up or 2. arg == file : run the fille as a bioruby shell script or 3. arg == str : create the new directory to work on Index: bioruby =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/bioruby,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** bioruby 7 Dec 2005 05:12:06 -0000 1.10 --- bioruby 9 Feb 2006 16:29:10 -0000 1.11 *************** *** 3,32 **** # = BioRuby shell - command line interface for the BioRuby library # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ # - #-- - # - # 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 - # - #++ - # - - # $: << File.dirname(__FILE__)+'/../lib' begin --- 3,12 ---- # = BioRuby shell - command line interface for the BioRuby library # ! # Copyright:: Copyright (C) 2005, 2006 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # begin *************** *** 39,42 **** --- 19,40 ---- include Bio::Shell + + ### Command line argument + + # working directory or script file + arg = ARGV.shift + if File.directory?(arg) + # directory or symlink to directory + Dir.chdir(arg) + elsif File.exists?(arg) + # BioRuby shell script (lib/bioruby.rb can be obsolete) + load arg + exit + elsif arg + Dir.mkdir(arg) + Dir.chdir(arg) + end + + ### BioRuby shell setup # loading configuration and plugins From k at pub.open-bio.org Thu Feb 9 16:20:59 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 16:20:59 +0000 Subject: [BioRuby-cvs] bioruby/lib bioruby.rb,1.1,NONE Message-ID: <200602091620.k19GKxVL017598@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv17594 Removed Files: bioruby.rb Log Message: * This functionality will be moved to bioruby shell --- bioruby.rb DELETED --- From k at pub.open-bio.org Thu Feb 9 16:29:43 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 16:29:43 +0000 Subject: [BioRuby-cvs] bioruby/bin br_biofetch.rb, 1.2, 1.3 br_bioflat.rb, 1.14, 1.15 br_biogetseq.rb, 1.2, 1.3 br_pmfetch.rb, 1.5, 1.6 Message-ID: <200602091629.k19GThVL017680@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv17676 Modified Files: br_biofetch.rb br_bioflat.rb br_biogetseq.rb br_pmfetch.rb Log Message: * license is changed to Ruby's Index: br_pmfetch.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/br_pmfetch.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** br_pmfetch.rb 11 Jul 2005 09:31:32 -0000 1.5 --- br_pmfetch.rb 9 Feb 2006 16:29:41 -0000 1.6 *************** *** 1,21 **** #!/usr/bin/env ruby # ! # pmfetch - PubMed client ! # ! # Copyright (C) 2004, 2005 Toshiaki Katayama ! # ! # This program is free software; you can redistribute it and/or modify ! # it under the terms of the GNU General Public License as published by ! # the Free Software Foundation; either version 2 of the License, or ! # (at your option) any later version. # ! # This program 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 General Public License for more details. # ! # You should have received a copy of the GNU General Public License ! # along with this program; if not, write to the Free Software ! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # --- 1,11 ---- #!/usr/bin/env ruby # ! # = pmfetch - PubMed client # ! # Copyright:: Copyright (C) 2004, 2005 ! # Toshiaki Katayama ! # License:: Ruby's # ! # $Id$ # Index: br_biogetseq.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/br_biogetseq.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** br_biogetseq.rb 21 Feb 2003 02:44:22 -0000 1.2 --- br_biogetseq.rb 9 Feb 2006 16:29:41 -0000 1.3 *************** *** 1,23 **** #!/usr/bin/env ruby # ! # biogetseq - OBDA sequence data retrieval (executable) ! # ! # Copyright (C) 2003 KATAYAMA Toshiaki ! # ! # This program is free software; you can redistribute it and/or modify ! # it under the terms of the GNU General Public License as published by ! # the Free Software Foundation; either version 2 of the License, or ! # (at your option) any later version. ! # ! # This program 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 General Public License for more details. ! # ! # You should have received a copy of the GNU General Public License ! # along with this program; if not, write to the Free Software ! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! # $Id$ # --- 1,11 ---- #!/usr/bin/env ruby # ! # = biogetseq - OBDA sequence data retrieval (executable) # ! # Copyright:: Copyright (C) 2003 ! # Toshiaki Katayama ! # License:: Ruby's ! # ! # $Id$ # Index: br_biofetch.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/br_biofetch.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** br_biofetch.rb 3 Dec 2002 18:54:43 -0000 1.2 --- br_biofetch.rb 9 Feb 2006 16:29:41 -0000 1.3 *************** *** 1,23 **** #!/usr/bin/env ruby # ! # biofetch - BioFetch client ! # ! # Copyright (C) 2002 KATAYAMA Toshiaki ! # ! # This program is free software; you can redistribute it and/or modify ! # it under the terms of the GNU General Public License as published by ! # the Free Software Foundation; either version 2 of the License, or ! # (at your option) any later version. ! # ! # This program 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 General Public License for more details. # ! # You should have received a copy of the GNU General Public License ! # along with this program; if not, write to the Free Software ! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! # $Id$ # --- 1,11 ---- #!/usr/bin/env ruby # ! # = biofetch - BioFetch client # ! # Copyright:: Copyright (C) 2002 ! # Toshiaki Katayama ! # License:: Ruby's # ! # $Id$ # Index: br_bioflat.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/br_bioflat.rb,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** br_bioflat.rb 27 Aug 2003 17:28:30 -0000 1.14 --- br_bioflat.rb 9 Feb 2006 16:29:41 -0000 1.15 *************** *** 1,23 **** #!/usr/bin/env ruby # ! # bioflat - OBDA flat file indexer (executable) ! # ! # Copyright (C) 2002 GOTO Naohisa ! # ! # This program is free software; you can redistribute it and/or modify ! # it under the terms of the GNU General Public License as published by ! # the Free Software Foundation; either version 2 of the License, or ! # (at your option) any later version. ! # ! # This program 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 General Public License for more details. ! # ! # You should have received a copy of the GNU General Public License ! # along with this program; if not, write to the Free Software ! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! # $Id$ # --- 1,11 ---- #!/usr/bin/env ruby # ! # = bioflat - OBDA flat file indexer (executable) # ! # Copyright:: Copyright (C) 2002 ! # Naohisa Goto ! # License:: Ruby's ! # ! # $Id$ # From k at pub.open-bio.org Thu Feb 9 20:17:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 20:17:06 +0000 Subject: [BioRuby-cvs] bioruby/bin bioruby,1.11,1.12 Message-ID: <200602092017.k19KH6VL018828@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv18814/bin Modified Files: bioruby Log Message: * fixed to run without argument. if argument is not given, current directory will be used to save session Index: bioruby =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/bioruby,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** bioruby 9 Feb 2006 16:29:10 -0000 1.11 --- bioruby 9 Feb 2006 20:17:03 -0000 1.12 *************** *** 23,37 **** # working directory or script file ! arg = ARGV.shift ! if File.directory?(arg) ! # directory or symlink to directory ! Dir.chdir(arg) ! elsif File.exists?(arg) ! # BioRuby shell script (lib/bioruby.rb can be obsolete) ! load arg ! exit ! elsif arg ! Dir.mkdir(arg) ! Dir.chdir(arg) end --- 23,38 ---- # working directory or script file ! if arg = ARGV.shift ! if File.directory?(arg) ! # directory or symlink to directory ! Dir.chdir(arg) ! elsif File.exists?(arg) ! # BioRuby shell script (lib/bioruby.rb can be obsolete) ! load arg ! exit ! elsif arg ! Dir.mkdir(arg) ! Dir.chdir(arg) ! end end From k at pub.open-bio.org Thu Feb 9 20:26:10 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 20:26:10 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.16,1.17 Message-ID: <200602092026.k19KQAVL018915@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv18893/lib/bio/shell Modified Files: core.rb Log Message: * /etc/bioinformatics/bioruby and ~/.bioinformatics/bioruby directories are not used anymore. * changed to save session files (history, config, object) in the 'session' directory in the current directory (or in the directory specified in command line argument) instead of in the './.bioruby' directory. * 'session', 'plugin', and 'data' directories are created by default when user save the session (no directory is created when the session is not saved) Index: core.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** core.rb 7 Dec 2005 10:54:23 -0000 1.16 --- core.rb 9 Feb 2006 20:26:08 -0000 1.17 *************** *** 2,32 **** # = bio/shell/core.rb - internal methods for the BioRuby shell # ! # Copyright:: Copyright (C) 2005 # Toshiaki Katayama ! # License:: LGPL # # $Id$ # ! #-- ! # ! # 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 ! # ! #++ ! # module Bio::Shell::Ghost CONFIG = "config" OBJECT = "object" --- 2,16 ---- # = bio/shell/core.rb - internal methods for the BioRuby shell # ! # Copyright:: Copyright (C) 2005, 2006 # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # ! module Bio::Shell::Ghost + SAVEDIR = "session/" CONFIG = "config" OBJECT = "object" *************** *** 34,43 **** 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 ] --- 18,24 ---- SCRIPT = "script.rb" PLUGIN = "plugin/" + DATADIR = "data/" BIOFLAT = "bioflat/" MARSHAL = [ Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION ] *************** *** 136,169 **** def create_save_dir ! dir = ask_save_dir ! create_real_dir(dir) ! create_real_dir(dir + PLUGIN) ! create_real_dir(dir + BIOFLAT) ! return dir end ! # 1. ask to save in SAVEDIR directory in the current directory ! # 2. otherwise save in USERDIR directory ! # 3. remember the choice in @cache[:savedir] once per session ! def ask_save_dir ! if @cache[:savedir] ! dir = @cache[:savedir] ! else ! dir = SAVEDIR ! if ! File.directory?(dir) ! loop do ! print "Save in \"#{dir}\" directory? [y/n]: " ! answer = gets ! if /^\s*[Yy]/.match(answer) ! break ! elsif /^\s*[Nn]/.match(answer) ! dir = USERDIR ! break ! end ! end end - @cache[:savedir] = dir end - return dir end --- 117,149 ---- def create_save_dir ! if @cache[:save].nil? ! if ask_yes_or_no("Save session in '#{SAVEDIR}' directory? [y/n]: ") ! create_real_dir(SAVEDIR) ! create_real_dir(DATADIR) ! create_real_dir(PLUGIN) ! # create_real_dir(BIOFLAT) ! @cache[:save] = true ! else ! @cache[:save] = false ! end ! end ! return @cache[:save] end ! def ask_yes_or_no(message) ! loop do ! print message ! answer = gets ! if answer.nil? ! # readline support might be broken ! return false ! elsif /^\s*[Nn]/.match(answer) ! return false ! elsif /^\s*[Yy]/.match(answer) ! return true ! else ! # loop end end end *************** *** 175,179 **** puts "done" rescue ! warn "Error: Failed to create #{dir} : #{$!}" end end --- 155,159 ---- puts "done" rescue ! warn "Error: Failed to create directory (#{dir}) : #{$!}" end end *************** *** 183,196 **** def create_flat_dir(dbname) ! if prefix = create_save_dir ! return prefix + BIOFLAT + dbname.to_s.strip ! else ! return nil end end def find_flat_dir(dbname) ! dir = SAVEDIR + BIOFLAT + dbname.to_s.strip ! dir = USERDIR + BIOFLAT + dbname.to_s.strip unless File.exists?(dir) if File.exists?(dir) return dir --- 163,178 ---- def create_flat_dir(dbname) ! dir = BIOFLAT + dbname.to_s.strip ! unless File.directory?(BIOFLAT) ! Dir.mkdir(BIOFLAT) end + unless File.directory?(dir) + Dir.mkdir(dir) + end + return dir end def find_flat_dir(dbname) ! dir = BIOFLAT + dbname.to_s.strip if File.exists?(dir) return dir *************** *** 203,208 **** def load_config - load_config_file(SITEDIR + CONFIG) - load_config_file(USERDIR + CONFIG) load_config_file(SAVEDIR + CONFIG) end --- 185,188 ---- *************** *** 219,224 **** def save_config ! dir = create_save_dir ! save_config_file(dir + CONFIG) end --- 199,205 ---- def save_config ! if create_save_dir ! save_config_file(SAVEDIR + CONFIG) ! end end *************** *** 274,279 **** def load_plugin - load_plugin_dir(SITEDIR + PLUGIN) - load_plugin_dir(USERDIR + PLUGIN) load_plugin_dir(SAVEDIR + PLUGIN) end --- 255,258 ---- *************** *** 292,297 **** def load_object - load_object_file(SITEDIR + OBJECT) - load_object_file(USERDIR + OBJECT) load_object_file(SAVEDIR + OBJECT) end --- 271,274 ---- *************** *** 319,324 **** def save_object ! dir = create_save_dir ! save_object_file(dir + OBJECT) end --- 296,302 ---- def save_object ! if create_save_dir ! save_object_file(SAVEDIR + OBJECT) ! end end *************** *** 359,364 **** def load_history if @cache[:readline] - load_history_file(SITEDIR + HISTORY) - load_history_file(USERDIR + HISTORY) load_history_file(SAVEDIR + HISTORY) end --- 337,340 ---- *************** *** 377,382 **** def save_history if @cache[:readline] ! dir = create_save_dir ! save_history_file(dir + HISTORY) end end --- 353,359 ---- def save_history if @cache[:readline] ! if create_save_dir ! save_history_file(SAVEDIR + HISTORY) ! end end end *************** *** 429,434 **** def save_script if @script_begin and @script_end and @script_begin <= @script_end ! dir = create_save_dir ! save_script_file(dir + SCRIPT) else puts "Error: script range #{@script_begin}..#{@script_end} is invalid" --- 406,412 ---- def save_script if @script_begin and @script_end and @script_begin <= @script_end ! if create_save_dir ! save_script_file(SAVEDIR + SCRIPT) ! end else puts "Error: script range #{@script_begin}..#{@script_end} is invalid" From k at pub.open-bio.org Thu Feb 9 20:48:55 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 20:48:55 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb, 1.17, 1.18 session.rb, 1.11, 1.12 Message-ID: <200602092048.k19KmtVL019068@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv19056/shell Modified Files: core.rb session.rb Log Message: * license is changed to Ruby's Index: session.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/session.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** session.rb 7 Dec 2005 07:50:44 -0000 1.11 --- session.rb 9 Feb 2006 20:48:53 -0000 1.12 *************** *** 2,28 **** # = bio/shell/session.rb - core user interface of the BioRuby shell # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,10 ---- # = bio/shell/session.rb - core user interface of the BioRuby shell # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # Index: core.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** core.rb 9 Feb 2006 20:26:08 -0000 1.17 --- core.rb 9 Feb 2006 20:48:53 -0000 1.18 *************** *** 2,8 **** # = bio/shell/core.rb - internal methods for the BioRuby shell # ! # Copyright:: Copyright (C) 2005, 2006 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ --- 2,8 ---- # = bio/shell/core.rb - internal methods for the BioRuby shell # ! # Copyright:: Copyright (C) 2005, 2006 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ From k at pub.open-bio.org Thu Feb 9 20:48:55 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 20:48:55 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin codon.rb, 1.12, 1.13 emboss.rb, 1.1, 1.2 entry.rb, 1.5, 1.6 flatfile.rb, 1.11, 1.12 keggapi.rb, 1.9, 1.10 midi.rb, 1.6, 1.7 obda.rb, 1.8, 1.9 seq.rb, 1.16, 1.17 Message-ID: <200602092048.k19KmtVL019073@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv19056/shell/plugin Modified Files: codon.rb emboss.rb entry.rb flatfile.rb keggapi.rb midi.rb obda.rb seq.rb Log Message: * license is changed to Ruby's Index: midi.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/midi.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** midi.rb 28 Nov 2005 12:06:18 -0000 1.6 --- midi.rb 9 Feb 2006 20:48:53 -0000 1.7 *************** *** 2,29 **** # = bio/shell/plugin/midi.rb - Sequence to MIDI converter # ! # Copyright:: Copyright (C) 2003, 2005 ! # Natsuhiro Ichinose , ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,11 ---- # = bio/shell/plugin/midi.rb - Sequence to MIDI converter # ! # Copyright:: Copyright (C) 2003, 2005 ! # Natsuhiro Ichinose , ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # Index: emboss.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/emboss.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** emboss.rb 28 Jan 2006 07:22:14 -0000 1.1 --- emboss.rb 9 Feb 2006 20:48:53 -0000 1.2 *************** *** 2,28 **** # = bio/shell/plugin/emboss.rb - methods to use EMBOSS # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,10 ---- # = bio/shell/plugin/emboss.rb - methods to use EMBOSS # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # Index: obda.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/obda.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** obda.rb 30 Nov 2005 02:01:04 -0000 1.8 --- obda.rb 9 Feb 2006 20:48:53 -0000 1.9 *************** *** 2,28 **** # = bio/shell/plugin/obda.rb - plugin for OBDA # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,10 ---- # = bio/shell/plugin/obda.rb - plugin for OBDA # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License: Ruby's # # $Id$ # Index: flatfile.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/flatfile.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** flatfile.rb 30 Nov 2005 01:57:18 -0000 1.11 --- flatfile.rb 9 Feb 2006 20:48:53 -0000 1.12 *************** *** 2,29 **** # = bio/shell/plugin/flatfile.rb - plugin for flatfile database # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ # - #-- - # - # 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 - # - #++ - # module Bio::Shell --- 2,11 ---- # = bio/shell/plugin/flatfile.rb - plugin for flatfile database # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License: Ruby's # # $Id$ # module Bio::Shell *************** *** 87,92 **** def flatindex(dbname, *flatfiles) - dir = Bio::Shell.create_flat_dir(dbname) begin print "Creating BioFlat index (#{dir}) ... " bdb = format = options = nil --- 69,74 ---- def flatindex(dbname, *flatfiles) begin + dir = Bio::Shell.create_flat_dir(dbname) print "Creating BioFlat index (#{dir}) ... " bdb = format = options = nil Index: keggapi.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/keggapi.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** keggapi.rb 6 Feb 2006 06:17:53 -0000 1.9 --- keggapi.rb 9 Feb 2006 20:48:53 -0000 1.10 *************** *** 2,28 **** # = bio/shell/plugin/keggapi.rb - plugin for KEGG API # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,10 ---- # = bio/shell/plugin/keggapi.rb - plugin for KEGG API # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # Index: seq.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/seq.rb,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** seq.rb 19 Dec 2005 01:20:06 -0000 1.16 --- seq.rb 9 Feb 2006 20:48:53 -0000 1.17 *************** *** 2,29 **** # = bio/shell/plugin/seq.rb - plugin for biological sequence manipulations # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ # - #-- - # - # 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 - # - #++ - # module Bio::Shell --- 2,11 ---- # = bio/shell/plugin/seq.rb - plugin for biological sequence manipulations # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # module Bio::Shell *************** *** 211,215 **** pos = self[n, size].rindex(separater) ! if self[n, size].length < size # last line of the folded str pos = nil end --- 193,197 ---- pos = self[n, size].rindex(separater) ! if self[n, size].length < size # last line of the folded str pos = nil end *************** *** 218,222 **** ary << self[n, pos+separater.length] n += pos + separater.length ! else # line too long or the last line ary << self[n, size] n += size --- 200,204 ---- ary << self[n, pos+separater.length] n += pos + separater.length ! else # line too long or the last line ary << self[n, size] n += size Index: codon.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/codon.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** codon.rb 19 Dec 2005 02:34:24 -0000 1.12 --- codon.rb 9 Feb 2006 20:48:53 -0000 1.13 *************** *** 2,28 **** # = bio/shell/plugin/codon.rb - plugin for the codon table # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,10 ---- # = bio/shell/plugin/codon.rb - plugin for the codon table # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # Index: entry.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/entry.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** entry.rb 28 Jan 2006 06:46:43 -0000 1.5 --- entry.rb 9 Feb 2006 20:48:53 -0000 1.6 *************** *** 2,28 **** # = bio/shell/plugin/entry.rb - extract entry and sequence # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,10 ---- # = bio/shell/plugin/entry.rb - extract entry and sequence # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # From k at pub.open-bio.org Thu Feb 9 20:48:55 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 09 Feb 2006 20:48:55 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio shell.rb,1.12,1.13 Message-ID: <200602092048.k19KmtVL019064@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv19056 Modified Files: shell.rb Log Message: * license is changed to Ruby's Index: shell.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** shell.rb 28 Jan 2006 06:46:42 -0000 1.12 --- shell.rb 9 Feb 2006 20:48:52 -0000 1.13 *************** *** 2,28 **** # = bio/shell.rb - Loading all BioRuby shell features # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License:: LGPL # # $Id$ - # - #-- - # - # 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 - # - #++ # --- 2,10 ---- # = bio/shell.rb - Loading all BioRuby shell features # ! # Copyright:: Copyright (C) 2005 ! # Toshiaki Katayama ! # License: Ruby's # # $Id$ # From nakao at pub.open-bio.org Mon Feb 13 15:49:02 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Mon, 13 Feb 2006 15:49:02 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl/bl2seq - New directory Message-ID: <200602131549.k1DFn2VL013843@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl/bl2seq In directory pub.open-bio.org:/tmp/cvs-serv13833/test/unit/bio/appl/bl2seq Log Message: Directory /home/repository/bioruby/bioruby/test/unit/bio/appl/bl2seq added to the repository From nakao at pub.open-bio.org Mon Feb 13 15:49:28 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Mon, 13 Feb 2006 15:49:28 +0000 Subject: [BioRuby-cvs] bioruby/test/data/bl2seq - New directory Message-ID: <200602131549.k1DFnSVL013870@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/bl2seq In directory pub.open-bio.org:/tmp/cvs-serv13860/test/data/bl2seq Log Message: Directory /home/repository/bioruby/bioruby/test/data/bl2seq added to the repository From nakao at pub.open-bio.org Mon Feb 13 15:51:13 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Mon, 13 Feb 2006 15:51:13 +0000 Subject: [BioRuby-cvs] bioruby/test/data/bl2seq cd8a_cd8b_blastp.bl2seq, NONE, 1.1 cd8a_p53_e-5blastp.bl2seq, NONE, 1.1 Message-ID: <200602131551.k1DFpDVL013915@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/bl2seq In directory pub.open-bio.org:/tmp/cvs-serv13903/test/data/bl2seq Added Files: cd8a_cd8b_blastp.bl2seq cd8a_p53_e-5blastp.bl2seq Log Message: * Newly added. --- NEW FILE: cd8a_p53_e-5blastp.bl2seq --- Query= CD8A_HUMAN P01732 T-cell surface glycoprotein CD8 alpha chain precursor (T-lymphocyte differentiation antigen T8/Leu-2). (235 letters) Lambda K H 0.323 0.137 0.436 Gapped Lambda K H 0.267 0.0410 0.140 Matrix: BLOSUM62 Gap Penalties: Existence: 11, Extension: 1 Number of Hits to DB: 175 Number of Sequences: 0 Number of extensions: 8 Number of successful extensions: 0 Number of sequences better than 1.0e-05: 0 Number of HSP's better than 0.0 without gapping: 0 Number of HSP's successfully gapped in prelim test: 0 Number of HSP's that attempted gapping in prelim test: 0 Number of HSP's gapped (non-prelim): 0 length of query: 235 length of database: 393 effective HSP length: 27 effective length of query: 208 effective length of database: 366 effective search space: 76128 effective search space used: 76128 T: 11 A: 40 X1: 16 ( 7.5 bits) X2: 38 (14.6 bits) X3: 64 (24.7 bits) S1: 41 (22.0 bits) S2: 74 (33.1 bits) --- NEW FILE: cd8a_cd8b_blastp.bl2seq --- Query= CD8A_HUMAN P01732 T-cell surface glycoprotein CD8 alpha chain precursor (T-lymphocyte differentiation antigen T8/Leu-2). (235 letters) >CD8B_HUMAN P10966 T-cell surface glycoprotein CD8 beta chain precursor (Antigen CD8B). Length = 210 Score = 29.6 bits (65), Expect = 5e-05 Identities = 21/90 (23%), Positives = 37/90 (41%), Gaps = 3/90 (3%) Query: 39 VELKCQVLLSNPTSGCSWLFQ---PRGAAASPTFLLYLSQNKPKAAEGLDTQRFSGKRLG 95 V L C+ +S WL Q P + L+ S E ++ ++ + R Sbjct: 37 VMLSCEAKISLSNMRIYWLRQRQAPSSDSHHEFLALWDSAKGTIHGEEVEQEKIAVFRDA 96 Query: 96 DTFVLTLSDFRRENEGYYFCSALSNSIMYF 125 F+L L+ + E+ G YFC + + + F Sbjct: 97 SRFILNLTSVKPEDSGIYFCMIVGSPELTF 126 Lambda K H 0.323 0.137 0.436 Gapped Lambda K H 0.267 0.0410 0.140 Matrix: BLOSUM62 Gap Penalties: Existence: 11, Extension: 1 Number of Hits to DB: 102 Number of Sequences: 0 Number of extensions: 5 Number of successful extensions: 3 Number of sequences better than 10.0: 1 Number of HSP's better than 10.0 without gapping: 1 Number of HSP's successfully gapped in prelim test: 0 Number of HSP's that attempted gapping in prelim test: 0 Number of HSP's gapped (non-prelim): 1 length of query: 235 length of database: 210 effective HSP length: 22 effective length of query: 213 effective length of database: 188 effective search space: 40044 effective search space used: 40044 T: 11 A: 40 X1: 16 ( 7.5 bits) X2: 38 (14.6 bits) X3: 64 (24.7 bits) S1: 20 (12.2 bits) S2: 20 (12.3 bits) From nakao at pub.open-bio.org Mon Feb 13 15:51:13 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Mon, 13 Feb 2006 15:51:13 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl/bl2seq test_report.rb, NONE, 1.1 Message-ID: <200602131551.k1DFpDVL013918@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl/bl2seq In directory pub.open-bio.org:/tmp/cvs-serv13903/test/unit/bio/appl/bl2seq Added Files: test_report.rb Log Message: * Newly added. --- NEW FILE: test_report.rb --- # # test/unit/bio/appl/bl2seq/test_report.rb - Unit test for # Bio::Blast::Bl2seq::Report # # Copyright:: Copyright (C) 2006 # Mitsuteru C. Nakao # License:: Ruby's # # $Id: test_report.rb,v 1.1 2006/02/13 15:51:11 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib'))).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/appl/bl2seq/report' module Bio class TestBl2seqReportData bioruby_root = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5)).cleanpath.to_s TestDataBl2seq = Pathname.new(File.join(bioruby_root, 'test', 'data', 'bl2seq')).cleanpath.to_s def self.output(format = 7) case format when 'empty' File.open(File.join(TestDataBl2seq, 'cd8a_p53_e-5blastp.bl2seq')).read when 'blastp' File.open(File.join(TestDataBl2seq, 'cd8a_cd8b_blastp.bl2seq')).read when 'blastn' when 'blastx' when 'tblastn' when 'tblastx' end end end class TestBl2seqReportConstants < Test::Unit::TestCase def test_rs rs = nil assert_equal(nil, Bio::Blast::Bl2seq::Report::RS) assert_equal(nil, Bio::Blast::Bl2seq::Report::DELIMITER) end end class TestBl2seqReport < Test::Unit::TestCase def setup @empty = Bio::Blast::Bl2seq::Report.new(Bio::TestBl2seqReportData.output('empty')) @blastp = Bio::Blast::Bl2seq::Report.new(Bio::TestBl2seqReportData.output('blastp')) end def test_new assert(@empty) assert(@blastp) end def test_undefed_methods methods = ['format0_parse_header', 'program', 'version', 'version_number', 'version_date', 'message', 'converged?', 'reference', 'db'] methods.each do |x| assert_nil(@empty.methods.include?(x)) end methods.each do |x| assert_nil(@blastp.methods.include?(x)) end end # TestF0dbstat < Test::Unit::TestCase def test_db_num assert_equal(0, @empty.db_num) assert_equal(0, @blastp.db_num) end def test_db_len assert_equal(393, @empty.db_len) assert_equal(210, @blastp.db_len) end # TestIteration < Test::Unit::TestCase def test_undefed_methods methods = ['message', 'pattern_in_database', 'pattern', 'pattern_positions', 'hits_found_again', 'hits_newly_found', 'hits_for_pattern', 'parse_hitlist', 'converged?'] methods.each do |x| assert_equal(false, @empty.iterations.first.methods.include?(x), "undifined? : #{x}") end methods.each do |x| assert_equal(false, @blastp.iterations.first.methods.include?(x), "undefined? : #{x}") end end end class TestBlastReportHit < Test::Unit::TestCase def setup @empty = Bio::Blast::Bl2seq::Report.new(Bio::TestBl2seqReportData.output('empty')) @blastp = Bio::Blast::Bl2seq::Report.new(Bio::TestBl2seqReportData.output('blastp')) @empty_hit = @empty.hits.first @blastp_hit = @blastp.hits.first end def test_hits assert_equal(0, @empty.hits.size) assert_equal(Bio::Blast::Bl2seq::Report::Hit, @blastp.hits.first.class) assert_equal(1, @blastp.hits.size) end end end # module Bio From k at pub.open-bio.org Tue Feb 14 13:12:08 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Tue, 14 Feb 2006 13:12:08 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio sequence.rb,0.53,0.54 Message-ID: <200602141312.k1EDC8VL017416@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv17407/lib/bio Modified Files: sequence.rb Log Message: * previous change made on initialize is moved to guess method itself to avoid dup in initialize to make things simple. * guess method is extended to accept 'length' and 'index' arguments to specify what portion of the string should be used to guess the amino or nucleic acid-ness of the sequence. Index: sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence.rb,v retrieving revision 0.53 retrieving revision 0.54 diff -C2 -d -r0.53 -r0.54 *** sequence.rb 8 Feb 2006 17:22:22 -0000 0.53 --- sequence.rb 14 Feb 2006 13:12:06 -0000 0.54 *************** *** 24,29 **** def initialize(str) ! @seq = str.dup ! @seq.extend Bio::Sequence::Common end --- 24,28 ---- def initialize(str) ! @seq = str end *************** *** 59,64 **** end ! def guess(threshold = 0.9) ! cmp = @seq.composition bases = cmp['A'] + cmp['T'] + cmp['G'] + cmp['C'] + --- 58,64 ---- end ! def guess(threshold = 0.9, length = 10000, index = 0) ! str = @seq.to_s[index,length].to_s.extend Bio::Sequence::Common ! cmp = str.composition bases = cmp['A'] + cmp['T'] + cmp['G'] + cmp['C'] + From k at pub.open-bio.org Tue Feb 14 13:18:37 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Tue, 14 Feb 2006 13:18:37 +0000 Subject: [BioRuby-cvs] bioruby/bin bioruby,1.12,1.13 Message-ID: <200602141318.k1EDIbVL017468@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv17451/bin Modified Files: bioruby Log Message: * Bio::Shell::Ghost#load/save methods are renamed to load_session/save_session respectively to avoid method name collision with Kernel#load Index: bioruby =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/bioruby,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** bioruby 9 Feb 2006 20:17:03 -0000 1.12 --- bioruby 14 Feb 2006 13:18:35 -0000 1.13 *************** *** 92,96 **** # loading workspace and command history ! Bio::Shell.load Signal.trap("SIGINT") do --- 92,96 ---- # loading workspace and command history ! Bio::Shell.load_session Signal.trap("SIGINT") do *************** *** 103,106 **** # saving workspace, command history and configuration before exit ! Bio::Shell.save --- 103,106 ---- # saving workspace, command history and configuration before exit ! Bio::Shell.save_session From k at pub.open-bio.org Tue Feb 14 13:18:37 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Tue, 14 Feb 2006 13:18:37 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.18,1.19 Message-ID: <200602141318.k1EDIbVL017472@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv17451/lib/bio/shell Modified Files: core.rb Log Message: * Bio::Shell::Ghost#load/save methods are renamed to load_session/save_session respectively to avoid method name collision with Kernel#load Index: core.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** core.rb 9 Feb 2006 20:48:53 -0000 1.18 --- core.rb 14 Feb 2006 13:18:35 -0000 1.19 *************** *** 58,62 **** attr_accessor :cache ! def load load_object load_history --- 58,62 ---- attr_accessor :cache ! def load_session load_object load_history *************** *** 64,68 **** end ! def save closing_splash save_history --- 64,68 ---- end ! def save_session closing_splash save_history From ngoto at pub.open-bio.org Tue Feb 14 13:42:42 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Tue, 14 Feb 2006 13:42:42 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db fasta.rb,1.23,1.24 Message-ID: <200602141342.k1EDggVL017584@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv17574/lib/bio/db Modified Files: fasta.rb Log Message: added to_seq method which returns a Bio::Sequence object Index: fasta.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/fasta.rb,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** fasta.rb 9 Feb 2006 03:28:48 -0000 1.23 --- fasta.rb 14 Feb 2006 13:42:40 -0000 1.24 *************** *** 244,247 **** --- 244,261 ---- end + # Returns sequence as a Bio::Sequence object. + # + # Note: If you modify the returned Bio::Sequence object, + # the sequence or definition in this FastaFormat object + # might also be changed (but not always be changed) + # because of efficiency. + # + def to_seq + seq + obj = Bio::Sequence.new(@seq) + obj.definition = self.definition + obj + end + # Parsing FASTA Defline, and extract IDs. # IDs are NSIDs (NCBI standard FASTA sequence identifiers) From k at pub.open-bio.org Tue Feb 14 13:46:45 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Tue, 14 Feb 2006 13:46:45 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin entry.rb,1.6,1.7 Message-ID: <200602141346.k1EDkjVL017671@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv17649/lib/bio/shell/plugin Modified Files: entry.rb Log Message: * Bio::Sequence.auto(str) is changed to return Bio::Sequence object instead of NA or AA object * Bio::Sequence#auto is added to replace the value of @seq with guessed type of Bio::Sequence::?A object Index: entry.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/entry.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** entry.rb 9 Feb 2006 20:48:53 -0000 1.6 --- entry.rb 14 Feb 2006 13:46:43 -0000 1.7 *************** *** 41,45 **** if tmp and tmp.is_a?(String) and not tmp.empty? ! seq = Bio::Sequence.auto(tmp) end return seq --- 41,45 ---- if tmp and tmp.is_a?(String) and not tmp.empty? ! seq = Bio::Sequence.auto(tmp).seq end return seq From k at pub.open-bio.org Tue Feb 14 13:46:45 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Tue, 14 Feb 2006 13:46:45 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio sequence.rb,0.54,0.55 Message-ID: <200602141346.k1EDkjVL017667@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv17649/lib/bio Modified Files: sequence.rb Log Message: * Bio::Sequence.auto(str) is changed to return Bio::Sequence object instead of NA or AA object * Bio::Sequence#auto is added to replace the value of @seq with guessed type of Bio::Sequence::?A object Index: sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence.rb,v retrieving revision 0.54 retrieving revision 0.55 diff -C2 -d -r0.54 -r0.55 *** sequence.rb 14 Feb 2006 13:12:06 -0000 0.54 --- sequence.rb 14 Feb 2006 13:46:42 -0000 0.55 *************** *** 48,59 **** end ! def self.auto(str) ! @moltype = self.guess(str) if @moltype == NA ! @seq = NA.new(str) else ! @seq = AA.new(str) end ! return @seq end --- 48,64 ---- end ! def auto ! @moltype = guess if @moltype == NA ! @seq = NA.new(@seq) else ! @seq = AA.new(@seq) end ! end ! ! def self.auto(str) ! seq = self.new(str) ! seq.auto ! return seq end From pjotr at pub.open-bio.org Fri Feb 17 14:59:29 2006 From: pjotr at pub.open-bio.org (Pjotr Prins) Date: Fri, 17 Feb 2006 14:59:29 +0000 Subject: [BioRuby-cvs] bioruby/doc Tutorial.rd,1.11,1.12 Message-ID: <200602171459.k1HExTVL030206@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/doc In directory pub.open-bio.org:/tmp/cvs-serv30194/doc Modified Files: Tutorial.rd Log Message: Fixed tutorial on updated sequence handling (throw exception instead of return nil value) Added a FASTA output example that allows for regex filtering like any2fasta.rb "/GAT[CT]/i" *.seq > reduced.fasta Index: Tutorial.rd =================================================================== RCS file: /home/repository/bioruby/bioruby/doc/Tutorial.rd,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Tutorial.rd 31 Jan 2006 07:45:22 -0000 1.11 --- Tutorial.rd 17 Feb 2006 14:59:26 -0000 1.12 *************** *** 7,11 **** Translated into English: Naohisa Goto ! Editor: PjotrPrins Copyright (C) 2001-2003 KATAYAMA Toshiaki , 2005-2006 all --- 7,11 ---- Translated into English: Naohisa Goto ! Editor: PjotrPrins

    Copyright (C) 2001-2003 KATAYAMA Toshiaki , 2005-2006 all *************** *** 128,136 **** 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".) ! ! (EDITOR'S NOTE: should 'subseq' not throw an exception instead?) The window_search(window_size, step_size) method shows a typical Ruby --- 128,134 ---- So when using String methods, you should subtract 1 from positions ! conventionally used in biology. (subseq method will throw an exception if you ! specify positions smaller than or equal to 0 for either one of the "from" or ! "to".) The window_search(window_size, step_size) method shows a typical Ruby *************** *** 402,405 **** --- 400,406 ---- p entry.seq # sequence data of the entry end + + An example that can take any input, filter using a regular expression to output + to a FASTA file can be found in sample/any2fasta.rb. Other methods to extract specific data from database objects can be From pjotr at pub.open-bio.org Fri Feb 17 14:59:29 2006 From: pjotr at pub.open-bio.org (Pjotr Prins) Date: Fri, 17 Feb 2006 14:59:29 +0000 Subject: [BioRuby-cvs] bioruby/sample any2fasta.rb,NONE,1.1 Message-ID: <200602171459.k1HExTVL030207@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/sample In directory pub.open-bio.org:/tmp/cvs-serv30194/sample Added Files: any2fasta.rb Log Message: Fixed tutorial on updated sequence handling (throw exception instead of return nil value) Added a FASTA output example that allows for regex filtering like any2fasta.rb "/GAT[CT]/i" *.seq > reduced.fasta --- NEW FILE: any2fasta.rb --- #!/usr/bin/env ruby # # any2fasta.rb - convert input file into FASTA format using a regex # filter # # Copyright (C) 2006 Pjotr Prins

    # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # $Id: any2fasta.rb,v 1.1 2006/02/17 14:59:27 pjotr Exp $ # require 'bio/io/flatfile' include Bio usage = < reduced.fasta USAGE if ARGV.size == 0 print usage exit 1 end # ---- Valid regular expression - if it is not a file regex = ARGV[0] if regex=~/^\// and !File.exist?(regex) ARGV.shift else regex = nil end ARGV.each do | fn | ff = Bio::FlatFile.auto(fn) ff.each_entry do |entry| if regex != nil next if eval("entry.seq !~ #{regex}") end print entry.seq.to_fasta(entry.definition,70) end end From k at pub.open-bio.org Fri Feb 17 17:09:19 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri, 17 Feb 2006 17:09:19 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.19,1.20 Message-ID: <200602171709.k1HH9JVL031249@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv31222/lib/bio/shell Modified Files: core.rb Log Message: * splash animation is separated from color mode * @config[:splash] is added for this purpose * mono animation mode is also added * user can use 'config :color' and 'config :splash' in combination * added accessor for DATADIR * fixed plugin dir from SAVEDIR+PLUGIN to PLUGIN * script.rb is changed to be saved in current directory instead of in SAVEDIR * script.rb is checked before overwritten * script function can be aborted with message (especially when the script content is emptry) * script.rb is changed from ruby script to bioruby script as lib/bioruby.rb is removed (changed from #!/usr/bin/env ruby; require 'bioruby' to #!/usr/bin/env bioruby) * "\n" are removed to make independent from LF/CR Index: core.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** core.rb 14 Feb 2006 13:18:35 -0000 1.19 --- core.rb 17 Feb 2006 17:09:17 -0000 1.20 *************** *** 37,40 **** --- 37,44 ---- } + def datadir + DATADIR + end + def esc_seq ESC_SEQ *************** *** 243,246 **** --- 247,256 ---- end + def config_splash + flag = ! @config[:splash] + @config[:splash] = flag + puts "Splash #{flag ? 'on' : 'off'}" + end + def config_pager(cmd = nil) @config[:pager] = cmd *************** *** 255,259 **** def load_plugin ! load_plugin_dir(SAVEDIR + PLUGIN) end --- 265,269 ---- def load_plugin ! load_plugin_dir(PLUGIN) end *************** *** 406,414 **** def save_script if @script_begin and @script_end and @script_begin <= @script_end ! if create_save_dir ! save_script_file(SAVEDIR + SCRIPT) end else ! puts "Error: script range #{@script_begin}..#{@script_end} is invalid" end end --- 416,433 ---- def save_script if @script_begin and @script_end and @script_begin <= @script_end ! if File.exists?(SCRIPT) ! message = "Overwrite script file (#{SCRIPT})? [y/n]: " ! else ! message = "Save script file (#{SCRIPT})? [y/n]: " end + if ask_yes_or_no(message) + save_script_file(SCRIPT) + else + puts " ... save aborted." + end + elsif @script_begin and @script_end and @script_begin - @script_end == 1 + puts " ... script aborted." else ! puts "Error: Script range #{@script_begin}..#{@script_end} is invalid" end end *************** *** 418,425 **** print "Saving script (#{file}) ... " File.open(file, "w") do |f| ! f.print "#!/usr/bin/env ruby\n\n" ! f.print "require 'bioruby'\n\n" f.puts Readline::HISTORY.to_a[@script_begin.. at script_end] ! f.print "\n\n" end puts "done" --- 437,444 ---- print "Saving script (#{file}) ... " File.open(file, "w") do |f| ! f.puts "#!/usr/bin/env bioruby" ! f.puts f.puts Readline::HISTORY.to_a[@script_begin.. at script_end] ! f.puts end puts "done" *************** *** 447,450 **** --- 466,486 ---- s = splash_message l = s.length + x = " " + 0.step(l,2) do |i| + l1 = l-i; l2 = l1/2; l4 = l2/2 + STDERR.print "#{s[0,i]}#{x*l1}#{s[i,1]}\r" + sleep(0.001) + STDERR.print "#{s[0,i]}#{x*l2}#{s[i,1]}#{x*(l1-l2)}\r" + sleep(0.002) + STDERR.print "#{s[0,i]}#{x*l4}#{s[i,1]}#{x*(l2-l4)}\r" + sleep(0.004) + STDERR.print "#{s[0,i+1]}#{x*l4}\r" + sleep(0.008) + end + end + + def splash_message_action_color + s = splash_message + l = s.length c = ESC_SEQ x = " " *************** *** 463,469 **** def opening_splash ! print "\n" ! if @config[:color] ! splash_message_action end if @config[:color] --- 499,509 ---- def opening_splash ! puts ! if @config[:splash] ! if @config[:color] ! splash_message_action_color ! else ! splash_message_action ! end end if @config[:color] *************** *** 472,482 **** 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 @config[:color] print splash_message_color --- 512,526 ---- print splash_message end ! puts ! puts print " Version : BioRuby #{Bio::BIORUBY_VERSION.join(".")}" ! print " / Ruby #{RUBY_VERSION}" ! puts ! puts end def closing_splash ! puts ! puts if @config[:color] print splash_message_color *************** *** 484,488 **** print splash_message end ! print "\n\n" end --- 528,533 ---- print splash_message end ! puts ! puts end From k at pub.open-bio.org Fri Feb 17 17:12:01 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri, 17 Feb 2006 17:12:01 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell interface.rb,1.12,1.13 Message-ID: <200602171712.k1HHC1VL031323@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv31314/lib/bio/shell Modified Files: interface.rb Log Message: * module name is changed from session.rb to interface.rb * config :splash is added * display method is renamed to disp as it overrides Object#display * savefile command is changed to offer saving file under the DATADIR (data/) * modified to use Bio::Shell.ask_yes_or_no function Index: interface.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/interface.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** interface.rb 9 Feb 2006 20:48:53 -0000 1.12 --- interface.rb 17 Feb 2006 17:11:59 -0000 1.13 *************** *** 1,4 **** # ! # = bio/shell/session.rb - core user interface of the BioRuby shell # # Copyright:: Copyright (C) 2005 --- 1,4 ---- # ! # = bio/shell/interface.rb - core user interface of the BioRuby shell # # Copyright:: Copyright (C) 2005 *************** *** 65,68 **** --- 65,70 ---- when :color, "color" Bio::Shell.config_color + when :splash, "splash" + Bio::Shell.config_splash when :pager, "pager" Bio::Shell.config_pager(*opts) *************** *** 86,90 **** end ! def display(*obj) # The original idea is from http://sheepman.parfait.ne.jp/20050215.html if Bio::Shell.config[:pager] --- 88,92 ---- end ! def disp(*obj) # The original idea is from http://sheepman.parfait.ne.jp/20050215.html if Bio::Shell.config[:pager] *************** *** 100,103 **** --- 102,106 ---- end else + # or use Object#display ? puts(*obj) end *************** *** 132,145 **** def savefile(file, *objs) if File.exists?(file) ! loop do ! print "Overwrite existing #{file}? [y/n]: " ! answer = gets ! return if /^\s*[Nn]/.match(answer) ! break if /^\s*[Yy]/.match(answer) end end begin ! print "Saving data (#{file}) ... " File.open(file, "w") do |f| objs.each do |obj| --- 135,152 ---- def savefile(file, *objs) + datadir = Bio::Shell.datadir + message = "Save file '#{file}' in '#{datadir}' directory? [y/n]: " + if ! file[/^#{datadir}/] and Bio::Shell.ask_yes_or_no(message) + file = datadir + file + end if File.exists?(file) ! message = "Overwrite existing '#{file}' file? [y/n]: " ! if ! Bio::Shell.ask_yes_or_no(message) ! puts " ... save aborted." ! return end end begin ! print "Saving file (#{file}) ... " File.open(file, "w") do |f| objs.each do |obj| From k at pub.open-bio.org Fri Feb 17 17:12:41 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri, 17 Feb 2006 17:12:41 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio shell.rb,1.13,1.14 Message-ID: <200602171712.k1HHCfVL031350@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv31346/lib/bio Modified Files: shell.rb Log Message: * session.rb is renamed to interface.rb Index: shell.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell.rb,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** shell.rb 9 Feb 2006 20:48:52 -0000 1.13 --- shell.rb 17 Feb 2006 17:12:39 -0000 1.14 *************** *** 17,21 **** require 'bio/shell/core' ! require 'bio/shell/session' require 'bio/shell/plugin/entry' require 'bio/shell/plugin/seq' --- 17,21 ---- require 'bio/shell/core' ! require 'bio/shell/interface' require 'bio/shell/plugin/entry' require 'bio/shell/plugin/seq' From k at pub.open-bio.org Fri Feb 17 17:15:10 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Fri, 17 Feb 2006 17:15:10 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio sequence.rb,0.55,0.56 Message-ID: <200602171715.k1HHFAVL031442@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv31436/lib/bio Modified Files: sequence.rb Log Message: * Bio::Sequence#na and aa methods are added which force to convert @seq object to Bio::Sequence::NA and AA object respectively Index: sequence.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence.rb,v retrieving revision 0.55 retrieving revision 0.56 diff -C2 -d -r0.55 -r0.56 *** sequence.rb 14 Feb 2006 13:46:42 -0000 0.55 --- sequence.rb 17 Feb 2006 17:15:08 -0000 0.56 *************** *** 83,86 **** --- 83,96 ---- end + def na + @seq = NA.new(@seq) + @moltype = NA + end + + def aa + @seq = AA.new(@seq) + @moltype = AA + end + end # Sequence From nakao at pub.open-bio.org Sat Feb 18 14:24:47 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 18 Feb 2006 14:24:47 +0000 Subject: [BioRuby-cvs] bioruby/test/data/aaindex - New directory Message-ID: <200602181424.k1IEOlVL001733@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/aaindex In directory pub.open-bio.org:/tmp/cvs-serv1723/test/data/aaindex Log Message: Directory /home/repository/bioruby/bioruby/test/data/aaindex added to the repository From nakao at pub.open-bio.org Sat Feb 18 14:44:42 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 18 Feb 2006 14:44:42 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio db.rb,0.32,0.33 Message-ID: <200602181444.k1IEigVL001790@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv1774/lib/bio Modified Files: db.rb Log Message: * db.rb: added '*' in the toptag. * aaindex.rb: added RDoc. added a facade method for both file formats (Bio::AAindex.auto). * test_aaindex.rb: added Index: db.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db.rb,v retrieving revision 0.32 retrieving revision 0.33 diff -C2 -d -r0.32 -r0.33 *** db.rb 12 Jan 2006 08:58:27 -0000 0.32 --- db.rb 18 Feb 2006 14:44:40 -0000 0.33 *************** *** 268,272 **** def toptag2array(str) sep = "\001" ! str.gsub(/\n([A-Za-z\/])/, "\n#{sep}\\1").split(sep) end --- 268,272 ---- def toptag2array(str) sep = "\001" ! str.gsub(/\n([A-Za-z\/\*])/, "\n#{sep}\\1").split(sep) end From nakao at pub.open-bio.org Sat Feb 18 14:44:42 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 18 Feb 2006 14:44:42 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/db test_aaindex.rb,NONE,1.1 Message-ID: <200602181444.k1IEigVL001788@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/db In directory pub.open-bio.org:/tmp/cvs-serv1774/test/unit/bio/db Added Files: test_aaindex.rb Log Message: * db.rb: added '*' in the toptag. * aaindex.rb: added RDoc. added a facade method for both file formats (Bio::AAindex.auto). * test_aaindex.rb: added --- NEW FILE: test_aaindex.rb --- # # test/unit/bio/db/test_aaindex.rb - Unit test for Bio::AAindex # # Copyright:: Copyright (C) 2006 # Mitsuteru C. Nakao # License:: Ruby's # # $Id: test_aaindex.rb,v 1.1 2006/02/18 14:44:40 nakao Exp $ # require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/io/fetch' require 'bio/db/aaindex' module Bio class DataAAindex bioruby_root = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4)).cleanpath.to_s TestDataAAindex = Pathname.new(File.join(bioruby_root, 'test', 'data', 'aaindex')).cleanpath.to_s def self.aax1 File.read(File.join(TestDataAAindex, "PRAM900102")) end def self.aax2 File.read(File.join(TestDataAAindex, "HENS920102")) end end # A super class for Bio::AAindex1 and Bio::AAindex2 class TestAAindexConstant < Test::Unit::TestCase def test_delimiter rs = "\n//\n" assert_equal(rs, Bio::AAindex::DELIMITER) assert_equal(rs, Bio::AAindex::RS) end def test_tagsize assert_equal(2, Bio::AAindex::TAGSIZE) end end class TestAAindex < Test::Unit::TestCase def test_api api_methods = ['entry_id', 'definition', 'dblinks', 'author', 'title', 'journal', 'comment'] api_methods.each do |m| end end def test_auto_aax1 assert_equal(Bio::AAindex1, Bio::AAindex.auto(DataAAindex.aax1).class) end def test_auto_aax2 assert_equal(Bio::AAindex2, Bio::AAindex.auto(DataAAindex.aax2).class) end end class TestAAindex1 < Test::Unit::TestCase def setup str = DataAAindex.aax1 @obj = Bio::AAindex1.new(str) end def test_entry_id assert_equal('PRAM900102', @obj.entry_id) end def test_definition assert_equal('Relative frequency in alpha-helix (Prabhakaran, 1990)', @obj.definition) end def test_dblinks assert_equal(['LIT:1614053b', 'PMID:2390062'], @obj.dblinks) end def test_author assert_equal('Prabhakaran, M.', @obj.author) end def test_title assert_equal('The distribution of physical, chemical and conformational properties in signal and nascent peptides', @obj.title) end def test_journal assert_equal('Biochem. J. 269, 691-696 (1990) Original reference of these three data: Creighton, T.E. In "Protein Structure and Melecular Properties", (Freeman, W.H., ed.), San Francisco P.235 (1983)', @obj.journal) end def test_comment assert_equal("", @obj.comment) end def test_correlation_coefficient # str = "LEVM780101 1.000 LEVM780104 0.964 PALJ810101 0.943 KANM800101 0.942 ISOY800101 0.929 MAXF760101 0.924 ROBB760101 0.916 GEIM800101 0.912 GEIM800104 0.907 RACS820108 0.904 PALJ810102 0.902 PALJ810109 0.898 NAGK730101 0.894 CRAJ730101 0.887 CHOP780201 0.873 TANS770101 0.854 KANM800103 0.850 QIAN880107 0.829 QIAN880106 0.827 BURA740101 0.805 NAGK730103 -0.809" # assert_equal(str, @obj.correlation_coefficient) # to be this ? hash = {'LEVM780101' => 1.000, 'LEVM780104' => 0.964, 'PALJ810101' => 0.943, 'KANM800101' => 0.942, 'ISOY800101' => 0.929, 'MAXF760101' => 0.924, 'ROBB760101' => 0.916, 'GEIM800101' => 0.912, 'GEIM800104' => 0.907, 'RACS820108' => 0.904, 'PALJ810102' => 0.902, 'PALJ810109' => 0.898, 'NAGK730101' => 0.894, 'CRAJ730101' => 0.887, 'CHOP780201' => 0.873, 'TANS770101' => 0.854, 'KANM800103' => 0.850, 'QIAN880107' => 0.829, 'QIAN880106' => 0.827, 'BURA740101' => 0.805, 'NAGK730103' => -0.809} assert_equal(hash, @obj.correlation_coefficient) end def test_index hash = {"V"=>0.91, "K"=>1.23, "W"=>0.99, "L"=>1.3, "A"=>1.29, "M"=>1.47, "Y"=>0.72, "C"=>1.11, "N"=>0.9, "D"=>1.04, "P"=>0.52, "E"=>1.44, "F"=>1.07, "Q"=>1.27, "G"=>0.56, "R"=>0.96, "S"=>0.82, "H"=>1.22, "T"=>0.82, "I"=>0.97} assert_equal(hash, @obj.index) end end class TestAAindex2 < Test::Unit::TestCase def setup str = DataAAindex.aax2 @obj = Bio::AAindex2.new(str) end def test_entry_id assert_equal('HENS920102', @obj.entry_id) end def test_definition assert_equal('BLOSUM62 substitution matrix (Henikoff-Henikoff, 1992)', @obj.definition) end def test_dblinks assert_equal(['LIT:1902106', 'PMID:1438297'], @obj.dblinks) end def test_author assert_equal("Henikoff, S. and Henikoff, J.G.", @obj.author) end def test_title assert_equal("Amino acid substitution matrices from protein blocks", @obj.title) end def test_journal assert_equal("Proc. Natl. Acad. Sci. USA 89, 10915-10919 (1992)", @obj.journal) end def test_comment assert_equal("matrix in 1/3 Bit Units", @obj.comment) end def test_rows ary = ["A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", "P", "S", "T", "W", "Y", "V"] assert_equal(ary, @obj.rows) end def test_cols ary = ["A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", "P", "S", "T", "W", "Y", "V"] assert_equal(ary, @obj.cols) end def test_matrix assert_equal(Matrix, @obj.matrix.class) # assert_equal('', @obj.matrix) end def test_matrix_2_2 assert_equal(8.0, @obj.matrix[2,2]) end def test_matrix_determinant assert_equal(0, @obj.matrix.determinant) end def test_matrix_rank assert_equal(1, @obj.matrix.rank) end def test_matrix_transpose ary = Matrix[[6.0, -2.0, -2.0, -3.0, -1.0, -1.0, -1.0, 0.0, -2.0, -2.0, -2.0, -1.0, -1.0, -3.0, -1.0, 2.0, 0.0, -4.0, -3.0, 0.0]] assert_equal(ary, @obj.matrix.transpose) end end end From nakao at pub.open-bio.org Sat Feb 18 14:44:43 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 18 Feb 2006 14:44:43 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db aaindex.rb,1.16,1.17 Message-ID: <200602181444.k1IEihVL001796@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv1774/lib/bio/db Modified Files: aaindex.rb Log Message: * db.rb: added '*' in the toptag. * aaindex.rb: added RDoc. added a facade method for both file formats (Bio::AAindex.auto). * test_aaindex.rb: added Index: aaindex.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/aaindex.rb,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** aaindex.rb 18 Dec 2005 15:58:41 -0000 1.16 --- aaindex.rb 18 Feb 2006 14:44:40 -0000 1.17 *************** *** 2,6 **** # = bio/db/aaindex.rb - AAindex database class # ! # Copyright:: Copyright (C) 2001 KAWASHIMA Shuichi # License:: LGPL # --- 2,9 ---- # = bio/db/aaindex.rb - AAindex database class # ! # Copyright:: Copyright (C) 2001 ! # KAWASHIMA Shuichi ! # Copyright:: Copyright (C) 2006 ! # Mitsuteru C. Nakao # License:: LGPL # *************** *** 8,15 **** --- 11,23 ---- # # == Description + # # Classes for Amino Acid Index Database (AAindex and AAindex2). # * AAindex Manual: http://www.genome.jp/dbget-bin/show_man?aaindex # # == Examples + # + # aax1 = Bio::AAindex.auto("PRAM900102.aaindex1") + # aax2 = Bio::AAindex.auto("HENS920102.aaindex2") + # # aax1 = Bio::AAindex1.new("PRAM900102.aaindex1") # aax1.entry_id *************** *** 22,25 **** --- 30,34 ---- # # == References + # # * http://www.genome.jp/aaindex/ # *************** *** 48,51 **** --- 57,61 ---- module Bio + # Super class for AAindex1 and AAindex2 class AAindex < KEGGDB *************** *** 59,118 **** TAGSIZE = 2 def initialize(entry) super(entry, TAGSIZE) end ! # Returns def entry_id field_fetch('H') end ! # Returns def definition field_fetch('D') end ! # Returns def dblinks ! field_fetch('R') end ! # Returns def author field_fetch('A') end ! # Returns def title field_fetch('T') end ! # Returns def journal field_fetch('J') end ! # Returns def comment ! get('*') end - end class AAindex1 < AAindex - def initialize(entry) super(entry) end ! # Returns def correlation_coefficient ! field_fetch('C') end ! # Returns def index(type = :float) aa = %w( A R N D C Q E G H I L K M F P S T W Y V ) --- 69,151 ---- TAGSIZE = 2 + # Auto detecter for two AAindex formats. + # returns a Bio::AAindex1 object or a Bio::AAindex2 object. + def self.auto(str) + case str + when /^I /m + Bio::AAindex1.new(str) + when /^M /m + Bio::AAindex2.new(str) + else + raise + end + end + # def initialize(entry) super(entry, TAGSIZE) end ! # Returns entry_id in the H line. def entry_id field_fetch('H') end ! # Returns definition in the D line. def definition field_fetch('D') end ! # Returns database links in the R line. ! # cf.) ['LIT:123456', 'PMID:12345678'] def dblinks ! field_fetch('R').split(' ') end ! # Returns authors in the A line. def author field_fetch('A') end ! # Returns title in the T line. def title field_fetch('T') end ! # Returns journal name in the J line. def journal field_fetch('J') end ! # Returns comment (if any). def comment ! field_fetch("*") end end + # Class for AAindex1 format. class AAindex1 < AAindex def initialize(entry) super(entry) end ! # Returns correlation_coefficient (Hash) in the C line. ! # ! # cf.) {'ABCD12010203' => 0.999, 'CDEF123456' => 0.543, ...} def correlation_coefficient ! hash = {} ! ary = field_fetch('C').split(' ') ! ary.each do |x| ! next unless x =~ /^[A-Z]/ ! hash[x] = ary[ary.index(x) + 1].to_f ! end ! hash end ! # Returns the index (Array) in the I line. ! # ! # an argument: :string, :float, :zscore or :integer def index(type = :float) aa = %w( A R N D C Q E G H I L K M F P S T W Y V ) *************** *** 163,174 **** class AAindex2 < AAindex - def initialize(entry) super(entry) end ! # Returns def rows label_data --- 196,207 ---- + # Class for AAindex2 format. class AAindex2 < AAindex def initialize(entry) super(entry) end ! # Returns row labels. def rows label_data *************** *** 176,180 **** end ! # Returns def cols label_data --- 209,213 ---- end ! # Returns col labels. def cols label_data *************** *** 182,186 **** end ! # Returns def matrix ma = Array.new --- 215,219 ---- end ! # Returns matrix in Matrix. def matrix ma = Array.new *************** *** 195,199 **** end ! # Returns def old_matrix # for AAindex <= ver 5.0 --- 228,232 ---- end ! # Returns def old_matrix # for AAindex <= ver 5.0 *************** *** 244,250 **** end ! end ! end --- 277,283 ---- end ! end # class AAindex2 ! end # module Bio *************** *** 260,263 **** --- 293,297 ---- p aax1.title p aax1.journal + p aax1.comment p aax1.correlation_coefficient p aax1.index *************** *** 270,273 **** --- 304,308 ---- p aax2.title p aax2.journal + p aax1.comment p aax2.rows p aax2.cols From nakao at pub.open-bio.org Sat Feb 18 15:03:50 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 18 Feb 2006 15:03:50 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db medline.rb,1.12,1.13 Message-ID: <200602181503.k1IF3oVL001888@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv1878/lib/bio/db Modified Files: medline.rb Log Message: * updated RDoc. Index: medline.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/medline.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** medline.rb 8 Sep 2005 01:22:11 -0000 1.12 --- medline.rb 18 Feb 2006 15:03:47 -0000 1.13 *************** *** 1,6 **** # ! # bio/db/medline.rb - NCBI PubMed/MEDLINE database class # ! # Copyright (C) 2001, 2005 KATAYAMA Toshiaki # # This library is free software; you can redistribute it and/or --- 1,25 ---- # ! # = bio/db/medline.rb - NCBI PubMed/MEDLINE database class # ! # Copyright:: Copyright (C) 2001, 2005 ! # KATAYAMA Toshiaki ! # License:: LGPL ! # ! # == Description ! # ! # NCBI PubMed/MEDLINE database class. ! # ! # == Examples ! # ! # medline = Bio::MEDLINE.new(txt) ! # medline.reference ! # medline.pmid == medline.entry_id ! # medilne.mesh ! # ! # == References ! # ! # $Id$ ! # ! #++ # # This library is free software; you can redistribute it and/or *************** *** 18,22 **** # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! # $Id$ # --- 37,41 ---- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! #-- # *************** *** 25,30 **** --- 44,51 ---- module Bio + # NCBI PubMed/MEDLINE database class. class MEDLINE < NCBIDB + # def initialize(entry) @pubmed = Hash.new('') *************** *** 40,44 **** ! # Reference object def reference hash = Hash.new('') --- 61,65 ---- ! # returns a Reference object. def reference hash = Hash.new('') From nakao at pub.open-bio.org Sat Feb 18 16:08:12 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 18 Feb 2006 16:08:12 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl blast.rb,1.27,1.28 Message-ID: <200602181608.k1IG8CVL002623@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv2613/lib/bio/appl Modified Files: blast.rb Log Message: * Added RDoc. * Changed license. Index: blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast.rb,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** blast.rb 18 Dec 2005 17:28:55 -0000 1.27 --- blast.rb 18 Feb 2006 16:08:10 -0000 1.28 *************** *** 1,23 **** # ! # bio/appl/blast.rb - BLAST wrapper # ! # Copyright (C) 2001 Mitsuteru C. Nakao ! # Copyright (C) 2002,2003 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$ # --- 1,30 ---- # ! # = bio/appl/blast.rb - BLAST wrapper # ! # Copyright:: Copyright (C) 2001 ! # Mitsuteru C. Nakao ! # Copyrigth:: Copyright (C) 2002,2003 ! # KATAYAMA Toshiaki ! # License:: Ruby's # ! # $Id$ # ! # = Description # ! # = Examples # ! # program = 'blastp' ! # database = 'SWISS' ! # options = '-e 0.0001' ! # serv = Bio::Blast.new(program, database, options) ! # server = 'genomenet' ! # genomenet = Bio::Blast.remote(program, database, options, server) ! # report = serv.query(sequence_text) ! # ! # = References ! # ! # * http://www.ncbi.nlm.nih.gov/blast/ ! # ! # * http://blast.genome.jp/ideas/ideas.html#blast # *************** *** 29,32 **** --- 36,73 ---- module Bio + # BLAST wrapper + # + # == Description + # + # A blastall program wrapper. + # + # == Examples + # + # program = 'blastp' + # database = 'SWISS' + # options = '-e 0.0001' + # serv = Bio::Blast.new(program, database, options) + # + # server = 'genomenet' + # genomenet = Bio::Blast.remote(program, database, options, server) + # + # report = serv.query(sequence_text) + # + # == Available databases for Blast.remote(@program, @db, option, 'genomenet') + # + # ----------+-------+--------------------------------------------------- + # @program | query | @db (supported in GenomeNet) + # ----------+-------+--------------------------------------------------- + # blastp | AA | nr-aa, genes, vgenes.pep, swissprot, swissprot-upd, + # ----------+-------+ pir, prf, pdbstr + # blastx | NA | + # ----------+-------+--------------------------------------------------- + # blastn | NA | nr-nt, genbank-nonst, gbnonst-upd, dbest, dbgss, + # ----------+-------+ htgs, dbsts, embl-nonst, embnonst-upd, epd, + # tblastn | AA | genes-nt, genome, vgenes.nuc + # ----------+-------+--------------------------------------------------- + # + # * See http://blast.genome.jp/ideas/ideas.html#blast for more details. + # class Blast *************** *** 39,42 **** --- 80,153 ---- include Bio::Command::Tools + # Sets up the blast program at the localhost + def self.local(program, db, option = '') + self.new(program, db, option, 'local') + end + + # Sets up the blast program at the remote host (server) + def self.remote(program, db, option = '', server = 'genomenet') + self.new(program, db, option, server) + 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 + + + # Program name for blastall -p (blastp, blastn, blastx, tblastn or tblastx). + attr_accessor :program + + # Database name for blastall -d + attr_accessor :db + + # Options for blastall + attr_accessor :options + + # + attr_accessor :server + + # Full path for blastall. (default: 'blastall'). + attr_accessor :blastall + + # Substitution matrix for blastall -M + attr_accessor :matrix + + # Filter option for blastall -F (T or F). + attr_accessor :filter + + # Returns a String containing blast execution output in as is the Bio::Blast#format. + attr_reader :output + + # Output report format for blastall -m + # + # 0, pairwise; 1; 2; 3; 4; 5; 6; 7, XML Blast outpu;, 8, tabular; + # 9, tabular with comment lines; 10, ASN text; 11, ASN binery [intege]. + attr_reader :format + + # + attr_writer :parser # to change :xmlparser, :rexml, :tab + + + # Returns a blast factory object (Bio::Blast). + # + # --- Bio::Blast.new(program, db, option = '', server = 'local') + # --- Bio::Blast.local(program, db, option = '') + # --- Bio::Blast.remote(program, db, option = '', server = 'genomenet') + # + # For the develpper, you can add server 'hoge' by adding + # exec_hoge(query) method. + # def initialize(program, db, opt = [], server = 'local') @program = program *************** *** 66,85 **** @options = [ *a ] end - attr_accessor :program, :db, :options, :server, :blastall, :matrix, :filter - attr_reader :output, :format - attr_writer :parser # to change :xmlparser, :rexml, :tab - - def self.local(program, db, option = '') - self.new(program, db, option, 'local') - end - - def self.remote(program, db, option = '', server = 'genomenet') - self.new(program, db, option, server) - end def query(query) return self.send("exec_#{@server}", query.to_s) end def option # backward compatibility --- 177,187 ---- @options = [ *a ] end + # Execute blast search and returns Report object (Bio::Blast::Report). def query(query) return self.send("exec_#{@server}", query.to_s) end + # option reader def option # backward compatibility *************** *** 87,90 **** --- 189,193 ---- end + # option setter def option=(str) # backward compatibility *************** *** 92,111 **** 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 - private --- 195,198 ---- *************** *** 190,200 **** end - def exec_ncbi(query) raise NotImplementedError end - end ! end --- 277,287 ---- end def exec_ncbi(query) raise NotImplementedError end ! end # class Blast ! ! end # module Bio *************** *** 214,269 **** end - - =begin - - = Bio::Blast - - --- Bio::Blast.new(program, db, option = '', server = 'local') - --- Bio::Blast.local(program, db, option = '') - --- Bio::Blast.remote(program, db, option = '', server = 'genomenet') - - Returns a blast factory object (Bio::Blast). - - For the develpper, you can add server 'hoge' by adding - exec_hoge(query) method. - - --- Bio::Blast#query(query) - - Execute blast search and returns Report object (Bio::Blast::Report). - - --- Bio::Blast#output - - Returns a String containing blast execution output in as is format. - - --- Bio::Blast#program - --- Bio::Blast#db - --- Bio::Blast#options - --- Bio::Blast#server - --- Bio::Blast#blastall - --- Bio::Blast#filter - - Accessors for the factory parameters. - - --- Bio::Blast#option - --- Bio::Blast#option=(str) - - Get/set options by string. - - == Available databases for Blast.remote(@program, @db, option, 'genomenet') - - # ----------+-------+--------------------------------------------------- - # @program | query | @db (supported in GenomeNet) - # ----------+-------+--------------------------------------------------- - # blastp | AA | nr-aa, genes, vgenes.pep, swissprot, swissprot-upd, - # ----------+-------+ pir, prf, pdbstr - # blastx | NA | - # ----------+-------+--------------------------------------------------- - # blastn | NA | nr-nt, genbank-nonst, gbnonst-upd, dbest, dbgss, - # ----------+-------+ htgs, dbsts, embl-nonst, embnonst-upd, epd, - # tblastn | AA | genes-nt, genome, vgenes.nuc - # ----------+-------+--------------------------------------------------- - - See http://blast.genome.jp/ideas/ideas.html#blast for more details. - - =end --- 301,303 ---- From ngoto at pub.open-bio.org Mon Feb 20 13:00:45 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Mon, 20 Feb 2006 13:00:45 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db/pdb pdb.rb,1.14,1.15 Message-ID: <200602201300.k1KD0jVL021301@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/pdb In directory pub.open-bio.org:/tmp/cvs-serv21291/lib/bio/db/pdb Modified Files: pdb.rb Log Message: added PDB#authors method. Index: pdb.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/pdb.rb,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** pdb.rb 29 Jan 2006 06:48:39 -0000 1.14 --- pdb.rb 20 Feb 2006 13:00:43 -0000 1.15 *************** *** 1808,1811 **** --- 1808,1816 ---- end + # Get authors in "AUTHOR". + def authors + self.record('AUTHOR').first.authorList + end + #-- # Bio::DB methods From nakao at pub.open-bio.org Tue Feb 21 17:38:18 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Tue, 21 Feb 2006 17:38:18 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/shell/plugin test_seq.rb, 1.5, 1.6 Message-ID: <200602211738.k1LHcIVL029014@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv29004/test/unit/bio/shell/plugin Modified Files: test_seq.rb Log Message: * Changed the library name required (bioruby -> bio/shell). Index: test_seq.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/shell/plugin/test_seq.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_seq.rb 19 Dec 2005 02:44:03 -0000 1.5 --- test_seq.rb 21 Feb 2006 17:38:15 -0000 1.6 *************** *** 26,30 **** require 'test/unit' ! require 'bioruby' module Bio --- 26,30 ---- require 'test/unit' ! require 'bio/shell' module Bio From nakao at pub.open-bio.org Tue Feb 21 17:40:39 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Tue, 21 Feb 2006 17:40:39 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio test_shell.rb,1.4,1.5 Message-ID: <200602211740.k1LHedVL029069@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio In directory pub.open-bio.org:/tmp/cvs-serv29059/test/unit/bio Modified Files: test_shell.rb Log Message: * Changed the library name required (bioruby -> bio/shell). Index: test_shell.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/test_shell.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_shell.rb 18 Dec 2005 17:00:10 -0000 1.4 --- test_shell.rb 21 Feb 2006 17:40:37 -0000 1.5 *************** *** 26,30 **** require 'test/unit' ! require 'bioruby' module Bio --- 26,30 ---- require 'test/unit' ! require 'bio/shell' module Bio From ngoto at pub.open-bio.org Tue Feb 21 18:02:01 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Tue, 21 Feb 2006 18:02:01 +0000 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.64,1.65 Message-ID: <200602211802.k1LI21VL029168@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv29148/lib Modified Files: bio.rb Log Message: added autoload for AAindex1 and AAindex2 Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** bio.rb 9 Feb 2006 16:21:47 -0000 1.64 --- bio.rb 21 Feb 2006 18:01:59 -0000 1.65 *************** *** 101,104 **** --- 101,106 ---- autoload :GFF, 'bio/db/gff' autoload :AAindex, 'bio/db/aaindex' + autoload :AAindex1, 'bio/db/aaindex' + autoload :AAindex2, 'bio/db/aaindex' autoload :TRANSFAC, 'bio/db/transfac' autoload :PROSITE, 'bio/db/prosite' From nakao at pub.open-bio.org Wed Feb 22 02:23:25 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 22 Feb 2006 02:23:25 +0000 Subject: [BioRuby-cvs] bioruby/test/data/aaindex HENS920102, NONE, 1.1 PRAM900102, NONE, 1.1 Message-ID: <200602220223.k1M2NPVL030747@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/aaindex In directory pub.open-bio.org:/tmp/cvs-serv30737/test/data/aaindex Added Files: HENS920102 PRAM900102 Log Message: * HENS920102: newly added a test data for Bio::AAindex2. * PRAM900102: newly added a test data for Bio::AAindex1. --- NEW FILE: HENS920102 --- H HENS920102 D BLOSUM62 substitution matrix (Henikoff-Henikoff, 1992) R LIT:1902106 PMID:1438297 A Henikoff, S. and Henikoff, J.G. T Amino acid substitution matrices from protein blocks J Proc. Natl. Acad. Sci. USA 89, 10915-10919 (1992) * matrix in 1/3 Bit Units M rows = ARNDCQEGHILKMFPSTWYV, cols = ARNDCQEGHILKMFPSTWYV 6. -2. 8. -2. -1. 8. -3. -2. 2. 9. -1. -5. -4. -5. 13. -1. 1. 0. 0. -4. 8. -1. 0. 0. 2. -5. 3. 7. 0. -3. -1. -2. -4. -3. -3. 8. -2. 0. 1. -2. -4. 1. 0. -3. 11. -2. -4. -5. -5. -2. -4. -5. -6. -5. 6. -2. -3. -5. -5. -2. -3. -4. -5. -4. 2. 6. -1. 3. 0. -1. -5. 2. 1. -2. -1. -4. -4. 7. -1. -2. -3. -5. -2. -1. -3. -4. -2. 2. 3. -2. 8. -3. -4. -4. -5. -4. -5. -5. -5. -2. 0. 1. -5. 0. 9. -1. -3. -3. -2. -4. -2. -2. -3. -3. -4. -4. -2. -4. -5. 11. 2. -1. 1. 0. -1. 0. 0. 0. -1. -4. -4. 0. -2. -4. -1. 6. 0. -2. 0. -2. -1. -1. -1. -2. -3. -1. -2. -1. -1. -3. -2. 2. 7. -4. -4. -6. -6. -3. -3. -4. -4. -4. -4. -2. -4. -2. 1. -5. -4. -4. 16. -3. -3. -3. -5. -4. -2. -3. -5. 3. -2. -2. -3. -1. 4. -4. -3. -2. 3. 10. 0. -4. -4. -5. -1. -3. -4. -5. -5. 4. 1. -3. 1. -1. -4. -2. 0. -4. -2. 6. // --- NEW FILE: PRAM900102 --- H PRAM900102 D Relative frequency in alpha-helix (Prabhakaran, 1990) R LIT:1614053b PMID:2390062 A Prabhakaran, M. T The distribution of physical, chemical and conformational properties in signal and nascent peptides J Biochem. J. 269, 691-696 (1990) Original reference of these three data: Creighton, T.E. In "Protein Structure and Melecular Properties", (Freeman, W.H., ed.), San Francisco P.235 (1983) C LEVM780101 1.000 LEVM780104 0.964 PALJ810101 0.943 KANM800101 0.942 ISOY800101 0.929 MAXF760101 0.924 ROBB760101 0.916 GEIM800101 0.912 GEIM800104 0.907 RACS820108 0.904 PALJ810102 0.902 PALJ810109 0.898 NAGK730101 0.894 CRAJ730101 0.887 CHOP780201 0.873 TANS770101 0.854 KANM800103 0.850 QIAN880107 0.829 QIAN880106 0.827 BURA740101 0.805 NAGK730103 -0.809 I A/L R/K N/M D/F C/P Q/S E/T G/W H/Y I/V 1.29 0.96 0.90 1.04 1.11 1.27 1.44 0.56 1.22 0.97 1.30 1.23 1.47 1.07 0.52 0.82 0.82 0.99 0.72 0.91 // From nakao at pub.open-bio.org Wed Feb 22 05:07:38 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 22 Feb 2006 05:07:38 +0000 Subject: [BioRuby-cvs] bioruby/test/data/aaindex DAYM780301, NONE, 1.1 HENS920102, 1.1, NONE Message-ID: <200602220507.k1M57cVL032222@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/data/aaindex In directory pub.open-bio.org:/tmp/cvs-serv32206/test/data/aaindex Added Files: DAYM780301 Removed Files: HENS920102 Log Message: * test_aaindex.rb: changed test data (HENS920102 -> DAYM780301) for Bio::AAindex2. * DAYM780301: newly added. * HENS920102: removed. --- HENS920102 DELETED --- --- NEW FILE: DAYM780301 --- H DAYM780301 D Log odds matrix for 250 PAMs (Dayhoff et al., 1978) R A Dayhoff, M.O., Schwartz, R.M. and Orcutt, B.C. T A model of evolutionary change in proteins J In "Atlas of Protein Sequence and Structure", Vol.5, Suppl.3 (Dayhoff, M.O., ed.), National Biomedical Research Foundation, Washington, D.C., p.352 (1978) M rows = ARNDCQEGHILKMFPSTWYV, cols = ARNDCQEGHILKMFPSTWYV 2. -2. 6. 0. 0. 2. 0. -1. 2. 4. -2. -4. -4. -5. 12. 0. 1. 1. 2. -5. 4. 0. -1. 1. 3. -5. 2. 4. 1. -3. 0. 1. -3. -1. 0. 5. -1. 2. 2. 1. -3. 3. 1. -2. 6. -1. -2. -2. -2. -2. -2. -2. -3. -2. 5. -2. -3. -3. -4. -6. -2. -3. -4. -2. 2. 6. -1. 3. 1. 0. -5. 1. 0. -2. 0. -2. -3. 5. -1. 0. -2. -3. -5. -1. -2. -3. -2. 2. 4. 0. 6. -4. -4. -4. -6. -4. -5. -5. -5. -2. 1. 2. -5. 0. 9. 1. 0. -1. -1. -3. 0. -1. -1. 0. -2. -3. -1. -2. -5. 6. 1. 0. 1. 0. 0. -1. 0. 1. -1. -1. -3. 0. -2. -3. 1. 2. 1. -1. 0. 0. -2. -1. 0. 0. -1. 0. -2. 0. -1. -3. 0. 1. 3. -6. 2. -4. -7. -8. -5. -7. -7. -3. -5. -2. -3. -4. 0. -6. -2. -5. 17. -3. -4. -2. -4. 0. -4. -4. -5. 0. -1. -1. -4. -2. 7. -5. -3. -3. 0. 10. 0. -2. -2. -2. -2. -2. -2. -1. -2. 4. 2. -2. 2. -1. -1. -1. 0. -6. -2. 4. // From nakao at pub.open-bio.org Wed Feb 22 05:07:38 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 22 Feb 2006 05:07:38 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/db test_aaindex.rb,1.1,1.2 Message-ID: <200602220507.k1M57cVL032218@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/db In directory pub.open-bio.org:/tmp/cvs-serv32206/test/unit/bio/db Modified Files: test_aaindex.rb Log Message: * test_aaindex.rb: changed test data (HENS920102 -> DAYM780301) for Bio::AAindex2. * DAYM780301: newly added. * HENS920102: removed. Index: test_aaindex.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/db/test_aaindex.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_aaindex.rb 18 Feb 2006 14:44:40 -0000 1.1 --- test_aaindex.rb 22 Feb 2006 05:07:36 -0000 1.2 *************** *** 27,31 **** def self.aax2 ! File.read(File.join(TestDataAAindex, "HENS920102")) end end --- 27,31 ---- def self.aax2 ! File.read(File.join(TestDataAAindex, "DAYM780301")) end end *************** *** 117,145 **** def test_entry_id ! assert_equal('HENS920102', @obj.entry_id) end def test_definition ! assert_equal('BLOSUM62 substitution matrix (Henikoff-Henikoff, 1992)', @obj.definition) end def test_dblinks ! assert_equal(['LIT:1902106', 'PMID:1438297'], @obj.dblinks) end def test_author ! assert_equal("Henikoff, S. and Henikoff, J.G.", @obj.author) end def test_title ! assert_equal("Amino acid substitution matrices from protein blocks", @obj.title) end def test_journal ! assert_equal("Proc. Natl. Acad. Sci. USA 89, 10915-10919 (1992)", @obj.journal) end def test_comment ! assert_equal("matrix in 1/3 Bit Units", @obj.comment) end --- 117,145 ---- def test_entry_id ! assert_equal('DAYM780301', @obj.entry_id) end def test_definition ! assert_equal('Log odds matrix for 250 PAMs (Dayhoff et al., 1978)', @obj.definition) end def test_dblinks ! assert_equal([], @obj.dblinks) end def test_author ! assert_equal("Dayhoff, M.O., Schwartz, R.M. and Orcutt, B.C.", @obj.author) end def test_title ! assert_equal("A model of evolutionary change in proteins", @obj.title) end def test_journal ! assert_equal('In "Atlas of Protein Sequence and Structure", Vol.5, Suppl.3 (Dayhoff, M.O., ed.), National Biomedical Research Foundation, Washington, D.C., p.352 (1978)', @obj.journal) end def test_comment ! assert_equal("", @obj.comment) end *************** *** 160,164 **** def test_matrix_2_2 ! assert_equal(8.0, @obj.matrix[2,2]) end --- 160,164 ---- def test_matrix_2_2 ! assert_equal(2.0, @obj.matrix[2,2]) end *************** *** 172,176 **** def test_matrix_transpose ! ary = Matrix[[6.0, -2.0, -2.0, -3.0, -1.0, -1.0, -1.0, 0.0, -2.0, -2.0, -2.0, -1.0, -1.0, -3.0, -1.0, 2.0, 0.0, -4.0, -3.0, 0.0]] assert_equal(ary, @obj.matrix.transpose) end --- 172,176 ---- def test_matrix_transpose ! ary = Matrix[[2.0, -2.0, 0.0, 0.0, -2.0, 0.0, 0.0, 1.0, -1.0, -1.0, -2.0, -1.0, -1.0, -4.0, 1.0, 1.0, 1.0, -6.0, -3.0, 0.0]] assert_equal(ary, @obj.matrix.transpose) end From ngoto at pub.open-bio.org Wed Feb 22 07:01:07 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 07:01:07 +0000 Subject: [BioRuby-cvs] bioruby/bin br_bioflat.rb,1.15,1.16 Message-ID: <200602220701.k1M717VL032455@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv32441/bin Modified Files: br_bioflat.rb Log Message: changed STDERR to $stderr Index: br_bioflat.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/br_bioflat.rb,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** br_bioflat.rb 9 Feb 2006 16:29:41 -0000 1.15 --- br_bioflat.rb 22 Feb 2006 07:01:05 -0000 1.16 *************** *** 140,144 **** else ! STDERR.print "Warning: ignoring invalid option #{x.inspect}\n" end end --- 140,144 ---- else ! $stderr.print "Warning: ignoring invalid option #{x.inspect}\n" end end *************** *** 180,186 **** db = Bio::FlatFileIndex.open(dbname) ARGV.each do |key| ! STDERR.print "Searching for \'#{key}\'...\n" #r = db.search(key) ! #STDERR.print "OK, #{r.size} entry found\n" #if r.size > 0 then # print r --- 180,186 ---- db = Bio::FlatFileIndex.open(dbname) ARGV.each do |key| ! $stderr.print "Searching for \'#{key}\'...\n" #r = db.search(key) ! #$stderr.print "OK, #{r.size} entry found\n" #if r.size > 0 then # print r *************** *** 193,201 **** end rescue RuntimeError ! STDERR.print "ERROR: #{$!}\n" next end r = [] unless r ! STDERR.print "OK, #{r.size} entry found\n" r.each do |i| print db.search_primary(i) --- 193,201 ---- end rescue RuntimeError ! $stderr.print "ERROR: #{$!}\n" next end r = [] unless r ! $stderr.print "OK, #{r.size} entry found\n" r.each do |i| print db.search_primary(i) *************** *** 241,252 **** end if k then ! STDERR.print "Format: #{k.to_s}\n" format = k else ! STDERR.print "ERROR: couldn't determine file format\n" return end end ! STDERR.print "Namespaces: (first line: primary namespace)\n" if format then parser = Bio::FlatFileIndex::Indexer::Parser.new(format) --- 241,252 ---- end if k then ! $stderr.print "Format: #{k.to_s}\n" format = k else ! $stderr.print "ERROR: couldn't determine file format\n" return end end ! $stderr.print "Namespaces: (first line: primary namespace)\n" if format then parser = Bio::FlatFileIndex::Indexer::Parser.new(format) From ngoto at pub.open-bio.org Wed Feb 22 07:01:07 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 07:01:07 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io/flatfile index.rb,1.16,1.17 Message-ID: <200602220701.k1M717VL032459@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io/flatfile In directory pub.open-bio.org:/tmp/cvs-serv32441/lib/bio/io/flatfile Modified Files: index.rb Log Message: changed STDERR to $stderr Index: index.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile/index.rb,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** index.rb 29 Jan 2006 10:06:43 -0000 1.16 --- index.rb 22 Feb 2006 07:01:05 -0000 1.17 *************** *** 414,425 **** # Module for output debug messages. # Default setting: If $DEBUG or $VERBOSE is true, output debug ! # messages to STDERR; Otherwise, don't output messages. # module DEBUG ! @@out = STDERR @@flag = nil # Set debug messages output destination. ! # If true is given, outputs to STDERR. # If nil is given, outputs nothing. # This method affects ALL of FlatFileIndex related objects/methods. --- 414,425 ---- # Module for output debug messages. # Default setting: If $DEBUG or $VERBOSE is true, output debug ! # messages to $stderr; Otherwise, don't output messages. # module DEBUG ! @@out = $stderr @@flag = nil # Set debug messages output destination. ! # If true is given, outputs to $stderr. # If nil is given, outputs nothing. # This method affects ALL of FlatFileIndex related objects/methods. *************** *** 428,432 **** if io then @@out = io ! @@out = STDERR if io == true @@flag = true else --- 428,432 ---- if io then @@out = io ! @@out = $stderr if io == true @@flag = true else From nakao at pub.open-bio.org Wed Feb 22 07:35:21 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 22 Feb 2006 07:35:21 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/db test_aaindex.rb,1.2,1.3 Message-ID: <200602220735.k1M7ZLVL032553@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/db In directory pub.open-bio.org:/tmp/cvs-serv32524/test/unit/bio/db Modified Files: test_aaindex.rb Log Message: * aaindex.rb: Added Bio::AAindex2#[](aa1, aa2) method for accessing the value in the matrix. Changed arguments of Bio::AAindex2#matrix(aa1 = nil, aa1 = nil) to access Bio::AAindex2#[](aa1, aa2) method. Added a lazy-parsing by using @data. * test_aaindex.rb: Changed test codes for Bio::AAindex2#[] and BioAAindex2#matrix. Index: test_aaindex.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/db/test_aaindex.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_aaindex.rb 22 Feb 2006 05:07:36 -0000 1.2 --- test_aaindex.rb 22 Feb 2006 07:35:19 -0000 1.3 *************** *** 156,164 **** def test_matrix assert_equal(Matrix, @obj.matrix.class) - # assert_equal('', @obj.matrix) end def test_matrix_2_2 ! assert_equal(2.0, @obj.matrix[2,2]) end --- 156,183 ---- def test_matrix assert_equal(Matrix, @obj.matrix.class) end def test_matrix_2_2 ! assert_equal(2.0, @obj.matrix[2, 2]) ! end ! ! def test_matrix_1_2 ! assert_equal(nil, @obj.matrix[1, 2]) ! end ! ! def test_access_A_R ! assert_equal(nil, @obj['A', 'R']) ! end ! ! def test_access_R_A ! assert_equal(-2.0, @obj['R', 'A']) ! end ! ! def test_matrix_A_R ! assert_equal(nil, @obj.matrix('A', 'R')) ! end ! ! def test_matrix_R_A ! assert_equal(-2.0, @obj.matrix('R', 'A')) end From nakao at pub.open-bio.org Wed Feb 22 07:35:22 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 22 Feb 2006 07:35:22 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db aaindex.rb,1.17,1.18 Message-ID: <200602220735.k1M7ZMVL032557@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv32524/lib/bio/db Modified Files: aaindex.rb Log Message: * aaindex.rb: Added Bio::AAindex2#[](aa1, aa2) method for accessing the value in the matrix. Changed arguments of Bio::AAindex2#matrix(aa1 = nil, aa1 = nil) to access Bio::AAindex2#[](aa1, aa2) method. Added a lazy-parsing by using @data. * test_aaindex.rb: Changed test codes for Bio::AAindex2#[] and BioAAindex2#matrix. Index: aaindex.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/aaindex.rb,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** aaindex.rb 18 Feb 2006 14:44:40 -0000 1.17 --- aaindex.rb 22 Feb 2006 07:35:19 -0000 1.18 *************** *** 18,22 **** # # aax1 = Bio::AAindex.auto("PRAM900102.aaindex1") ! # aax2 = Bio::AAindex.auto("HENS920102.aaindex2") # # aax1 = Bio::AAindex1.new("PRAM900102.aaindex1") --- 18,22 ---- # # aax1 = Bio::AAindex.auto("PRAM900102.aaindex1") ! # aax2 = Bio::AAindex.auto("DAYM780301.aaindex2") # # aax1 = Bio::AAindex1.new("PRAM900102.aaindex1") *************** *** 24,31 **** # aax1.index # ! # aax2 = Bio::AAindex2.new("HENS920102.aaindex2") # aax2.entry_id # aax2.matrix # aax2.matrix[2,2] # # == References --- 24,33 ---- # aax1.index # ! # aax2 = Bio::AAindex2.new("DAYM780301.aaindex2") # aax2.entry_id # aax2.matrix # aax2.matrix[2,2] + # aax2.matrix('R', 'A') + # aax2['R', 'A'] # # == References *************** *** 89,98 **** # Returns entry_id in the H line. def entry_id ! field_fetch('H') end # Returns definition in the D line. def definition ! field_fetch('D') end --- 91,108 ---- # Returns entry_id in the H line. def entry_id ! if @data['entry_id'] ! @data['entry_id'] ! else ! @data['entry_id'] = field_fetch('H') ! end end # Returns definition in the D line. def definition ! if @data['definition'] ! @data['definition'] ! else ! @data['definition'] = field_fetch('D') ! end end *************** *** 100,124 **** # cf.) ['LIT:123456', 'PMID:12345678'] def dblinks ! field_fetch('R').split(' ') end # Returns authors in the A line. def author ! field_fetch('A') end # Returns title in the T line. def title ! field_fetch('T') end # Returns journal name in the J line. def journal ! field_fetch('J') end # Returns comment (if any). def comment ! field_fetch("*") end end --- 110,154 ---- # cf.) ['LIT:123456', 'PMID:12345678'] def dblinks ! if @data['ref'] ! @data['ref'] ! else ! @data['ref'] = field_fetch('R').split(' ') ! end end # Returns authors in the A line. def author ! if @data['author'] ! @data['author'] ! else ! @data['author'] = field_fetch('A') ! end end # Returns title in the T line. def title ! if @data['title'] ! @data['title'] ! else ! @data['title'] = field_fetch('T') ! end end # Returns journal name in the J line. def journal ! if @data['journal'] ! @data['journal'] ! else ! @data['journal'] = field_fetch('J') ! end end # Returns comment (if any). def comment ! if @data['comment'] ! @data['comment'] ! else ! @data['comment'] = field_fetch('*') ! end end end *************** *** 136,146 **** # cf.) {'ABCD12010203' => 0.999, 'CDEF123456' => 0.543, ...} def correlation_coefficient ! hash = {} ! ary = field_fetch('C').split(' ') ! ary.each do |x| ! next unless x =~ /^[A-Z]/ ! hash[x] = ary[ary.index(x) + 1].to_f end - hash end --- 166,180 ---- # cf.) {'ABCD12010203' => 0.999, 'CDEF123456' => 0.543, ...} def correlation_coefficient ! if @data['correlation_coefficient'] ! @data['correlation_coefficient'] ! else ! hash = {} ! ary = field_fetch('C').split(' ') ! ary.each do |x| ! next unless x =~ /^[A-Z]/ ! hash[x] = ary[ary.index(x) + 1].to_f ! end ! @data['correlation_coefficient'] = hash end end *************** *** 205,236 **** # Returns row labels. def rows ! label_data ! @rows end # Returns col labels. def cols ! label_data ! @cols end ! # Returns matrix in Matrix. ! def matrix ! ma = Array.new ! data = label_data ! data.each_line do |line| ! list = line.strip.split(/\s+/).map{|x| x.to_f} ! ma.push(list) ! end ! Matrix[*ma] end ! # Returns def old_matrix # for AAindex <= ver 5.0 ! @aa = {} # used to determine row/column of the aa attr_reader :aa field = field_fetch('I') --- 239,289 ---- # Returns row labels. def rows ! if @data['rows'] ! @data['rows'] ! else ! label_data ! @rows ! end end # Returns col labels. def cols ! if @data['cols'] ! @data['cols'] ! else ! label_data ! @cols ! end end ! # Returns the value of amino acids substitution (aa1 -> aa2). ! def [](aa1 = nil, aa2 = nil) ! matrix[cols.index(aa1), rows.index(aa2)] ! end ! # Returns amino acids matrix in Matrix. ! def matrix(aa1 = nil, aa2 = nil) ! return self[aa1, aa2] if aa1 and aa2 ! if @data['matrix'] ! @data['matrix'] ! else ! ma = [] ! label_data.each_line do |line| ! ma << line.strip.split(/\s+/).map {|x| x.to_f } ! end ! @data['matrix'] = Matrix[*ma] ! end end ! # Returns amino acids matrix in Matrix for the old format (<= ver 5.0). def old_matrix # for AAindex <= ver 5.0 + return @data['matrix'] if @data['matrix'] ! @aa = {} ! # used to determine row/column of the aa attr_reader :aa + alias_method :aa, :rows + alias_method :aa, :cols field = field_fetch('I') *************** *** 256,261 **** end end ! Matrix[*ma] ! when / -ARNDCQEGHILKMFPSTWYV / # 21x20/2 matrix (with gap) raise NotImplementedError --- 309,313 ---- end end ! @data['matrix'] = Matrix[*ma] when / -ARNDCQEGHILKMFPSTWYV / # 21x20/2 matrix (with gap) raise NotImplementedError *************** *** 268,278 **** def label_data ! label, data = get('M').split("\n", 2) ! if /M rows = (\S+), cols = (\S+)/.match(label) ! rows, cols = $1, $2 ! @rows = rows.split('') ! @cols = cols.split('') end - return data end --- 320,334 ---- def label_data ! if @data['data'] ! @data['data'] ! else ! label, data = get('M').split("\n", 2) ! if /M rows = (\S+), cols = (\S+)/.match(label) ! rows, cols = $1, $2 ! @rows = rows.split('') ! @cols = cols.split('') ! end ! @data['data'] = data end end *************** *** 296,301 **** p aax1.correlation_coefficient p aax1.index ! puts "### AAindex2 (HENS920102)" ! aax2 = Bio::AAindex2.new(Bio::Fetch.query('aaindex', 'HENS920102', 'raw')) p aax2.entry_id p aax2.definition --- 352,358 ---- p aax1.correlation_coefficient p aax1.index ! p aax1 ! puts "### AAindex2 (DAYM780301)" ! aax2 = Bio::AAindex2.new(Bio::Fetch.query('aaindex', 'DAYM780301', 'raw')) p aax2.entry_id p aax2.definition *************** *** 309,315 **** --- 366,375 ---- p aax2.matrix p aax2.matrix[2,2] + p aax2.matrix[2,3] + p aax2.matrix[4,3] p aax2.matrix.determinant p aax2.matrix.rank p aax2.matrix.transpose + p aax2 end From ngoto at pub.open-bio.org Wed Feb 22 08:38:43 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 08:38:43 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io flatfile.rb,1.43,1.44 Message-ID: <200602220838.k1M8chVL032682@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory pub.open-bio.org:/tmp/cvs-serv32672/lib/bio/io Modified Files: flatfile.rb Log Message: Completely rewritten. Please see Changes-0.7.rd for incompatible changes. Index: flatfile.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile.rb,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** flatfile.rb 29 Jan 2006 06:54:14 -0000 1.43 --- flatfile.rb 22 Feb 2006 08:38:41 -0000 1.44 *************** *** 2,26 **** # = bio/io/flatfile.rb - flatfile access wrapper class # ! # Copyright:: Copyright (C) 2001, 2002 GOTO Naohisa ! # License:: LGPL ! # ! #-- ! # 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. [...1570 lines suppressed...] + #fastaformat.is_prior_to(debug_last) + + a.rehash + return a + end + + end #class AutoDetect + end #class FlatFile end #module Bio if __FILE__ == $0 if ARGV.size == 2 *************** *** 500,502 **** end end - --- 1199,1200 ---- From ngoto at pub.open-bio.org Wed Feb 22 08:40:33 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 08:40:33 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io/flatfile index.rb,1.17,1.18 Message-ID: <200602220840.k1M8eXVL032748@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io/flatfile In directory pub.open-bio.org:/tmp/cvs-serv32738/lib/bio/io/flatfile Modified Files: index.rb Log Message: changed lisence to Ruby's Index: index.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile/index.rb,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** index.rb 22 Feb 2006 07:01:05 -0000 1.17 --- index.rb 22 Feb 2006 08:40:31 -0000 1.18 *************** *** 3,27 **** # # Copyright:: Copyright (C) 2002 ! # GOTO Naohisa ! # License:: LGPL # # $Id$ # - #-- - # 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 - #++ - # # = About Bio::FlatFileIndex # --- 3,11 ---- # # Copyright:: Copyright (C) 2002 ! # GOTO Naohisa ! # License:: Ruby's # # $Id$ # # = About Bio::FlatFileIndex # From ngoto at pub.open-bio.org Wed Feb 22 08:41:05 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 08:41:05 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io/flatfile indexer.rb,1.22,1.23 Message-ID: <200602220841.k1M8f5VL032765@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io/flatfile In directory pub.open-bio.org:/tmp/cvs-serv32755/lib/bio/io/flatfile Modified Files: indexer.rb Log Message: changes were made due to the Bio::FlatFile internal change Index: indexer.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile/indexer.rb,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** indexer.rb 29 Jan 2006 06:54:14 -0000 1.22 --- indexer.rb 22 Feb 2006 08:41:03 -0000 1.23 *************** *** 1,20 **** # ! # bio/io/flatfile/indexer.rb - OBDA flatfile indexer ! # ! # Copyright (C) 2002 GOTO Naohisa ! # ! # 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$ --- 1,7 ---- # ! # = bio/io/flatfile/indexer.rb - OBDA flatfile indexer # ! # Copyright:: Copyright (C) 2002 GOTO Naohisa ! # License:: Ruby's # # $Id$ *************** *** 133,140 **** def each - pos = @flatfile.pos @flatfile.each do |x| @entry = x ! len = @flatfile.entry_raw.length begin yield pos, len --- 120,127 ---- def each @flatfile.each do |x| @entry = x ! pos = @flatfile.entry_start_pos ! len = @flatfile.entry_ended_pos - @flatfile.entry_start_pos begin yield pos, len *************** *** 153,157 **** end end #rescue - pos = @flatfile.pos end end --- 140,143 ---- *************** *** 206,218 **** end self.add_secondary_namespaces(*sec_names) - end - def open_flatfile(fileid, file) - super - @flatfile.pos = 0 - begin - pos = @flatfile.pos - line = @flatfile.gets - end until (!line or line =~ /^LOCUS /) - @flatfile.pos = pos end end #class GenBankParser --- 192,195 ---- From ngoto at pub.open-bio.org Wed Feb 22 08:43:17 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 08:43:17 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db nbrf.rb,1.7,1.8 Message-ID: <200602220843.k1M8hHVL000347@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv337/lib/bio/db Modified Files: nbrf.rb Log Message: * changed license to Ruby's. * DELIMITER is changed like Bio::FastaFormat. * Added new constant DELIMITER_OVERRUN for Bio::FlatFile. Index: nbrf.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/nbrf.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** nbrf.rb 18 Dec 2005 15:58:41 -0000 1.7 --- nbrf.rb 22 Feb 2006 08:43:15 -0000 1.8 *************** *** 2,24 **** # = bio/db/nbrf.rb - NBRF/PIR format sequence data class # ! # Copyright:: Copyright (C) 2001-2003 GOTO Naohisa # Copyright (C) 2001-2002 KATAYAMA Toshiaki ! # License:: LGPL ! # ! #-- ! # 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$ --- 2,8 ---- # = bio/db/nbrf.rb - NBRF/PIR format sequence data class # ! # Copyright:: Copyright (C) 2001-2003,2006 Naohisa Goto # Copyright (C) 2001-2002 KATAYAMA Toshiaki ! # License:: Ruby's # # $Id$ *************** *** 45,49 **** # Delimiter of each entry. Bio::FlatFile uses it. ! DELIMITER = RS = "*\n" # Creates a new NBRF object. It stores the comment and sequence --- 29,41 ---- # Delimiter of each entry. Bio::FlatFile uses it. ! DELIMITER = RS = "\n>" ! ! # (Integer) excess read size included in DELIMITER. ! DELIMITER_OVERRUN = 1 # '>' ! ! #-- ! # Note: DELIMITER is changed due to the change of Bio::FlatFile. ! # DELIMITER = RS = "*\n" ! #++ # Creates a new NBRF object. It stores the comment and sequence From ngoto at pub.open-bio.org Wed Feb 22 08:44:49 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 08:44:49 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db fasta.rb,1.24,1.25 Message-ID: <200602220844.k1M8inVL000375@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv365/lib/bio/db Modified Files: fasta.rb Log Message: added a new constant DELIMITER_OVERRUN for Bio::FlatFile. Index: fasta.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/fasta.rb,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** fasta.rb 14 Feb 2006 13:42:40 -0000 1.24 --- fasta.rb 22 Feb 2006 08:44:46 -0000 1.25 *************** *** 139,142 **** --- 139,145 ---- DELIMITER = RS = "\n>" + # (Integer) excess read size included in DELIMITER. + DELIMITER_OVERRUN = 1 # '>' + # The comment line of the FASTA formatted data. attr_accessor :definition From ngoto at pub.open-bio.org Wed Feb 22 08:46:17 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 08:46:17 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/blast format0.rb, 1.16, 1.17 wublast.rb, 1.5, 1.6 Message-ID: <200602220846.k1M8kHVL000400@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/blast In directory pub.open-bio.org:/tmp/cvs-serv384/lib/bio/appl/blast Modified Files: format0.rb wublast.rb Log Message: * changed license to Ruby's. * added a new constant DELIMITER_OVERRUN for Bio::FlatFile. Index: wublast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/wublast.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** wublast.rb 18 Dec 2005 15:58:39 -0000 1.5 --- wublast.rb 22 Feb 2006 08:46:15 -0000 1.6 *************** *** 3,23 **** # # Copyright:: Copyright (C) 2003 GOTO Naohisa ! # License:: LGPL ! # ! #-- ! # 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$ --- 3,7 ---- # # Copyright:: Copyright (C) 2003 GOTO Naohisa ! # License:: Ruby's # # $Id$ *************** *** 338,341 **** --- 322,328 ---- # Delimter of each entry for TBLAST. Bio::FlatFile uses it. DELIMITER = RS = "\nTBLAST" + + # (Integer) excess read size included in DELIMITER. + DELIMITER_OVERRUN = 6 # "TBLAST" end #class Report_TBlast Index: format0.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/format0.rb,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** format0.rb 1 Nov 2005 05:32:23 -0000 1.16 --- format0.rb 22 Feb 2006 08:46:15 -0000 1.17 *************** *** 3,24 **** # # Author:: Naohisa GOTO ! # Copyright:: Copyright (C) 2003 GOTO Naohisa ! # License:: LGPL ! # ! #-- ! # 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$ --- 3,8 ---- # # Author:: Naohisa GOTO ! # Copyright:: Copyright (C) 2003-2006 GOTO Naohisa ! # License:: Ruby's # # $Id$ *************** *** 57,60 **** --- 41,47 ---- DELIMITER = RS = "\nBLAST" + # (Integer) excess read size included in DELIMITER. + DELIMITER_OVERRUN = 5 # "BLAST" + # Opens file by using Bio::FlatFile.open. def self.open(filename, *mode) *************** *** 1202,1205 **** --- 1189,1195 ---- # Delimter of each entry for TBLAST. Bio::FlatFile uses it. DELIMITER = RS = "\nTBLAST" + + # (Integer) excess read size included in DELIMITER. + DELIMITER_OVERRUN = 6 # "TBLAST" end #class Report_TBlast From ngoto at pub.open-bio.org Wed Feb 22 08:46:17 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 08:46:17 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/spidey report.rb,1.8,1.9 Message-ID: <200602220846.k1M8kHVL000396@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/spidey In directory pub.open-bio.org:/tmp/cvs-serv384/lib/bio/appl/spidey Modified Files: report.rb Log Message: * changed license to Ruby's. * added a new constant DELIMITER_OVERRUN for Bio::FlatFile. Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/spidey/report.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** report.rb 18 Dec 2005 15:58:41 -0000 1.8 --- report.rb 22 Feb 2006 08:46:15 -0000 1.9 *************** *** 3,23 **** # # Copyright:: Copyright (C) 2004 GOTO Naohisa ! # License:: LGPL ! # ! #-- ! # 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$ --- 3,7 ---- # # Copyright:: Copyright (C) 2004 GOTO Naohisa ! # License:: Ruby's # # $Id$ *************** *** 45,48 **** --- 29,34 ---- # Spidey report parser class. + # Please see bio/appl/spidey/report.rb for details. + # # Its object may contain some Bio::Spidey::Report::Hit objects. class Report #< DB *************** *** 53,56 **** --- 39,45 ---- # Delimiter of each entry. Bio::FlatFile uses it. DELIMITER = RS = "\n--SPIDEY " + + # (Integer) excess read size included in DELIMITER. + DELIMITER_OVERRUN = 9 # "--SPIDEY ".length # Creates a new Bio::Spidey::Report object from String. From ngoto at pub.open-bio.org Wed Feb 22 09:15:24 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 09:15:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io flatfile.rb,1.44,1.45 Message-ID: <200602220915.k1M9FOVL000832@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory pub.open-bio.org:/tmp/cvs-serv822/lib/bio/io Modified Files: flatfile.rb Log Message: changed HEADER to FLATFILE_HEADER. Index: flatfile.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile.rb,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** flatfile.rb 22 Feb 2006 08:38:41 -0000 1.44 --- flatfile.rb 22 Feb 2006 09:15:22 -0000 1.45 *************** *** 273,277 **** # It sees following constants in the given class. # DELIMITER:: (String) delimiter indicates the end of a entry. ! # HEADER:: (String) start of a entry, located on head of a line. # DELIMITER_OVERRUN:: (Integer) excess read size included in DELIMITER. # --- 273,277 ---- # It sees following constants in the given class. # DELIMITER:: (String) delimiter indicates the end of a entry. ! # FLATFILE_HEADER:: (String) start of a entry, located on head of a line. # DELIMITER_OVERRUN:: (Integer) excess read size included in DELIMITER. # *************** *** 283,287 **** @stream = bstream @delimiter = klass::DELIMITER rescue nil ! @header = klass::HEADER rescue nil # for specific classes' benefit unless header --- 283,287 ---- @stream = bstream @delimiter = klass::DELIMITER rescue nil ! @header = klass::FLATFILE_HEADER rescue nil # for specific classes' benefit unless header *************** *** 306,310 **** # If @header is not nil, it reads till the contents of @header # comes at the head of a line. ! # If correct HEADER is found, returns true. # Otherwise, returns nil. def skip_leader --- 306,310 ---- # If @header is not nil, it reads till the contents of @header # comes at the head of a line. ! # If correct FLATFILE_HEADER is found, returns true. # Otherwise, returns nil. def skip_leader From ngoto at pub.open-bio.org Wed Feb 22 10:01:29 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 10:01:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io flatfile.rb,1.45,1.46 Message-ID: <200602221001.k1MA1TVL000938@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory pub.open-bio.org:/tmp/cvs-serv917/lib/bio/io Modified Files: flatfile.rb Log Message: in Bio::FlatFile::AutoDetect#autodetect_flatfile calls autodetect rules before reading the stream if meta information (file path, etc) is available. Index: flatfile.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile.rb,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** flatfile.rb 22 Feb 2006 09:15:22 -0000 1.45 --- flatfile.rb 22 Feb 2006 10:01:27 -0000 1.46 *************** *** 989,994 **** # Returns nil if failed. def autodetect_flatfile(ff, lines = 31) stream = ff.instance_eval { @stream } ! meta = { :path => stream.path } 1.upto(lines) do |x| break unless line = stream.prefetch_gets --- 989,1006 ---- # Returns nil if failed. def autodetect_flatfile(ff, lines = 31) + meta = {} stream = ff.instance_eval { @stream } ! begin ! path = stream.path ! rescue NameError ! end ! if path then ! meta[:path] = path ! # call autodetect onece with meta and without any read action ! if r = self.autodetect(stream.prefetch_buffer, meta) ! return r ! end ! end ! # reading stream 1.upto(lines) do |x| break unless line = stream.prefetch_gets From ngoto at pub.open-bio.org Wed Feb 22 15:09:47 2006 From: ngoto at pub.open-bio.org (Naohisa Goto) Date: Wed, 22 Feb 2006 15:09:47 +0000 Subject: [BioRuby-cvs] bioruby/doc Changes-0.7.rd,1.14,1.15 Message-ID: <200602221509.k1MF9lVL001795@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/doc In directory pub.open-bio.org:/tmp/cvs-serv1785/doc Modified Files: Changes-0.7.rd Log Message: added Bio::FlatFile incompatible changes. Index: Changes-0.7.rd =================================================================== RCS file: /home/repository/bioruby/bioruby/doc/Changes-0.7.rd,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Changes-0.7.rd 16 Jan 2006 15:25:43 -0000 1.14 --- Changes-0.7.rd 22 Feb 2006 15:09:45 -0000 1.15 *************** *** 227,230 **** --- 227,252 ---- * There are more and more changes to be written... + --- Bio::FlatFile + + In 0.7.2: + + * Bio::FlatFile.open, Bio::FlatFile.auto and Bio::FlatFile.new are changed + not to accept the last argument to specify raw mode, e.g. :raw => true, + :raw => false, true or false. Instead, please use Bio::FlatFile#raw= + method after creating a new object. + * Now, first argument of Bio::FlatFile.open, which shall be a database + class or nil, can be omitted, and you can do + Bio::FlatFile.open(filename, ...). Note that + Bio::FlatFile.open(dbclass, filaname, ...) is still available. + * Bio::FlatFile#io is obsoleted. Please use Bio::FlatFile#to_io instead. + * When reading GenBank or GenPept files, comments at the head of the file + before the first "LOCUS" lines are now skipped by default. + When reading other file formats, white space characters are skipped. + * File format autodetection routine is completely rewritten. + If it fails to determine data format which was previously determined, + please report us with the data. + * Internal structure is now completely changed. Codes depend on the internal + structure (which is not recommended) would not work. + === Deleted files From k at pub.open-bio.org Thu Feb 23 04:51:25 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Thu, 23 Feb 2006 04:51:25 +0000 Subject: [BioRuby-cvs] bioruby/doc KEGG_API.rd, 1.1, 1.2 KEGG_API.rd.ja, 1.7, 1.8 Message-ID: <200602230451.k1N4pPVL004729@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/doc In directory pub.open-bio.org:/tmp/cvs-serv4725/doc Modified Files: KEGG_API.rd KEGG_API.rd.ja Log Message: * updated for KEGG API v5.0 Index: KEGG_API.rd.ja =================================================================== RCS file: /home/repository/bioruby/bioruby/doc/KEGG_API.rd.ja,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** KEGG_API.rd.ja 31 Aug 2005 13:29:01 -0000 1.7 --- KEGG_API.rd.ja 23 Feb 2006 04:51:23 -0000 1.8 *************** *** 1,7 **** =begin ! ! $Id$ ! ! Copyright (C) 2003-2005 Toshiaki Katayama = KEGG API --- 1,7 ---- =begin ! ! $Id$ ! ! Copyright (C) 2003-2006 Toshiaki Katayama = KEGG API *************** *** 30,33 **** --- 30,34 ---- * (()), (()) * (()), (()) + * (()), (()) * (()) * (()) *************** *** 39,45 **** (()), (()), ! (()) * (()) * (()) * (()) * (()), --- 40,59 ---- (()), (()), ! (()), ! (()) * (()) * (()) + * (()), + (()) + * (()), + (()), + (()), + (()), + (()), + (()), + (()), + (()), + (()), + (()) * (()) * (()), *************** *** 63,69 **** * (()), (()), (()), ! (()) ! * (()), (()), (()), --- 77,86 ---- * (()), (()), + (()), (()), ! (()), ! (()) ! * (()), ! (()), (()), (()), *************** *** 78,93 **** (()) * (()) - * (()), - (()) - * (()), - (()), - (()), - (()), - (()), - (()), - (()), - (()), - (()), - (()) * (()) * (()) --- 95,98 ---- *************** *** 634,637 **** --- 639,654 ---- ?????? LinkDBRelation ???????????????????????? + + PathwayElement ?? + + element_id ?????????????????????????????????????????? ID (int) + type ?????????????????? ("gene", "enzyme" ????) (string) + names ???????????????????????????????????? (ArrayOfstring) + components ?????????????????????????????????????????????? (ArrayOfint) + + + ArrayOfPathwayElement ?? + + ?????? PathwayElement ???????????????????????? + + === ???????????? *************** *** 740,743 **** --- 757,772 ---- btit("hsa:1798 mmu:13478 dme:CG5287-PA cel:Y60A3A.14") + --- bconv(string) + + ?????????????????? ID ?? KEGG ?? ID ???????????????????????????????????? + ???????? NCBI Gene ID, NCBI GI, GenBank ID, UniProt ID ?????? + ?????????????????????????? ID ?????? ID ?????????????????????????????????? + + ?????? + string + + ???? + # NCBI GI ?? Gene ID ?? KEGG genes_id ?????? + serv.bconv("ncbi-gi:10047086 ncbi-gi:10047090 ncbi-geneid:14751") ==== LinkDB *************** *** 756,759 **** --- 785,925 ---- get_linkdb_by_entry('eco:b0002', 'pathway', 11, 10) + + ?????????????????????? + + --- get_genes_by_enzyme(enzyme_id, org) + + ???????????????????????????????????????????????????????????????????? + + ?????? + ArrayOfstring (genes_id) + + ???? + # ???????? 1.1.1.1 ???????????????????????????? + get_genes_by_enzyme('ec:1.1.1.1', 'eco') + + --- get_enzymes_by_gene(genes_id) + + ???????????????????????????????????????????????????? + + ?????? + ArrayOfstring (enzyme_id) + + ???? + # ???????????? 'eco:b0002' ?????????????????? + get_enzymes_by_gene(eco:b0002) + + + + ???????????????????????????????? + + --- get_enzymes_by_compound(compound_id) + + ???????????????????????????????????????????????????? + + ?????? + ArrayOfstring (compound_id) + + ???? + # ?????? 'cpd:C00345' ?????????????????????????? + get_enzymes_by_compound('cpd:C00345') + + --- get_enzymes_by_glycan(compound_id) + + ?????????????????????????????????????????????????? + + ?????? + ArrayOfstring (glycan_id) + + ???? + # ???? 'gl:G00001' ?????????????????????????? + get_enzymes_by_glycan('gl:G00001') + + --- get_enzymes_by_reaction(reaction_id) + + ?????????????????????????????????????????????????????????????? + + ?????? + ArrayOfstring (reaction_id) + + ???? + # ???????????????? R00100 ?????????????????? + get_enzymes_by_reaction('rn:R00100') + + --- get_compounds_by_enzyme(enzyme_id) + + ???????????????????????????????????????????????????? + + ?????? + ArrayOfstring (compound_id) + + ???? + # ???????? 'ec:2.7.1.12' ???????????????????????????? + get_compounds_by_enzyme('ec:2.7.1.12') + + --- get_compounds_by_reaction(reaction_id) + + ???????????????????????????????????????????????????????? + + ?????? + ArrayOfstring (compound_id) + + ???? + # ???????????????? 'rn:R00100' ???????????????????????????? + get_compounds_by_reaction('rn:R00100') + + --- get_glycans_by_enzyme(enzyme_id) + + ?????????????????????????????????????????????????? + + ?????? + ArrayOfstring (glycan_id) + + ???? + # ???????? 'ec:2.4.1.141' ?????????????????????????? + get_glycans_by_enzyme('ec:2.4.1.141') + + --- get_glycans_by_reaction(reaction_id) + + ?????????????????????????????????????????????????????? + + ?????? + ArrayOfstring (glycan_id) + + ???? + # ???????????????? 'rn:R06164' ?????????????????????????? + get_glycans_by_reaction('rn:R06164') + + --- get_reactions_by_enzyme(enzyme_id) + + ?????????????????????????????????????????????????????????? + + ?????? + ArrayOfstring (reaction_id) + + ???? + # ???????? 'ec:2.7.1.12' ?????????????????????????????????????? + get_reactions_by_enzyme('ec:2.7.1.12') + + --- get_reactions_by_compound(compound_id) + + ???????????????????????????????????????????????????????? + + ?????? + ArrayOfstring (reaction_id) + + ???? + # ?????? 'cpd:C00199' ?????????????????????????????????????????? + get_reactions_by_compound('cpd:C00199') + + --- get_reactions_by_glycan(glycan_id) + + ?????????????????????????????????????????????????????? + + ?????? + ArrayOfstring (reaction_id) + + ???? + # ???? 'gl:G00001' ?????????????????????????????????????????? + get_reactions_by_glycan('gl:G00001') + ==== SSDB *************** *** 1009,1012 **** --- 1175,1217 ---- color_pathway_by_objects('path:eco00053', obj_list, fg_list, bg_list) + --- color_pathway_by_elements(pathway_id, element_id_list, fg_color_list, bg_color_list) + + ???????? element_id ?????????????????????????????????????????????????????? + ?????????????????? fg_color_list ???????????????????? bg_color_list ?? + ???????????????????????????????????? URL ????????????object_id_list ?? + fg_color_list, bg_color_list ?????????????????????????????????????? + ???????????????? + + KEGG PATHWAY ?????????????????????????????????????????????????????????? + ???????????????????????????????????????????????????????????????????? + ?????????????? color_pathway_by_objects ???????????????????????????? + ??????????????color_pathway_by_elements ?????????????????????????? + + element_id ?? KEGG PATHWAY ?? XML ?????????? KGML ?? ?????? + ???????????????????????????????????????????????????????????????????? + ???????????????????????? element_id ?? get_elements_by_pathway ?????????? + PathwayElement ?????????????????????????????????????????????? + PathwayElement ?? type ?? name ???????????????????????????????????? + ????????????element_id ?????????????????????????????????????? + + KGML ???????????????????????????????????????????????? + + * (()) + + ???????? + string (URL) + + ???? + # ?????????????????? path:bsu00010 ???????????????? + # ?????? bsu:BG11350 (element_id 78, ec:3.2.1.86) ??????/???????? + # ?????? bsu:BG11203 (element_id 79, ec:3.2.1.86) ??????/???????? + # ?????? bsu:BG11685 (element_id 51, ec:2.7.1.2) ??????/???????? + # ?????? bsu:BG11685 (element_id 47, ec:2.7.1.2) ??????/???????? + # ?????????????????????? URL ???????????? + element_id_list = [ 78, 79, 51, 47 ] + fg_list = [ '#ff0000', '#0000ff', '#ff0000', '#0000ff' ] + bg_list = [ '#ffff00', '#ffff00', '#ffcc00', '#ffcc00' ] + color_pathway_by_elements('path:bsu00010', element_id_list, fg_list, bg_list) + --- get_html_of_marked_pathway_by_objects(pathway_id, object_id_list) *************** *** 1027,1031 **** ?????????????????????????????????????? HTML ???????? URL ?????? ! ???????????? 'color_pathway_by_object' ?????????????? ?????? --- 1232,1236 ---- ?????????????????????????????????????? HTML ???????? URL ?????? ! ???????????? 'color_pathway_by_objects' ?????????????? ?????? *************** *** 1041,1046 **** --- 1246,1296 ---- get_html_of_colored_pathway_by_objects('path:eco00970', obj_list, fg_list, bg_list) + --- get_html_of_colored_pathway_by_elements(pathway_id, element_id_list, fg_color_list, bg_color_list) + + ?????????????????????????????????????? HTML ???????? URL ?????? + ???????????? 'color_pathway_by_elements' ?????????????? + + ?????? + string (URL) + + ???? + # ?????????????????? path:bsu00010 ???????????????? + # ?????? bsu:BG11350 (element_id 78, ec:3.2.1.86) ??????/???????? + # ?????? bsu:BG11203 (element_id 79, ec:3.2.1.86) ??????/???????? + # ?????? bsu:BG11685 (element_id 51, ec:2.7.1.2) ??????/???????? + # ?????? bsu:BG11685 (element_id 47, ec:2.7.1.2) ??????/???????? + # ?????????????????????????????????????????? HTML ?? URL ???????????? + element_id_list = [ 78, 79, 51, 47 ] + fg_list = [ '#ff0000', '#0000ff', '#ff0000', '#0000ff' ] + bg_list = [ '#ffff00', '#ffff00', '#ffcc00', '#ffcc00' ] + color_pathway_by_elements('path:bsu00010', element_id_list, fg_list, bg_list) + + ?????????????????????????????? + --- get_elements_by_pathway(pathway_id) + + ???????????????????????????????????????????????????????????????????? + ???????????????? color_pathway_by_elements ???????????????????????????? + + ?????? + ArrayOfPathwayElement + + ???? + # ?????????????????? path:bsu00010 ?????????????? PathwayElement ?? + # ?????????????????? + get_elements_by_pathway('path:bsu00010') + + # Ruby ???????? bsu:BG11350, bsu:BG11203 ?? bsu:BG11685 ?? element_id ?? + # ?????????? + elems = serv.get_elements_by_pathway('path:bsu00010') + genes = [ 'bsu:BG11350', 'bsu:BG11203', 'bsu:BG11685' ] + elems.each do |elem| + genes.each do |gene| + if elem.names.include?(gene) + puts gene, elem.element_id + end + end + end + --- get_genes_by_pathway(pathway_id) *************** *** 1097,1101 **** ???? # ?????????????????? 00260 ?????????????????????????????????? ! get_reactions_by_pathways('path:eco00260') --- get_kos_by_pathway(pathway_id) --- 1347,1351 ---- ???? # ?????????????????? 00260 ?????????????????????????????????? ! get_reactions_by_pathway('path:eco00260') --- get_kos_by_pathway(pathway_id) *************** *** 1200,1341 **** - + ?????????????????????? - - --- get_genes_by_enzyme(enzyme_id, org) - - ???????????????????????????????????????????????????????????????????? - - ?????? - ArrayOfstring (genes_id) - - ???? - # ???????? 1.1.1.1 ???????????????????????????? - get_genes_by_enzyme('ec:1.1.1.1', 'eco') - - --- get_enzymes_by_gene(genes_id) - - ???????????????????????????????????????????????????? - - ?????? - ArrayOfstring (enzyme_id) - - ???? - # ???????????? 'eco:b0002' ?????????????????? - get_enzymes_by_gene(eco:b0002) - - - + ???????????????????????????????? - - --- get_enzymes_by_compound(compound_id) - - ???????????????????????????????????????????????????? - - ?????? - ArrayOfstring (compound_id) - - ???? - # ?????? 'cpd:C00345' ?????????????????????????? - get_enzymes_by_compound('cpd:C00345') - - --- get_enzymes_by_glycan(compound_id) - - ?????????????????????????????????????????????????? - - ?????? - ArrayOfstring (glycan_id) - - ???? - # ???? 'gl:G00001' ?????????????????????????? - get_enzymes_by_glycan('gl:G00001') - - --- get_enzymes_by_reaction(reaction_id) - - ?????????????????????????????????????????????????????????????? - - ?????? - ArrayOfstring (reaction_id) - - ???? - # ???????????????? R00100 ?????????????????? - get_enzymes_by_reaction('rn:R00100') - - --- get_compounds_by_enzyme(enzyme_id) - - ???????????????????????????????????????????????????? - - ?????? - ArrayOfstring (compound_id) - - ???? - # ???????? 'ec:2.7.1.12' ???????????????????????????? - get_compounds_by_enzyme('ec:2.7.1.12') - - --- get_compounds_by_reaction(reaction_id) - - ???????????????????????????????????????????????????????? - - ?????? - ArrayOfstring (compound_id) - - ???? - # ???????????????? 'rn:R00100' ???????????????????????????? - get_compounds_by_reaction('rn:R00100') - - --- get_glycans_by_enzyme(enzyme_id) - - ?????????????????????????????????????????????????? - - ?????? - ArrayOfstring (glycan_id) - - ???? - # ???????? 'ec:2.4.1.141' ?????????????????????????? - get_glycans_by_enzyme('ec:2.4.1.141') - - --- get_glycans_by_reaction(reaction_id) - - ?????????????????????????????????????????????????????? - - ?????? - ArrayOfstring (glycan_id) - - ???? - # ???????????????? 'rn:R06164' ?????????????????????????? - get_glycans_by_reaction('rn:R06164') - - --- get_reactions_by_enzyme(enzyme_id) - - ?????????????????????????????????????????????????????????? - - ?????? - ArrayOfstring (reaction_id) - - ???? - # ???????? 'ec:2.7.1.12' ?????????????????????????????????????? - get_reactions_by_enzyme('ec:2.7.1.12') - - --- get_reactions_by_compound(compound_id) - - ???????????????????????????????????????????????????????? - - ?????? - ArrayOfstring (reaction_id) - - ???? - # ?????? 'cpd:C00199' ?????????????????????????????????????????? - get_reactions_by_compound('cpd:C00199') - - --- get_reactions_by_glycan(glycan_id) - - ?????????????????????????????????????????????????????? - - ?????? - ArrayOfstring (reaction_id) - - ???? - # ???? 'gl:G00001' ?????????????????????????????????????????? - get_reactions_by_glycan('gl:G00001') - - ==== GENES --- 1450,1453 ---- *************** *** 1395,1399 **** == Notes ! Last updated: May 31, 2005 =end --- 1507,1512 ---- == Notes ! Last updated: Feb 17, 2006 =end + Index: KEGG_API.rd =================================================================== RCS file: /home/repository/bioruby/bioruby/doc/KEGG_API.rd,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** KEGG_API.rd 31 Aug 2005 13:29:01 -0000 1.1 --- KEGG_API.rd 23 Feb 2006 04:51:23 -0000 1.2 *************** *** 3,7 **** $Id$ ! Copyright (C) 2003-2005 Toshiaki Katayama = KEGG API --- 3,7 ---- $Id$ ! Copyright (C) 2003-2006 Toshiaki Katayama = KEGG API *************** *** 80,83 **** --- 80,84 ---- * (()), (()) * (()), (()) + * (()), (()) * (()) * (()) *************** *** 89,95 **** (()), (()), ! (()) * (()) * (()) * (()) * (()), --- 90,109 ---- (()), (()), ! (()), ! (()) * (()) * (()) + * (()), + (()) + * (()), + (()), + (()), + (()), + (()), + (()), + (()), + (()), + (()), + (()) * (()) * (()), *************** *** 113,119 **** * (()), (()), (()), ! (()) ! * (()), (()), (()), --- 127,136 ---- * (()), (()), + (()), (()), ! (()), ! (()) ! * (()), ! (()), (()), (()), *************** *** 128,143 **** (()) * (()) - * (()), - (()) - * (()), - (()), - (()), - (()), - (()), - (()), - (()), - (()), - (()), - (()) * (()) * (()) --- 145,148 ---- *************** *** 508,513 **** === Terminology ! * 'org' is a three-letter organism code used in KEGG. The list can be ! found at (see the description of the list_organisms method below): * (()) --- 513,519 ---- === Terminology ! * 'org' is a three-letter (or four-letter) organism code used in KEGG. ! The list can be found at (see the description of the list_organisms ! method below): * (()) *************** *** 623,627 **** # * get_similarity_between_genes ! This problem is fixed in the version 3.2. + ArrayOfSSDBRelation --- 629,633 ---- # * get_similarity_between_genes ! This problem is fixed in the KEGG API version 3.2. + ArrayOfSSDBRelation *************** *** 672,675 **** --- 678,695 ---- ArrayOfLinkDBRelation data type is a list of the LinkDBRelation data type. + + PathwayElement + + PathwayElement data type contains the following fields: + + element_id unique identifier of the object on the pathway (int) + type type of the object ("gene", "enzyme" etc.) (string) + names array of names of the object (ArrayOfstring) + components array of element_ids of the group components (ArrayOfint) + + + ArrayOfPathwayElement + + ArrayOfPathwayElement data type is a list of the PathwayElement data type. + + === Methods *************** *** 770,773 **** --- 790,806 ---- btit("hsa:1798 mmu:13478 dme:CG5287-PA cel:Y60A3A.14") + --- bconv(string) + + The bconv command converts external IDs (NCBI GI, NCBI GeneID, GenBank ID, + and UniProt ID) to KEGG IDs. The result is the tab separated pair of the + given ID and the converted ID in each line. + + Return value: + string + + Example: + # Convert NCBI GI and NCBI GeneID to KEGG genes_id + serv.bconv("ncbi-gi:10047086 ncbi-gi:10047090 ncbi-geneid:14751") + ==== LinkDB *************** *** 785,788 **** --- 818,970 ---- get_linkdb_by_entry('eco:b0002', 'pathway', 11, 10) + + Relation among genes and enzymes + + --- get_genes_by_enzyme(enzyme_id, org) + + Retrieve all genes of the given organism. + + Return value: + ArrayOfstring (genes_id) + + Example: + # Returns all the GENES entry IDs in E.coli genome which are assigned + # EC number ec:1.2.1.1 + get_genes_by_enzyme('ec:1.2.1.1', 'eco') + + --- get_enzymes_by_gene(genes_id) + + Retrieve all the EC numbers which are assigned to the given gene. + + Return value: + ArrayOfstring (enzyme_id) + + Example: + # Returns the EC numbers which are assigned to E.coli genes b0002 + get_enzymes_by_gene('eco:b0002') + + + + Relation among enzymes, compounds and reactions + + --- get_enzymes_by_compound(compound_id) + + Retrieve all enzymes which have a link to the given compound_id. + + Return value: + ArrayOfstring (enzyme_id) + + Example: + # Returns the ENZYME entry IDs which have a link to the COMPOUND entry, + # 'cpd:C00345' + get_enzymes_by_compound('cpd:C00345') + + --- get_enzymes_by_glycan(glycan_id) + + Retrieve all enzymes which have a link to the given glycan_id. + + Return value: + ArrayOfstring (enzyme_id) + + Example + # Returns the ENZYME entry IDs which have a link to the GLYCAN entry, + # 'gl:G00001' + get_enzymes_by_glycan('gl:G00001') + + --- get_enzymes_by_reaction(reaction_id) + + Retrieve all enzymes which have a link to the given reaction_id. + + Return value: + ArrayOfstring (enzyme_id) + + Example: + # Returns the ENZYME entry IDs which have a link to the REACTION entry, + # 'rn:R00100'. + get_enzymes_by_reaction('rn:R00100') + + --- get_compounds_by_enzyme(enzyme_id) + + Retrieve all compounds which have a link to the given enzyme_id. + + Return value: + ArrayOfstring (compound_id) + + Example: + # Returns the COMPOUND entry IDs which have a link to the ENZYME entry, + # 'ec:2.7.1.12'. + get_compounds_by_enzyme('ec:2.7.1.12') + + --- get_compounds_by_reaction(reaction_id) + + Retrieve all compounds which have a link to the given reaction_id. + + Return value: + ArrayOfstring (compound_id) + + Example: + # Returns the COMPOUND entry IDs which have a link to the REACTION entry, + # 'rn:R00100' + get_compounds_by_reaction('rn:R00100') + + --- get_glycans_by_enzyme(enzyme_id) + + Retrieve all glycans which have a link to the given enzyme_id. + + Return value: + ArrayOfstring (glycan_id) + + Example + # Returns the GLYCAN entry IDs which have a link to the ENZYME entry, + # 'ec:2.4.1.141' + get_glycans_by_enzyme('ec:2.4.1.141') + + --- get_glycans_by_reaction(reaction_id) + + Retrieve all glycans which have a link to the given reaction_id. + + Return value: + ArrayOfstring (glycan_id) + + Example + # Returns the GLYCAN entry IDs which have a link to the REACTION entry, + # 'rn:R06164' + get_glycans_by_reaction('rn:R06164') + + --- get_reactions_by_enzyme(enzyme_id) + + Retrieve all reactions which have a link to the given enzyme_id. + + Return value: + ArrayOfstring (reaction_id) + + Example: + # Returns the REACTION entry IDs which have a link to the ENZYME entry, + # 'ec:2.7.1.12' + get_reactions_by_enzyme('ec:2.7.1.12') + + --- get_reactions_by_compound(compound_id) + + Retrieve all reactions which have a link to the given compound_id. + + Return value: + ArrayOfstring (reaction_id) + + Example: + # Returns the REACTION entry IDs which have a link to the COMPOUND entry, + # 'cpd:C00199' + get_reactions_by_compound('cpd:C00199') + + --- get_reactions_by_glycan(glycan_id) + + Retrieve all reactions which have a link to the given glycan_id. + + Return value: + ArrayOfstring (reaction_id) + + Example + # Returns the REACTION entry IDs which have a link to the GLYCAN entry, + # 'gl:G00001' + get_reactions_by_glycan('gl:G00001') + + ==== SSDB *************** *** 1031,1034 **** --- 1213,1252 ---- color_pathway_by_objects('path:eco00260', obj_list, fg_list, bg_list) + --- color_pathway_by_elements(pathway_id, element_id_list, fg_color_list, bg_color_list) + + Color the objects (rectangles and circles on a pathway map) corresponding + to the given 'element_id_list' with the specified colors and return the + URL of the colored image. 'fg_color_list' is used for specifying the + color of text and border of the objects with given 'element_id_list' and + 'bg_color_list' is used for its background area. The order of colors in + these lists correspond with the order of objects in the 'element_id_list' + list. + + This method is useful to specify which graphical object on the pathway + to be colored as there are some cases that multiple genes are assigned to + one rectangle or a gene is assigned to more than one rectangle on the + pathway map. The 'element_id' is an unique numerical identifier on the + pathway defined by the KGML (XML represeentation of the KEGG PATHWAY) + in the tag. List of the 'element_id's can be obtained by the + 'get_elements_by_pathway' method. + + For more details on KGML, see: + + * (()) + + Return value: + string (URL) + + Example: + # Returns the URL of the colored image of given pathway 'path:bsu00010' with + # * gene bsu:BG11350 (element_id 78, ec:3.2.1.86) colored in red on yellow + # * gene bsu:BG11203 (element_id 79, ec:3.2.1.86) colored in blue on yellow + # * gene bsu:BG11685 (element_id 51, ec:2.7.1.2) colored in red on orange + # * gene bsu:BG11685 (element_id 47, ec:2.7.1.2) colored in blue on orange + element_id_list = [ 78, 79, 51, 47 ] + fg_list = [ '#ff0000', '#0000ff', '#ff0000', '#0000ff' ] + bg_list = [ '#ffff00', '#ffff00', '#ffcc00', '#ffcc00' ] + color_pathway_by_elements('path:bsu00010', element_id_list, fg_list, bg_list) + --- get_html_of_marked_pathway_by_objects(pathway_id, object_id_list) *************** *** 1060,1066 **** Example: # Returns the URL of the HTML which can be passed to the web browser ! # as a clickable map of coloerd image of the given pathway 'path:eco00970' # with a gene 'eco:b4258' colored in gray/red, a compound 'cpd:C00135' ! # coloerd in green/yellow and a KO 'ko:K01881' colored in blue/orange. obj_list = ['eco:b4258', 'cpd:C00135', 'ko:K01881'] fg_list = ['gray', '#00ff00', 'blue'] --- 1278,1284 ---- Example: # Returns the URL of the HTML which can be passed to the web browser ! # as a clickable map of colored image of the given pathway 'path:eco00970' # with a gene 'eco:b4258' colored in gray/red, a compound 'cpd:C00135' ! # colored in green/yellow and a KO 'ko:K01881' colored in blue/orange. obj_list = ['eco:b4258', 'cpd:C00135', 'ko:K01881'] fg_list = ['gray', '#00ff00', 'blue'] *************** *** 1068,1074 **** --- 1286,1338 ---- get_html_of_colored_pathway_by_objects('path:eco00970', obj_list, fg_list, bg_list) + --- get_html_of_colored_pathway_by_elements(pathway_id, element_id_list, fg_color_list, bg_color_list) + + HTML version of the 'color_pathway_by_elements' method. + Color the objects corresponding to the given 'element_id_list' on the pathway + map with the specified colors and return the URL of the HTML containing the + colored image as a clickable map. + + Return value: + string (URL) + + Example: + # Returns the URL of the HTML which can be passed to the web browser as a + # clickable map of colored image of the given pathway 'path:bsu00010' with + # * gene bsu:BG11350 (element_id 78, ec:3.2.1.86) colored in red on yellow + # * gene bsu:BG11203 (element_id 79, ec:3.2.1.86) colored in blue on yellow + # * gene bsu:BG11685 (element_id 51, ec:2.7.1.2) colored in red on orange + # * gene bsu:BG11685 (element_id 47, ec:2.7.1.2) colored in blue on orange + element_id_list = [ 78, 79, 51, 47 ] + fg_list = [ '#ff0000', '#0000ff', '#ff0000', '#0000ff' ] + bg_list = [ '#ffff00', '#ffff00', '#ffcc00', '#ffcc00' ] + get_html_of_colored_pathway_by_elements('path:bsu00010', element_id_list, fg_list, bg_list) + Objects on the pathway + --- get_elements_by_pathway(pathway_id) + + Search all objects on the specified pathway. This method will be used in + combination with the color_pathway_by_elements method to distingish graphical + objects on the pathway sharing the same name. + + Return value: + ArrayOfPathwayElement + + Example: + # Returns list of PathwayElement on the pathway map 'path:bsu00010' + get_elements_by_pathway('path:bsu00010') + + # Find entry_ids for genes 'bsu:BG11350', 'bsu:BG11203' and 'bsu:BG11685' + # in Ruby language + elems = serv.get_elements_by_pathway('path:bsu00010') + genes = [ 'bsu:BG11350', 'bsu:BG11203', 'bsu:BG11685' ] + elems.each do |elem| + genes.each do |gene| + if elem.names.include?(gene) + puts gene, elem.element_id + end + end + end + --- get_genes_by_pathway(pathway_id) *************** *** 1227,1379 **** - + Relation among genes and enzymes - - --- get_genes_by_enzyme(enzyme_id, org) - - Retrieve all genes of the given organism. - - Return value: - ArrayOfstring (genes_id) - - Example: - # Returns all the GENES entry IDs in E.coli genome which are assigned - # EC number ec:1.2.1.1 - get_genes_by_enzyme('ec:1.2.1.1', 'eco') - - --- get_enzymes_by_gene(genes_id) - - Retrieve all the EC numbers which are assigned to the given gene. - - Return value: - ArrayOfstring (enzyme_id) - - Example: - # Returns the EC numbers which are assigned to E.coli genes b0002 - get_enzymes_by_gene('eco:b0002') - - - + Relation among enzymes, compounds and reactions - - --- get_enzymes_by_compound(compound_id) - - Retrieve all enzymes which have a link to the given compound_id. - - Return value: - ArrayOfstring (enzyme_id) - - Example: - # Returns the ENZYME entry IDs which have a link to the COMPOUND entry, - # 'cpd:C00345' - get_enzymes_by_compound('cpd:C00345') - - --- get_enzymes_by_glycan(glycan_id) - - Retrieve all enzymes which have a link to the given glycan_id. - - Return value: - ArrayOfstring (enzyme_id) - - Example - # Returns the ENZYME entry IDs which have a link to the GLYCAN entry, - # 'gl:G00001' - get_enzymes_by_glycan('gl:G00001') - - --- get_enzymes_by_reaction(reaction_id) - - Retrieve all enzymes which have a link to the given reaction_id. - - Return value: - ArrayOfstring (enzyme_id) - - Example: - # Returns the ENZYME entry IDs which have a link to the REACTION entry, - # 'rn:R00100'. - get_enzymes_by_reaction('rn:R00100') - - --- get_compounds_by_enzyme(enzyme_id) - - Retrieve all compounds which have a link to the given enzyme_id. - - Return value: - ArrayOfstring (compound_id) - - Example: - # Returns the COMPOUND entry IDs which have a link to the ENZYME entry, - # 'ec:2.7.1.12'. - get_compounds_by_enzyme('ec:2.7.1.12') - - --- get_compounds_by_reaction(reaction_id) - - Retrieve all compounds which have a link to the given reaction_id. - - Return value: - ArrayOfstring (compound_id) - - Example: - # Returns the COMPOUND entry IDs which have a link to the REACTION entry, - # 'rn:R00100' - get_compounds_by_reaction('rn:R00100') - - --- get_glycans_by_enzyme(enzyme_id) - - Retrieve all glycans which have a link to the given enzyme_id. - - Return value: - ArrayOfstring (glycan_id) - - Example - # Returns the GLYCAN entry IDs which have a link to the ENZYME entry, - # 'ec:2.4.1.141' - get_glycans_by_enzyme('ec:2.4.1.141') - - --- get_glycans_by_reaction(reaction_id) - - Retrieve all glycans which have a link to the given reaction_id. - - Return value: - ArrayOfstring (glycan_id) - - Example - # Returns the GLYCAN entry IDs which have a link to the REACTION entry, - # 'rn:R06164' - get_glycans_by_reaction('rn:R06164') - - --- get_reactions_by_enzyme(enzyme_id) - - Retrieve all reactions which have a link to the given enzyme_id. - - Return value: - ArrayOfstring (reaction_id) - - Example: - # Returns the REACTION entry IDs which have a link to the ENZYME entry, - # 'ec:2.7.1.12' - get_reactions_by_enzyme('ec:2.7.1.12') - - --- get_reactions_by_compound(compound_id) - - Retrieve all reactions which have a link to the given compound_id. - - Return value: - ArrayOfstring (reaction_id) - - Example: - # Returns the REACTION entry IDs which have a link to the COMPOUND entry, - # 'cpd:C00199' - get_reactions_by_compound('cpd:C00199') - - --- get_reactions_by_glycan(glycan_id) - - Retrieve all reactions which have a link to the given glycan_id. - - Return value: - ArrayOfstring (reaction_id) - - Example - # Returns the REACTION entry IDs which have a link to the GLYCAN entry, - # 'gl:G00001' - get_reactions_by_glycan('gl:G00001') - - ==== GENES --- 1491,1494 ---- *************** *** 1432,1436 **** == Notes ! Last updated: May 31, 2005 =end --- 1547,1551 ---- == Notes ! Last updated: Feb 17, 2006 =end From nakao at pub.open-bio.org Thu Feb 23 22:25:32 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Thu, 23 Feb 2006 22:25:32 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl/bl2seq test_report.rb, 1.1, 1.2 Message-ID: <200602232225.k1NMPWVL007689@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl/bl2seq In directory pub.open-bio.org:/tmp/cvs-serv7677/test/unit/bio/appl/bl2seq Modified Files: test_report.rb Log Message: * Changed class TestBlastReportHit -> class TestBl2seqReportHit. Index: test_report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/appl/bl2seq/test_report.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_report.rb 13 Feb 2006 15:51:11 -0000 1.1 --- test_report.rb 23 Feb 2006 22:25:30 -0000 1.2 *************** *** 114,118 **** ! class TestBlastReportHit < Test::Unit::TestCase def setup @empty = Bio::Blast::Bl2seq::Report.new(Bio::TestBl2seqReportData.output('empty')) --- 114,118 ---- ! class TestBl2seqReportHit < Test::Unit::TestCase def setup @empty = Bio::Blast::Bl2seq::Report.new(Bio::TestBl2seqReportData.output('empty')) *************** *** 122,128 **** end ! def test_hits assert_equal(0, @empty.hits.size) assert_equal(Bio::Blast::Bl2seq::Report::Hit, @blastp.hits.first.class) assert_equal(1, @blastp.hits.size) --- 122,130 ---- end ! def test_empty_hits assert_equal(0, @empty.hits.size) + end + def test_hits assert_equal(Bio::Blast::Bl2seq::Report::Hit, @blastp.hits.first.class) assert_equal(1, @blastp.hits.size) From k at pub.open-bio.org Mon Feb 27 09:09:59 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:09:59 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.20,1.21 Message-ID: <200602270910.k1R99xVL000442@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv424/lib/bio/shell Modified Files: core.rb Log Message: * policy of directory creation is changed - session, data, plugin directories are created at a start time without asking to incorporate rails smoothly. * functions of splash animation and color/mono mode are separated Index: core.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** core.rb 17 Feb 2006 17:09:17 -0000 1.20 --- core.rb 27 Feb 2006 09:09:57 -0000 1.21 *************** *** 37,40 **** --- 37,44 ---- } + def history + SAVEDIR + HISTORY + end + def datadir DATADIR *************** *** 70,107 **** def save_session closing_splash ! save_history ! save_object ! save_config ! end ! ! #-- ! # *TODO* How to prevent terminal collapse and suppress loading messages? ! #++ ! def load_thread ! message = '' ! begin ! t1 = Thread.new do ! require 'stringio' ! sio = StringIO.new('') ! begin ! stdout_save = STDOUT.clone ! STDOUT.reopen(sio) ! load_object ! load_history ! ensure ! STDOUT.reopen(stdout_save) ! stdout_save.close ! message = sio.read ! sio.close ! end ! end ! t2 = Thread.new do ! opening_splash ! end ! t1.join ! t2.join ! rescue end - puts message end --- 74,82 ---- def save_session closing_splash ! if create_save_dir_ask ! #save_history # changed to use our own... ! save_object ! save_config end end *************** *** 121,126 **** def create_save_dir if @cache[:save].nil? ! if ask_yes_or_no("Save session in '#{SAVEDIR}' directory? [y/n]: ") create_real_dir(SAVEDIR) create_real_dir(DATADIR) --- 96,110 ---- def create_save_dir + create_real_dir(SAVEDIR) + create_real_dir(DATADIR) + create_real_dir(PLUGIN) + end + + def create_save_dir_ask + if File.directory?(SAVEDIR) + @cache[:save] = true + end if @cache[:save].nil? ! if ask_yes_or_no("Save session in '#{SAVEDIR}' directory? [y/n] ") create_real_dir(SAVEDIR) create_real_dir(DATADIR) *************** *** 137,141 **** def ask_yes_or_no(message) loop do ! print message answer = gets if answer.nil? --- 121,125 ---- def ask_yes_or_no(message) loop do ! print "#{message}" answer = gets if answer.nil? *************** *** 203,209 **** def save_config ! if create_save_dir ! save_config_file(SAVEDIR + CONFIG) ! end end --- 187,191 ---- def save_config ! save_config_file(SAVEDIR + CONFIG) end *************** *** 247,258 **** end def config_splash flag = ! @config[:splash] @config[:splash] = flag puts "Splash #{flag ? 'on' : 'off'}" ! end ! ! def config_pager(cmd = nil) ! @config[:pager] = cmd end --- 229,241 ---- end + def config_pager(cmd = nil) + @config[:pager] = cmd + end + def config_splash flag = ! @config[:splash] @config[:splash] = flag puts "Splash #{flag ? 'on' : 'off'}" ! opening_splash end *************** *** 260,263 **** --- 243,247 ---- str ||= MESSAGE @config[:message] = str + opening_splash end *************** *** 306,312 **** def save_object ! if create_save_dir ! save_object_file(SAVEDIR + OBJECT) ! end end --- 290,294 ---- def save_object ! save_object_file(SAVEDIR + OBJECT) end *************** *** 355,359 **** print "Loading history (#{file}) ... " File.open(file).each do |line| ! Readline::HISTORY.push line.chomp end puts "done" --- 337,343 ---- print "Loading history (#{file}) ... " File.open(file).each do |line| ! #Readline::HISTORY.push line.chomp ! date, hist = line.chomp.split("\t") ! Readline::HISTORY.push hist if hist end puts "done" *************** *** 363,369 **** def save_history if @cache[:readline] ! if create_save_dir ! save_history_file(SAVEDIR + HISTORY) ! end end end --- 347,351 ---- def save_history if @cache[:readline] ! save_history_file(SAVEDIR + HISTORY) end end *************** *** 417,423 **** if @script_begin and @script_end and @script_begin <= @script_end if File.exists?(SCRIPT) ! message = "Overwrite script file (#{SCRIPT})? [y/n]: " else ! message = "Save script file (#{SCRIPT})? [y/n]: " end if ask_yes_or_no(message) --- 399,405 ---- if @script_begin and @script_end and @script_begin <= @script_end if File.exists?(SCRIPT) ! message = "Overwrite script file (#{SCRIPT})? [y/n] " else ! message = "Save script file (#{SCRIPT})? [y/n] " end if ask_yes_or_no(message) *************** *** 463,468 **** end ! def splash_message_action ! s = splash_message l = s.length x = " " --- 445,450 ---- end ! def splash_message_action(message = nil) ! s = message || splash_message l = s.length x = " " *************** *** 480,485 **** end ! def splash_message_action_color ! s = splash_message l = s.length c = ESC_SEQ --- 462,467 ---- end ! def splash_message_action_color(message = nil) ! s = message || splash_message l = s.length c = ESC_SEQ From k at pub.open-bio.org Mon Feb 27 09:11:03 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:11:03 +0000 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.65,1.66 Message-ID: <200602270911.k1R9B3VL000498@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory pub.open-bio.org:/tmp/cvs-serv494/lib Modified Files: bio.rb Log Message: * prepared for 1.0.0 release Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** bio.rb 21 Feb 2006 18:01:59 -0000 1.65 --- bio.rb 27 Feb 2006 09:11:01 -0000 1.66 *************** *** 11,15 **** module Bio ! BIORUBY_VERSION = [0, 8, 0].extend(Comparable) ### Basic data types --- 11,15 ---- module Bio ! BIORUBY_VERSION = [1, 0, 0].extend(Comparable) ### Basic data types *************** *** 101,106 **** autoload :GFF, 'bio/db/gff' autoload :AAindex, 'bio/db/aaindex' ! autoload :AAindex1, 'bio/db/aaindex' ! autoload :AAindex2, 'bio/db/aaindex' autoload :TRANSFAC, 'bio/db/transfac' autoload :PROSITE, 'bio/db/prosite' --- 101,106 ---- autoload :GFF, 'bio/db/gff' autoload :AAindex, 'bio/db/aaindex' ! autoload :AAindex1, 'bio/db/aaindex' # change to AAindex::AAindex1 ? ! autoload :AAindex2, 'bio/db/aaindex' # change to AAindex::AAindex2 ? autoload :TRANSFAC, 'bio/db/transfac' autoload :PROSITE, 'bio/db/prosite' From k at pub.open-bio.org Mon Feb 27 09:12:20 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:12:20 +0000 Subject: [BioRuby-cvs] bioruby/doc Tutorial.rd.ja,1.19,1.20 Message-ID: <200602270912.k1R9CKVL000546@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/doc In directory pub.open-bio.org:/tmp/cvs-serv542/doc Modified Files: Tutorial.rd.ja Log Message: * added PDB documantation by Naohisa Goto * added some examples of the BioRuby shell Index: Tutorial.rd.ja =================================================================== RCS file: /home/repository/bioruby/bioruby/doc/Tutorial.rd.ja,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Tutorial.rd.ja 16 Jan 2006 15:23:11 -0000 1.19 --- Tutorial.rd.ja 27 Feb 2006 09:12:18 -0000 1.20 *************** *** 3,7 **** $Id$ ! Copyright (C) 2001-2003, 2005 KATAYAMA Toshiaki = BioRuby ???????? --- 3,8 ---- $Id$ ! Copyright (C) 2001-2003, 2005, 2006 Toshiaki Katayama ! Copyright (C) 2005, 2006 Naohisa Goto [...1508 lines suppressed...] ! ??????NCBI ?????????????????? PubMed ?????????????????????????????????????????? #!/usr/bin/env ruby *************** *** 1833,1839 **** ?????????????????? bibtex ?????????? BibTeX ???????????????????????????? ! ???????????????? bibitem ????????????????????nature ?????????? nar ???? ! ???????????????????????????????????????????????????????????????????? ! ?????????????????????????????????????????????????????????????? === BibTeX ?????????????? --- 2351,2357 ---- ?????????????????? bibtex ?????????? BibTeX ???????????????????????????? ! ???????????????? bibitem ?????????????????????????????????????????? ! ??????????????????????????nature ?????????? nar ?????????????????????? ! ???????????????????????????????? === BibTeX ?????????????? From k at pub.open-bio.org Mon Feb 27 09:13:10 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:13:10 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio db.rb,0.33,0.34 Message-ID: <200602270913.k1R9DAVL000596@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv592/lib/bio Modified Files: db.rb Log Message: * license is changed from LGPL to Ruby's Index: db.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db.rb,v retrieving revision 0.33 retrieving revision 0.34 diff -C2 -d -r0.33 -r0.34 *** db.rb 18 Feb 2006 14:44:40 -0000 0.33 --- db.rb 27 Feb 2006 09:13:08 -0000 0.34 *************** *** 4,8 **** # Copyright:: Copyright (C) 2001, 2002, 2005 # KATAYAMA Toshiaki ! # License:: LGPL # # $Id$ --- 4,8 ---- # Copyright:: Copyright (C) 2001, 2002, 2005 # KATAYAMA Toshiaki ! # License:: Ruby's # # $Id$ *************** *** 145,166 **** # The name of the organism. # - #-- - # - # 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 - # - #++ - # require 'bio/sequence' --- 145,148 ---- From k at pub.open-bio.org Mon Feb 27 09:13:48 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:13:48 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio feature.rb,1.9,1.10 Message-ID: <200602270913.k1R9DmVL000647@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv642/lib/bio Modified Files: feature.rb Log Message: * license is changed from LGPL to Ruby's Index: feature.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/feature.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** feature.rb 30 Nov 2005 01:54:38 -0000 1.9 --- feature.rb 27 Feb 2006 09:13:46 -0000 1.10 *************** *** 4,16 **** # Copyright:: Copyright (c) 2002, 2005 # Toshiaki Katayama ! # License:: LGPL # # $Id$ # - #-- - # *TODO* - # add to_gff method - #++ - # # == INSD Feature table definition # --- 4,11 ---- # Copyright:: Copyright (c) 2002, 2005 # Toshiaki Katayama ! # License:: Ruby's # # $Id$ # # == INSD Feature table definition # *************** *** 44,65 **** # end # - #-- - # - # 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 - # - #++ - # require 'bio/location' --- 39,42 ---- *************** *** 158,167 **** # Returns an Array of Feature objects. attr_accessor :features - - def to_gff - # *TODO* - # to generate Bio::GFF object and implement Bio::GFF#to_s or - # to generate GFF string in this method? - end # Appends a Feature object to Features. --- 135,138 ---- From k at pub.open-bio.org Mon Feb 27 09:14:32 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:14:32 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl emboss.rb,1.3,1.4 Message-ID: <200602270914.k1R9EWVL000696@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory pub.open-bio.org:/tmp/cvs-serv692/lib/bio/appl Modified Files: emboss.rb Log Message: * license is changed from LGPL to Ruby's Index: emboss.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/emboss.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** emboss.rb 28 Jan 2006 06:46:42 -0000 1.3 --- emboss.rb 27 Feb 2006 09:14:30 -0000 1.4 *************** *** 4,8 **** # Copyright:: Copyright (C) 2002, 2005 # KATAYAMA Toshiaki ! # License:: LGPL # # $Id$ --- 4,8 ---- # Copyright:: Copyright (C) 2002, 2005 # KATAYAMA Toshiaki ! # License:: Ruby's # # $Id$ *************** *** 11,32 **** # # * http://www.emboss.org - # - #-- - # - # 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 - # - #++ # --- 11,14 ---- From k at pub.open-bio.org Mon Feb 27 09:16:15 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:16:15 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell object.rb,NONE,1.1 Message-ID: <200602270916.k1R9GFVL000786@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv773/lib/bio/shell Added Files: object.rb Log Message: * Object extention for Rails --- NEW FILE: object.rb --- # # = bio/shell/object.rb - Object extension for the BioRuby shell # # Copyright:: Copyright (C) 2006 # Nobuya Tanaka , # Toshiaki Katayama # License:: Ruby's # # $Id: object.rb,v 1.1 2006/02/27 09:16:13 k Exp $ # require 'cgi' require 'pp' ### Object extention class Object # Couldn't work for Fixnum (Marshal) attr_accessor :memo # *TODO* def to_html if self.is_a?(String) "

    " + self + "
    " else str = "" PP.pp(self, str) "
    " + str + "
    " #"
    " + CGI.escapeHTML(str) + "
    " #self.inspect #"
    " + self.inspect + "
    " #"
    " + self.to_s + "
    " end end end =begin module Bio class DB def to_html html = "" html += "" @data.each do |k, v| html += "" end html += "
    #{k}#{v}
    " end end end =end From k at pub.open-bio.org Mon Feb 27 09:22:44 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:22:44 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell web.rb,NONE,1.1 Message-ID: <200602270922.k1R9MiVL000860@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv856/lib/bio/shell Added Files: web.rb Log Message: * 'web' command to start BioRuby shell on Rails --- NEW FILE: web.rb --- # # = bio/shell/web.rb - GUI for the BioRuby shell # # Copyright:: Copyright (C) 2006 # Nobuya Tanaka , # Toshiaki Katayama # License:: Ruby's # # $Id: web.rb,v 1.1 2006/02/27 09:22:42 k Exp $ # module Bio::Shell private def rails_directory_setup server = "script/server" unless File.exists?(server) require 'fileutils' basedir = File.dirname(__FILE__) print "Copying web server files ... " FileUtils.cp_r("#{basedir}/rails/.", ".") puts "done" end end def rails_server_setup require 'open3' $web_server = Open3.popen3(server) $web_error_log = File.open("log/web-error.log", "a") $web_server[2].reopen($web_error_log) while line = $web_server[1].gets if line[/druby:\/\/localhost/] uri = line.chomp puts uri if $DEBUG break end end $web_access_log = File.open("log/web-access.log", "a") $web_server[1].reopen($web_access_log) return uri end def web return if $web_server require 'drb/drb' # $SAFE = 1 # disable eval() and friends rails_directory_setup #uri = rails_server_setup uri = 'druby://localhost:81064' # baioroji- $drb_server = DRbObject.new_with_uri(uri) $drb_server.puts_remote("Connected") puts "Connected to server #{uri}" puts "Open http://localhost:3000/shell/" io = IRB.conf[:MAIN_CONTEXT].io io.class.class_eval do alias_method :shell_original_gets, :gets end def io.gets bind = IRB.conf[:MAIN_CONTEXT].workspace.binding vars = eval("local_variables", bind) vars.each do |var| next if var == "_" if val = eval("#{var}", bind) $drb_server[var] = val else $drb_server.delete(var) end end line = shell_original_gets line end end end From k at pub.open-bio.org Mon Feb 27 09:33:25 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:33:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell demo.rb,NONE,1.1 Message-ID: <200602270933.k1R9XPVL000936@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv932/lib/bio/shell Added Files: demo.rb Log Message: * 'demo' command for BioRuby shell --- NEW FILE: demo.rb --- # # = bio/shell/demo.rb - demo mode for the BioRuby shell # # Copyright:: Copyright (C) 2006 # Toshiaki Katayama # License:: Ruby's # # $Id: demo.rb,v 1.1 2006/02/27 09:33:22 k Exp $ # module Bio::Shell private def demo(part = nil) demo = Demo.new if part demo.send(part) else demo.all end end class Demo def initialize @bind = IRB.conf[:MAIN_CONTEXT].workspace.binding end def all sequence && entry && shell && pdb && true end def tutorial end def mito run(%q[entry = ent("data/kumamushi.gb")], "Load kumamushi gene from GenBank database entry ...", false) && run(%q[disp entry], "Check the contents ...", false) && run(%q[kuma = flatparse(entry)], "Parse the database entry ...", true) && run(%q[web], "Start BioRuby on Rails...", false) && run(%q[puts kuma.entry_id], "Extract entry ID ...", false) && run(%q[puts kuma.definition], "Extract definition ...", false) && run(%q[gene = kuma.seq], "Extract DNA sequence of the gene ...", true) && run(%q[doublehelix(gene)], "Show the sequence in ascii art ...", false) && run(%q[seqstat(gene)], "Statistics of the gene ...", false) && run(%q[config :color], "Change to color mode...", false) && run(%q[seqstat(gene)], "Statistics of the gene ...", false) && #run(%q[codontable], "Codontalble ...", false) && run(%q[protein = gene.translate], "Translate DNA into protein ...", true) && run(%q[comp = protein.composition], "Composition of the amino acids ...", false) && run(%q[pp comp], "Check the composition ...", false) && run(%q[puts protein.molecular_weight], "Molecular weight ...", false) && run(%q[midifile("data/kumamushi.mid", gene)], "Gene to music ...", false) && run(%q[`open "data/kumamushi.mid"`], "Let's listen ...", false) && true end def sequence run(%q[dna = seq("atgc" * 100)], "Generating DNA sequence ...", true) && run(%q[doublehelix dna], "Double helix representation", false) && run(%q[protein = dna.translate], "Translate DNA into Protein ...", true) && run(%q[protein.molecular_weight], "Calculating molecular weight ...", true) && run(%q[protein.composition], "Amino acid composition ...", true) && true end def entry run(%q[kuma = obj("gb:AF237819")], "Obtain an entry from GenBank database", false) && run(%q[kuma.definition], "Definition of the entry", true) && run(%q[kuma.naseq], "Sequence of the entry", true) && run(%q[kuma.naseq.translate], "Translate the sequence to protein", true) && run(%q[midifile("data/AF237819.mid", kuma.naseq)], "Generate gene music ...", false) && true end def shell run(%q[pwd], "Show current working directory ...", false) && run(%q[dir], "Show directory contents ...", false) && run(%q[dir "session"], "Show directory contents ...", false) && true end def pdb run(%q[ent_1bl8 = ent("pdb:1bl8")], "Retrieving PDB entry 1BL8 ...", false) && run(%q[head ent_1bl8], "Head part of the entry ...", false) && run(%q[savefile("1bl8.pdb", ent_1bl8)], "Saving the original entry in file ...", false) && run(%q[less "data/1bl8.pdb"], "Look through the entire entry ...", false) && run(%q[pdb_1bl8 = flatparse(ent_1bl8)], "Parsing the entry ...", false) && run(%q[pdb_1bl8.entry_id], "Showing the entry ID ...", true) && run(%q[pdb_1bl8.each_heterogen { |heterogen| p heterogen.resName }], "Showing each heterogen object ...", false) && true end def pdb_hetdic run(%q[het_dic = open("http://deposit.pdb.org/het_dictionary.txt").read], "Retrieving the het_dic database ...", false) && run(%q[savefile("data/het_dictionary.txt", het_dic)], "Saving the file ... ", false) && run(%q[het_dic.size], "Bytes of the file ...", true) && run(%q[less "data/het_dictionary.txt"], "Take a look on the contents ...", true) && run(%q[flatindex("het_dic", "data/het_dictionary.txt")], "Creating index to make the seaarchable database ...", false) && run(%q[ethanol = flatsearch("het_dic", "EOH")], "Search an ethanol entry ...", true) && run(%q[osake = flatparse(ethanol)], "Parse the entry ...", true) && run(%q[sake.conect], "Showing connect table (conect) of the molecule ...", true) && true end private def run(cmd, msg, echo) comment(msg) splash(cmd) result = eval(cmd, @bind) if echo pp result end continue? end def comment(msg) puts "### #{msg}" end def splash(msg) Bio::Shell.splash_message_action("bioruby> #{msg}") print "bioruby> #{msg}" gets end def continue? Bio::Shell.ask_yes_or_no("Continue? [y/n] ") end end end From k at pub.open-bio.org Mon Feb 27 09:34:25 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:34:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio shell.rb,1.14,1.15 Message-ID: <200602270934.k1R9YPVL000983@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory pub.open-bio.org:/tmp/cvs-serv979/lib/bio Modified Files: shell.rb Log Message: * added object, web, demo modules Index: shell.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell.rb,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** shell.rb 17 Feb 2006 17:12:39 -0000 1.14 --- shell.rb 27 Feb 2006 09:34:23 -0000 1.15 *************** *** 2,6 **** # = bio/shell.rb - Loading all BioRuby shell features # ! # Copyright:: Copyright (C) 2005 # Toshiaki Katayama # License: Ruby's --- 2,6 ---- # = bio/shell.rb - Loading all BioRuby shell features # ! # Copyright:: Copyright (C) 2005, 2006 # Toshiaki Katayama # License: Ruby's *************** *** 18,21 **** --- 18,24 ---- require 'bio/shell/core' require 'bio/shell/interface' + require 'bio/shell/object' + require 'bio/shell/web' + require 'bio/shell/demo' require 'bio/shell/plugin/entry' require 'bio/shell/plugin/seq' From k at pub.open-bio.org Mon Feb 27 09:36:37 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:36:37 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell interface.rb,1.13,1.14 Message-ID: <200602270936.k1R9abVL001075@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell In directory pub.open-bio.org:/tmp/cvs-serv1071/lib/bio/shell Modified Files: interface.rb Log Message: * 'less' command is removed and merged into 'disp' command Index: interface.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/interface.rb,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** interface.rb 17 Feb 2006 17:11:59 -0000 1.13 --- interface.rb 27 Feb 2006 09:36:35 -0000 1.14 *************** *** 20,23 **** --- 20,24 ---- } puts list.inspect + return list end *************** *** 71,74 **** --- 72,77 ---- when :message, "message" Bio::Shell.config_message(*opts) + else + puts "Invalid mode (#{mode}) - :show, :echo, :color, :splash, :massage" end end *************** *** 82,86 **** def pager(cmd = nil) unless Bio::Shell.config[:pager] ! cmd = ENV['PAGER'] || cmd end Bio::Shell.config_pager(cmd) --- 85,89 ---- def pager(cmd = nil) unless Bio::Shell.config[:pager] ! cmd ||= ENV['PAGER'] end Bio::Shell.config_pager(cmd) *************** *** 88,99 **** end ! def disp(*obj) # The original idea is from http://sheepman.parfait.ne.jp/20050215.html ! if Bio::Shell.config[:pager] ! pg = IO.popen(Bio::Shell.config[:pager], "w") begin stdout_save = STDOUT.clone STDOUT.reopen(pg) ! puts(*obj) ensure STDOUT.reopen(stdout_save) --- 91,112 ---- end ! def disp(*objs) # The original idea is from http://sheepman.parfait.ne.jp/20050215.html ! if cmd = Bio::Shell.config[:pager] ! pg = IO.popen(cmd, "w") begin stdout_save = STDOUT.clone STDOUT.reopen(pg) ! objs.each do |obj| ! if obj.is_a?(String) ! if File.exists?(obj) ! system("#{cmd} #{obj}") ! else ! obj.display ! end ! else ! pp obj ! end ! end ensure STDOUT.reopen(stdout_save) *************** *** 102,115 **** end else ! # or use Object#display ? ! puts(*obj) end end - def less(file) - pager = Bio::Shell.config[:pager] || ENV['PAGER'] || "less" - system("#{pager} #{file}") - end - def head(arg, num = 10) str = "" --- 115,128 ---- end else ! objs.each do |obj| ! if obj.is_a?(String) ! obj.display ! else ! pp obj ! end ! end end end def head(arg, num = 10) str = "" *************** *** 136,145 **** def savefile(file, *objs) datadir = Bio::Shell.datadir ! message = "Save file '#{file}' in '#{datadir}' directory? [y/n]: " if ! file[/^#{datadir}/] and Bio::Shell.ask_yes_or_no(message) file = datadir + file end if File.exists?(file) ! message = "Overwrite existing '#{file}' file? [y/n]: " if ! Bio::Shell.ask_yes_or_no(message) puts " ... save aborted." --- 149,158 ---- def savefile(file, *objs) datadir = Bio::Shell.datadir ! message = "Save file '#{file}' in '#{datadir}' directory? [y/n] " if ! file[/^#{datadir}/] and Bio::Shell.ask_yes_or_no(message) file = datadir + file end if File.exists?(file) ! message = "Overwrite existing '#{file}' file? [y/n] " if ! Bio::Shell.ask_yes_or_no(message) puts " ... save aborted." From k at pub.open-bio.org Mon Feb 27 09:37:16 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:37:16 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin entry.rb,1.7,1.8 Message-ID: <200602270937.k1R9bGVL001123@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv1119/lib/bio/shell/plugin Modified Files: entry.rb Log Message: * added a tiny doc Index: entry.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/entry.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** entry.rb 14 Feb 2006 13:46:43 -0000 1.7 --- entry.rb 27 Feb 2006 09:37:14 -0000 1.8 *************** *** 86,89 **** --- 86,90 ---- end + # Obtain a parsed object from sources that ent() supports. def obj(arg) str = ent(arg) From nakao at pub.open-bio.org Mon Feb 27 09:40:15 2006 From: nakao at pub.open-bio.org (Mitsuteru C. Nakao) Date: Mon, 27 Feb 2006 09:40:15 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/shell/plugin test_seq.rb, 1.6, 1.7 Message-ID: <200602270940.k1R9eFVL001208@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/shell/plugin In directory pub.open-bio.org:/tmp/cvs-serv1173/test/unit/bio/shell/plugin Modified Files: test_seq.rb Log Message: * Fixed Bio::Shell namespace for tesing.. Index: test_seq.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/shell/plugin/test_seq.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_seq.rb 21 Feb 2006 17:38:15 -0000 1.6 --- test_seq.rb 27 Feb 2006 09:40:13 -0000 1.7 *************** *** 2,22 **** # test/unit/bio/shell/plugin/test_seq.rb - Unit test for Bio::Shell plugin for biological sequence manipulations # ! # Copyright (C) 2005 Mitsuteru Nakao ! # ! # 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$ # --- 2,10 ---- # test/unit/bio/shell/plugin/test_seq.rb - Unit test for Bio::Shell plugin for biological sequence manipulations # ! # Copyright:: Copyright (C) 2005 ! # Mitsuteru Nakao ! # License:: Ruby's # ! # $Id$ # *************** *** 27,36 **** require 'test/unit' require 'bio/shell' module Bio class TestShellPluginSeq < Test::Unit::TestCase - # include Bio::Shell - # Bio::Shell.instance_variable_set :@config, {} def test_naseq --- 15,41 ---- require 'test/unit' require 'bio/shell' + require 'bio/shell/plugin/seq' module Bio + class TestShellPluginSeq < Test::Unit::TestCase + include Bio::Shell + + Bio::Shell.config = {:color => false} + + def test_htmlseq + str = 'ATGC' + html =< + a + t + g + c +
    + + END + assert_equal(html, htmlseq(str)) + end def test_naseq *************** *** 41,44 **** --- 46,50 ---- end + def test_aaseq str = 'WD' *************** *** 48,51 **** --- 54,58 ---- end + def test_na_seqstat naseq = 'atgcatgcatgc' *************** *** 113,116 **** --- 120,124 ---- end + def test_aa_seqstat aaseq = 'WD' *************** *** 139,142 **** --- 147,151 ---- end + def test_doublehelix seq = 'ACGTACGTACGTACGT' *************** *** 173,175 **** --- 182,185 ---- end + end From k at pub.open-bio.org Mon Feb 27 09:41:21 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:41:21 +0000 Subject: [BioRuby-cvs] bioruby/bin bioruby,1.13,1.14 Message-ID: <200602270941.k1R9fLVL001227@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv1204/bin Modified Files: bioruby Log Message: * history file with timestamp * rails server workaround (may not yet complete with open3) Index: bioruby =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/bioruby,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** bioruby 14 Feb 2006 13:18:35 -0000 1.13 --- bioruby 27 Feb 2006 09:41:19 -0000 1.14 *************** *** 16,26 **** end require 'bio/shell' include Bio::Shell ! ### Command line argument ! ! # working directory or script file if arg = ARGV.shift if File.directory?(arg) --- 16,28 ---- end + + ### BioRuby shell setup + require 'bio/shell' include Bio::Shell ! # command line argument (working directory or bioruby shell script file) ! script = nil if arg = ARGV.shift if File.directory?(arg) *************** *** 28,45 **** Dir.chdir(arg) elsif File.exists?(arg) ! # BioRuby shell script (lib/bioruby.rb can be obsolete) ! load arg ! exit elsif arg Dir.mkdir(arg) Dir.chdir(arg) end end - ### BioRuby shell setup - # loading configuration and plugins Bio::Shell.setup ### IRB setup --- 30,54 ---- Dir.chdir(arg) elsif File.exists?(arg) ! # BioRuby shell script (load script after the previous session is restored) ! dir = File.dirname(arg) ! script = File.basename(arg) ! Dir.chdir(dir) elsif arg Dir.mkdir(arg) Dir.chdir(arg) end + else + unless File.exists?(Bio::Shell.history) + message = "Are you sure to start new session in this directory? [y/n] " + unless Bio::Shell.ask_yes_or_no(message) + exit + end + end end # loading configuration and plugins Bio::Shell.setup + ### IRB setup *************** *** 84,88 **** #IRB.conf[:AUTO_INDENT] = true ! ### IRB main loop irb = IRB::Irb.new --- 93,98 ---- #IRB.conf[:AUTO_INDENT] = true ! ! ### Start IRB irb = IRB::Irb.new *************** *** 94,97 **** --- 104,140 ---- Bio::Shell.load_session + if script + # *TODO* - variables are seemed to exist, but couldn't access them ... + #eval("ls", irb.context.workspace.binding) + #eval("ls") + #eval("load '#{script}'", irb.context.workspace.binding) + #eval("load '#{script}'", IRB.conf[:MAIN_CONTEXT].workspace.binding) + #eval("load '#{script}'") + #eval("load '#{script}', true") + #eval("File.read('#{script}')", irb.context.workspace.binding) + #eval("File.read('#{script}')") + load script + exit + end + + Bio::Shell.create_save_dir + + $history_file = File.open(Bio::Shell.history, "a") + $history_file.sync = true + + # overwrite gets to store history with time stamp + io = IRB.conf[:MAIN_CONTEXT].io + + io.class.class_eval do + alias_method :irb_original_gets, :gets + end + + def io.gets + line = irb_original_gets + $history_file.puts "#{Time.now}\t#{line}" if line + line + end + + # main loop Signal.trap("SIGINT") do irb.signal_handle *************** *** 100,103 **** --- 143,157 ---- catch(:IRB_EXIT) do irb.eval_input + end + + $history_file.close if $history_file + + # shut down the rails server + if $web_server + $web_server.each do |io| + io.close + end + $web_access_log.close if $web_access_log + $web_error_log.close if $web_error_log end From k at pub.open-bio.org Mon Feb 27 09:41:56 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 09:41:56 +0000 Subject: [BioRuby-cvs] bioruby/bin bioruby,1.14,1.15 Message-ID: <200602270941.k1R9fuVL001254@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory pub.open-bio.org:/tmp/cvs-serv1250/bin Modified Files: bioruby Log Message: * temporal cleanup Index: bioruby =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/bioruby,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** bioruby 27 Feb 2006 09:41:19 -0000 1.14 --- bioruby 27 Feb 2006 09:41:54 -0000 1.15 *************** *** 105,117 **** if script - # *TODO* - variables are seemed to exist, but couldn't access them ... - #eval("ls", irb.context.workspace.binding) - #eval("ls") - #eval("load '#{script}'", irb.context.workspace.binding) - #eval("load '#{script}'", IRB.conf[:MAIN_CONTEXT].workspace.binding) - #eval("load '#{script}'") - #eval("load '#{script}', true") - #eval("File.read('#{script}')", irb.context.workspace.binding) - #eval("File.read('#{script}')") load script exit --- 105,108 ---- From k at pub.open-bio.org Mon Feb 27 10:12:19 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:19 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails - New directory Message-ID: <200602271012.k1RACJVL001397@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails In directory pub.open-bio.org:/tmp/cvs-serv1393/lib/bio/shell/rails Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:29 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/log - New directory Message-ID: <200602271012.k1RACTVL001461@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/log In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/log Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/log added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:29 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public - New directory Message-ID: <200602271012.k1RACTVL001464@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/public Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:29 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/config - New directory Message-ID: <200602271012.k1RACTVL001449@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/config In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/config Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/config added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:29 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/lib - New directory Message-ID: <200602271012.k1RACTVL001458@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/lib Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:29 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/doc - New directory Message-ID: <200602271012.k1RACTVL001455@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/doc In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/doc Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/doc added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:30 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:30 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script - New directory Message-ID: <200602271012.k1RACUVL001467@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/script Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/script added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:46 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/lib/tasks - New directory Message-ID: <200602271012.k1RACkVL001542@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib/tasks In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/lib/tasks Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib/tasks added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:30 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:30 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/vendor - New directory Message-ID: <200602271012.k1RACUVL001473@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/vendor Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:48 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:48 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/unit - New directory Message-ID: <200602271012.k1RACmVL001571@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/unit In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/test/unit Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/unit added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:29 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/db - New directory Message-ID: <200602271012.k1RACTVL001452@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/db In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/db Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/db added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:47 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:47 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/stylesheets - New directory Message-ID: <200602271012.k1RAClVL001553@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/stylesheets In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/public/stylesheets Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/stylesheets added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:47 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:47 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/javascripts - New directory Message-ID: <200602271012.k1RAClVL001550@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/javascripts In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/public/javascripts Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/javascripts added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:46 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/helpers - New directory Message-ID: <200602271012.k1RACkVL001527@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/helpers In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/app/helpers Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/helpers added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:28 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:28 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app - New directory Message-ID: <200602271012.k1RACSVL001443@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/app Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:28 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:28 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/components - New directory Message-ID: <200602271012.k1RACSVL001446@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/components In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/components Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/components added to the repository From k at pub.open-bio.org Mon Feb 27 10:22:30 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:22:30 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails - New directory Message-ID: <200602271022.k1RAMUVL001703@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails In directory pub.open-bio.org:/tmp/cvs-serv1699/rails Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:04 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:04 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app - New directory Message-ID: <200602271023.k1RAN4VL001751@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app In directory pub.open-bio.org:/tmp/cvs-serv1726/app Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:04 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:04 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/controllers - New directory Message-ID: <200602271023.k1RAN4VL001760@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/controllers In directory pub.open-bio.org:/tmp/cvs-serv1726/app/controllers Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/controllers added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:05 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:05 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/views/layouts - New directory Message-ID: <200602271023.k1RAN5VL001778@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views/layouts In directory pub.open-bio.org:/tmp/cvs-serv1726/app/views/layouts Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views/layouts added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/db - New directory Message-ID: <200602271023.k1RAN6VL001806@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/db In directory pub.open-bio.org:/tmp/cvs-serv1726/db Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/db added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:05 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:05 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/views - New directory Message-ID: <200602271023.k1RAN5VL001773@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views In directory pub.open-bio.org:/tmp/cvs-serv1726/app/views Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:07 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:07 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/images - New directory Message-ID: <200602271023.k1RAN7VL001842@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/images In directory pub.open-bio.org:/tmp/cvs-serv1726/public/images Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/images added to the repository From k at pub.open-bio.org Mon Feb 27 13:24:31 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 13:24:31 +0000 Subject: [BioRuby-cvs] bioruby rdoc.zsh,NONE,1.1 Message-ID: <200602271324.k1RDOVVL003151@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv3147 Added Files: rdoc.zsh Log Message: * simple zsh script to generate rdoc --- NEW FILE: rdoc.zsh --- #!/usr/bin/env zsh #DIAGRAM='--diagram' WEBCVS='http://cvs.open-bio.org/cgi-bin/viewcvs/viewcvs.cgi' rdoc ${DIAGRAM} --op rdoc --inline-source \ --webcvs "${WEBCVS}/bioruby/\%s?cvsroot=bioruby" \ bin/*(.) lib/**/*.rb [A-Z]*(.) doc/*rd etc/bioinformatics/*(.) From k at pub.open-bio.org Mon Feb 27 10:23:09 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:09 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/unit - New directory Message-ID: <200602271023.k1RAN9VL001893@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/unit In directory pub.open-bio.org:/tmp/cvs-serv1726/test/unit Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/unit added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:10 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:10 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/vendor/plugins - New directory Message-ID: <200602271023.k1RANAVL001900@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins In directory pub.open-bio.org:/tmp/cvs-serv1726/vendor/plugins Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins added to the repository From k at pub.open-bio.org Mon Feb 27 13:22:07 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 13:22:07 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db rebase.rb,1.2,1.3 Message-ID: <200602271322.k1RDM7VL003034@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv3030/db Modified Files: rebase.rb Log Message: * autoload problem on YAML with Ruby 1.8.2 is fixed * RDoc is moved in the head Index: rebase.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/rebase.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rebase.rb 13 Dec 2005 15:02:41 -0000 1.2 --- rebase.rb 27 Feb 2006 13:22:05 -0000 1.3 *************** *** 1,7 **** - require 'bio/reference' - module Bio - # ! # bio/db/rebase.rb - Interface for EMBOSS formatted REBASE files # # Copyright:: Copyright (C) 2005 Trevor Wennblom --- 1,4 ---- # ! # = bio/db/rebase.rb - Interface for EMBOSS formatted REBASE files # # Copyright:: Copyright (C) 2005 Trevor Wennblom *************** *** 11,14 **** --- 8,98 ---- # # + # == Synopsis + # + # Bio::REBASE provides utilties for interacting with REBASE data in EMBOSS + # format. REBASE is the Restriction Enzyme Database, more information + # can be found here: + # + + # * http://rebase.neb.com + # + # EMBOSS formatted files located at: + # + # * http://rebase.neb.com/rebase/rebase.f37.html + # + # These files are the same as the "emboss_?.???" files located at: + # + # * ftp://ftp.neb.com/pub/rebase/ + # + # To easily get started with the data you can simply type this command + # at your shell prompt: + # + # % wget ftp://ftp.neb.com/pub/rebase/emboss* + # + # + # == Usage + # + # require 'bio/db/rebase' + # require 'pp' + # + # enz = File.read('emboss_e') + # ref = File.read('emboss_r') + # sup = File.read('emboss_s') + # + # # When creating a new instance of Bio::REBASE + # # the contents of the enzyme file must be passed. + # # The references and suppiers file contents + # # may also be passed. + # rebase = Bio::REBASE.new( enz ) + # rebase = Bio::REBASE.new( enz, ref ) + # rebase = Bio::REBASE.new( enz, ref, sup ) + # + # # The 'read' class method allows you to read in files + # # that are REBASE EMBOSS formatted + # rebase = Bio::REBASE.read( 'emboss_e' ) + # rebase = Bio::REBASE.read( 'emboss_e', 'emboss_r' ) + # rebase = Bio::REBASE.read( 'emboss_e', 'emboss_r', 'emboss_s' ) + # + # # The data loaded may be saved in YAML format + # rebase.save_yaml( 'enz.yaml' ) + # rebase.save_yaml( 'enz.yaml', 'ref.yaml' ) + # rebase.save_yaml( 'enz.yaml', 'ref.yaml', 'sup.yaml' ) + # + # # YAML formatted files can also be read with the + # # class method 'load_yaml' + # rebase = Bio::REBASE.load_yaml( 'enz.yaml' ) + # rebase = Bio::REBASE.load_yaml( 'enz.yaml', 'ref.yaml' ) + # rebase = Bio::REBASE.load_yaml( 'enz.yaml', 'ref.yaml', 'sup.yaml' ) + # + # pp rebase.enzymes[0..4] # ["AarI", "AasI", "AatI", "AatII", "Acc16I"] + # pp rebase['AarI'].pattern # "CACCTGC" + # pp rebase['AarI'].blunt? # false + # pp rebase['AarI'].organism # "Arthrobacter aurescens SS2-322" + # pp rebase['AarI'].source # "A. Janulaitis" + # pp rebase['AarI'].primary_strand_cut1 # 11 + # pp rebase['AarI'].primary_strand_cut2 # 0 + # pp rebase['AarI'].complementary_strand_cut1 # 15 + # pp rebase['AarI'].complementary_strand_cut2 # 0 + # pp rebase['AarI'].suppliers # ["F"] + # pp rebase['AarI'].supplier_names # ["Fermentas International Inc."] + # + # pp rebase['AarI'].isoschizomers # Currently none stored in the references file + # pp rebase['AarI'].methylation # "" + # + # pp rebase['EcoRII'].methylation # "2(5)" + # pp rebase['EcoRII'].suppliers # ["F", "J", "M", "O", "S"] + # pp rebase['EcoRII'].supplier_names # ["Fermentas International Inc.", "Nippon Gene Co., Ltd.", + # # "Roche Applied Science", "Toyobo Biochemicals", + # # "Sigma Chemical Corporation"] + # + # # Number of enzymes in the database + # pp rebase.size # 673 + # pp rebase.enzymes.size # 673 + # + # rebase.each do |name, info| + # pp "#{name}: #{info.methylation}" unless info.methylation.empty? + # end + # + # #-- # *************** *** 29,130 **** #++ # - # - - =begin rdoc - bio/db/rebase.rb - Interface for EMBOSS formatted REBASE files - - == Synopsis - - Bio::REBASE provides utilties for interacting with REBASE data in EMBOSS - format. REBASE is the Restriction Enzyme Database, more information - can be found here: - * http://rebase.neb.com - - EMBOSS formatted files located at: - * http://rebase.neb.com/rebase/rebase.f37.html - - These files are the same as the "emboss_?.???" files located at: - * ftp://ftp.neb.com/pub/rebase/ - - To easily get started with the data you can simply type this command at your shell prompt: - wget ftp://ftp.neb.com/pub/rebase/emboss* - - - == Usage - - require 'bio/db/rebase' - require 'pp' - - enz = File.read('emboss_e') - ref = File.read('emboss_r') - sup = File.read('emboss_s') - - # When creating a new instance of Bio::REBASE - # the contents of the enzyme file must be passed. - # The references and suppiers file contents - # may also be passed. - rebase = Bio::REBASE.new( enz ) - rebase = Bio::REBASE.new( enz, ref ) - rebase = Bio::REBASE.new( enz, ref, sup ) - - # The 'read' class method allows you to read in files - # that are REBASE EMBOSS formatted - rebase = Bio::REBASE.read( 'emboss_e' ) - rebase = Bio::REBASE.read( 'emboss_e', 'emboss_r' ) - rebase = Bio::REBASE.read( 'emboss_e', 'emboss_r', 'emboss_s' ) - - # The data loaded may be saved in YAML format - rebase.save_yaml( 'enz.yaml' ) - rebase.save_yaml( 'enz.yaml', 'ref.yaml' ) - rebase.save_yaml( 'enz.yaml', 'ref.yaml', 'sup.yaml' ) ! # YAML formatted files can also be read with the ! # class method 'load_yaml' ! rebase = Bio::REBASE.load_yaml( 'enz.yaml' ) ! rebase = Bio::REBASE.load_yaml( 'enz.yaml', 'ref.yaml' ) ! rebase = Bio::REBASE.load_yaml( 'enz.yaml', 'ref.yaml', 'sup.yaml' ) ! ! pp rebase.enzymes[0..4] # ["AarI", "AasI", "AatI", "AatII", "Acc16I"] ! pp rebase['AarI'].pattern # "CACCTGC" ! pp rebase['AarI'].blunt? # false ! pp rebase['AarI'].organism # "Arthrobacter aurescens SS2-322" ! pp rebase['AarI'].source # "A. Janulaitis" ! pp rebase['AarI'].primary_strand_cut1 # 11 ! pp rebase['AarI'].primary_strand_cut2 # 0 ! pp rebase['AarI'].complementary_strand_cut1 # 15 ! pp rebase['AarI'].complementary_strand_cut2 # 0 ! pp rebase['AarI'].suppliers # ["F"] ! pp rebase['AarI'].supplier_names # ["Fermentas International Inc."] ! ! pp rebase['AarI'].isoschizomers # Currently none stored in the references file ! pp rebase['AarI'].methylation # "" ! ! pp rebase['EcoRII'].methylation # "2(5)" ! pp rebase['EcoRII'].suppliers # ["F", "J", "M", "O", "S"] ! pp rebase['EcoRII'].supplier_names # ["Fermentas International Inc.", "Nippon Gene Co., Ltd.", ! # "Roche Applied Science", "Toyobo Biochemicals", ! # "Sigma Chemical Corporation"] ! ! # Number of enzymes in the database ! pp rebase.size # 673 ! pp rebase.enzymes.size # 673 ! ! rebase.each do |name, info| ! pp "#{name}: #{info.methylation}" unless info.methylation.empty? ! end ! ! ! == Author ! Trevor Wennblom ! == Copyright ! Copyright (C) 2005 Trevor Wennblom ! Licensed under the same terms as BioRuby. - =end class REBASE - autoload(:YAML, 'yaml') class DynamicMethod_Hash < Hash --- 113,125 ---- #++ # ! autoload :YAML, 'yaml' + module Bio ! autoload :Reference, 'reference' class REBASE class DynamicMethod_Hash < Hash *************** *** 415,417 **** --- 410,413 ---- end # REBASE + end # Bio From k at pub.open-bio.org Mon Feb 27 13:03:16 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 13:03:16 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util contingency_table.rb,1.2,1.3 Message-ID: <200602271303.k1RD3GVL002935@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util In directory pub.open-bio.org:/tmp/cvs-serv2931 Modified Files: contingency_table.rb Log Message: * RDoc is moved in the head and folded for readability Index: contingency_table.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/contingency_table.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** contingency_table.rb 13 Dec 2005 14:58:37 -0000 1.2 --- contingency_table.rb 27 Feb 2006 13:03:14 -0000 1.3 *************** *** 1,6 **** - module Bio # ! # bio/util/contingency_table.rb - Statistical contingency table analysis for aligned sequences # # Copyright:: Copyright (C) 2005 Trevor Wennblom --- 1,5 ---- # ! # = bio/util/contingency_table.rb - Statistical contingency table analysis for aligned sequences # # Copyright:: Copyright (C) 2005 Trevor Wennblom *************** *** 9,13 **** # $Id$ # ! # #-- # --- 8,236 ---- # $Id$ # ! # == Synopsis ! # ! # The Bio::ContingencyTable class provides basic statistical contingency table ! # analysis for two positions within aligned sequences. ! # ! # When ContingencyTable is instantiated the set of characters in the ! # aligned sequences may be passed to it as an array. This is ! # important since it uses these characters to create the table's rows ! # and columns. If this array is not passed it will use it's default ! # of an amino acid and nucleotide alphabet in lowercase along with the ! # clustal spacer '-'. ! # ! # To get data from the table the most used functions will be ! # chi_square and contingency_coefficient: ! # ! # ctable = Bio::ContingencyTable.new() ! # ctable['a']['t'] += 1 ! # # .. put more values into the table ! # puts ctable.chi_square ! # puts ctable.contingency_coefficient # between 0.0 and 1.0 ! # ! # The contingency_coefficient represents the degree of correlation of ! # change between two sequence positions in a multiple-sequence ! # alignment. 0.0 indicates no correlation, 1.0 is the maximum ! # correlation. ! # ! # ! # == Further Reading ! # ! # * http://en.wikipedia.org/wiki/Contingency_table ! # * http://www.physics.csbsju.edu/stats/exact.details.html ! # * Numerical Recipes in C by Press, Flannery, Teukolsky, and Vetterling ! # # ! # == Usage ! # ! # What follows is an example of ContingencyTable in typical usage ! # analyzing results from a clustal alignment. ! # ! # require 'bio' ! # require 'bio/contingency_table' ! # ! # seqs = {} ! # max_length = 0 ! # Bio::ClustalW::Report.new( IO.read('sample.aln') ).to_a.each do |entry| ! # data = entry.data.strip ! # seqs[entry.definition] = data.downcase ! # max_length = data.size if max_length == 0 ! # raise "Aligned sequences must be the same length!" unless data.size == max_length ! # end ! # ! # VERBOSE = true ! # puts "i\tj\tchi_square\tcontingency_coefficient" if VERBOSE ! # correlations = {} ! # ! # 0.upto(max_length - 1) do |i| ! # (i+1).upto(max_length - 1) do |j| ! # ctable = Bio::ContingencyTable.new() ! # seqs.each_value { |seq| ctable.table[ seq[i].chr ][ seq[j].chr ] += 1 } ! # ! # chi_square = ctable.chi_square ! # contingency_coefficient = ctable.contingency_coefficient ! # puts [(i+1), (j+1), chi_square, contingency_coefficient].join("\t") if VERBOSE ! # ! # correlations["#{i+1},#{j+1}"] = contingency_coefficient ! # correlations["#{j+1},#{i+1}"] = contingency_coefficient # Both ways are accurate ! # end ! # end ! # ! # require 'yaml' ! # File.new('results.yml', 'a+') { |f| f.puts correlations.to_yaml } ! # ! # ! # == Tutorial ! # ! ! # ContingencyTable returns the statistical significance of change ! # between two positions in an alignment. If you would like to see how ! # every possible combination of positions in your alignment compares ! # to one another you must set this up yourself. Hopefully the ! # provided examples will help you get started without too much ! # trouble. ! # ! # def lite_example(sequences, max_length, characters) ! # ! # %w{i j chi_square contingency_coefficient}.each { |x| print x.ljust(12) } ! # puts ! # ! # 0.upto(max_length - 1) do |i| ! # (i+1).upto(max_length - 1) do |j| ! # ctable = Bio::ContingencyTable.new( characters ) ! # sequences.each do |seq| ! # i_char = seq[i].chr ! # j_char = seq[j].chr ! # ctable.table[i_char][j_char] += 1 ! # end ! # chi_square = ctable.chi_square ! # contingency_coefficient = ctable.contingency_coefficient ! # [(i+1), (j+1), chi_square, contingency_coefficient].each { |x| print x.to_s.ljust(12) } ! # puts ! # end ! # end ! # ! # end ! # ! # allowed_letters = Array.new ! # allowed_letters = 'abcdefghijk'.split('') ! # ! # seqs = Array.new ! # seqs << 'abcde' ! # seqs << 'abcde' ! # seqs << 'aacje' ! # seqs << 'aacae' ! # ! # length_of_every_sequence = seqs[0].size # 5 letters long ! # ! # lite_example(seqs, length_of_every_sequence, allowed_letters) ! # ! # ! # Producing the following results: ! # ! # i j chi_square contingency_coefficient ! # 1 2 0.0 0.0 ! # 1 3 0.0 0.0 ! # 1 4 0.0 0.0 ! # 1 5 0.0 0.0 ! # 2 3 0.0 0.0 ! # 2 4 4.0 0.707106781186548 ! # 2 5 0.0 0.0 ! # 3 4 0.0 0.0 ! # 3 5 0.0 0.0 ! # 4 5 0.0 0.0 ! # ! # The position i=2 and j=4 has a high contingency coefficient ! # indicating that the changes at these positions are related. Note ! # that i and j are arbitrary, this could be represented as i=4 and j=2 ! # since they both refer to position two and position four in the ! # alignment. Here are some more examples: ! # ! # seqs = Array.new ! # seqs << 'abcde' ! # seqs << 'abcde' ! # seqs << 'aacje' ! # seqs << 'aacae' ! # seqs << 'akcfe' ! # seqs << 'akcfe' ! # ! # length_of_every_sequence = seqs[0].size # 5 letters long ! # ! # lite_example(seqs, length_of_every_sequence, allowed_letters) ! # ! # ! # Results: ! # ! # i j chi_square contingency_coefficient ! # 1 2 0.0 0.0 ! # 1 3 0.0 0.0 ! # 1 4 0.0 0.0 ! # 1 5 0.0 0.0 ! # 2 3 0.0 0.0 ! # 2 4 12.0 0.816496580927726 ! # 2 5 0.0 0.0 ! # 3 4 0.0 0.0 ! # 3 5 0.0 0.0 ! # 4 5 0.0 0.0 ! # ! # Here we can see that the strength of the correlation of change has ! # increased when more data is added with correlated changes at the ! # same positions. ! # ! # seqs = Array.new ! # seqs << 'abcde' ! # seqs << 'abcde' ! # seqs << 'kacje' # changed first letter ! # seqs << 'aacae' ! # seqs << 'akcfa' # changed last letter ! # seqs << 'akcfe' ! # ! # length_of_every_sequence = seqs[0].size # 5 letters long ! # ! # lite_example(seqs, length_of_every_sequence, allowed_letters) ! # ! # ! # Results: ! # ! # i j chi_square contingency_coefficient ! # 1 2 2.4 0.534522483824849 ! # 1 3 0.0 0.0 ! # 1 4 6.0 0.707106781186548 ! # 1 5 0.24 0.196116135138184 ! # 2 3 0.0 0.0 ! # 2 4 12.0 0.816496580927726 ! # 2 5 2.4 0.534522483824849 ! # 3 4 0.0 0.0 ! # 3 5 0.0 0.0 ! # 4 5 2.4 0.534522483824849 ! # ! # With random changes it becomes more difficult to identify correlated ! # changes, yet positions two and four still have the highest ! # correlation as indicated by the contingency coefficient. The best ! # way to improve the accuracy of your results, as is often the case ! # with statistics, is to increase the sample size. ! # ! # ! # == A Note on Efficiency ! # ! ! # ContingencyTable is slow. It involves many calculations for even a ! # seemingly small five-string data set. Even worse, it's very ! # dependent on matrix traversal, and this is done with two dimensional ! # hashes which dashes any hope of decent speed. ! # ! ! # Finally, half of the matrix is redundant and positions could be ! # summed with their companion position to reduce calculations. For ! # example the positions (5,2) and (2,5) could both have their values ! # added together and just stored in (2,5) while (5,2) could be an ! # illegal position. Also, positions (1,1), (2,2), (3,3), etc. will ! # never be used. ! # ! # The purpose of this package is flexibility and education. The code ! # is short and to the point in aims of achieving that purpose. If the ! # BioRuby project moves towards C extensions in the future a ! # professional caliber version will likely be created. ! # ! # #-- # *************** *** 30,252 **** # ! =begin rdoc ! bio/util/contingency_table.rb - Statistical contingency table analysis for aligned sequences ! ! == Synopsis ! ! The Bio::ContingencyTable class provides basic statistical contingency table ! analysis for two positions within aligned sequences. ! ! When ContingencyTable is instantiated the set of characters in the aligned sequences may be ! passed to it as an array. This is important since it uses these characters ! to create the table's rows and columns. If this array is not passed it will ! use it's default of an amino acid and nucleotide alphabet in lowercase along with the ! clustal spacer '-'. ! ! To get data from the table the most used functions will be chi_square and contingency_coefficient: ! ctable = Bio::ContingencyTable.new() ! ctable['a']['t'] += 1 ! # .. put more values into the table ! puts ctable.chi_square ! puts ctable.contingency_coefficient # between 0.0 and 1.0 ! ! The contingency_coefficient represents the degree of correlation of change between two ! sequence positions in a multiple-sequence alignment. 0.0 indicates no correlation, 1.0 is the ! maximum correlation. ! ! ! == Further Reading ! ! * http://en.wikipedia.org/wiki/Contingency_table ! * http://www.physics.csbsju.edu/stats/exact.details.html ! * Numerical Recipes in C by Press, Flannery, Teukolsky, and Vetterling ! ! ! == Usage ! ! What follows is an example of ContingencyTable in typical usage analyzing results from a clustal alignment. ! ! require 'bio' ! require 'bio/contingency_table' ! ! seqs = {} ! max_length = 0 ! Bio::ClustalW::Report.new( IO.read('sample.aln') ).to_a.each do |entry| ! data = entry.data.strip ! seqs[entry.definition] = data.downcase ! max_length = data.size if max_length == 0 ! raise "Aligned sequences must be the same length!" unless data.size == max_length ! end ! ! VERBOSE = true ! puts "i\tj\tchi_square\tcontingency_coefficient" if VERBOSE ! correlations = {} ! ! 0.upto(max_length - 1) do |i| ! (i+1).upto(max_length - 1) do |j| ! ctable = Bio::ContingencyTable.new() ! seqs.each_value { |seq| ctable.table[ seq[i].chr ][ seq[j].chr ] += 1 } ! ! chi_square = ctable.chi_square ! contingency_coefficient = ctable.contingency_coefficient ! puts [(i+1), (j+1), chi_square, contingency_coefficient].join("\t") if VERBOSE ! ! correlations["#{i+1},#{j+1}"] = contingency_coefficient ! correlations["#{j+1},#{i+1}"] = contingency_coefficient # Both ways are accurate ! end ! end ! ! require 'yaml' ! File.new('results.yml', 'a+') { |f| f.puts correlations.to_yaml } ! ! ! == Tutorial ! ! ContingencyTable returns the statistical significance of change between two positions in an alignment. ! If you would like to see how every possible combination of positions in your alignment compares to one another ! you must set this up yourself. Hopefully the provided examples will help you get started without ! too much trouble. ! ! def lite_example(sequences, max_length, characters) ! ! %w{i j chi_square contingency_coefficient}.each { |x| print x.ljust(12) } ! puts ! ! 0.upto(max_length - 1) do |i| ! (i+1).upto(max_length - 1) do |j| ! ctable = Bio::ContingencyTable.new( characters ) ! sequences.each do |seq| ! i_char = seq[i].chr ! j_char = seq[j].chr ! ctable.table[i_char][j_char] += 1 ! end ! chi_square = ctable.chi_square ! contingency_coefficient = ctable.contingency_coefficient ! [(i+1), (j+1), chi_square, contingency_coefficient].each { |x| print x.to_s.ljust(12) } ! puts ! end ! end ! ! end ! ! allowed_letters = Array.new ! allowed_letters = 'abcdefghijk'.split('') ! ! seqs = Array.new ! seqs << 'abcde' ! seqs << 'abcde' ! seqs << 'aacje' ! seqs << 'aacae' ! ! length_of_every_sequence = seqs[0].size # 5 letters long ! ! lite_example(seqs, length_of_every_sequence, allowed_letters) ! ! ! Producing the following results: ! ! i j chi_square contingency_coefficient ! 1 2 0.0 0.0 ! 1 3 0.0 0.0 ! 1 4 0.0 0.0 ! 1 5 0.0 0.0 ! 2 3 0.0 0.0 ! 2 4 4.0 0.707106781186548 ! 2 5 0.0 0.0 ! 3 4 0.0 0.0 ! 3 5 0.0 0.0 ! 4 5 0.0 0.0 ! ! The position i=2 and j=4 has a high contingency coefficient indicating that the changes at these ! positions are related. Note that i and j are arbitrary, this could be represented as i=4 and j=2 ! since they both refer to position two and position four in the alignment. Here are some more examples: ! ! seqs = Array.new ! seqs << 'abcde' ! seqs << 'abcde' ! seqs << 'aacje' ! seqs << 'aacae' ! seqs << 'akcfe' ! seqs << 'akcfe' ! ! length_of_every_sequence = seqs[0].size # 5 letters long ! ! lite_example(seqs, length_of_every_sequence, allowed_letters) ! ! ! Results: ! ! i j chi_square contingency_coefficient ! 1 2 0.0 0.0 ! 1 3 0.0 0.0 ! 1 4 0.0 0.0 ! 1 5 0.0 0.0 ! 2 3 0.0 0.0 ! 2 4 12.0 0.816496580927726 ! 2 5 0.0 0.0 ! 3 4 0.0 0.0 ! 3 5 0.0 0.0 ! 4 5 0.0 0.0 ! ! Here we can see that the strength of the correlation of change has increased when more data is added with correlated changes at the same positions. ! ! seqs = Array.new ! seqs << 'abcde' ! seqs << 'abcde' ! seqs << 'kacje' # changed first letter ! seqs << 'aacae' ! seqs << 'akcfa' # changed last letter ! seqs << 'akcfe' ! ! length_of_every_sequence = seqs[0].size # 5 letters long ! ! lite_example(seqs, length_of_every_sequence, allowed_letters) ! ! ! Results: ! ! i j chi_square contingency_coefficient ! 1 2 2.4 0.534522483824849 ! 1 3 0.0 0.0 ! 1 4 6.0 0.707106781186548 ! 1 5 0.24 0.196116135138184 ! 2 3 0.0 0.0 ! 2 4 12.0 0.816496580927726 ! 2 5 2.4 0.534522483824849 ! 3 4 0.0 0.0 ! 3 5 0.0 0.0 ! 4 5 2.4 0.534522483824849 ! ! With random changes it becomes more difficult to identify correlated changes, yet positions two ! and four still have the highest correlation as indicated by the contingency coefficient. The ! best way to improve the accuracy of your results, as is often the case with statistics, is to ! increase the sample size. ! ! ! == A Note on Efficiency ! ! ContingencyTable is slow. It involves many calculations for even a seemingly small five-string data set. ! Even worse, it's very dependent on matrix traversal, and this is done with two dimensional hashes which ! dashes any hope of decent speed. ! ! Finally, half of the matrix is redundant and positions could be summed with their companion position to reduce ! calculations. For example the positions (5,2) and (2,5) could both have their values added together and ! just stored in (2,5) while (5,2) could be an illegal position. Also, positions (1,1), (2,2), (3,3), etc. ! will never be used. ! ! The purpose of this package is flexibility and education. The code is short and to the point in ! aims of achieving that purpose. If the BioRuby project moves towards C extensions in the future a ! professional caliber version will likely be created. ! ! ! == Author ! Trevor Wennblom ! ! ! == Copyright ! Copyright (C) 2005 Trevor Wennblom ! Licensed under the same terms as BioRuby. ! ! =end class ContingencyTable --- 253,257 ---- # ! module Bio class ContingencyTable From k at pub.open-bio.org Mon Feb 27 13:23:03 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 13:23:03 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util contingency_table.rb,1.3,1.4 Message-ID: <200602271323.k1RDN3VL003103@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util In directory pub.open-bio.org:/tmp/cvs-serv3099/util Modified Files: contingency_table.rb Log Message: * tiny clenaup Index: contingency_table.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/contingency_table.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** contingency_table.rb 27 Feb 2006 13:03:14 -0000 1.3 --- contingency_table.rb 27 Feb 2006 13:23:01 -0000 1.4 *************** *** 1,3 **** - # # = bio/util/contingency_table.rb - Statistical contingency table analysis for aligned sequences --- 1,2 ---- *************** *** 340,342 **** end ! end --- 339,343 ---- end ! ! end # Bio ! From k at pub.open-bio.org Mon Feb 27 13:11:30 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 13:11:30 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util restriction_enzyme.rb,1.2,1.3 Message-ID: <200602271311.k1RDBUVL002969@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util In directory pub.open-bio.org:/tmp/cvs-serv2965 Modified Files: restriction_enzyme.rb Log Message: * RDoc is moved in the header and folded for readability * The data file enzymes.yaml should not be included in the library so self.rebase method is modified to require yaml file to be loaded. Index: restriction_enzyme.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** restriction_enzyme.rb 18 Feb 2006 22:00:55 -0000 1.2 --- restriction_enzyme.rb 27 Feb 2006 13:11:28 -0000 1.3 *************** *** 1,18 **** - require 'pathname' - libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3, 'lib')).cleanpath.to_s - $:.unshift(libpath) unless $:.include?(libpath) - - require 'bio' - require 'bio/db/rebase' - require 'bio/util/restriction_enzyme/double_stranded' - require 'bio/util/restriction_enzyme/single_strand' - require 'bio/util/restriction_enzyme/cut_symbol' - require 'bio/util/restriction_enzyme/analysis' - - - module Bio; end - # ! # bio/util/restriction_enzyme.rb - Digests DNA based on restriction enzyme cut patterns # # Copyright:: Copyright (C) 2006 Trevor Wennblom --- 1,4 ---- # ! # = bio/util/restriction_enzyme.rb - Digests DNA based on restriction enzyme cut patterns # # Copyright:: Copyright (C) 2006 Trevor Wennblom *************** *** 22,25 **** --- 8,174 ---- # # + # NOTE: This documentation and the module are still very much under + # development. It has been released as it is relatively stable and + # comments would be appreciated. + # + # == Synopsis + # + # Bio::RestrictionEnzyme allows you to fragment a DNA strand using one + # or more restriction enzymes. Bio::RestrictionEnzyme is aware that + # multiple enzymes may be competing for the same recognition site and + # returns the various possible fragmentation patterns that result in + # such circumstances. + # + + # Using Bio::RestrictionEnzyme you may simply use the name of common + # enzymes to cut with or you may construct your own unique enzymes to use. + # + # + # == Basic Usage + # + # # EcoRI cut pattern: + # # G|A A T T C + # # +-------+ + # # C T T A A|G + # # + # # This can also be written as: + # # G^AATTC + # + # require 'bio/restriction_enzyme' + # require 'pp' + # + # seq = Bio::Sequence::NA.new('gaattc') + # cuts = seq.cut_with_enzyme('EcoRI') + # p cuts.primary # ["aattc", "g"] + # p cuts.complement # ["g", "cttaa"] + # pp cuts # ==> + # # [#, + # # #] + # + # seq = Bio::Sequence::NA.new('gaattc') + # cuts = seq.cut_with_enzyme('g^aattc') + # p cuts.primary # ["aattc", "g"] + # p cuts.complement # ["g", "cttaa"] + # + # seq = Bio::Sequence::NA.new('gaattc') + # cuts = seq.cut_with_enzyme('g^aattc', 'gaatt^c') + # p cuts.primary # ["c", "aattc", "g", "gaatt"] + # p cuts.complement # ["g", "c", "cttaa", "ttaag"] + # + # seq = Bio::Sequence::NA.new('gaattcgaattc') + # cuts = seq.cut_with_enzyme('EcoRI') + # p cuts.primary # ["aattc", "aattcg", "g"] + # p cuts.complement # ["g", "gcttaa", "cttaa"] + # + # seq = Bio::Sequence::NA.new('gaattcgggaattc') + # cuts = seq.cut_with_enzyme('EcoRI') + # p cuts.primary # ["aattc", "aattcggg", "g"] + # p cuts.complement # ["g", "gcccttaa", "cttaa"] + # + # + # == Advanced Usage + # + # require 'bio/restriction_enzyme' + # require 'pp' + # enzyme_1 = Bio::RestrictionEnzyme.new('anna', [1,1], [3,3]) + # enzyme_2 = Bio::RestrictionEnzyme.new('gg', [1,1]) + # a = Bio::RestrictionEnzyme::Analysis.cut('agga', enzyme_1, enzyme_2) + # p a.primary # ["a", "ag", "g", "ga"] + # + # b = Bio::RestrictionEnzyme::Analysis.cut_and_return_by_permutations('agga', enzyme_1, enzyme_2) + # pp b + # + # + # Output (NOTE: to be cleaned): + # + # {[1, 0]=> + # #, + # #], + # @__fragments_current=true, + # @c_left=3, + # @c_right=3, + # @cut_ranges= + # [#], + # @left=0, + # @p_left=0, + # @p_right=0, + # @right=3, + # @size=4, + # @tags={}>, + # [0, 1]=> + # #, + # #, + # #, + # #], + # @__fragments_current=true, + # @c_left=3, + # @c_right=3, + # @cut_ranges= + # [#, + # #, + # #], + # @left=0, + # @p_left=0, + # @p_right=0, + # @right=3, + # @size=4, + # @tags={}>} + # + # + # == Todo + # + # Currently under development: + # + # * Optimizations in restriction_enzyme/analysis.rb to cut down on + # factorial growth of computation space. + # * Circular DNA cutting + # * Tagging of sequence data + # * Much more documentation + # + # #-- # *************** *** 42,215 **** # - =begin rdoc ! bio/util/restriction_enzyme.rb - Digests DNA based on restriction enzyme cut patterns ! ! NOTE: This documentation and the module are still very much under development. ! It has been released as it is relatively stable and comments would be appreciated. ! ! == Synopsis ! ! Bio::RestrictionEnzyme allows you to fragment a DNA strand using one or ! more restriction enzymes. Bio::RestrictionEnzyme is aware that multiple enzymes may ! be competing for the same recognition site and returns the various possible ! fragmentation patterns that result in such circumstances. ! ! Using Bio::RestrictionEnzyme you may simply use the name of common enzymes to ! cut with or you may construct your own unique enzymes to use. ! ! ! == Basic Usage ! ! # EcoRI cut pattern: ! # G|A A T T C ! # +-------+ ! # C T T A A|G ! # ! # This can also be written as: ! # G^AATTC ! ! require 'bio/restriction_enzyme' ! require 'pp' ! ! seq = Bio::Sequence::NA.new('gaattc') ! cuts = seq.cut_with_enzyme('EcoRI') ! p cuts.primary # ["aattc", "g"] ! p cuts.complement # ["g", "cttaa"] ! pp cuts # ==> ! # [#, ! # #] ! ! seq = Bio::Sequence::NA.new('gaattc') ! cuts = seq.cut_with_enzyme('g^aattc') ! p cuts.primary # ["aattc", "g"] ! p cuts.complement # ["g", "cttaa"] ! ! seq = Bio::Sequence::NA.new('gaattc') ! cuts = seq.cut_with_enzyme('g^aattc', 'gaatt^c') ! p cuts.primary # ["c", "aattc", "g", "gaatt"] ! p cuts.complement # ["g", "c", "cttaa", "ttaag"] ! ! seq = Bio::Sequence::NA.new('gaattcgaattc') ! cuts = seq.cut_with_enzyme('EcoRI') ! p cuts.primary # ["aattc", "aattcg", "g"] ! p cuts.complement # ["g", "gcttaa", "cttaa"] ! ! seq = Bio::Sequence::NA.new('gaattcgggaattc') ! cuts = seq.cut_with_enzyme('EcoRI') ! p cuts.primary # ["aattc", "aattcggg", "g"] ! p cuts.complement # ["g", "gcccttaa", "cttaa"] ! ! ! == Advanced Usage ! ! require 'bio/restriction_enzyme' ! require 'pp' ! enzyme_1 = Bio::RestrictionEnzyme.new('anna', [1,1], [3,3]) ! enzyme_2 = Bio::RestrictionEnzyme.new('gg', [1,1]) ! a = Bio::RestrictionEnzyme::Analysis.cut('agga', enzyme_1, enzyme_2) ! p a.primary # ["a", "ag", "g", "ga"] ! ! b = Bio::RestrictionEnzyme::Analysis.cut_and_return_by_permutations('agga', enzyme_1, enzyme_2) ! pp b ! ! ! Output (NOTE: to be cleaned): ! ! {[1, 0]=> ! #, ! #], ! @__fragments_current=true, ! @c_left=3, ! @c_right=3, ! @cut_ranges= ! [#], ! @left=0, ! @p_left=0, ! @p_right=0, ! @right=3, ! @size=4, ! @tags={}>, ! [0, 1]=> ! #, ! #, ! #, ! #], ! @__fragments_current=true, ! @c_left=3, ! @c_right=3, ! @cut_ranges= ! [#, ! #, ! #], ! @left=0, ! @p_left=0, ! @p_right=0, ! @right=3, ! @size=4, ! @tags={}>} ! ! ! == Todo ! Currently under development: ! * Optimizations in restriction_enzyme/analysis.rb to cut down on factorial growth of computation space. ! * Circular DNA cutting ! * Tagging of sequence data ! * Much more documentation ! ! ! == Author ! Trevor Wennblom ! == Copyright ! Copyright (C) 2006 Trevor Wennblom ! Licensed under the same terms as BioRuby. - =end class Bio::RestrictionEnzyme include CutSymbol --- 191,204 ---- # ! require 'bio/db/rebase' ! require 'bio/util/restriction_enzyme/double_stranded' ! require 'bio/util/restriction_enzyme/single_strand' ! require 'bio/util/restriction_enzyme/cut_symbol' ! require 'bio/util/restriction_enzyme/analysis' ! module Bio class Bio::RestrictionEnzyme include CutSymbol *************** *** 225,234 **** # Returns a Bio::REBASE object loaded with all of the enzyme data on file. # ! def self.rebase ! ! # NOTE open for debate ... maybe this should be stored somewhere else in bioruby? ! data_file_location = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3, 'lib')).cleanpath.to_s + '/bio/util/restriction_enzyme/enzymes.yaml' ! ! @@rebase_enzymes ||= Bio::REBASE.load_yaml( data_file_location ) @@rebase_enzymes end --- 214,219 ---- # Returns a Bio::REBASE object loaded with all of the enzyme data on file. # ! def self.rebase(enzymes_yaml) ! @@rebase_enzymes ||= Bio::REBASE.load_yaml(enzymes_yaml) @@rebase_enzymes end *************** *** 253,254 **** --- 238,241 ---- end + + end # Bio From k at pub.open-bio.org Mon Feb 27 12:55:02 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 12:55:02 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme README, 1.1, NONE Message-ID: <200602271255.k1RCt2VL002892@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv2886/restriction_enzyme Removed Files: README Log Message: * document should go under bioruby-x.x.x/doc/ directory (may be in the Tutorial.rd) --- README DELETED --- From k at pub.open-bio.org Mon Feb 27 12:28:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 12:28:06 +0000 Subject: [BioRuby-cvs] bioruby README,1.13,1.14 Message-ID: <200602271228.k1RCS6VL002726@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv2722 Modified Files: README Log Message: * recommendation of Ruby 1.8.4 or later is added Index: README =================================================================== RCS file: /home/repository/bioruby/bioruby/README,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** README 4 Feb 2006 19:17:16 -0000 1.13 --- README 27 Feb 2006 12:28:03 -0000 1.14 *************** *** 69,73 **** * Ruby 1.8.2 or later -- (()) ! == OPTIONAL REQUIREMENTS --- 69,73 ---- * Ruby 1.8.2 or later -- (()) ! (Ruby 1.8.4 or later is recommended) == OPTIONAL REQUIREMENTS From k at pub.open-bio.org Mon Feb 27 12:13:56 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 12:13:56 +0000 Subject: [BioRuby-cvs] bioruby gemspec.rb,1.6,1.7 Message-ID: <200602271213.k1RCDuVL002659@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv2655 Modified Files: gemspec.rb Log Message: * prepared for 1.0.0 release Index: gemspec.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/gemspec.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** gemspec.rb 24 Jan 2006 11:42:17 -0000 1.6 --- gemspec.rb 27 Feb 2006 12:13:54 -0000 1.7 *************** *** 4,8 **** spec = Gem::Specification.new do |s| s.name = 'bio' ! s.version = "0.7.1" s.author = "BioRuby project" --- 4,8 ---- spec = Gem::Specification.new do |s| s.name = 'bio' ! s.version = "1.0.0" s.author = "BioRuby project" From k at pub.open-bio.org Mon Feb 27 11:38:16 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:38:16 +0000 Subject: [BioRuby-cvs] bioruby ChangeLog,1.49,1.50 Message-ID: <200602271138.k1RBcGVL002462@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv2456 Modified Files: ChangeLog Log Message: * prepared for 1.0.0 release Index: ChangeLog =================================================================== RCS file: /home/repository/bioruby/bioruby/ChangeLog,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** ChangeLog 1 Feb 2006 07:30:19 -0000 1.49 --- ChangeLog 27 Feb 2006 11:38:14 -0000 1.50 *************** *** 1,18 **** ! 2005-02-01 Trevor Wennblom ! * Bio::RestrictionEnzyme first commit for comments. * See lib/bio/util/restriction_enzyme.rb and ! test/unit/bio/util/restriction_enzyme ! 2005-01-20 Toshiaki Katayama * BioRuby 0.7.1 is released. ! 2005-01-12 Toshiaki Katayama * lib/bio/db.ra: fixed a bug of the tag_cut method introduced in 0.7.0 (reported by Alex Gutteridge) ! 2005-01-04 Naohisa Goto * Bio::PDB is refactored. See doc/Changes-0.7 for more details. --- 1,51 ---- ! 2006-02-27 Toshiaki Katayama ! * BioRuby 1.0.0 released ! ! 2006-02-10 Toshiaki Katayama ! ! * BioRuby shell is changed to use session/ directory under the current ! or specified directory to store the session information instead of ! ./.bioruby directory. ! ! 2006-02-05 Toshiaki Katayama ! ! * License to be changed to Ruby's (not yet completed). ! ! 2006-02-01 Trevor Wennblom ! ! * Bio::RestrictionEnzyme first commit for comments. * See lib/bio/util/restriction_enzyme.rb and ! test/unit/bio/util/restriction_enzyme ! 2006-01-28 Toshiaki Katayama ! ! * lib/bio/appl/emboss.rb ! ! EMBOSS USA format is now accepted via seqret/entret commands ! and also utilized in the BioRuby shell (lib/bio/shell.rb, ! plugin/entry.rb, plugin/emboss.rb). ! ! * lib/bio/io/brdb.rb is removed - unused Bio::BRDB (BioRuby DB) ! ! 2006-01-23 Toshiaki Katayama ! ! * lib/bio/sequence.rb ! ! Bio::Sequence is refactored to be a container class for ! any sequence annotations. Functionality is separared into ! several files under the lib/bio/sequence/ direcotry as ! common.rb, compat.rb, aa.rb, na.rb, format.rb ! ! 2006-01-20 Toshiaki Katayama * BioRuby 0.7.1 is released. ! 2006-01-12 Toshiaki Katayama * lib/bio/db.ra: fixed a bug of the tag_cut method introduced in 0.7.0 (reported by Alex Gutteridge) ! 2006-01-04 Naohisa Goto * Bio::PDB is refactored. See doc/Changes-0.7 for more details. From k at pub.open-bio.org Mon Feb 27 11:38:16 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:38:16 +0000 Subject: [BioRuby-cvs] bioruby/doc Changes-0.7.rd,1.15,1.16 Message-ID: <200602271138.k1RBcGVL002464@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/doc In directory pub.open-bio.org:/tmp/cvs-serv2456/doc Modified Files: Changes-0.7.rd Log Message: * prepared for 1.0.0 release Index: Changes-0.7.rd =================================================================== RCS file: /home/repository/bioruby/bioruby/doc/Changes-0.7.rd,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Changes-0.7.rd 22 Feb 2006 15:09:45 -0000 1.15 --- Changes-0.7.rd 27 Feb 2006 11:38:14 -0000 1.16 *************** *** 50,53 **** --- 50,66 ---- --- Bio::Sequence + Bio::Sequence is completely refactored to be a container class for + any sequence annotations. Functionalities are separated into several + files under the lib/bio/sequence/ directory as + + * common.rb : module provides common methods for NA and AA sequences + * compat.rb : methods for backward compatibility + * aa.rb : Bio::Sequence::AA class + * na.rb : Bio::Sequence::NA class + * format.rb : module for format conversion + + Bio::Sequence is no longer a sub-class of String, instead, + Bio::Sequence::NA and AA inherits String directly. + * Bio::Sequence::NA#gc_percent returns integer instead of float * Bio::Sequence::NA#gc (was aliased to gc_percent) is removed From k at pub.open-bio.org Mon Feb 27 11:16:24 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/doc README_FOR_APP, NONE, 1.1 Message-ID: <200602271116.k1RBGOVL002307@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/doc In directory pub.open-bio.org:/tmp/cvs-serv2240/doc Added Files: README_FOR_APP Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: README_FOR_APP --- Use this README file to introduce your application and point to useful places in the API for learning more. Run "rake appdoc" to generate API documentation for your models and controllers. From k at pub.open-bio.org Mon Feb 27 11:16:26 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:26 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script/process reaper, NONE, 1.1 spawner, NONE, 1.1 spinner, NONE, 1.1 Message-ID: <200602271116.k1RBGQVL002329@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/process In directory pub.open-bio.org:/tmp/cvs-serv2240/script/process Added Files: reaper spawner spinner Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: spinner --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spinner' --- NEW FILE: spawner --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner' --- NEW FILE: reaper --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper' From k at pub.open-bio.org Mon Feb 27 11:16:25 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/images icon.png, NONE, 1.1 rails.png, NONE, 1.1 Message-ID: <200602271116.k1RBGPVL002313@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/images In directory pub.open-bio.org:/tmp/cvs-serv2240/public/images Added Files: icon.png rails.png Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: icon.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: rails.png --- (This appears to be a binary file; contents omitted.) From k at pub.open-bio.org Mon Feb 27 11:16:26 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:26 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script/performance benchmarker, NONE, 1.1 profiler, NONE, 1.1 Message-ID: <200602271116.k1RBGQVL002318@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/performance In directory pub.open-bio.org:/tmp/cvs-serv2240/script/performance Added Files: benchmarker profiler Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: benchmarker --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker' --- NEW FILE: profiler --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler' From k at pub.open-bio.org Mon Feb 27 11:16:24 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/config boot.rb, NONE, 1.1 database.yml, NONE, 1.1 environment.rb, NONE, 1.1 routes.rb, NONE, 1.1 Message-ID: <200602271116.k1RBGOVL002301@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/config In directory pub.open-bio.org:/tmp/cvs-serv2240/config Added Files: boot.rb database.yml environment.rb routes.rb Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: routes.rb --- ActionController::Routing::Routes.draw do |map| # Add your own custom routes here. # The priority is based upon order of creation: first created -> highest priority. # Here's a sample route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action # You can have the root of your site routed by hooking up '' # -- just remember to delete public/index.html. # map.connect '', :controller => "welcome" # Allow downloading Web Service WSDL as a file with an extension # instead of a file named 'wsdl' map.connect ':controller/service.wsdl', :action => 'wsdl' # Install the default route as the lowest priority. map.connect ':controller/:action/:id' end --- NEW FILE: database.yml --- # MySQL (default setup). Versions 4.1 and 5.0 are recommended. # # Get the fast C bindings: # gem install mysql # (on OS X: gem install mysql -- --include=/usr/local/lib) # And be sure to use new-style password hashing: # http://dev.mysql.com/doc/refman/5.0/en/old-client.html development: adapter: mysql database: kumamushi_development username: root password: socket: /tmp/mysql.sock # Connect on a TCP socket. If omitted, the adapter will connect on the # domain socket given by socket instead. #host: localhost #port: 3306 # Warning: The database defined as 'test' will be erased and # re-generated from your development database when you run 'rake'. # Do not set this db to the same as development or production. test: adapter: mysql database: kumamushi_test username: root password: socket: /tmp/mysql.sock production: adapter: mysql database: kumamushi_production username: root password: socket: /tmp/mysql.sock # PostgreSQL versions 7.4 - 8.1 # # Get the C bindings: # gem install postgres # or use the pure-Ruby bindings on Windows: # gem install postgres-pr postgresql_example: adapter: postgresql database: kumamushi_development username: kumamushi password: # Connect on a TCP socket. Omitted by default since the client uses a # domain socket that doesn't need configuration. #host: remote-database #port: 5432 # Schema search path. The server defaults to $user,public #schema_search_path: myapp,sharedapp,public # Character set encoding. The server defaults to sql_ascii. #encoding: UTF8 # Minimum log levels, in increasing order: # debug5, debug4, debug3, debug2, debug1, # info, notice, warning, error, log, fatal, or panic # The server defaults to notice. #min_messages: warning # SQLite version 2.x # gem install sqlite-ruby sqlite_example: adapter: sqlite database: db/development.sqlite2 # SQLite version 3.x # gem install sqlite3-ruby sqlite3_example: adapter: sqlite3 database: db/development.sqlite3 # In-memory SQLite 3 database. Useful for tests. sqlite3_in_memory_example: adapter: sqlite3 database: ":memory:" --- NEW FILE: boot.rb --- # Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb unless defined?(RAILS_ROOT) root_path = File.join(File.dirname(__FILE__), '..') unless RUBY_PLATFORM =~ /mswin32/ require 'pathname' root_path = Pathname.new(root_path).cleanpath(true).to_s end RAILS_ROOT = root_path end if File.directory?("#{RAILS_ROOT}/vendor/rails") require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" else require 'rubygems' require 'initializer' end Rails::Initializer.run(:set_load_path) --- NEW FILE: environment.rb --- # Be sure to restart your web server when you modify this file. # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way # ENV['RAILS_ENV'] ||= 'production' # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') Rails::Initializer.run do |config| # Settings in config/environments/* take precedence those specified here # Skip frameworks you're not going to use # config.frameworks -= [ :action_web_service, :action_mailer ] # Add additional load paths for your own custom dirs # config.load_paths += %W( #{RAILS_ROOT}/extras ) # Force all environments to use the same logger level # (by default production uses :info, the others :debug) # config.log_level = :debug # Use the database for sessions instead of the file system # (create the session table with 'rake create_sessions_table') # config.action_controller.session_store = :active_record_store # Enable page/fragment caching by setting a file-based store # (remember to create the caching directory and make it readable to the application) # config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache" # Activate observers that should always be running # config.active_record.observers = :cacher, :garbage_collector # Make Active Record use UTC-base instead of local time # config.active_record.default_timezone = :utc # Use Active Record's schema dumper instead of SQL when creating the test database # (enables use of different database adapters for development and test environments) # config.active_record.schema_format = :ruby # See Rails::Configuration for more options end # Add new inflection rules using the following format # (all these examples are active by default): # Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end # Include your application configuration below From k at pub.open-bio.org Mon Feb 27 11:16:25 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script about, NONE, 1.1 breakpointer, NONE, 1.1 console, NONE, 1.1 destroy, NONE, 1.1 generate, NONE, 1.1 plugin, NONE, 1.1 runner, NONE, 1.1 server, NONE, 1.1 Message-ID: <200602271116.k1RBGPVL002316@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script In directory pub.open-bio.org:/tmp/cvs-serv2240/script Added Files: about breakpointer console destroy generate plugin runner server Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: breakpointer --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/breakpointer' --- NEW FILE: about --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about' --- NEW FILE: console --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console' --- NEW FILE: plugin --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin' --- NEW FILE: runner --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner' --- NEW FILE: destroy --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy' --- NEW FILE: generate --- #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate' --- NEW FILE: server --- #!/usr/bin/env ruby # # = BioRuby shell on Rails server - GUI for the BioRuby shell # # Copyright:: Copyright (C) 2006 # Nobuya Tanaka , # Toshiaki Katayama # License:: Ruby's # # $Id: server,v 1.1 2006/02/27 11:16:23 k Exp $ # require 'bio/shell' require 'drb/drb' require './app/models/shell_connection' $drb_server = ShellConnection.new ## Access Control List # # require 'drb/acl' # # list = %w(deny all # allow 127.0.0.1 # ) # acl = ACL.new(list, ACL::DENY_ALLOW) # DRb.install_acl(acl) # STDOUT.sync = true #uri = "druby://localhost:0" uri = 'druby://localhost:81064' # baioroji- DRb.start_service(uri, $drb_server) puts DRb.uri puts "starting ..." require './config/boot' require 'commands/server' puts "exiting ..." From k at pub.open-bio.org Mon Feb 27 11:16:25 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public 404.html, NONE, 1.1 500.html, NONE, 1.1 dispatch.cgi, NONE, 1.1 dispatch.fcgi, NONE, 1.1 dispatch.rb, NONE, 1.1 favicon.ico, NONE, 1.1 index.html, NONE, 1.1 robots.txt, NONE, 1.1 Message-ID: <200602271116.k1RBGPVL002310@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public In directory pub.open-bio.org:/tmp/cvs-serv2240/public Added Files: 404.html 500.html dispatch.cgi dispatch.fcgi dispatch.rb favicon.ico index.html robots.txt Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: favicon.ico --- --- NEW FILE: dispatch.cgi --- #!/usr/bin/env ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired require "dispatcher" ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) Dispatcher.dispatch --- NEW FILE: 404.html ---

    File not found

    Change this error message for pages not found in public/404.html

    --- NEW FILE: robots.txt --- # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file --- NEW FILE: index.html --- Ruby on Rails: Welcome aboard

    Getting started

    Here’s how to get rolling:

    1. Create your databases and edit config/database.yml

      Rails needs to know your login and password.

    2. Use script/generate to create your models and controllers

      To see all available options, run it without parameters.

    3. Set up a default route and remove or rename this file

      Routes are setup in config/routes.rb.

    --- NEW FILE: dispatch.rb --- #!/usr/bin/env ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired require "dispatcher" ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) Dispatcher.dispatch --- NEW FILE: dispatch.fcgi --- #!/usr/bin/env ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log # and the GC period is nil (turned off). A reasonable number of requests # could range from 10-100 depending on the memory footprint of your app. # # Example: # # Default log path, normal GC behavior. # RailsFCGIHandler.process! # # # Default log path, 50 requests between GC. # RailsFCGIHandler.process! nil, 50 # # # Custom log path, normal GC behavior. # RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log' # require File.dirname(__FILE__) + "/../config/environment" require 'fcgi_handler' RailsFCGIHandler.process! --- NEW FILE: 500.html ---

    Application error (Apache)

    Change this error message for exceptions thrown outside of an action (like in Dispatcher setups or broken Ruby code) in public/500.html

    From k at pub.open-bio.org Mon Feb 27 11:16:23 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:23 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails Rakefile,NONE,1.1 Message-ID: <200602271116.k1RBGNVL002274@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails In directory pub.open-bio.org:/tmp/cvs-serv2240 Added Files: Rakefile Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: Rakefile --- # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/switchtower.rake, and they will automatically be available to Rake. require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails' From k at pub.open-bio.org Mon Feb 27 10:23:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/lib - New directory Message-ID: <200602271023.k1RAN6VL001816@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib In directory pub.open-bio.org:/tmp/cvs-serv1726/lib Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:07 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:07 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/log - New directory Message-ID: <200602271023.k1RAN7VL001827@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/log In directory pub.open-bio.org:/tmp/cvs-serv1726/log Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/log added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:30 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:30 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test - New directory Message-ID: <200602271012.k1RACUVL001470@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test In directory pub.open-bio.org:/tmp/cvs-serv1419/lib/bio/shell/rails/test Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:08 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:08 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test - New directory Message-ID: <200602271023.k1RAN8VL001869@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test In directory pub.open-bio.org:/tmp/cvs-serv1726/test Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:08 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:08 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script - New directory Message-ID: <200602271023.k1RAN8VL001856@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script In directory pub.open-bio.org:/tmp/cvs-serv1726/script Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/script added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:07 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:07 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public - New directory Message-ID: <200602271023.k1RAN7VL001834@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public In directory pub.open-bio.org:/tmp/cvs-serv1726/public Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:10 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:10 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/vendor - New directory Message-ID: <200602271023.k1RANAVL001896@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor In directory pub.open-bio.org:/tmp/cvs-serv1726/vendor Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:46 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/views - New directory Message-ID: <200602271012.k1RACkVL001530@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/app/views Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/lib/tasks - New directory Message-ID: <200602271023.k1RAN6VL001822@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib/tasks In directory pub.open-bio.org:/tmp/cvs-serv1726/lib/tasks Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/lib/tasks added to the repository From k at pub.open-bio.org Mon Feb 27 11:17:36 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:17:36 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public .htaccess, NONE, 1.1 Message-ID: <200602271117.k1RBHaVL002389@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public In directory pub.open-bio.org:/tmp/cvs-serv2375/lib/bio/shell/rails/public Added Files: .htaccess Log Message: * forgotten dot file --- NEW FILE: .htaccess --- # General Apache options AddHandler fastcgi-script .fcgi AddHandler cgi-script .cgi Options +FollowSymLinks +ExecCGI # If you don't want Rails to look in certain directories, # use the following rewrite rules so that Apache won't rewrite certain requests # # Example: # RewriteCond %{REQUEST_URI} ^/notrails.* # RewriteRule .* - [L] # Redirect all requests not available on the filesystem to Rails # By default the cgi dispatcher is used which is very slow # # For better performance replace the dispatcher with the fastcgi one # # Example: # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] RewriteEngine On # If your Rails application is accessed via an Alias directive, # then you MUST also set the RewriteBase in this htaccess file. # # Example: # Alias /myrailsapp /path/to/myrailsapp/public # RewriteBase /myrailsapp RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.cgi [QSA,L] # In case Rails experiences terminal errors # Instead of displaying this message you can supply a file here which will be rendered instead # # Example: # ErrorDocument 500 /500.html ErrorDocument 500 "

    Application error

    Rails application failed to start properly" From k at pub.open-bio.org Mon Feb 27 10:23:04 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:04 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/models - New directory Message-ID: <200602271023.k1RAN4VL001769@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/models In directory pub.open-bio.org:/tmp/cvs-serv1726/app/models Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/models added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:09 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:09 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/mocks - New directory Message-ID: <200602271023.k1RAN9VL001882@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks In directory pub.open-bio.org:/tmp/cvs-serv1726/test/mocks Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:05 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:05 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/components - New directory Message-ID: <200602271023.k1RAN5VL001792@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/components In directory pub.open-bio.org:/tmp/cvs-serv1726/components Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/components added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:46 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/models - New directory Message-ID: <200602271012.k1RACkVL001529@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/models In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/app/models Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/models added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:48 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:48 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/mocks - New directory Message-ID: <200602271012.k1RACmVL001568@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/test/mocks Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:04 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:04 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/helpers - New directory Message-ID: <200602271023.k1RAN4VL001765@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/helpers In directory pub.open-bio.org:/tmp/cvs-serv1726/app/helpers Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/helpers added to the repository From k at pub.open-bio.org Mon Feb 27 11:16:26 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:26 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test test_helper.rb, NONE, 1.1 Message-ID: <200602271116.k1RBGQVL002332@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test In directory pub.open-bio.org:/tmp/cvs-serv2240/test Added Files: test_helper.rb Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: test_helper.rb --- ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class Test::Unit::TestCase # Transactional fixtures accelerate your tests by wrapping each test method # in a transaction that's rolled back on completion. This ensures that the # test database remains unchanged so your fixtures don't have to be reloaded # between every test method. Fewer database queries means faster tests. # # Read Mike Clark's excellent walkthrough at # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting # # Every Active Record database supports transactions except MyISAM tables # in MySQL. Turn off transactional fixtures in this case; however, if you # don't care one way or the other, switching from MyISAM to InnoDB tables # is recommended. self.use_transactional_fixtures = true # Instantiated fixtures are slow, but give you @david where otherwise you # would need people(:david). If you don't want to migrate your existing # test cases which use the @david style and don't mind the speed hit (each # instantiated fixtures translates to a database query per test method), # then set this back to true. self.use_instantiated_fixtures = false # Add more helper methods to be used by all tests here... end From k at pub.open-bio.org Mon Feb 27 10:23:08 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:08 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/fixtures - New directory Message-ID: <200602271023.k1RAN8VL001874@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/fixtures In directory pub.open-bio.org:/tmp/cvs-serv1726/test/fixtures Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/fixtures added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:46 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/images - New directory Message-ID: <200602271012.k1RACkVL001547@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/images In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/public/images Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/images added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:47 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:47 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/fixtures - New directory Message-ID: <200602271012.k1RAClVL001562@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/fixtures In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/test/fixtures Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/fixtures added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:47 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:47 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script/process - New directory Message-ID: <200602271012.k1RAClVL001559@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/process In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/script/process Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/process added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:48 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:48 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/vendor/plugins - New directory Message-ID: <200602271012.k1RACmVL001574@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/vendor/plugins Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:08 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:08 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script/process - New directory Message-ID: <200602271023.k1RAN8VL001866@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/process In directory pub.open-bio.org:/tmp/cvs-serv1726/script/process Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/process added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:05 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:05 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/views/shell - New directory Message-ID: <200602271023.k1RAN5VL001787@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views/shell In directory pub.open-bio.org:/tmp/cvs-serv1726/app/views/shell Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views/shell added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:45 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:45 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/controllers - New directory Message-ID: <200602271012.k1RACjVL001522@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/controllers In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/app/controllers Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/controllers added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:47 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:47 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/functional - New directory Message-ID: <200602271012.k1RAClVL001565@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/functional In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/test/functional Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/functional added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:09 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:09 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/functional - New directory Message-ID: <200602271023.k1RAN9VL001879@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/functional In directory pub.open-bio.org:/tmp/cvs-serv1726/test/functional Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/functional added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:09 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:09 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/mocks/test - New directory Message-ID: <200602271023.k1RAN9VL001890@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks/test In directory pub.open-bio.org:/tmp/cvs-serv1726/test/mocks/test Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks/test added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:07 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:07 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/stylesheets - New directory Message-ID: <200602271023.k1RAN7VL001851@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/stylesheets In directory pub.open-bio.org:/tmp/cvs-serv1726/public/stylesheets Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/stylesheets added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:08 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:08 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script/performance - New directory Message-ID: <200602271023.k1RAN8VL001863@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/performance In directory pub.open-bio.org:/tmp/cvs-serv1726/script/performance Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/performance added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:47 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:47 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/script/performance - New directory Message-ID: <200602271012.k1RAClVL001556@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/performance In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/script/performance Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/script/performance added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:07 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:07 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/javascripts - New directory Message-ID: <200602271023.k1RAN7VL001847@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/javascripts In directory pub.open-bio.org:/tmp/cvs-serv1726/public/javascripts Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/javascripts added to the repository From k at pub.open-bio.org Mon Feb 27 10:23:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/config/environments - New directory Message-ID: <200602271023.k1RAN6VL001803@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/config/environments In directory pub.open-bio.org:/tmp/cvs-serv1726/config/environments Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/config/environments added to the repository From k at pub.open-bio.org Mon Feb 27 10:12:46 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:12:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/config/environments - New directory Message-ID: <200602271012.k1RACkVL001532@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/config/environments In directory pub.open-bio.org:/tmp/cvs-serv1495/lib/bio/shell/rails/config/environments Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/config/environments added to the repository From k at pub.open-bio.org Mon Feb 27 11:16:25 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/stylesheets main.css, NONE, 1.1 Message-ID: <200602271116.k1RBGPVL002315@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/stylesheets In directory pub.open-bio.org:/tmp/cvs-serv2240/public/stylesheets Added Files: main.css Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: main.css --- body { background-color: #fff; color: #333; } body, p, td { font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; line-height: 18px; } pre { background-color: #eee; padding: 10px; font-size: 11px; } a { color: #000; } a:visited { color: #666; } a:hover { color: #fff; background-color:#000; } .fieldWithErrors { padding: 2px; background-color: red; display: table; } table { text-align: top; } #ErrorExplanation { width: 400px; border: 2px solid red; padding: 7px; padding-bottom: 12px; margin-bottom: 20px; background-color: #f0f0f0; } #ErrorExplanation h2 { text-align: left; font-weight: bold; padding: 5px 5px 5px 15px; font-size: 12px; margin: -7px; background-color: #c00; color: #fff; } #ErrorExplanation p { color: #333; margin-bottom: 0; padding: 5px; } #ErrorExplanation ul li { font-size: 12px; list-style: square; } h1{ color: #333; padding: 10px; margin: 12px; } #banner{ margin-left: 5em; margin-right: -6px; text-align: center; font-size: 30px; border-top: 1px solid silver; border-bottom: 1px solid silver; padding: 10px 0px 10px 0px; } tr{ vertical-align: top; text-align: left; } #side img{ background-color: black; width:12em; } #side{ position: absolute; margin: -13px; top: 1em; left: 1em; width: 10em; } #side ul{ font-size: 13px; margin: 0em; } #side h2{ font-size: 12px; text-align: center; width: 13em; background-color: black; color: white; } #side input{ text-align: center; } #main { margin-left: 10em; padding-top: 4x; padding-left: 2em; background: white; } .main { margin-left: 10em; padding-top: 4x; padding-left: 2em; background: white; } #menu { margin-left: 10em; padding-top: 4x; padding-left: 2em; background: white; } div.uploadStatus { margin: 5px; } div.progressBar { margin: 5px; } div.progressBar div.border { background-color: #fff; border: 1px solid grey; width: 100%; } div.progressBar div.background { background-color: #333; height: 18px; width: 0%; } .tabs { position:relative; height: 20px; margin: 0; padding: 0; background: #aaa repeat-x; overflow:hidden } .tabs li { display:inline; } .tabs a:hover, .tabs a.tab-active { color:#333; background:#fff url("bar_on.gif") repeat-x; border-right: 1px solid #fff } .tabs a { height: 27px; font:12px verdana, helvetica, sans-serif; font-weight:bold; position:relative; padding:6px 10px 10px 10px; margin: 0px -4px 0px 0px; color:#333; text-decoration:none; border-left:1px solid #fff; border-right:1px solid #333; } .tab-container { background: #fff; border:1px solid #555; } .tab-panes { margin: 3px } From k at pub.open-bio.org Mon Feb 27 10:23:09 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:09 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/test/mocks/development - New directory Message-ID: <200602271023.k1RAN9VL001887@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks/development In directory pub.open-bio.org:/tmp/cvs-serv1726/test/mocks/development Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/test/mocks/development added to the repository From k at pub.open-bio.org Mon Feb 27 11:16:23 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:23 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/helpers application_helper.rb, NONE, 1.1 Message-ID: <200602271116.k1RBGNVL002282@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/helpers In directory pub.open-bio.org:/tmp/cvs-serv2240/app/helpers Added Files: application_helper.rb Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: application_helper.rb --- # Methods added to this helper will be available to all templates in the application. module ApplicationHelper end From k at pub.open-bio.org Mon Feb 27 11:16:24 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/views/layouts shell.rhtml, NONE, 1.1 Message-ID: <200602271116.k1RBGOVL002292@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views/layouts In directory pub.open-bio.org:/tmp/cvs-serv2240/app/views/layouts Added Files: shell.rhtml Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: shell.rhtml --- BioRuby shell on Rails

    Local variables

      <% @local_vars.each do |idx, var| %>
    • <%= link_to idx, {:action => "show", :id => idx}%>
    • <% end %>
    <%= @content_for_layout %>
    From k at pub.open-bio.org Mon Feb 27 11:16:24 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/models shell_connection.rb, NONE, 1.1 Message-ID: <200602271116.k1RBGOVL002287@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/models In directory pub.open-bio.org:/tmp/cvs-serv2240/app/models Added Files: shell_connection.rb Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: shell_connection.rb --- # Model object for rails class ShellConnection # include DRb::DRbObservable attr_reader :registry def puts_remote(str) STDOUT.puts(str) end def initialize @connected = false @registry = {} end def [] o_id @registry[o_id] end def []=(name, obj) @registry[name] = obj end def delete(name) @registry.delete(name) end end From k at pub.open-bio.org Mon Feb 27 11:16:24 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/views/shell history.rhtml, NONE, 1.1 index.rhtml, NONE, 1.1 show.rhtml, NONE, 1.1 Message-ID: <200602271116.k1RBGOVL002297@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/views/shell In directory pub.open-bio.org:/tmp/cvs-serv2240/app/views/shell Added Files: history.rhtml index.rhtml show.rhtml Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: index.rhtml ---

    Connected!

    --- NEW FILE: show.rhtml --- <%= @inheritance %> <%= @contents %> <%= form_tag(:action => "show")%> <%= end_form_tag %> --- NEW FILE: history.rhtml ---
    <%= @history %>
    
    From k at pub.open-bio.org Mon Feb 27 10:23:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/doc - New directory Message-ID: <200602271023.k1RAN6VL001811@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/doc In directory pub.open-bio.org:/tmp/cvs-serv1726/doc Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/doc added to the repository From k at pub.open-bio.org Mon Feb 27 11:16:23 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:23 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/app/controllers application.rb, NONE, 1.1 shell_controller.rb, NONE, 1.1 Message-ID: <200602271116.k1RBGNVL002278@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/controllers In directory pub.open-bio.org:/tmp/cvs-serv2240/app/controllers Added Files: application.rb shell_controller.rb Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: application.rb --- # Filters added to this controller will be run for all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base end --- NEW FILE: shell_controller.rb --- class DocumentRegistry @@registry = [] def self.[](class_name) @@registry.each do |block| url = block.call(class_name) return url if url end "" end def self.register &block @@registry.push(block) end end DocumentRegistry.register() do |class_name| if m = /Bio::(.+)/.match(class_name) "http://bioruby.org/rdoc/classes/Bio/#{m[1].split('::').join('/')}.html" else false end end DocumentRegistry.register do |class_name| if m = /Chem::(.+)/.match(class_name) "http://chemruby.org/rdoc/classes/Chem/#{m[1].split('::').join('/')}.html" else false end end DocumentRegistry.register do |class_name| "http://www.ruby-doc.org/core/classes/#{class_name.split('::').join('/')}.html" end class ShellController < ApplicationController layout 'shell' #, :except => [:rss_feed, :rss_with_content] def index setup end def show setup @obj = $drb_server[params[:id]] if @obj.nil? @inheritance = "

    Unknown local variable! : #{params[:var]}

    " else @inheritance = get_inheritance @obj.class if @obj.respond_to?(:to_html) @contents = @obj.to_html else @contents = "Undefined :to_html" end end @title = params[:id] end =begin def history setup @history = File.read("session/history") end =end private def setup @local_vars = $drb_server.registry end def get_inheritance obj # mods = obj.included_modules - [PP::ObjectMixin, Bio::Shell, WEBrick] mods = obj.included_modules module_links = mods.collect{|m| " [#{m.to_s}] " }.join("|") inherit = [] loop do inherit.push(" [#{obj.to_s}] ") break if obj == Object obj = obj.superclass end "" + "
    Inheritance" + inherit.join(" < ") + "
    Mix-in" + module_links + "
    " end end From k at pub.open-bio.org Mon Feb 27 11:16:24 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/config/environments development.rb, NONE, 1.1 production.rb, NONE, 1.1 test.rb, NONE, 1.1 Message-ID: <200602271116.k1RBGOVL002304@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/config/environments In directory pub.open-bio.org:/tmp/cvs-serv2240/config/environments Added Files: development.rb production.rb test.rb Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: production.rb --- # Settings specified here will take precedence over those in config/environment.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Use a different logger for distributed setups # config.logger = SyslogLogger.new # Full error reports are disabled and caching is turned on config.action_controller.consider_all_requests_local = false config.action_controller.perform_caching = true # Enable serving of images, stylesheets, and javascripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" # Disable delivery errors if you bad email addresses should just be ignored # config.action_mailer.raise_delivery_errors = false --- NEW FILE: test.rb --- # Settings specified here will take precedence over those in config/environment.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! config.cache_classes = true # Log error messages when you accidentally call methods on nil. config.whiny_nils = true # Show full error reports and disable caching config.action_controller.consider_all_requests_local = true config.action_controller.perform_caching = false # Tell ActionMailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test --- NEW FILE: development.rb --- # Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.cache_classes = false # Log error messages when you accidentally call methods on nil. config.whiny_nils = true # Enable the breakpoint server that script/breakpointer connects to config.breakpoint_server = true # Show full error reports and disable caching config.action_controller.consider_all_requests_local = true config.action_controller.perform_caching = false # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false From k at pub.open-bio.org Mon Feb 27 10:23:06 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 10:23:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/config - New directory Message-ID: <200602271023.k1RAN6VL001797@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/config In directory pub.open-bio.org:/tmp/cvs-serv1726/config Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/shell/rails/config added to the repository From trevor at pub.open-bio.org Wed Feb 1 07:17:46 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:17:46 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme - New directory Message-ID: <200602010724.k117ObVL028599@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv28589/restriction_enzyme Log Message: Directory /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme added to the repository From trevor at pub.open-bio.org Wed Feb 1 07:18:46 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:18:46 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme/single_strand - New directory Message-ID: <200602010725.k117PdVL028617@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/single_strand In directory pub.open-bio.org:/tmp/cvs-serv28607/single_strand Log Message: Directory /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/single_strand added to the repository From trevor at pub.open-bio.org Wed Feb 1 07:19:05 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:19:05 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme/double_stranded - New directory Message-ID: <200602010725.k117PtVL028635@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/double_stranded In directory pub.open-bio.org:/tmp/cvs-serv28623/double_stranded Log Message: Directory /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/double_stranded added to the repository From trevor at pub.open-bio.org Wed Feb 1 07:19:10 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:19:10 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme/analysis - New directory Message-ID: <200602010725.k117PuVL028638@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/analysis In directory pub.open-bio.org:/tmp/cvs-serv28623/analysis Log Message: Directory /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/analysis added to the repository From trevor at pub.open-bio.org Wed Feb 1 07:19:38 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:19:38 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme - New directory Message-ID: <200602010726.k117QUVL028654@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv28644/restriction_enzyme Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme added to the repository From trevor at pub.open-bio.org Wed Feb 1 07:19:59 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:19:59 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/double_stranded - New directory Message-ID: <200602010726.k117QrVL028677@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/double_stranded In directory pub.open-bio.org:/tmp/cvs-serv28660/double_stranded Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/double_stranded added to the repository From trevor at pub.open-bio.org Wed Feb 1 07:19:59 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:19:59 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/single_strand - New directory Message-ID: <200602010726.k117QrVL028680@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/single_strand In directory pub.open-bio.org:/tmp/cvs-serv28660/single_strand Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/single_strand added to the repository From trevor at pub.open-bio.org Wed Feb 1 07:20:00 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:20:00 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/analysis - New directory Message-ID: <200602010726.k117QrVL028674@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis In directory pub.open-bio.org:/tmp/cvs-serv28660/analysis Log Message: Directory /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis added to the repository From trevor at pub.open-bio.org Wed Feb 1 07:23:32 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:23:32 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util restriction_enzyme.rb,NONE,1.1 Message-ID: <200602010730.k117UMVL028726@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util In directory pub.open-bio.org:/tmp/cvs-serv28712/lib/bio/util Added Files: restriction_enzyme.rb Log Message: Bio::RestrictionEnzyme inital commit. --- NEW FILE: restriction_enzyme.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio' require 'bio/db/rebase' require 'bio/util/restriction_enzyme/double_stranded' require 'bio/util/restriction_enzyme/single_strand' require 'bio/util/restriction_enzyme/cut_symbol' require 'bio/util/restriction_enzyme/analysis' module Bio; end # # bio/util/restriction_enzyme.rb - Digests DNA based on restriction enzyme cut patterns # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: restriction_enzyme.rb,v 1.1 2006/02/01 07:30:19 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme.rb - Digests DNA based on restriction enzyme cut patterns NOTE: This documentation and the module are still very much under development. It has been released as it is relatively stable and comments would be appreciated. == Synopsis Bio::RestrictionEnzyme allows you to fragment a DNA strand using one or more restriction enzymes. Bio::RestrictionEnzyme is aware that multiple enzymes may be competing for the same recognition site and returns the various possible fragmentation patterns that result in such circumstances. Using Bio::RestrictionEnzyme you may simply use the name of common enzymes to cut with or you may construct your own unique enzymes to use. == Basic Usage # EcoRI cut pattern: # G|A A T T C # +-------+ # C T T A A|G # # This can also be written as: # G^AATTC require 'bio/restriction_enzyme' require 'pp' seq = Bio::Sequence::NA.new('gaattc') cuts = seq.cut_with_enzyme('EcoRI') p cuts.primary # ["aattc", "g"] p cuts.complement # ["g", "cttaa"] pp cuts # ==> # [#, # #] seq = Bio::Sequence::NA.new('gaattc') cuts = seq.cut_with_enzyme('g^aattc') p cuts.primary # ["aattc", "g"] p cuts.complement # ["g", "cttaa"] seq = Bio::Sequence::NA.new('gaattc') cuts = seq.cut_with_enzyme('g^aattc', 'gaatt^c') p cuts.primary # ["c", "aattc", "g", "gaatt"] p cuts.complement # ["g", "c", "cttaa", "ttaag"] seq = Bio::Sequence::NA.new('gaattcgaattc') cuts = seq.cut_with_enzyme('EcoRI') p cuts.primary # ["aattc", "aattcg", "g"] p cuts.complement # ["g", "gcttaa", "cttaa"] seq = Bio::Sequence::NA.new('gaattcgggaattc') cuts = seq.cut_with_enzyme('EcoRI') p cuts.primary # ["aattc", "aattcggg", "g"] p cuts.complement # ["g", "gcccttaa", "cttaa"] == Advanced Usage require 'bio/restriction_enzyme' require 'pp' enzyme_1 = Bio::RestrictionEnzyme.new('anna', [1,1], [3,3]) enzyme_2 = Bio::RestrictionEnzyme.new('gg', [1,1]) a = Bio::RestrictionEnzyme::Analysis.cut('agga', enzyme_1, enzyme_2) p a.primary # ["a", "ag", "g", "ga"] b = Bio::RestrictionEnzyme::Analysis.cut_and_return_by_permutations('agga', enzyme_1, enzyme_2) pp b Output (NOTE: to be cleaned): {[1, 0]=> #, #], @__fragments_current=true, @c_left=3, @c_right=3, @cut_ranges= [#], @left=0, @p_left=0, @p_right=0, @right=3, @size=4, @tags={}>, [0, 1]=> #, #, #, #], @__fragments_current=true, @c_left=3, @c_right=3, @cut_ranges= [#, #, #], @left=0, @p_left=0, @p_right=0, @right=3, @size=4, @tags={}>} == Todo Currently under development: * Optimizations in restriction_enzyme/analysis.rb to cut down on factorial growth of computation space. * Circular DNA cutting * Tagging of sequence data * Much more documentation == Notes This module includes Florian Frank's permutation.rb licensed under the GPL. To prevent licensing issues the source code to Bio::RestrictionEnzyme must be included whenever Bio::RestrictionEnzyme is distributed. == Author Trevor Wennblom == Copyright Copyright (C) 2006 Trevor Wennblom Licensed under the same terms as BioRuby. =end class Bio::RestrictionEnzyme include CutSymbol extend CutSymbol # Factory for DoubleStranded def self.new(users_enzyme_or_rebase_or_pattern, *cut_locations) DoubleStranded.new(users_enzyme_or_rebase_or_pattern, *cut_locations) end # REBASE enzyme data information # # Returns a Bio::REBASE object loaded with all of the enzyme data on file. # def self.rebase # NOTE open for debate ... maybe this should be stored somewhere else in bioruby? data_file_location = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3, 'lib')).cleanpath.to_s + '/bio/util/restriction_enzyme/enzymes.yaml' @@rebase_enzymes ||= Bio::REBASE.load_yaml( data_file_location ) @@rebase_enzymes end # Primitive way of determining if a string is an enzyme name. # # Should work just fine thanks to dumb luck. A nucleotide or nucleotide # set can't ever contain an 'i'. Restriction enzymes always end in 'i'. # #-- # Could also look for cut symbols. #++ # def self.enzyme_name?( str ) str[-1].chr.downcase == 'i' end # See Bio::RestrictionEnzyme::Analysis.cut def self.cut( sequence, enzymes ) Bio::RestrictionEnzyme::Analysis.cut( sequence, enzymes ) end end From trevor at pub.open-bio.org Wed Feb 1 07:23:32 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:23:32 -0000 Subject: [BioRuby-cvs] bioruby ChangeLog,1.48,1.49 Message-ID: <200602010730.k117ULVL028724@pub.open-bio.org> Update of /home/repository/bioruby/bioruby In directory pub.open-bio.org:/tmp/cvs-serv28712 Modified Files: ChangeLog Log Message: Bio::RestrictionEnzyme inital commit. Index: ChangeLog =================================================================== RCS file: /home/repository/bioruby/bioruby/ChangeLog,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** ChangeLog 20 Jan 2006 14:04:47 -0000 1.48 --- ChangeLog 1 Feb 2006 07:30:19 -0000 1.49 *************** *** 1,2 **** --- 1,8 ---- + 2005-02-01 Trevor Wennblom + + * Bio::RestrictionEnzyme first commit for comments. + * See lib/bio/util/restriction_enzyme.rb and + test/unit/bio/util/restriction_enzyme + 2005-01-20 Toshiaki Katayama From trevor at pub.open-bio.org Wed Feb 1 07:27:27 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:27:27 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/analysis calculated_cuts.rb, NONE, 1.1 cut_range.rb, NONE, 1.1 cut_ranges.rb, NONE, 1.1 fragment.rb, NONE, 1.1 fragments.rb, NONE, 1.1 horizontal_cut_range.rb, NONE, 1.1 permutation.rb, NONE, 1.1 sequence_range.rb, NONE, 1.1 tags.rb, NONE, 1.1 vertical_cut_range.rb, NONE, 1.1 Message-ID: <200602010734.k117YDVL028868@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis In directory pub.open-bio.org:/tmp/cvs-serv28844/analysis Added Files: calculated_cuts.rb cut_range.rb cut_ranges.rb fragment.rb fragments.rb horizontal_cut_range.rb permutation.rb sequence_range.rb tags.rb vertical_cut_range.rb Log Message: Bio::RestrictionEnzyme --- NEW FILE: vertical_cut_range.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/analysis/cut_range' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/vertical_cut_range.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: vertical_cut_range.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/vertical_cut_range.rb - =end class VerticalCutRange < CutRange attr_reader :p_cut_left, :p_cut_right attr_reader :c_cut_left, :c_cut_right attr_reader :min, :max attr_reader :range def initialize( p_cut_left=nil, p_cut_right=nil, c_cut_left=nil, c_cut_right=nil ) @p_cut_left = p_cut_left @p_cut_right = p_cut_right @c_cut_left = c_cut_left @c_cut_right = c_cut_right a = [@p_cut_left, @c_cut_left, @p_cut_right, @c_cut_right] a.delete(nil) a.sort! @min = a.first @max = a.last @range = nil @range = (@min.. at max) unless @min == nil or @max == nil end def include?(i) return false if @range == nil @range.include?(i) end end end end --- NEW FILE: tags.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) #require 'bio/util/restriction_enzyme/analysis/shared_information' require 'bio' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/tags.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: tags.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/tags.rb - =end class Tags < Hash end end end --- NEW FILE: cut_range.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/cut_range.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_range.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/cut_range.rb - =end class CutRange end end end --- NEW FILE: permutation.rb --- # = permutation.rb - Permutation class for Ruby # # == Author # # Florian Frank mailto:flori at ping.de # # == License # # This is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License Version 2 as published by the Free # Software Foundation: www.gnu.org/copyleft/gpl.html # # == Download # # The latest version of permutation can be found at # # * http://rubyforge.org/frs/?group_id=291 # # The homepage of this library is located at # # * http://permutation.rubyforge.org # # == Description # # This class has a dual purpose: It can be used to create permutations # of a given size and to do some simple computations with/on # permutations. The instances of this class don't require much memory # because they don't include the permutation as a data structure. They # only save the information necessary to create the permutation if asked # to do so. # # To generate permutations the ranking/unranking method described in [SS97] # is used. Because of Ruby's Bignum arithmetic it is useful also # for permutations of very large size. # # == Examples # # In this section some examples show what can be done with this class. # # Creating all permutations and project them on data: # # perm = Permutation.new(3) # # => # # perm.map { |p| p.value } # # => [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]] # colors = [:r, :g, :b] # # => [:r, :g, :b] # perm.map { |p| p.project(colors) } # # => [[:r, :g, :b], [:r, :b, :g], [:g, :r, :b], [:g, :b, :r], [:b, :r, :g], # # [:b, :g, :r]] # string = "abc"# => "abc" # perm.map { |p| p.project(string) } # # => ["abc", "acb", "bac", "bca", "cab", "cba"] # # Or perhaps more convenient to use: # # perm = Permutation.for("abc") # perm.map { |p| p.project } # # => ["abc", "acb", "bac", "bca", "cab", "cba"] # # Finding the successor and predecessor of Permutations or a # certain Permutation for a given rank: # # perm = Permutation.new(7) # # => # # perm.succ! # # => # # perm.succ! # # => # # perm.succ! # # => # # perm.pred! # # => # # perm.rank = 3200 # # => 3200 # perm # # => # # perm.value # # => [4, 2, 5, 1, 3, 0, 6] # # Generating random Permutations # # perm = Permutation.new(10) # # => # # perm.random!.value # # => [6, 4, 9, 7, 3, 5, 8, 1, 2, 0] # perm.random!.value # # => [3, 7, 6, 1, 4, 8, 9, 2, 5, 0] # perm.random!.value # # => [2, 8, 4, 9, 3, 5, 6, 7, 0, 1] # perm.random!.project("ABCDEFGHIJ") # # => "DFJGAEBCIH" # perm.random!.project("ABCDEFGHIJ") # # => "BFADEGHJCI" # # Performing some mathematical operations on/with Permutations # # p1 = Permutation.from_cycles([[1, 3, 2], [5, 7]], 10) # # => # # p2 = Permutation.from_value [3, 2, 0, 5, 6, 8, 9, 1, 4, 7] # # => # # p3 = p1 * p2 # # => # # p3.value # # => [2, 1, 0, 7, 6, 8, 9, 3, 4, 5] # p3.cycles # # => [[0, 2], [3, 7], [4, 6, 9, 5, 8]] # p4 = p1 * -p2 # # => # # p4.value # # => [1, 5, 3, 0, 8, 2, 4, 9, 7, 6] # p4.cycles # # => [[0, 1, 5, 2, 3], [4, 8, 7, 9, 6]] # id = p1 * -p1 # # => # # # == References # # [SS97] The Algorithm Design Manual, Steven S. Skiena, Telos/Springer, 1997. # class Permutation include Enumerable include Comparable # Creates a new Permutation instance of size # (and ranked with rank). def initialize(size, rank = 0) @size, @rank = size, rank @last = factorial(size) - 1 end # Creates a new Permutation instance from the Array # indices, that should consist of a permutation of Fixnums # in the range of 0 and indices.size - 1. This is # for example the result of a call to the Permutation#value method. def self.from_value(indices) obj = new(indices.size) obj.instance_eval do self.rank = rank_indices(indices) end obj end # Creates a new Permutation instance from the Array of Arrays # cycles. This is for example the result of a # call to the Permutation#cycles method . def self.from_cycles(cycles, max = 0) indices = Array.new(max) cycles.each do |cycle| cycle.empty? and next for i in 0...cycle.size indices[ cycle[i - 1] ] = cycle[i] end end indices.each_with_index { |r, i| r or indices[i] = i } from_value(indices) end # A permutation instance of size collection.size is created with # collection as the default Permutation#project data object. A # collection should respond to size, [], and []=. The Permutation # instance will default to rank 0 if none is given. def self.for(collection, rank = 0) perm = new(collection.size, rank) perm.instance_variable_set(:@collection, collection) perm end # Returns the size of this permutation, a Fixnum. attr_reader :size # Returns the size of this permutation, a Fixnum in the range # of 0 and Permutation#last. attr_reader :rank # Returns the rank of the last ranked Permutation of size # Permutation#size . attr_reader :last # Assigns m to the rank attribute of this Permutation # instance. That implies that the indices produced by a call to the # Permutation#value method of this instance is the permutation ranked with # this new rank. def rank=(m) last = factorial(size) - 1 while m > last do m -= last end while m < 0 do m += last end @rank = m end # Returns the indices in the range of 0 to Permutation#size - 1 # of this permutation that is ranked with Permutation#rank. # # Example: # perm = Permutation.new(6, 312) # # => # # perm.value # # => [2, 4, 0, 1, 3, 5] def value unrank_indices(@rank) end # Returns the projection of this instance's Permutation#value # into the data object that should respond to # the #[] method. If this Permutation inbstance was created # with Permutation.for the collection used to create # it is used as a data object. # # Example: # perm = Permutation.new(6, 312) # # => # # perm.project("abcdef") # # => "ceabdf" def project(data = @collection) data or raise ArgumentError.new("a collection is required to project") raise ArgumentError.new("data size is != #{size}!") if data.size != size projection = data.clone value.each_with_index { |i, j| projection[j] = data[i] } projection end # Switches this instances to the next ranked Permutation. # If this was the Permutation#last permutation it wraps around # the first (rank == 0) permutation. def next! @rank += 1 last = factorial(size) - 1 @rank = 0 if @rank > last self end alias succ! next! # Returns the next ranked Permutation instance. # If this instance is the Permutation#last permutation it returns the first # (rank == 0) permutation. def next clone.next! end alias succ next # Switches this instances to the previously ranked Permutation. # If this was the first permutation it returns the last (rank == # Permutation#last) permutation. def pred! @rank -= 1 last = factorial(size) - 1 @rank = last if @rank < 0 self end # Returns the previously ranked Permutation. If this was the first # permutation it returns the last (rank == Permutation#last) # permutation. def pred clone.pred! end # Switches this Permutation instance to random permutation # of size Permutation#size. def random! new_rank = rand(last).to_i self.rank = new_rank self end # Returns a random Permutation instance # of size Permutation#size. def random clone.random! end # Iterates over all permutations of size Permutation#size starting with the # first (rank == 0) ranked permutation and ending with the # last (rank == Permutation#last) ranked permutation while # yielding to a freshly created Permutation instance for every iteration # step. # # The mixed in methods from the Enumerable module rely on this method. def each # :yields: perm 0.upto(last) do |r| klon = clone klon.rank = r yield klon end end # Does something similar to Permutation#each. It doesn't create new # instances (less overhead) for every iteration step, but yields to a # modified self instead. This is useful if one only wants to call a # method on the yielded value and work with the result of this call. It's # not a good idea to put the yielded values in a data structure because the # will all reference the same (this!) instance. If you want to do this # use Permutation#each. def each! old_rank = rank 0.upto(last) do |r| self.rank = r yield self end self.rank = old_rank end # Compares to Permutation instances according to their Permutation#size # and the Permutation#rank. # # The mixed in methods from the Comparable module rely on this method. def <=>(other) size <=> other.size.zero? || rank <=> other.rank end # Returns true if this Permutation instance and the other have the same # value, that is both Permutation instances have the same Permutation#size # and the same Permutation#rank. def eql?(other) self.class == other.class && size == other.size && rank == other.rank end alias == eql? # Computes a unique hash value for this Permutation instance. def hash size.hash ^ rank.hash end # Switchtes this Permutation instance to the inverted permutation. # (See Permutation#compose for an example.) def invert! indices = unrank_indices(rank) inverted = Array.new(size) for i in 0...size inverted[indices[i]] = i end self.rank = rank_indices(inverted) self end # Returns the inverted Permutation of this Permutation instance. # (See Permutation#compose for an example.) def invert clone.invert! end alias -@ invert # Compose this Permutation instance and the other to # a new Permutation. Note that a permutation # composed with it's inverted permutation yields # the identity permutation, the permutation with rank 0. # # Example: # p1 = Permutation.new(5, 42) # # => # # p2 = p1.invert # # => # # p1.compose(p2) # => # # Or a little nicer to look at: # p1 * -p1 # # => # def compose(other) size == other.size or raise ArgumentError.new( "permutations of unequal sizes cannot be composed!") indices = self.value composed = other.value.map { |i| indices[i] } klon = clone klon.rank = rank_indices(composed) klon end alias * compose # Returns the cycles representation of this Permutation instance. # The return value of this method can be used to create a # new Permutation instance with the Permutation.from_cycles method. # # Example: # perm = Permutation.new(7, 23) # # => # # perm.cycles # # => [[3, 6], [4, 5]] def cycles perm = value result = [[]] seen = {} current = nil until seen == perm.size current or current = perm.find { |x| !seen[x] } break unless current if seen[current] current = nil result << [] else seen[current] = true result[-1] << current current = perm[current] end end result.pop result.select { |c| c.size > 1 }.map do |c| min_index = c.index(c.min) c[min_index..-1] + c[0...min_index] end end # Returns the signum of this Permutation instance. # It's -1 if this permutation is odd and 1 if it's # an even permutation. # # A permutation is odd if it can be represented by an odd number of # transpositions (cycles of length 2), or even if it can be represented of # an even number of transpositions. def signum s = 1 cycles.each do |c| c.size % 2 == 0 and s *= -1 end s end alias sgn signum # Returns true if this permutation is even, false otherwise. def even? signum == 1 end # Returns true if this permutation is odd, false otherwise. def odd? signum == -1 end private @@factorial_cache = {} def factorial(n) f = @@factorial_cache[n] and return f f = 1 for i in 2..n do f *= i end @@factorial_cache[n] = f end def rank_indices(p) result = 0 for i in 0...size result += p[i] * factorial(size - i - 1) for j in (i + 1)...size p[j] -= 1 if p[j] > p[i] end end result end def unrank_indices(m) result = Array.new(size, 0) for i in 0...size f = factorial(i) x = m % (f * (i + 1)) m -= x x /= f result[size - i - 1] = x x -= 1 for j in (size - i)...size result[j] += 1 if result[j] > x end end result end end --- NEW FILE: fragment.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/analysis/tags' require 'bio/util/restriction_enzyme/analysis/cut_ranges' require 'bio/util/restriction_enzyme/analysis/horizontal_cut_range' require 'bio' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/fragment.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: fragment.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/fragment.rb - =end class Fragment attr_reader :size # attr_reader :tags def initialize( primary_bin, complement_bin ) # @tags = [] @primary_bin = primary_bin @complement_bin = complement_bin end # def add_tag( index, info=nil ) # @tags[index] = info # end DisplayFragment = Struct.new(:primary, :complement) def for_display(p_str=nil, c_str=nil) df = DisplayFragment.new df.primary = '' df.complement = '' both_bins = (@primary_bin + @complement_bin).sort.uniq both_bins.each do |item| @primary_bin.include?(item) ? df.primary << p_str[item] : df.primary << ' ' @complement_bin.include?(item) ? df.complement << c_str[item] : df.complement << ' ' end df end end end end --- NEW FILE: horizontal_cut_range.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/analysis/cut_range' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/horizontal_cut_range.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: horizontal_cut_range.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/horizontal_cut_range.rb - =end class HorizontalCutRange < CutRange attr_reader :p_cut_left, :p_cut_right attr_reader :c_cut_left, :c_cut_right attr_reader :min, :max attr_reader :hcuts def initialize( left, right=left ) raise "left > right" if left > right # The 'range' here is actually off by one on the left # side in relation to a normal CutRange, so using the normal # variables from CutRange would result in unpredictable # behavior. @p_cut_left = nil @p_cut_right = nil @c_cut_left = nil @c_cut_right = nil @min = nil @max = nil @range = nil @hcuts = (left..right) end def include?(i) @range.include?(i) end end end end --- NEW FILE: cut_ranges.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/cut_ranges.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_ranges.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/cut_ranges.rb - =end class CutRanges < Array def min; self.collect{|a| a.min}.flatten.sort.first; end def max; self.collect{|a| a.max}.flatten.sort.last; end def include?(i); self.collect{|a| a.include?(i)}.include?(true); end end end end --- NEW FILE: fragments.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/fragments.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: fragments.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/fragments.rb - =end class Fragments < Array attr_accessor :primary attr_accessor :complement def initialize(primary, complement) @primary = primary @complement = complement end DisplayFragment = Struct.new(:primary, :complement) def for_display(p_str=nil, c_str=nil) p_str ||= @primary c_str ||= @complement pretty_fragments = [] self.each { |fragment| pretty_fragments << fragment.for_display(p_str, c_str) } pretty_fragments end end end end --- NEW FILE: sequence_range.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/analysis/tags' require 'bio/util/restriction_enzyme/analysis/cut_ranges' require 'bio/util/restriction_enzyme/analysis/horizontal_cut_range' require 'bio/util/restriction_enzyme/analysis/vertical_cut_range' require 'bio/util/restriction_enzyme/analysis/calculated_cuts' require 'bio/util/restriction_enzyme/analysis/fragments' require 'bio/util/restriction_enzyme/analysis/fragment' require 'bio' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/sequence_range.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: sequence_range.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/sequence_range.rb - =end class SequenceRange attr_reader :p_left, :p_right attr_reader :c_left, :c_right attr_reader :left, :right attr_reader :size attr_reader :tags attr_reader :cut_ranges def initialize( p_left = nil, p_right = nil, c_left = nil, c_right = nil ) @__fragments_current = false raise ArgumentError if p_left == nil and c_left == nil raise ArgumentError if p_right == nil and c_right == nil (raise ArgumentError unless p_left <= p_right) unless p_left == nil or p_right == nil (raise ArgumentError unless c_left <= c_right) unless c_left == nil or c_right == nil @p_left = p_left @p_right = p_right @c_left = c_left @c_right = c_right tmp = [p_left, c_left] tmp.delete(nil) @left = tmp.sort.first tmp = [p_right, c_right] tmp.delete(nil) @right = tmp.sort.last @size = (@right - @left) + 1 unless @left == nil or @right == nil @tags = Tags.new @cut_ranges = CutRanges.new end =begin Special Case: Horizontal cuts at beginning or end of strand =end Bin = Struct.new(:c, :p) def fragments return @__fragments if @__fragments_current == true @__fragments_current = true cc = CalculatedCuts.new(@size) cc.add_cuts_from_cut_ranges(@cut_ranges) cc.remove_incomplete_cuts p_cut = cc.vc_primary c_cut = cc.vc_complement h = cc.hc_between_strands if @circular # NOTE # if it's circular we should start at the beginning of a cut for orientation # scan for it, hack off the first set of hcuts and move them to the back else # last_index = @size - 1 p_cut.unshift(-1) unless p_cut.include?(-1) # p_cut.push(last_index) unless p_cut.include?(last_index) c_cut.unshift(-1) unless c_cut.include?(-1) # c_cut.push(last_index) unless c_cut.include?(last_index) end if @circular largest_bin = 0 else largest_bin = -1 end p_bin = largest_bin c_bin = largest_bin bins = { largest_bin => Bin.new } # bin_id, bin bins[ largest_bin ].p = [] bins[ largest_bin ].c = [] x = lambda do |bin_id| largest_bin += 1 bins[ bin_id ] = Bin.new bins[ bin_id ].p = [] bins[ bin_id ].c = [] end -1.upto(@size-1) do |idx| # if bins are out of sync but the strands are attached if p_bin != c_bin and h.include?(idx) == false bins.delete( [p_bin, c_bin].sort.last ) p_bin = c_bin = [p_bin, c_bin].sort.first largest_bin -= 1 end bins[ p_bin ].p << idx bins[ c_bin ].c << idx if p_cut.include? idx p_bin = largest_bin + 1 x.call(p_bin) end if c_cut.include? idx c_bin = largest_bin + 1 x.call(c_bin) end end # Easy way to indicate the start of a strand just in case # there is a horizontal cut at position 0 bins.delete(-1) unless @circular # require 'pp' # pp bins #NOTE str1 = nil str2 = nil num_txt_repeat = lambda { num_txt = '0123456789'; (num_txt * ( @size / num_txt.size.to_f ).ceil)[0.. at size-1] } (str1 == nil) ? a = num_txt_repeat.call : a = str1.dup (str2 == nil) ? b = num_txt_repeat.call : b = str2.dup fragments = Fragments.new(a,b) bins.sort.each do |k, bin| fragment = Fragment.new( bin.p, bin.c ) @tags.each { |k,v| fragment.add_tag(k,v) if (ts.left..ts.right).include?(k) } fragments << fragment end #pp fragments.for_display # pp fragments # exit @__fragments = fragments return fragments end def add_tag( index, info=nil ) @__fragments_current = false raise IndexError unless index >= @left and index <= @right @tags[index] = info end # Cut occurs immediately after the index supplied. # For example, a cut at '0' would mean a cut occurs between 0 and 1. def add_cut_range( p_cut_left=nil, p_cut_right=nil, c_cut_left=nil, c_cut_right=nil ) @__fragments_current = false if p_cut_left.kind_of? CutRange @cut_ranges << p_cut_left else (raise IndexError unless p_cut_left >= @left and p_cut_left <= @right) unless p_cut_left == nil (raise IndexError unless p_cut_right >= @left and p_cut_right <= @right) unless p_cut_right == nil (raise IndexError unless c_cut_left >= @left and c_cut_left <= @right) unless c_cut_left == nil (raise IndexError unless c_cut_right >= @left and c_cut_right <= @right) unless c_cut_right == nil @cut_ranges << VerticalCutRange.new( p_cut_left, p_cut_right, c_cut_left, c_cut_right ) end end def add_cut_ranges(*cut_ranges) cut_ranges.flatten! cut_ranges.each do |cut_range| raise TypeError, "Not of type CutRange" unless cut_range.kind_of? CutRange self.add_cut_range( cut_range ) end end def add_horizontal_cut_range( left, right=left ) @__fragments_current = false @cut_ranges << HorizontalCutRange.new( left, right ) end end end end --- NEW FILE: calculated_cuts.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/cut_symbol' require 'bio/util/restriction_enzyme/string_formatting' module Bio; end class Bio::RestrictionEnzyme class Analysis # # bio/util/restriction_enzyme/analysis/calculated_cuts.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: calculated_cuts.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restriction_enzyme/analysis/calculated_cuts.rb - 1 2 3 4 5 6 7 G A|T T A C A +-----+ C T A A T|G T 1 2 3 4 5 6 7 Primary cut = 2 Complement cut = 5 Horizontal cuts = 3, 4, 5 =end class CalculatedCuts include CutSymbol include StringFormatting # Vertical cuts on the primary strand attr_reader :vc_primary # Vertical cuts on the complement strand attr_reader :vc_complement # Horizontal cuts attr_reader :hc_between_strands # Set to +true+ if the fragment CalculatedCuts is working on is circular attr_accessor :circular def initialize(size=nil, circular=false) @size = size @circular = circular @vc_primary = [] @vc_complement = [] @hc_between_strands = [] end def add_cuts_from_cut_ranges(cut_ranges) @strands_for_display_current = false cut_ranges.each do |cut_range| @vc_primary += [cut_range.p_cut_left, cut_range.p_cut_right] @vc_complement += [cut_range.c_cut_left, cut_range.c_cut_right] if cut_range.class == VerticalCutRange ( cut_range.min + 1 ).upto( cut_range.max ){|i| @hc_between_strands << i} if cut_range.min < cut_range.max elsif cut_range.class == HorizontalCutRange ( cut_range.hcuts.first ).upto( cut_range.hcuts.last ){|i| @hc_between_strands << i} end end clean_all end def remove_incomplete_cuts(size=nil) @strands_for_display_current = false @size = size if size raise IndexError, "Size of the strand must be provided here or during initalization." if !@size.kind_of?(Fixnum) and not @circular vcuts = (@vc_primary + @vc_complement).uniq.sort hcuts = @hc_between_strands last_index = @size - 1 good_hcuts = [] potential_hcuts = [] if @circular # NOTE # if it's circular we should start at the beginning of a cut for orientation # scan for it, hack off the first set of hcuts and move them to the back else vcuts.unshift(-1) unless vcuts.include?(-1) vcuts.push(last_index) unless vcuts.include?(last_index) end hcuts.each do |hcut| raise IndexError if hcut < -1 or hcut > last_index # skipped a nucleotide potential_hcuts.clear if !potential_hcuts.empty? and (hcut - potential_hcuts.last).abs > 1 if potential_hcuts.empty? if vcuts.include?( hcut ) and vcuts.include?( hcut - 1 ) good_hcuts += [hcut] elsif vcuts.include?( hcut - 1 ) potential_hcuts << hcut end else if vcuts.include?( hcut ) good_hcuts += potential_hcuts + [hcut] potential_hcuts.clear else potential_hcuts << hcut end end end check_vc = lambda do |vertical_cuts, opposing_vcuts| # opposing_vcuts is here only to check for blunt cuts, so there shouldn't # be any out-of-order problems with this good_vc = [] vertical_cuts.each { |vc| good_vc << vc if good_hcuts.include?( vc ) or good_hcuts.include?( vc + 1 ) or opposing_vcuts.include?( vc ) } good_vc end @vc_primary = check_vc.call(@vc_primary, @vc_complement) @vc_complement = check_vc.call(@vc_complement, @vc_primary) @hc_between_strands = good_hcuts clean_all end def strands_for_display(str1 = nil, str2 = nil, vcp=nil, vcc=nil, hc=nil) return @strands_for_display if @strands_for_display_current vcs = '|' hcs = '-' vhcs = '+' num_txt_repeat = lambda { num_txt = '0123456789'; (num_txt * ( @size / num_txt.size.to_f ).ceil)[0.. at size-1] } (str1 == nil) ? a = num_txt_repeat.call : a = str1.dup (str2 == nil) ? b = num_txt_repeat.call : b = str2.dup vcp = @vc_primary if vcp==nil vcc = @vc_complement if vcc==nil hc = @hc_between_strands if hc==nil vcuts = (vcp + vcc).uniq.sort vcp.reverse.each { |c| a.insert(c+1, vcs) } vcc.reverse.each { |c| b.insert(c+1, vcs) } between = ' ' * @size hc.each {|hcut| between[hcut,1] = hcs } s_a = add_spacing(a, vcs) s_b = add_spacing(b, vcs) s_bet = add_spacing(between) # NOTE watch this for circular i = 0 0.upto( s_a.size-1 ) do if (s_a[i,1] == vcs) or (s_b[i,1] == vcs) s_bet[i] = vhcs elsif i != 0 and s_bet[i-1,1] == hcs and s_bet[i+1,1] == hcs s_bet[i] = hcs end i+=1 end @strands_for_display_current = true @strands_for_display = [s_a, s_bet, s_b] end =begin def vc_primary_add(c) @vc_primary << c @current = false end def vc_complement_add(c) @vc_complement << c @current = false end def hc_between_strands_add(c) @hc_between_strands << c @current = false end =end ######### protected ######### def clean_all [@vc_primary, @vc_complement, @hc_between_strands].collect { |a| a.delete(nil); a.uniq!; a.sort! } end end end end From trevor at pub.open-bio.org Wed Feb 1 07:27:28 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:27:28 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme README, NONE, 1.1 analysis.rb, NONE, 1.1 cut_symbol.rb, NONE, 1.1 double_stranded.rb, NONE, 1.1 enzymes.yaml, NONE, 1.1 integer.rb, NONE, 1.1 single_strand.rb, NONE, 1.1 single_strand_complement.rb, NONE, 1.1 string_formatting.rb, NONE, 1.1 Message-ID: <200602010734.k117YDVL028860@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv28844 Added Files: README analysis.rb cut_symbol.rb double_stranded.rb enzymes.yaml integer.rb single_strand.rb single_strand_complement.rb string_formatting.rb Log Message: Bio::RestrictionEnzyme --- NEW FILE: integer.rb --- # # bio/util/restrction_enzyme/integer.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: integer.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restrction_enzyme/integer.rb - =end class Integer def negative? self < 0 end end --- NEW FILE: string_formatting.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/cut_symbol' module Bio; end class Bio::RestrictionEnzyme # # bio/util/restriction_enzyme/string_formatting.rb - Useful functions for string manipulation # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: string_formatting.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/string_formatting.rb - Useful functions for string manipulation =end module StringFormatting include CutSymbol extend CutSymbol # Return the sequence with spacing for alignment. Does not add whitespace # around cut symbols. # # Example: # pattern = 'n^ng^arraxt^n' # add_spacing( pattern ) # # Returns: # "n^n g^a r r a x t^n" # def add_spacing( seq, cs = cut_symbol ) str = '' flag = false seq.each_byte do |c| c = c.chr if c == cs str += c flag = false elsif flag str += ' ' + c else str += c flag = true end end str end # Remove extraneous nucleic acid wildcards ('n' padding) from the # left and right sides def strip_padding( s ) if s[0].chr == 'n' s =~ %r{(n+)(.+)} s = $2 end if s[-1].chr == 'n' s =~ %r{(.+?)(n+)$} s = $1 end s end # Remove extraneous nucleic acid wildcards ('n' padding) from the # left and right sides and remove cut symbols def strip_cuts_and_padding( s ) strip_padding( s.tr(cut_symbol, '') ) end # Return the 'n' padding on the left side of the strand def left_padding( s ) s =~ %r{^n+} ret = $& ret ? ret : '' # Don't pass nil values end # Return the 'n' padding on the right side of the strand def right_padding( s ) s =~ %r{n+$} ret = $& ret ? ret : '' # Don't pass nil values end end end --- NEW FILE: single_strand.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation' require 'bio/util/restriction_enzyme/cut_symbol' require 'bio/util/restriction_enzyme/string_formatting' require 'bio/sequence' class Bio::RestrictionEnzyme # # bio/util/restriction_enzyme/single_strand.rb - Single strand of a restriction enzyme sequence # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: single_strand.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/single_strand.rb - Single strand of a restriction enzyme sequence A single strand of restriction enzyme sequence pattern with a 5' to 3' orientation. DoubleStranded puts the SingleStrand and SingleStrandComplement together to create the sequence pattern with cuts on both strands. =end class SingleStrand < Bio::Sequence::NA include CutSymbol include StringFormatting # The cut locations in enzyme notation. Contains a # CutLocationsInEnzymeNotation object. attr_reader :cut_locations_in_enzyme_notation # The cut locations transformed from enzyme index notation to 0-based # array index notation. Contains an Array attr_reader :cut_locations # Orientation of the strand, 5' to 3' def orientation; [5,3]; end # +sequence+:: The enzyme sequence. # +c+:: Cut locations in enzyme notation. See CutLocationsInEnzymeNotation. # # * +sequence+ is required, +c+ is optional # * You cannot provide a sequence with cut symbols and provide cut locations. # * If +c+ is omitted, +input_pattern+ must contain a cut symbol. # * +sequence+ cannot contain adjacent cut symbols. # * +c+ is in enzyme index notation and therefore cannot contain a 0. # # +sequence+ must be a kind of: # * String # * Bio::Sequence::NA # * Bio::RestrictionEnzyme::SingleStrand # # +c+ must be a kind of: # * Integer, one or more # * Array # * CutLocationsInEnzymeNotation # def initialize( sequence, *c ) c.flatten! # if an array was supplied as an argument validate_args(sequence, c) sequence.downcase! if sequence =~ re_cut_symbol @cut_locations_in_enzyme_notation = CutLocationsInEnzymeNotation.new( strip_padding(sequence) ) else @cut_locations_in_enzyme_notation = CutLocationsInEnzymeNotation.new( c ) end @stripped = Bio::Sequence::NA.new( strip_cuts_and_padding( sequence ) ) super( pattern ) @cut_locations = @cut_locations_in_enzyme_notation.to_array_index end # Returns true if this enzyme is palindromic with its reverse complement. # Does not report if the +cut_locations+ are palindromic or not. # # Examples: # * This would be palindromic: # 5' - ATGCAT - 3' # TACGTA # # * This would not be palindromic: # 5' - ATGCGTA - 3' # TACGCAT # def palindromic? @stripped.reverse_complement == @stripped end # Pattern with no cut symbols and no 'n' padding. # * SingleStrand.new('garraxt', [-2, 1, 7]).stripped # "garraxt" attr_reader :stripped # The sequence with 'n' padding and cut symbols. # * SingleStrand.new('garraxt', [-2, 1, 7]).with_cut_symbols # => "n^ng^arraxt^n" def with_cut_symbols s = pattern @cut_locations_in_enzyme_notation.to_array_index.sort.reverse.each { |c| s.insert(c+1, cut_symbol) } s end # The sequence with 'n' padding on the left and right for cuts larger than the sequence. # * SingleStrand.new('garraxt', [-2, 1, 7]).pattern # => "nngarraxtn" def pattern return stripped if @cut_locations_in_enzyme_notation.min == nil left = (@cut_locations_in_enzyme_notation.min.negative? ? 'n' * @cut_locations_in_enzyme_notation.min.abs : '') # Add one more 'n' if a cut is at the last position right = (@cut_locations_in_enzyme_notation.max >= @stripped.length ? 'n' * (@cut_locations_in_enzyme_notation.max - @stripped.length + 1) : '') [left, stripped, right].to_s end # The sequence with 'n' pads, cut symbols, and spacing for alignment. # * SingleStrand.new('garraxt', [-2, 1, 7]).with_spaces # => "n^n g^a r r a x t^n" def with_spaces add_spacing( with_cut_symbols ) end # NOTE: BEING WORKED ON, BUG EXISTS IN Bio::NucleicAcid =begin to_re - important example z = [agc] z must match [agcz] not just [agc] =end ######### protected ######### def validate_args( input_pattern, input_cut_locations ) unless input_pattern.kind_of?(String) err = "input_pattern is not a String, Bio::Sequence::NA, or Bio::RestrictionEnzyme::SingleStrand::Sequence object\n" err += "pattern: #{input_pattern}\n" err += "class: #{input_pattern.class}" raise ArgumentError, err end if ( input_pattern =~ re_cut_symbol ) and !input_cut_locations.empty? err = "Cut symbol found in sequence, but cut locations were also supplied. Ambiguous.\n" err += "pattern: #{input_pattern}\n" err += "symbol: #{cut_symbol}\n" err += "locations: #{input_cut_locations.inspect}" raise ArgumentError, err end input_pattern.each_byte do |c| c = c.chr.downcase unless Bio::NucleicAcid::NAMES.has_key?(c) or c == 'x' or c == 'X' or c == cut_symbol err = "Invalid character in pattern.\n" err += "Not a nucleotide or representation of possible nucleotides. See Bio::NucleicAcid::NAMES for more information.\n" err += "char: #{c}\n" err += "input_pattern: #{input_pattern}" raise ArgumentError, err end end end # Tadayoshi Funaba's method as discussed in Programming Ruby 2ed, p390 def self.once(*ids) for id in ids module_eval <<-"end;" alias_method :__#{id.to_i}__, :#{id.to_s} private :__#{id.to_i}__ def #{id.to_s}(*args, &block) (@__#{id.to_i}__ ||= [__#{id.to_i}__(*args, &block)])[0] end end; end end once :pattern, :with_cut_symbols, :with_spaces, :to_re end end --- NEW FILE: README --- todo --- NEW FILE: enzymes.yaml --- --- TspRI: :c4: "0" :c1: "7" :len: "5" :c2: "-3" :c3: "0" :pattern: CASTG :name: TspRI :blunt: "0" :ncuts: "2" MvnI: :c4: "0" :c1: "2" :len: "4" :c2: "2" :c3: "0" :pattern: CGCG :name: MvnI [...6692 lines suppressed...] BseMI: :c4: "0" :c1: "8" :len: "6" :c2: "6" :c3: "0" :pattern: GCAATG :name: BseMI :blunt: "0" :ncuts: "2" EcoRII: :c4: "0" :c1: "-1" :len: "5" :c2: "5" :c3: "0" :pattern: CCWGG :name: EcoRII :blunt: "0" :ncuts: "2" --- NEW FILE: single_strand_complement.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/single_strand' module Bio; end class Bio::RestrictionEnzyme # # bio/util/restriction_enzyme/single_strand_complement.rb - Single strand restriction enzyme sequence in complement orientation # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: single_strand_complement.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/single_strand_complement.rb - Single strand restriction enzyme sequence in complement orientation A single strand of restriction enzyme sequence pattern with a 3' to 5' orientation. =end class SingleStrandComplement < SingleStrand # Orientation of the strand, 3' to 5' def orientation; [3, 5]; end end end --- NEW FILE: analysis.rb --- #if RUBY_VERSION[0..2] == '1.9' or RUBY_VERSION == '2.0' # err = "This class makes use of 'include' on ranges quite a bit. Possibly unstable in development Ruby. 2005/12/20." # err += "http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/167182?167051-169742" # raise err #end require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio' class Bio::Sequence::NA def cut_with_enzyme(*args) Bio::RestrictionEnzyme::Analysis.cut(self, *args) end alias cut_with_enzymes cut_with_enzyme end require 'pp' require 'bio/util/restriction_enzyme' require 'bio/util/restriction_enzyme/analysis/sequence_range.rb' require 'bio/util/restriction_enzyme/analysis/permutation.rb' class Bio::RestrictionEnzyme # # bio/util/restrction_enzyme/analysis.rb - Does the work of fragmenting the DNA from the enzymes # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: analysis.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restrction_enzyme/analysis.rb - Does the work of fragmenting the DNA from the enzymes =end class Analysis def self.cut( sequence, *args ) self.new.cut( sequence, *args ) end def self.cut_without_permutations( sequence, *args ) self.new.cut_without_permutations( sequence, *args ) end def self.cut_and_return_by_permutations( sequence, *args ) self.new.cut_and_return_by_permutations( sequence, *args ) end def cut_without_permutations( sequence, *args ) sequence = Bio::Sequence::NA.new( sequence ) enzyme_actions = create_enzyme_actions( sequence, *args ) sr_with_cuts = SequenceRange.new( 0, 0, sequence.size-1, sequence.size-1 ) enzyme_actions.each do |id, enzyme_action| enzyme_action.cut_ranges.each do |cut_range| sr_with_cuts.add_cut_range(cut_range) end end sr_with_cuts.fragments.primary = sequence sr_with_cuts.fragments.complement = sequence.forward_complement tmp = {} tmp[0] = sr_with_cuts unique_fragments_for_display( tmp ) end def cut_and_return_by_permutations( sequence, *args ) sequence = Bio::Sequence::NA.new( sequence ) enzyme_actions = create_enzyme_actions( sequence, *args ) permutations = Permutation.new(enzyme_actions.size).map { |p| p.value } # Indexed by permutation. hash_of_sequence_ranges_with_cuts = {} permutations.each do |permutation| previous_cut_ranges = [] sr_with_cuts = SequenceRange.new( 0, 0, sequence.size-1, sequence.size-1 ) permutation.each do |id| enzyme_action = enzyme_actions[id] # conflict is false if the current enzyme action may cut in it's range. # conflict is true if it cannot do to a previous enzyme action making # a cut where this enzyme action needs a whole recognition site. conflict = false # If current size of enzyme_action overlaps with previous cut_range, don't cut # note that the enzyme action may fall in the middle of a previous enzyme action # so all cut locations must be checked that would fall underneath. previous_cut_ranges.each do |cut_range| next unless cut_range.class == VerticalCutRange # we aren't concerned with horizontal cuts previous_cut_left = cut_range.range.first previous_cut_right = cut_range.range.last =begin puts "--- #{permutation.inspect} ---" puts "Previous cut left: #{previous_cut_left}" puts "EA.left #{enzyme_action.left}" puts "Previous cut right: #{previous_cut_right}" puts "EA.right: #{enzyme_action.right}" =end # Keep in mind: # * The cut location is to the immediate right of the base located at the index. # ex: at^gc -- the cut location is at index 1 # * The enzyme action location is located at the base of the index. # ex: atgc -- 0 => 'a', 1 => 't', 2 => 'g', 3 => 'c' if (enzyme_action.right <= previous_cut_left) or (enzyme_action.left > previous_cut_right) or (enzyme_action.left > previous_cut_left and enzyme_action.right <= previous_cut_right) # in between cuts # no conflict #puts "no conflict" else conflict = true #puts "conflict" end end next if conflict == true enzyme_action.cut_ranges.each { |cut_range| sr_with_cuts.add_cut_range(cut_range) } previous_cut_ranges += enzyme_action.cut_ranges end hash_of_sequence_ranges_with_cuts[permutation] = sr_with_cuts end hash_of_sequence_ranges_with_cuts.each do |permutation, sr_with_cuts| sr_with_cuts.fragments.primary = sequence sr_with_cuts.fragments.complement = sequence.forward_complement end #pp hash_of_sequence_ranges_with_cuts hash_of_sequence_ranges_with_cuts end def cut( sequence, *args ) hash_of_sequence_ranges_with_cuts = cut_and_return_by_permutations( sequence, *args ) unique_fragments_for_display( hash_of_sequence_ranges_with_cuts ) end ######### protected ######### UniqueFragment = Struct.new(:primary, :complement) class UniqueFragments < Array def primary tmp = [] self.each { |uf| tmp << uf.primary } tmp.sort.map { |e| e.tr(' ', '') } end def complement tmp = [] self.each { |uf| tmp << uf.complement } tmp.sort.map { |e| e.tr(' ', '') } end end def unique_fragments_for_display( hash_of_sequence_ranges_with_cuts ) uf_ary = UniqueFragments.new hash_of_sequence_ranges_with_cuts.each do |permutation, sr_with_cuts| sr_with_cuts.fragments.for_display.each do |fragment| uf = UniqueFragment.new uf.primary = fragment.primary uf.complement = fragment.complement duplicate = false uf_ary.each do |element| if (uf.primary == element.primary) and (uf.complement == element.complement) duplicate = true break end end uf_ary << uf unless duplicate end end uf_ary end =begin Strand = Struct.new(:primary, :complement, :p_left, :p_right, :c_left, :c_right) def ts_fragments_to_strands( sequence, fragments ) sequence = Bio::Sequence::NA.new( sequence ) strands = [] fragments.each do |f| p = sequence[f.p_left..f.p_right] c = sequence[f.c_left..f.c_right] strands << Strand.new(p, c, f.p_left, f.p_right, f.c_left, f.c_right) end strands end =end # Defines a single enzyme action, in this case being a range that correlates # to the DNA sequence that may contain it's own internal cuts. class EnzymeAction < SequenceRange end # Creates an array of EnzymeActions based on the DNA sequence and supplied enzymes. # # +sequence+:: The string of DNA to match the enzyme recognition sites against # +args+:: The enzymes to use. def create_enzyme_actions( sequence, *args ) id = 0 enzyme_actions = {} args.each do |enzyme| enzyme = Bio::RestrictionEnzyme.new(enzyme) unless enzyme.class == Bio::RestrictionEnzyme::DoubleStranded find_match_locations( sequence, enzyme.primary.to_re ).each do |offset| enzyme_actions[id] = enzyme_to_enzyme_action( enzyme, offset ) id += 1 end end enzyme_actions end # Returns the offsets of the match of a RegExp to a string. # # +string+:: The string to scan. # +re+:: A regexp to use. def find_match_locations( string, re ) md = string.match( re ) locations = [] location = -1 while md location += md.pre_match.size + 1 locations << location # md[0] is the same as $&, or "the match" itself md = (md[0][1..-1] + md.post_match).match( re ) end locations end # Takes a RestrictionEnzyme and a numerical offset to the sequence and # returns an EnzymeAction # # +enzyme+:: RestrictionEnzyme # +offset+:: Numerical offset of where the enzyme action occurs on the seqeunce def enzyme_to_enzyme_action( enzyme, offset ) enzyme_action = EnzymeAction.new(offset, offset + enzyme.primary.size-1, offset, offset + enzyme.complement.size-1) enzyme.cut_locations.each do |cut_pair| p = cut_pair[0] c = cut_pair[1] if c >= p enzyme_action.add_cut_range(offset+p, nil, nil, offset+c) else enzyme_action.add_cut_range(nil, offset+p, offset+c, nil) end end enzyme_action end end end --- NEW FILE: cut_symbol.rb --- module Bio; end class Bio::RestrictionEnzyme # # bio/util/restrction_enzyme/cut_symbol.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_symbol.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # # =begin rdoc bio/util/restrction_enzyme/cut_symbol.rb - =end module CutSymbol require 'singleton' class CutSymbol__ include Singleton attr_accessor :cut_symbol attr_accessor :escaped_cut_symbol end # NOTE verify this sometime def cut_symbol=(c) CutSymbol__.instance.cut_symbol = c end def cut_symbol CutSymbol__.instance.cut_symbol ||= '^' end def escaped_cut_symbol CutSymbol__.instance.escaped_cut_symbol ||= "\\#{cut_symbol}" # \^ end # Used to check if multiple cut symbols are next to each other def re_cut_symbol_adjacent %r"#{escaped_cut_symbol}{2}" end # A Regexp of the cut_symbol. Convenience method. def re_cut_symbol %r"#{escaped_cut_symbol}" end end end --- NEW FILE: double_stranded.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/db/rebase' require 'bio/util/restriction_enzyme' require 'bio/util/restriction_enzyme/cut_symbol' require 'bio/util/restriction_enzyme/single_strand' require 'bio/util/restriction_enzyme/single_strand_complement' require 'bio/util/restriction_enzyme/double_stranded/aligned_strands' require 'bio/util/restriction_enzyme/double_stranded/cut_locations' require 'bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation' module Bio; end class Bio::RestrictionEnzyme # # bio/util/restriction_enzyme/double_stranded.rb - DoubleStranded restriction enzyme sequence # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: double_stranded.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/double_stranded.rb - DoubleStranded restriction enzyme sequence A pair of +SingleStrand+ and +SingleStrandComplement+ objects with methods to add utility to their relation. == Notes * This is created by Bio::RestrictionEnzyme.new for convenience. * The two strands accessible are +primary+ and +complement+. * SingleStrand methods may be used on DoubleStranded and they will be passed to +primary+. =end class DoubleStranded include CutSymbol extend CutSymbol include StringFormatting extend StringFormatting # The primary strand attr_reader :primary # The complement strand attr_reader :complement # Cut locations in 0-based index format, DoubleStranded::CutLocations object attr_reader :cut_locations # Cut locations in enzyme index notation, DoubleStranded::CutLocationsInEnzymeNotation object attr_reader :cut_locations_in_enzyme_notation # +erp+:: Enzyme or Rebase or Pattern. One of three: The name of an enzyme. A REBASE::EnzymeEntry object. A nucleotide pattern. # +raw_cut_pairs+:: The cut locations in enzyme index notation. # # Enzyme index notation:: 1.._n_, value before 1 is -1 # # Examples of the allowable cut locations for +raw_cut_pairs+ follows. 'p' and # 'c' refer to a cut location on the 'p'rimary and 'c'omplement strands. # # 1, [3,2], [20,22], 57 # p, [p,c], [p, c], p # # Which is the same as: # # 1, (3..2), (20..22), 57 # p, (p..c), (p..c), p # # Examples of partial cuts: # 1, [nil,2], [20,nil], 57 # p, [p, c], [p, c], p # def initialize(erp, *raw_cut_pairs) k = erp.class if k == Bio::REBASE::EnzymeEntry # Passed a Bio::REBASE::EnzymeEntry object unless raw_cut_pairs.empty? err = "A Bio::REBASE::EnzymeEntry object was passed, however the cut locations contained values. Ambiguous or redundant.\n" err += "inspect = #{raw_cut_pairs.inspect}" raise ArgumentError, err end initialize_with_rebase( erp ) elsif erp.kind_of? String # Passed something that could be an enzyme pattern or an anzyme name # Decide if this String is an enzyme name or a pattern if Bio::RestrictionEnzyme.enzyme_name?( erp ) # Check if it's a known name known_enzyme = false known_enzyme = true if Bio::RestrictionEnzyme.rebase[ erp ] # Try harder to find the enzyme unless known_enzyme re = %r"^#{erp}$"i Bio::RestrictionEnzyme.rebase.each { |name, v| (known_enzyme = true; erp = name; break) if name =~ re } end if known_enzyme initialize_with_rebase( Bio::RestrictionEnzyme.rebase[erp] ) else raise IndexError, "No entry found for enzyme named '#{erp}'" end else # Not an enzyme name, so a pattern is assumed if erp =~ re_cut_symbol initialize_with_pattern_and_cut_symbols( erp ) else initialize_with_pattern_and_cut_locations( erp, raw_cut_pairs ) end end elsif k == NilClass err = "Passed a nil value. Perhaps you tried to pass a Bio::REBASE::EnzymeEntry that does not exist?\n" err += "inspect = #{erp.inspect}" raise ArgumentError, err else err = "I don't know what to do with class #{k} for erp.\n" err += "inspect = #{erp.inspect}" raise ArgumentError, err end end # See AlignedStrands.align def aligned_strands AlignedStrands.align(@primary.pattern, @complement.pattern) end # See AlignedStrands.align_with_cuts def aligned_strands_with_cuts AlignedStrands.align_with_cuts(@primary.pattern, @complement.pattern, @primary.cut_locations, @complement.cut_locations) end # Returns +true+ if the cut pattern creates blunt fragments def blunt? as = aligned_strands_with_cuts ary = [as.primary, as.complement] ary.collect! { |seq| seq.split( cut_symbol ) } # convert the cut sections to their lengths ary.each { |i| i.collect! { |c| c.length } } ary[0] == ary[1] end # Returns +true+ if the cut pattern creates sticky fragments def sticky? !blunt? end ######### protected ######### def initialize_with_pattern_and_cut_symbols( s ) p_cl = SingleStrand::CutLocationsInEnzymeNotation.new( strip_padding(s) ) s = Bio::Sequence::NA.new( strip_cuts_and_padding(s) ) # * Reflect cuts that are in enzyme notation # * 0 is not a valid enzyme index, decrement 0 and all negative # c_cl = p_cl.collect { |n| s.length - n }.collect { |n| n <= 0 ? n - 1 : n } #wrong. c_cl = p_cl.collect {|n| (n >= s.length or n < 1) ? ((s.length - n) - 1) : (s.length - n)} create_cut_locations( p_cl.zip(c_cl) ) create_primary_and_complement( s, p_cl, c_cl ) end def initialize_with_pattern_and_cut_locations( s, raw_cl ) create_cut_locations(raw_cl) create_primary_and_complement( Bio::Sequence::NA.new(s), @cut_locations_in_enzyme_notation.primary, @cut_locations_in_enzyme_notation.complement ) end def create_primary_and_complement(primary_seq, p_cuts, c_cuts) @primary = SingleStrand.new( primary_seq, p_cuts ) @complement = SingleStrandComplement.new( primary_seq.forward_complement, c_cuts ) end def create_cut_locations(raw_cl) @cut_locations_in_enzyme_notation = CutLocationsInEnzymeNotation.new( *raw_cl.collect {|cl| CutLocationPairInEnzymeNotation.new(cl)} ) @cut_locations = @cut_locations_in_enzyme_notation.to_array_index end def initialize_with_rebase( e ) p_cl = [e.primary_strand_cut1, e.primary_strand_cut2] c_cl = [e.complementary_strand_cut1, e.complementary_strand_cut2] # If there's no cut in REBASE it's represented as a 0. # 0 is an invalid index, it just means no cut. p_cl.delete(0) c_cl.delete(0) raise IndexError unless p_cl.size == c_cl.size initialize_with_pattern_and_cut_locations( e.pattern, p_cl.zip(c_cl) ) end end end From trevor at pub.open-bio.org Wed Feb 1 07:27:32 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:27:32 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/double_stranded aligned_strands.rb, NONE, 1.1 cut_location_pair.rb, NONE, 1.1 cut_location_pair_in_enzyme_notation.rb, NONE, 1.1 cut_locations.rb, NONE, 1.1 cut_locations_in_enzyme_notation.rb, NONE, 1.1 Message-ID: <200602010734.k117YDVL028880@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/double_stranded In directory pub.open-bio.org:/tmp/cvs-serv28844/double_stranded Added Files: aligned_strands.rb cut_location_pair.rb cut_location_pair_in_enzyme_notation.rb cut_locations.rb cut_locations_in_enzyme_notation.rb Log Message: Bio::RestrictionEnzyme --- NEW FILE: aligned_strands.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/single_strand' require 'bio/util/restriction_enzyme/cut_symbol' require 'bio/util/restriction_enzyme/string_formatting' module Bio; end class Bio::RestrictionEnzyme class DoubleStranded # # bio/util/restriction_enzyme/double_stranded/aligned_strands.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: aligned_strands.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/double_stranded/aligned_strands.rb - Align two SingleStrand::Pattern objects and return a Result object with +primary+ and +complement+ accessors. =end class AlignedStrands extend CutSymbol extend StringFormatting # The object returned for alignments Result = Struct.new(:primary, :complement) # Pad and align two String objects. # # +a+:: First String # +b+:: Second String # # Example invocation: # AlignedStrands.align('nngattacannnnn', 'nnnnnctaatgtnn') # # Example return value: # # # def self.align(a, b) a = a.to_s b = b.to_s validate_input( strip_padding(a), strip_padding(b) ) left = [left_padding(a), left_padding(b)].sort.last right = [right_padding(a), right_padding(b)].sort.last p = left + strip_padding(a) + right c = left + strip_padding(b) + right Result.new(p,c) end # Pad and align two String objects with cut symbols. # # +a+:: First String # +b+:: Second String # +a_cuts+:: First strand cut locations in 0-based index notation # +b_cuts+:: Second strand cut locations in 0-based index notation # # Example invocation: # AlignedStrands.with_cuts('nngattacannnnn', 'nnnnnctaatgtnn', [0, 10, 12], [0, 2, 12]) # # Example return value: # # # # Notes: # * To make room for the cut symbols each nucleotide is spaced out. # * This is meant to be able to handle multiple cuts and completely # unrelated cutsites on the two strands, therefore no biological # shortcuts are made. # def self.align_with_cuts(a,b,a_cuts,b_cuts) a = a.to_s b = b.to_s validate_input( strip_padding(a), strip_padding(b) ) a_left, a_right = left_padding(a), right_padding(a) b_left, b_right = left_padding(b), right_padding(b) left_diff = a_left.length - b_left.length right_diff = a_right.length - b_right.length (right_diff > 0) ? (b_right += 'n' * right_diff) : (a_right += 'n' * right_diff.abs) a_adjust = b_adjust = 0 if left_diff > 0 b_left += 'n' * left_diff b_adjust = left_diff else a_left += 'n' * left_diff.abs a_adjust = left_diff.abs end a = a_left + strip_padding(a) + a_right b = b_left + strip_padding(b) + b_right a_cuts.sort.reverse.each { |c| a.insert(c+1+a_adjust, cut_symbol) } b_cuts.sort.reverse.each { |c| b.insert(c+1+b_adjust, cut_symbol) } Result.new( add_spacing(a), add_spacing(b) ) end ######### protected ######### def self.validate_input(a,b) unless a.size == b.size err = "Result sequences are not the same size. Does not align sequences with differing lengths after strip_padding.\n" err += "#{a.size}, #{a.inspect}\n" err += "#{b.size}, #{b.inspect}" raise ArgumentError, err end end end end end --- NEW FILE: cut_locations.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/double_stranded/cut_location_pair' module Bio; end class Bio::RestrictionEnzyme class DoubleStranded # # bio/util/restriction_enzyme/double_stranded/cut_locations.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_locations.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/double_stranded/cut_locations.rb - =end class CutLocations < Array def initialize(*args) validate_args(args) super(args) end def primary self.collect {|a| a[0]} end def complement self.collect {|a| a[1]} end ######### protected ######### def validate_args(args) args.each do |a| unless a.class == Bio::RestrictionEnzyme::DoubleStranded::CutLocationPair err = "Not a CutLocationPair\n" err += "class: #{a.class}\n" err += "inspect: #{a.inspect}" raise ArgumentError, err end end end end end end --- NEW FILE: cut_locations_in_enzyme_notation.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/double_stranded/cut_locations' require 'bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation' module Bio; end class Bio::RestrictionEnzyme class DoubleStranded # # bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_locations_in_enzyme_notation.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb - =end class CutLocationsInEnzymeNotation < CutLocations def primary_to_array_index helper_for_to_array_index(self.primary) end def complement_to_array_index helper_for_to_array_index(self.complement) end def to_array_index unless self.primary_to_array_index.size == self.complement_to_array_index.size err = "Primary and complement strand cut locations are not available in equal numbers.\n" err += "primary: #{self.primary_to_array_index.inspect}\n" err += "primary.size: #{self.primary_to_array_index.size}\n" err += "complement: #{self.complement_to_array_index.inspect}\n" err += "complement.size: #{self.complement_to_array_index.size}" raise IndexError, err end a = self.primary_to_array_index.zip(self.complement_to_array_index) CutLocations.new( *a.collect {|cl| CutLocationPair.new(cl)} ) end ######### protected ######### def helper_for_to_array_index(a) minimum = (self.primary + self.complement).flatten minimum.delete(nil) minimum = minimum.sort.first return [] if minimum == nil # no elements if minimum.negative? calc = lambda do |n| unless n == nil n -= 1 unless n.negative? n += minimum.abs end n end else calc = lambda do |n| n -= 1 unless n == nil n end end a.collect(&calc) end def validate_args(args) args.each do |a| unless a.class == Bio::RestrictionEnzyme::DoubleStranded::CutLocationPairInEnzymeNotation err = "Not a CutLocationPairInEnzymeNotation\n" err += "class: #{a.class}\n" err += "inspect: #{a.inspect}" raise TypeError, err end end end end end end --- NEW FILE: cut_location_pair_in_enzyme_notation.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/double_stranded/cut_location_pair' require 'bio/util/restriction_enzyme/integer' module Bio; end class Bio::RestrictionEnzyme class DoubleStranded # # bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_location_pair_in_enzyme_notation.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb - See CutLocationPair =end class CutLocationPairInEnzymeNotation < CutLocationPair ######### protected ######### def validate_2( a, b ) if a == 0 raise ArgumentError, "Enzyme index notation only. 0 values are illegal." end if b == 0 raise ArgumentError, "Enzyme index notation only. 0 values are illegal." end if a == nil and b == nil raise ArgumentError, "Neither strand has a cut. Ambiguous." end end end end end --- NEW FILE: cut_location_pair.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/cut_symbol' require 'bio/util/restriction_enzyme/integer' module Bio; end class Bio::RestrictionEnzyme class DoubleStranded # # bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb - # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_location_pair.rb,v 1.1 2006/02/01 07:34:11 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb - Stores a cut location pair in 0-based index notation Input: +pair+:: May be two values represented as an Array, a Range, or a combination of Integer and nil values. The first value represents a cut on the primary strand, the second represents a cut on the complement strand. Example: clp = CutLocationPair.new(3,2) clp.primary # 3 clp.complement # 2 Notes: * a value of +nil+ is an explicit representation of 'no cut' =end class CutLocationPair < Array attr_reader :primary, :complement def initialize( *pair ) a = b = nil if pair[0].kind_of? Array a,b = init_with_array( pair[0] ) elsif pair[0].kind_of? Range a,b = init_with_array( [pair[0].first, pair[0].last] ) elsif pair[0].kind_of? Integer or pair[0].kind_of? NilClass a,b = init_with_array( [pair[0], pair[1]] ) else raise ArgumentError, "#{pair[0].class} is an invalid class type." end super( [a,b] ) @primary = a @complement = b end ######### protected ######### def init_with_array( ary ) validate_1(ary) a = ary.shift ary.empty? ? b = nil : b = ary.shift validate_2(a,b) [a,b] end def validate_1( ary ) unless ary.size == 1 or ary.size == 2 raise ArgumentError, "Must be one or two elements." end end def validate_2( a, b ) if a != nil and a.negative? raise ArgumentError, "0-based index notation only. Negative values are illegal." end if b != nil and b.negative? raise ArgumentError, "0-based index notation only. Negative values are illegal." end if a == nil and b == nil raise ArgumentError, "Neither strand has a cut. Ambiguous." end end end end end From trevor at pub.open-bio.org Wed Feb 1 07:27:39 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:27:39 -0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/single_strand cut_locations_in_enzyme_notation.rb, NONE, 1.1 Message-ID: <200602010734.k117YEVL028888@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/single_strand In directory pub.open-bio.org:/tmp/cvs-serv28844/single_strand Added Files: cut_locations_in_enzyme_notation.rb Log Message: Bio::RestrictionEnzyme --- NEW FILE: cut_locations_in_enzyme_notation.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'bio/util/restriction_enzyme/cut_symbol' require 'bio/util/restriction_enzyme/integer' require 'bio/sequence' module Bio; end class Bio::RestrictionEnzyme class SingleStrand < Bio::Sequence::NA # # bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb - The cut locations, in enzyme notation # # Copyright:: Copyright (C) 2006 Trevor Wennblom # License:: LGPL # # $Id: cut_locations_in_enzyme_notation.rb,v 1.1 2006/02/01 07:34:12 trevor Exp $ # # #-- # # 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 # #++ # =begin rdoc bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb - The cut locations, in enzyme notation Stores the cut location in thier enzyme index notation May be initialized with a series of cuts or an enzyme pattern marked with cut symbols. Enzyme index notation:: 1.._n_, value before 1 is -1 Notes: * 0 is invalid as it does not refer to any index * +nil+ is not allowed here as it has no meaning * +nil+ values are kept track of in DoubleStranded::CutLocations as they need a reference point on the correlating strand. +nil+ represents no cut or a partial digestion. =end class CutLocationsInEnzymeNotation < Array include CutSymbol extend CutSymbol attr_reader :min, :max def initialize(*a) a.flatten! # in case an array was passed as an argument if a.size == 1 and a[0].kind_of? String and a[0] =~ re_cut_symbol # Initialize with a cut symbol pattern such as 'n^ng^arraxt^n' s = a[0] a = [] i = -( s.tr(cut_symbol, '') =~ %r{[^n]} ) # First character that's not 'n' s.each_byte { |c| (a << i; next) if c.chr == cut_symbol; i += 1 } a.collect! { |n| n <= 0 ? n-1 : n } # 0 is not a valid enzyme index, decrement from 0 and all negative else a.collect! { |n| n.to_i } # Cut locations are always integers end validate_cut_locations( a ) super(a) self.sort! @min = self.first @max = self.last self.freeze end # Transform the cut locations from enzyme index notation to 0-based index # notation. # # input -> output # [ 1, 2, 3 ] -> [ 0, 1, 2 ] # [ 1, 3, 5 ] -> [ 0, 2, 4 ] # [ -1, 1, 2 ] -> [ 0, 1, 2 ] # [ -2, 1, 3 ] -> [ 0, 2, 4 ] # def to_array_index return [] if @min == nil if @min.negative? calc = lambda do |n| n -= 1 unless n.negative? n + @min.abs end else calc = lambda { |n| n - 1 } end self.collect(&calc) end ######### protected ######### def validate_cut_locations( input_cut_locations ) unless input_cut_locations == input_cut_locations.uniq err = "The cut locations supplied contain duplicate values. Redundant / undefined meaning.\n" err += "cuts: #{input_cut_locations.inspect}\n" err += "unique: #{input_cut_locations.uniq.inspect}" raise ArgumentError, err end if input_cut_locations.include?(nil) err = "The cut locations supplied contained a nil. nil has no index for enzyme notation, alternative meaning is 'no cut'.\n" err += "cuts: #{input_cut_locations.inspect}" raise ArgumentError, err end if input_cut_locations.include?(0) err = "The cut locations supplied contained a '0'. '0' has no index for enzyme notation, alternative meaning is 'no cut'.\n" err += "cuts: #{input_cut_locations.inspect}" raise ArgumentError, err end end end end end From trevor at pub.open-bio.org Wed Feb 1 07:31:24 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:31:24 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme/double_stranded test_aligned_strands.rb, NONE, 1.1 test_cut_location_pair.rb, NONE, 1.1 test_cut_location_pair_in_enzyme_notation.rb, NONE, 1.1 test_cut_locations.rb, NONE, 1.1 test_cut_locations_in_enzyme_notation.rb, NONE, 1.1 Message-ID: <200602010738.k117cEVL028965@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/double_stranded In directory pub.open-bio.org:/tmp/cvs-serv28943/double_stranded Added Files: test_aligned_strands.rb test_cut_location_pair.rb test_cut_location_pair_in_enzyme_notation.rb test_cut_locations.rb test_cut_locations_in_enzyme_notation.rb Log Message: Bio::RestrictionEnzyme tests --- NEW FILE: test_cut_locations_in_enzyme_notation.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation' module Bio class TestDoubleStrandedCutLocationsInEnzymeNotation < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPairInEnzymeNotation @tt = Bio::RestrictionEnzyme::DoubleStranded::CutLocationsInEnzymeNotation @obj_1 = @t.new([3,5]) @obj_2 = @t.new(3, 5) @obj_3 = @t.new((3..5)) @obj_4 = @t.new(-3..5) @obj_5 = @t.new(3) @obj_6 = @t.new(nil,3) @obj_7 = @t.new(3,nil) @obj_8 = @t.new(-8, -7) @locations = @tt.new(@obj_1, @obj_2, @obj_3, @obj_4, @obj_5, @obj_6, @obj_7, @obj_8) @loc_2 = @tt.new(@t.new(-2,-2), @t.new(1,1)) @loc_3 = @tt.new(@t.new(1,2)) end def test_contents assert_equal([3,5], @locations[0]) assert_equal([3,nil], @locations[-2]) end def test_primary assert_equal([3, 3, 3, -3, 3, nil, 3, -8], @locations.primary) end def test_complement assert_equal([5, 5, 5, 5, nil, 3, nil, -7], @locations.complement) end def test_primary_to_array_index assert_equal([10, 10, 10, 5, 10, nil, 10, 0], @locations.primary_to_array_index) assert_equal([0,2], @loc_2.primary_to_array_index) assert_equal([0], @loc_3.primary_to_array_index) end def test_primary_to_array_index_class assert_equal(Array, @locations.primary_to_array_index.class) assert_equal(Array, @loc_2.primary_to_array_index.class) end def test_complement_to_array_index assert_equal([12, 12, 12, 12, nil, 10, nil, 1], @locations.complement_to_array_index) assert_equal([0,2], @loc_2.complement_to_array_index) assert_equal([1], @loc_3.complement_to_array_index) end def test_complement_to_array_index_class assert_equal(Array, @locations.complement_to_array_index.class) assert_equal(Array, @loc_2.complement_to_array_index.class) end def test_to_array_index assert_equal( [ [10, 12], [10, 12], [10, 12], [5, 12], [10, nil], [nil, 10], [10, nil], [0, 1] ], @locations.to_array_index) assert_equal( [ [0, 0], [2, 2], ], @loc_2.to_array_index) assert_equal([[0,1]], @loc_3.to_array_index) end def test_to_array_index_class assert_equal(Bio::RestrictionEnzyme::DoubleStranded::CutLocations, @locations.to_array_index.class) assert_equal(Bio::RestrictionEnzyme::DoubleStranded::CutLocations, @loc_2.to_array_index.class) end end end --- NEW FILE: test_aligned_strands.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/double_stranded/aligned_strands' require 'bio/util/restriction_enzyme/double_stranded' module Bio class TestDoubleStrandedAlignedStrands < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::DoubleStranded::AlignedStrands @s = Bio::Sequence::NA @ds = Bio::RestrictionEnzyme::DoubleStranded @s_1 = @s.new('gattaca') @s_2 = @s_1.forward_complement @s_3 = @s.new('tttttttnnn') @s_4 = @s.new('nnnaaaaaaa') @ds_1 = @ds.new('nnnn^ngattacann^nn^n') @obj_1 = @t.align(@s_1, @s_2) @obj_2 = @t.align(@s_1, @s_3) @obj_3 = @t.align(@s_1, @s_4) @obj_4 = @t.align(@s_3, @s_4) @obj_5 = @t.align(@ds_1.primary, @ds_1.complement) @obj_8 = @t.align_with_cuts(@ds_1.primary, @ds_1.complement, @ds_1.primary.cut_locations, @ds_1.complement.cut_locations) @obj_6 = @t.align_with_cuts(@s_1, @s_2, [1,2], [3,4]) @obj_7 = @t.align_with_cuts(@s_3, @s_4, [1,2], [3,4]) end def test_ds assert_equal('nngattacannnnn', @ds_1.primary) assert_equal('nnnnnctaatgtnn', @ds_1.complement) assert_equal( 'n^ngattacann^nn^n', @ds_1.primary.with_cut_symbols) assert_equal('n^nn^nnctaatgtn^n' , @ds_1.complement.with_cut_symbols) assert_equal([0, 10, 12], @ds_1.primary.cut_locations) assert_equal([0, 2, 12], @ds_1.complement.cut_locations) end def test_align assert_equal('gattaca', @obj_1.primary) assert_equal('ctaatgt', @obj_1.complement) assert_equal('gattacannn', @obj_2.primary) assert_equal('tttttttnnn', @obj_2.complement) assert_equal('nnngattaca', @obj_3.primary) assert_equal('nnnaaaaaaa', @obj_3.complement) assert_equal('nnntttttttnnn', @obj_4.primary) assert_equal('nnnaaaaaaannn', @obj_4.complement) assert_equal('nnnnngattacannnnn', @obj_5.primary) assert_equal('nnnnnctaatgtnnnnn', @obj_5.complement) end def test_align_with_cuts assert_equal('g a^t^t a c a', @obj_6.primary) assert_equal('c t a a^t^g t', @obj_6.complement) # Looks incorrect at first, but this is deliberate. # The correct cuts need to be supplied by the user. assert_equal('n n n t t^t^t t t t n n n', @obj_7.primary) assert_equal('n n n a^a^a a a a a n n n', @obj_7.complement) assert_equal('n n n n^n g a t t a c a n n^n n^n', @obj_8.primary) assert_equal('n^n n^n n c t a a t g t n^n n n n', @obj_8.complement) end def test_argument_error assert_raise(ArgumentError) { @t.new('arg', 'agg') } assert_raise(ArgumentError) { @t.new(@s.new('arg'), 'agg') } assert_raise(ArgumentError) { @t.new('arg', @s.new('agg')) } assert_raise(ArgumentError) { @t.new(@s.new('argg'), @s.new('agg')) } end end end --- NEW FILE: test_cut_locations.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/double_stranded/cut_locations' module Bio class TestDoubleStrandedCutLocations < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPair @tt = Bio::RestrictionEnzyme::DoubleStranded::CutLocations @obj_1 = @t.new([3,5]) @obj_2 = @t.new(3, 5) @obj_3 = @t.new((3..5)) @obj_4 = @t.new(3..5) @obj_5 = @t.new(3) @obj_6 = @t.new(nil,3) @obj_7 = @t.new(3,nil) @locations = @tt.new(@obj_1, @obj_2, @obj_3, @obj_4, @obj_5, @obj_6, @obj_7) end def test_contents assert_equal([3,5], @locations[0]) assert_equal([3,nil], @locations[-1]) end def test_primary assert_equal([3, 3, 3, 3, 3, nil, 3], @locations.primary) end def test_complement assert_equal([5, 5, 5, 5, nil, 3, nil], @locations.complement) end end end --- NEW FILE: test_cut_location_pair_in_enzyme_notation.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation' module Bio class TestDoubleStrandedCutLocationPairInEnzymeNotation < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPairInEnzymeNotation @obj_1 = @t.new([3,5]) @obj_2 = @t.new(3, 5) @obj_3 = @t.new((3..5)) @obj_4 = @t.new(-3..5) @obj_5 = @t.new(3) @obj_6 = @t.new(nil,3) @obj_7 = @t.new(3,nil) end def test_contents assert_equal([3,5], @obj_1) assert_equal([3,5], @obj_2) assert_equal([3,5], @obj_3) assert_equal([-3,5], @obj_4) assert_equal([3,nil], @obj_5) assert_equal([nil,3], @obj_6) assert_equal([3,nil], @obj_7) end def test_primary assert_equal(3, @obj_1.primary) assert_equal(3, @obj_2.primary) assert_equal(3, @obj_3.primary) assert_equal(-3, @obj_4.primary) assert_equal(3, @obj_5.primary) assert_equal(nil, @obj_6.primary) assert_equal(3, @obj_7.primary) end def test_complement assert_equal(5, @obj_1.complement) assert_equal(5, @obj_2.complement) assert_equal(5, @obj_3.complement) assert_equal(5, @obj_4.complement) assert_equal(nil, @obj_5.complement) assert_equal(3, @obj_6.complement) assert_equal(nil, @obj_7.complement) end def test_argument_error assert_raise(ArgumentError) { @t.new([3,5,6]) } assert_raise(ArgumentError) { @t.new(0,1) } assert_raise(ArgumentError) { @t.new(0,0) } assert_raise(ArgumentError) { @t.new('3',5) } end end end --- NEW FILE: test_cut_location_pair.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/double_stranded/cut_location_pair' module Bio class TestDoubleStrandedCutLocationPair < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPair @obj_1 = @t.new([3,5]) @obj_2 = @t.new(3, 5) @obj_3 = @t.new((3..5)) @obj_4 = @t.new(0..5) @obj_5 = @t.new(3) @obj_6 = @t.new(nil,3) @obj_7 = @t.new(3,nil) end def test_contents assert_equal([3,5], @obj_1) assert_equal([3,5], @obj_2) assert_equal([3,5], @obj_3) assert_equal([0,5], @obj_4) assert_equal([3,nil], @obj_5) assert_equal([nil,3], @obj_6) assert_equal([3,nil], @obj_7) end def test_primary assert_equal(3, @obj_1.primary) assert_equal(3, @obj_2.primary) assert_equal(3, @obj_3.primary) assert_equal(0, @obj_4.primary) assert_equal(3, @obj_5.primary) assert_equal(nil, @obj_6.primary) assert_equal(3, @obj_7.primary) end def test_complement assert_equal(5, @obj_1.complement) assert_equal(5, @obj_2.complement) assert_equal(5, @obj_3.complement) assert_equal(5, @obj_4.complement) assert_equal(nil, @obj_5.complement) assert_equal(3, @obj_6.complement) assert_equal(nil, @obj_7.complement) end def test_argument_error assert_raise(ArgumentError) { @t.new([3,5,6]) } assert_raise(ArgumentError) { @t.new(3,-1) } assert_raise(ArgumentError) { @t.new(-3,1) } assert_raise(ArgumentError) { @t.new(nil,nil) } assert_raise(ArgumentError) { @t.new('3',5) } end end end From trevor at pub.open-bio.org Wed Feb 1 07:31:24 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:31:24 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme/single_strand test_cut_locations_in_enzyme_notation.rb, NONE, 1.1 Message-ID: <200602010738.k117cEVL028968@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/single_strand In directory pub.open-bio.org:/tmp/cvs-serv28943/single_strand Added Files: test_cut_locations_in_enzyme_notation.rb Log Message: Bio::RestrictionEnzyme tests --- NEW FILE: test_cut_locations_in_enzyme_notation.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation' module Bio class TestSingleStrandCutLocationsInEnzymeNotation < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation @obj_1 = @t.new([-2,1,3]) @obj_2 = @t.new(-2,1,3) @obj_3 = @t.new(7,1,3) @obj_4 = @t.new(-7,-8,-2,1,3) end def test_max assert_equal(3, @obj_1.max) assert_equal(3, @obj_2.max) assert_equal(7, @obj_3.max) end def test_min assert_equal(-2, @obj_1.min) assert_equal(-2, @obj_2.min) assert_equal(1, @obj_3.min) end def test_to_array_index assert_equal([0,2,4], @obj_1.to_array_index) assert_equal([0,2,4], @obj_2.to_array_index) assert_equal([0,2,6], @obj_3.to_array_index) assert_equal([0, 1, 6, 8, 10], @obj_4.to_array_index) end def test_initialize_with_pattern @obj_5 = @t.new('n^ng^arraxt^n') @obj_6 = @t.new('g^arraxt^n') @obj_7 = @t.new('nnn^nn^nga^rraxt^nn') @obj_8 = @t.new('^g^arraxt^n') assert_equal([-2,1,7], @obj_5) assert_equal([0,2,8], @obj_5.to_array_index) assert_equal([1,7], @obj_6) assert_equal([0,6], @obj_6.to_array_index) assert_equal([-4, -2, 2, 7], @obj_7) assert_equal([0, 2, 5, 10], @obj_7.to_array_index) assert_equal([-1,1,7], @obj_8) assert_equal([0,1,7], @obj_8.to_array_index) end def test_argument_error assert_raise(ArgumentError) { @t.new([0,1,2]) } assert_raise(ArgumentError) { @t.new(0,1,2,0) } assert_raise(ArgumentError) { @t.new([nil,1,2]) } assert_raise(ArgumentError) { @t.new(nil,1,2,nil) } assert_raise(ArgumentError) { @t.new([1,1,2]) } assert_raise(ArgumentError) { @t.new(1,1,2,2) } end end end From trevor at pub.open-bio.org Wed Feb 1 07:31:24 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:31:24 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme/analysis test_calculated_cuts.rb, NONE, 1.1 test_sequence_range.rb, NONE, 1.1 Message-ID: <200602010738.k117cEVL028960@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/analysis In directory pub.open-bio.org:/tmp/cvs-serv28943/analysis Added Files: test_calculated_cuts.rb test_sequence_range.rb Log Message: Bio::RestrictionEnzyme tests --- NEW FILE: test_sequence_range.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/analysis/sequence_range' require 'bio/util/restriction_enzyme/analysis/fragments' require 'bio/util/restriction_enzyme/analysis/cut_range' require 'bio/util/restriction_enzyme/analysis/horizontal_cut_range' require 'bio/util/restriction_enzyme/analysis/vertical_cut_range' require 'bio/util/restriction_enzyme/analysis/cut_ranges' module Bio class TestAnalysisSequenceRange < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::Analysis::SequenceRange @fs = Bio::RestrictionEnzyme::Analysis::Fragments #a.add_cut_range(p_cut_left, p_cut_right, c_cut_left, c_cut_right ) @vcr = Bio::RestrictionEnzyme::Analysis::VerticalCutRange @crs = Bio::RestrictionEnzyme::Analysis::CutRanges @hcr = Bio::RestrictionEnzyme::Analysis::HorizontalCutRange @obj_1 = @t.new(0,5) @obj_1.add_cut_range(0,nil,nil,3) @obj_1.add_cut_range(nil,2,nil,nil) @obj_2 = @t.new(0,5) @obj_2.add_cut_ranges( @crs.new( [@vcr.new(0,2,nil,nil), @vcr.new(3,nil,4,nil)] )) @obj_3 = @t.new(0,5) @obj_3.add_cut_ranges( @crs.new( [@vcr.new(0,2,nil,nil), @vcr.new(3,nil,4,nil)] )) @obj_3.add_cut_ranges( @crs.new( [@hcr.new(0), @hcr.new(5)] )) @obj_4 = @t.new(0,5) @obj_4.add_cut_ranges( @crs.new( [@vcr.new(0,2,1,3)] )) @obj_5 = @t.new(0,5) @obj_5.add_cut_ranges( @crs.new( [@vcr.new(0,nil,nil,nil), @vcr.new(nil,4,3,nil), @hcr.new(1,2)] )) @obj_6 = @t.new(0,5) @obj_6.add_cut_ranges( @crs.new( [@vcr.new(nil,nil,0,nil), @hcr.new(1,2), @vcr.new(nil,4,3,nil)] )) @obj_7 = @t.new(0,5) @obj_7.add_cut_ranges( @crs.new( [@vcr.new(nil,2,nil,nil), @hcr.new(0,2)] )) @obj_8 = @t.new(0,11) @obj_8.add_cut_ranges( @crs.new( [@hcr.new(0,1), @vcr.new(nil,nil,nil,5), @hcr.new(7,8), @hcr.new(10), @vcr.new(nil,10,nil,nil)] )) @obj_9 = @t.new(0,5) @obj_9.add_cut_ranges( @crs.new( [@vcr.new(nil,3,nil,3)] )) @obj_10 = @t.new(0,5) @obj_10.add_cut_ranges( @crs.new( [@vcr.new(0,nil,nil,3), @vcr.new(nil,2,nil,2)] )) end def test_fragments assert_equal(@fs, @obj_1.fragments.class) end # '0|1 2|3 4 5' # ' +---+-+ ' # '0 1 2 3|4 5' def test_fragments_for_display_1 x = @obj_1 assert_equal(3, x.fragments.for_display.size) assert_equal('0 ', x.fragments.for_display[0].primary) assert_equal('0123', x.fragments.for_display[0].complement) assert_equal('12', x.fragments.for_display[1].primary) assert_equal(' ', x.fragments.for_display[1].complement) assert_equal('345', x.fragments.for_display[2].primary) assert_equal(' 45', x.fragments.for_display[2].complement) end # '0|1 2|3|4 5' # ' +---+ +-+ ' # '0 1 2 3 4|5' def test_fragments_for_display_2 x = @obj_2 assert_equal(3, x.fragments.for_display.size) assert_equal('0 3 ', x.fragments.for_display[0].primary) assert_equal('01234', x.fragments.for_display[0].complement) assert_equal('12', x.fragments.for_display[1].primary) assert_equal(' ', x.fragments.for_display[1].complement) assert_equal('45', x.fragments.for_display[2].primary) assert_equal(' 5', x.fragments.for_display[2].complement) end # '0|1 2|3|4 5' # '-+---+ +-+-' # '0 1 2 3 4|5' def test_fragments_for_display_3 x = @obj_3 assert_equal(5, x.fragments.for_display.size) assert_equal('0', x.fragments.for_display[0].primary) assert_equal(' ', x.fragments.for_display[0].complement) assert_equal(' 3 ', x.fragments.for_display[1].primary) assert_equal('01234', x.fragments.for_display[1].complement) assert_equal('12', x.fragments.for_display[2].primary) assert_equal(' ', x.fragments.for_display[2].complement) assert_equal('45', x.fragments.for_display[3].primary) assert_equal(' ', x.fragments.for_display[3].complement) assert_equal(' ', x.fragments.for_display[4].primary) assert_equal('5', x.fragments.for_display[4].complement) end # '0|1 2|3 4 5' # ' +-+-+-+ ' # '0 1|2 3|4 5' def test_fragments_for_display_4 x = @obj_4 assert_equal(4, x.fragments.for_display.size) assert_equal('0 ', x.fragments.for_display[0].primary) assert_equal('01', x.fragments.for_display[0].complement) assert_equal('12', x.fragments.for_display[1].primary) assert_equal(' ', x.fragments.for_display[1].complement) assert_equal(' ', x.fragments.for_display[2].primary) assert_equal('23', x.fragments.for_display[2].complement) assert_equal('345', x.fragments.for_display[3].primary) assert_equal(' 45', x.fragments.for_display[3].complement) end # '0 1 2 3 4|5' # ' +-+ ' # '0 1 2 3|4 5' def test_fragments_for_display_5 x = @obj_5 assert_equal(2, x.fragments.for_display.size) assert_equal('01234', x.fragments.for_display[0].primary) assert_equal('0123 ', x.fragments.for_display[0].complement) assert_equal(' 5', x.fragments.for_display[1].primary) assert_equal('45', x.fragments.for_display[1].complement) end # '0 1 2 3 4|5' # ' +-+ ' # '0 1 2 3|4 5' def test_fragments_for_display_6 x = @obj_6 assert_equal(2, x.fragments.for_display.size) assert_equal('01234', x.fragments.for_display[0].primary) assert_equal('0123 ', x.fragments.for_display[0].complement) assert_equal(' 5', x.fragments.for_display[1].primary) assert_equal('45', x.fragments.for_display[1].complement) end # '0 1 2|3 4 5' # '-----+ ' # '0 1 2 3 4 5' def test_fragments_for_display_7 x = @obj_7 assert_equal(2, x.fragments.for_display.size) assert_equal('012', x.fragments.for_display[0].primary) assert_equal(' ', x.fragments.for_display[0].complement) assert_equal(' 345', x.fragments.for_display[1].primary) assert_equal('012345', x.fragments.for_display[1].complement) end # '0 1 2 3 4 5 6 7 8 9 0 1' # ' ' # '0 1 2 3 4 5 6 7 8 9 0 1' def test_fragments_for_display_8 x = @obj_8 assert_equal(1, x.fragments.for_display.size) assert_equal('012345678901', x.fragments.for_display[0].primary) assert_equal('012345678901', x.fragments.for_display[0].complement) end # '0 1 2 3|4 5' # ' + ' # '0 1 2 3|4 5' def test_fragments_for_display_9 x = @obj_9 assert_equal(2, x.fragments.for_display.size) assert_equal('0123', x.fragments.for_display[0].primary) assert_equal('0123', x.fragments.for_display[0].complement) assert_equal('45', x.fragments.for_display[1].primary) assert_equal('45', x.fragments.for_display[1].complement) end # '0|1 2|3 4 5' # ' +---+-+ ' # '0 1 2|3|4 5' def test_fragments_for_display_10 x = @obj_10 assert_equal(4, x.fragments.for_display.size) assert_equal('0 ', x.fragments.for_display[0].primary) assert_equal('012', x.fragments.for_display[0].complement) assert_equal('12', x.fragments.for_display[1].primary) assert_equal(' ', x.fragments.for_display[1].complement) assert_equal('345', x.fragments.for_display[2].primary) assert_equal(' 45', x.fragments.for_display[2].complement) assert_equal(' ', x.fragments.for_display[3].primary) assert_equal('3', x.fragments.for_display[3].complement) end end end --- NEW FILE: test_calculated_cuts.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/analysis/calculated_cuts' require 'bio/util/restriction_enzyme/analysis/cut_range' require 'bio/util/restriction_enzyme/analysis/horizontal_cut_range' require 'bio/util/restriction_enzyme/analysis/vertical_cut_range' require 'bio/util/restriction_enzyme/analysis/cut_ranges' module Bio class TestAnalysisCalculatedCuts < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::Analysis::CalculatedCuts @vcr = Bio::RestrictionEnzyme::Analysis::VerticalCutRange @crs = Bio::RestrictionEnzyme::Analysis::CutRanges @hcr = Bio::RestrictionEnzyme::Analysis::HorizontalCutRange #a.add_cut_range(p_cut_left, p_cut_right, c_cut_left, c_cut_right ) @obj_1 = @t.new(6) @obj_1.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(0,nil,nil,3), @vcr.new(nil,2,nil,nil)] )) @obj_1b = @obj_1.dup @obj_1b.remove_incomplete_cuts @obj_2 = @t.new(6) @obj_2.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(0,2,nil,nil), @vcr.new(3,nil,4,nil)] )) @obj_2b = @obj_2.dup @obj_2b.remove_incomplete_cuts @obj_3 = @t.new(6) @obj_3.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(0,2,nil,nil), @vcr.new(3,nil,4,nil)] )) @obj_3.add_cuts_from_cut_ranges( @crs.new( [@hcr.new(0), @hcr.new(5)] )) @obj_3b = @obj_3.dup @obj_3b.remove_incomplete_cuts @obj_4 = @t.new(6) @obj_4.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(0,2,1,3)] )) @obj_4b = @obj_4.dup @obj_4b.remove_incomplete_cuts # Same thing, declared a different way @obj_4_c1 = @t.new(6) @obj_4_c1.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(nil,nil,1,3), @vcr.new(0,2,nil,nil)] )) @obj_4b_c1 = @obj_4_c1.dup @obj_4b_c1.remove_incomplete_cuts # Same thing, declared a different way @obj_4_c2 = @t.new(6) @obj_4_c2.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(0,nil,nil,3), @vcr.new(nil,2,1,nil)] )) @obj_4b_c2 = @obj_4_c2.dup @obj_4b_c2.remove_incomplete_cuts @obj_5 = @t.new(6) @obj_5.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(0,nil,nil,nil), @vcr.new(nil,4,3,nil), @hcr.new(1,2)] )) @obj_5b = @obj_5.dup @obj_5b.remove_incomplete_cuts @obj_6 = @t.new(6) @obj_6.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(nil,nil,0,nil), @hcr.new(1,2), @vcr.new(nil,4,3,nil)] )) @obj_6b = @obj_6.dup @obj_6b.remove_incomplete_cuts @obj_7 = @t.new(6) @obj_7.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(nil,2,nil,nil), @hcr.new(0,2)] )) @obj_7b = @obj_7.dup @obj_7b.remove_incomplete_cuts @obj_8 = @t.new(12) @obj_8.add_cuts_from_cut_ranges( @crs.new( [@hcr.new(0,1), @vcr.new(nil,nil,nil,5), @hcr.new(7,8), @hcr.new(10), @vcr.new(nil,10,nil,nil)] )) @obj_8b = @obj_8.dup @obj_8b.remove_incomplete_cuts @obj_9 = @t.new(6) @obj_9.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(nil,3,nil,3)] )) @obj_9b = @obj_9.dup @obj_9b.remove_incomplete_cuts @obj_10 = @t.new(6) @obj_10.add_cuts_from_cut_ranges( @crs.new( [@vcr.new(0,nil,nil,3), @vcr.new(nil,2,nil,2)] )) @obj_10b = @obj_10.dup @obj_10b.remove_incomplete_cuts end def test_cuts x = @obj_1 assert_equal([0,2], x.vc_primary) assert_equal([3], x.vc_complement) assert_equal([1,2,3], x.hc_between_strands) x = @obj_2 assert_equal([0,2,3], x.vc_primary) assert_equal([4], x.vc_complement) assert_equal([1,2,4], x.hc_between_strands) x = @obj_3 assert_equal([0,2,3], x.vc_primary) assert_equal([4], x.vc_complement) assert_equal([0,1,2,4,5], x.hc_between_strands) x = @obj_4 assert_equal([0,2], x.vc_primary) assert_equal([1,3], x.vc_complement) assert_equal([1,2,3], x.hc_between_strands) x = @obj_4_c1 assert_equal([0,2], x.vc_primary) assert_equal([1,3], x.vc_complement) assert_equal([1,2,3], x.hc_between_strands) x = @obj_4_c2 assert_equal([0,2], x.vc_primary) assert_equal([1,3], x.vc_complement) assert_equal([1,2,3], x.hc_between_strands) x = @obj_5 assert_equal([0,4], x.vc_primary) assert_equal([3], x.vc_complement) assert_equal([1,2,4], x.hc_between_strands) x = @obj_6 assert_equal([4], x.vc_primary) assert_equal([0,3], x.vc_complement) assert_equal([1,2,4], x.hc_between_strands) x = @obj_7 assert_equal([2], x.vc_primary) assert_equal([], x.vc_complement) assert_equal([0,1,2], x.hc_between_strands) x = @obj_8 assert_equal([10], x.vc_primary) assert_equal([5], x.vc_complement) assert_equal([0,1,7,8,10], x.hc_between_strands) x = @obj_9 assert_equal([3], x.vc_primary) assert_equal([3], x.vc_complement) assert_equal([], x.hc_between_strands) x = @obj_10 assert_equal([0,2], x.vc_primary) assert_equal([2,3], x.vc_complement) assert_equal([1,2,3], x.hc_between_strands) end def test_cuts_after_remove_incomplete_cuts x = @obj_1b assert_equal([0,2], x.vc_primary) assert_equal([3], x.vc_complement) assert_equal([1,2,3], x.hc_between_strands) end def test_strands_for_display_current #check object_id end def test_strands_for_display x = @obj_1 assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +---+-+ ', x.strands_for_display[1]) assert_equal('0 1 2 3|4 5', x.strands_for_display[2]) x = @obj_1b assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +---+-+ ', x.strands_for_display[1]) assert_equal('0 1 2 3|4 5', x.strands_for_display[2]) x = @obj_2 assert_equal('0|1 2|3|4 5', x.strands_for_display[0]) assert_equal(' +---+ +-+ ', x.strands_for_display[1]) assert_equal('0 1 2 3 4|5', x.strands_for_display[2]) x = @obj_2b assert_equal('0|1 2|3|4 5', x.strands_for_display[0]) assert_equal(' +---+ +-+ ', x.strands_for_display[1]) assert_equal('0 1 2 3 4|5', x.strands_for_display[2]) x = @obj_3 assert_equal('0|1 2|3|4 5', x.strands_for_display[0]) assert_equal('-+---+ +-+-', x.strands_for_display[1]) assert_equal('0 1 2 3 4|5', x.strands_for_display[2]) x = @obj_3b assert_equal('0|1 2|3|4 5', x.strands_for_display[0]) assert_equal('-+---+ +-+-', x.strands_for_display[1]) assert_equal('0 1 2 3 4|5', x.strands_for_display[2]) x = @obj_4 assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +-+-+-+ ', x.strands_for_display[1]) assert_equal('0 1|2 3|4 5', x.strands_for_display[2]) x = @obj_4b assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +-+-+-+ ', x.strands_for_display[1]) assert_equal('0 1|2 3|4 5', x.strands_for_display[2]) x = @obj_4_c1 assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +-+-+-+ ', x.strands_for_display[1]) assert_equal('0 1|2 3|4 5', x.strands_for_display[2]) x = @obj_4b_c1 assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +-+-+-+ ', x.strands_for_display[1]) assert_equal('0 1|2 3|4 5', x.strands_for_display[2]) x = @obj_4_c2 assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +-+-+-+ ', x.strands_for_display[1]) assert_equal('0 1|2 3|4 5', x.strands_for_display[2]) x = @obj_4b_c2 assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +-+-+-+ ', x.strands_for_display[1]) assert_equal('0 1|2 3|4 5', x.strands_for_display[2]) x = @obj_5 assert_equal('0|1 2 3 4|5', x.strands_for_display[0]) assert_equal(' +--- +-+ ', x.strands_for_display[1]) assert_equal('0 1 2 3|4 5', x.strands_for_display[2]) x = @obj_5b assert_equal('0 1 2 3 4|5', x.strands_for_display[0]) assert_equal(' +-+ ', x.strands_for_display[1]) assert_equal('0 1 2 3|4 5', x.strands_for_display[2]) x = @obj_6 assert_equal('0 1 2 3 4|5', x.strands_for_display[0]) assert_equal(' +--- +-+ ', x.strands_for_display[1]) assert_equal('0|1 2 3|4 5', x.strands_for_display[2]) x = @obj_6b assert_equal('0 1 2 3 4|5', x.strands_for_display[0]) assert_equal(' +-+ ', x.strands_for_display[1]) assert_equal('0 1 2 3|4 5', x.strands_for_display[2]) x = @obj_7 assert_equal('0 1 2|3 4 5', x.strands_for_display[0]) assert_equal('-----+ ', x.strands_for_display[1]) assert_equal('0 1 2 3 4 5', x.strands_for_display[2]) x = @obj_7b assert_equal('0 1 2|3 4 5', x.strands_for_display[0]) assert_equal('-----+ ', x.strands_for_display[1]) assert_equal('0 1 2 3 4 5', x.strands_for_display[2]) x = @obj_8 assert_equal('0 1 2 3 4 5 6 7 8 9 0|1', x.strands_for_display[0]) assert_equal('--- + --- -+ ', x.strands_for_display[1]) assert_equal('0 1 2 3 4 5|6 7 8 9 0 1', x.strands_for_display[2]) x = @obj_8b assert_equal('0 1 2 3 4 5 6 7 8 9 0 1', x.strands_for_display[0]) assert_equal(' ', x.strands_for_display[1]) assert_equal('0 1 2 3 4 5 6 7 8 9 0 1', x.strands_for_display[2]) x = @obj_9 assert_equal('0 1 2 3|4 5', x.strands_for_display[0]) assert_equal(' + ', x.strands_for_display[1]) assert_equal('0 1 2 3|4 5', x.strands_for_display[2]) x = @obj_9b assert_equal('0 1 2 3|4 5', x.strands_for_display[0]) assert_equal(' + ', x.strands_for_display[1]) assert_equal('0 1 2 3|4 5', x.strands_for_display[2]) x = @obj_10 assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +---+-+ ', x.strands_for_display[1]) assert_equal('0 1 2|3|4 5', x.strands_for_display[2]) x = @obj_10b assert_equal('0|1 2|3 4 5', x.strands_for_display[0]) assert_equal(' +---+-+ ', x.strands_for_display[1]) assert_equal('0 1 2|3|4 5', x.strands_for_display[2]) end end end From trevor at pub.open-bio.org Wed Feb 1 07:31:25 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Wed, 01 Feb 2006 07:31:25 -0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme test_analysis.rb, NONE, 1.1 test_double_stranded.rb, NONE, 1.1 test_integer.rb, NONE, 1.1 test_single_strand.rb, NONE, 1.1 test_single_strand_complement.rb, NONE, 1.1 test_string_formatting.rb, NONE, 1.1 Message-ID: <200602010738.k117cEVL028959@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv28943 Added Files: test_analysis.rb test_double_stranded.rb test_integer.rb test_single_strand.rb test_single_strand_complement.rb test_string_formatting.rb Log Message: Bio::RestrictionEnzyme tests --- NEW FILE: test_integer.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/integer' module Bio class TestCutLocationsInEnzymeNotation < Test::Unit::TestCase def test_negative? assert_equal(false, 1.negative?) assert_equal(false, 0.negative?) assert_equal(true, -1.negative?) end end end --- NEW FILE: test_string_formatting.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/string_formatting' module Bio class TestStringFormatting < Test::Unit::TestCase include Bio::RestrictionEnzyme::StringFormatting def setup @t = String @obj_1 = @t.new('gata') @obj_2 = @t.new('garraxt') @obj_3 = @t.new('gArraXT') @obj_4 = @t.new('nnnnnnngarraxtnn') end def test_strip_padding assert_equal('gata', strip_padding(@obj_1)) assert_equal('garraxt', strip_padding(@obj_2)) assert_equal('gArraXT', strip_padding(@obj_3)) assert_equal('garraxt', strip_padding(@obj_4)) end def test_left_padding assert_equal('', left_padding(@obj_1)) assert_equal('', left_padding(@obj_2)) assert_equal('', left_padding(@obj_3)) assert_equal('nnnnnnn', left_padding(@obj_4)) end def test_right_padding assert_equal('', right_padding(@obj_1)) assert_equal('', right_padding(@obj_2)) assert_equal('', right_padding(@obj_3)) assert_equal('nn', right_padding(@obj_4)) end def test_add_spacing assert_equal('n^n g^a t^a', add_spacing('n^ng^at^a') ) assert_equal('n^n g^a r r a x t^n', add_spacing('n^ng^arraxt^n') ) end end end --- NEW FILE: test_analysis.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/analysis' module Bio class TestAnalysis < Test::Unit::TestCase def setup @enz = Bio::RestrictionEnzyme @t = Bio::RestrictionEnzyme::Analysis @obj_1 = @t.cut('cagagag', 'ag^ag') @obj_2 = @t.cut('agagag', 'ag^ag') @obj_3 = @t.cut('cagagagt', 'ag^ag') e1 = @enz.new('atgcatgc', [3,3]) @obj_4 = @t.cut('atgcatgcatgc', e1) e2 = @enz.new('atgcatgc', [3,5]) @obj_5 = @t.cut('atgcatgcatgc', e2) e3 = @enz.new('anna', [1,1], [3,3]) e4 = @enz.new('gg', [1,1]) @obj_6 = @t.cut('agga', e3, e4) @obj_7 = @t.cut('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII') @obj_8 = @t.cut('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII', 'HincII') @obj_1d = @t.cut_without_permutations('cagagag', 'ag^ag') @obj_2d = @t.cut_without_permutations('agagag', 'ag^ag') @obj_3d = @t.cut_without_permutations('cagagagt', 'ag^ag') e1 = @enz.new('atgcatgc', [3,3]) @obj_4d = @t.cut_without_permutations('atgcatgcatgc', e1) e2 = @enz.new('atgcatgc', [3,5]) @obj_5d = @t.cut_without_permutations('atgcatgcatgc', e2) e3 = @enz.new('anna', [1,1], [3,3]) e4 = @enz.new('gg', [1,1]) @obj_6d = @t.cut_without_permutations('agga', e3, e4) @obj_7d = @t.cut_without_permutations('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII') @obj_8d = @t.cut_without_permutations('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII', 'HincII') end def test_cut assert_equal(["ag", "cag"], @obj_1.primary) assert_equal(["gtc", "tc"], @obj_1.complement) assert_equal(2, @obj_1.size) assert_equal(Bio::RestrictionEnzyme::Analysis::UniqueFragments, @obj_1.class) assert_equal(Bio::RestrictionEnzyme::Analysis::UniqueFragment, @obj_1[0].class) assert_equal(["ag"], @obj_2.primary) assert_equal(["ag", "agt", "cag"], @obj_3.primary) assert_equal(["atg", "atgcatg", "catg", "catgc"], @obj_4.primary) assert_equal(["atg", "atgcatg", "catgc", "catgcatgc"], @obj_5.primary) assert_equal(["a", "ag", "g", "ga"], @obj_6.primary) assert_equal(["ccaggaaaaaga", "ccaggaaag", "cctggaaaagttaac", "ga"], @obj_7.primary) assert_equal(["aac", "ccaggaaaaaga", "ccaggaaag", "cctggaaaagtt", "ga"], @obj_8.primary) end def test_cut_without_permutations assert_equal(["ag", "cag"], @obj_1d.primary) assert_equal(["ag"], @obj_2d.primary) assert_equal(["ag", "agt", "cag"], @obj_3d.primary) assert_equal(["atg", "catg", "catgc"], @obj_4d.primary) assert_equal(["atg", "catg", "catgc"], @obj_5d.primary) assert_equal(["a", "g"], @obj_6d.primary) assert_equal(["ccaggaaaaaga", "ccaggaaag", "cctggaaaagttaac", "ga"], @obj_7d.primary) assert_equal(["aac", "ccaggaaaaaga", "ccaggaaag", "cctggaaaagtt", "ga"], @obj_8d.primary) end def test_cut_from_bio_sequence_na assert_equal(["ag", "cag"], Bio::Sequence::NA.new('cagagag').cut_with_enzyme('ag^ag').primary ) assert_equal(["ag", "cag"], Bio::Sequence::NA.new('cagagag').cut_with_enzymes('ag^ag').primary ) assert_equal(["ag", "cag"], Bio::Sequence::NA.new('cagagag').cut_with_enzymes('ag^ag', 'EcoRII').primary ) # NOTE: investigate where the '' is coming from assert_equal(["", "ag", "ag", "cag", "ccagg"], Bio::Sequence::NA.new('cagagagccagg').cut_with_enzymes('ag^ag', 'EcoRII').primary ) end end end --- NEW FILE: test_double_stranded.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/double_stranded' module Bio class TestDoubleStranded < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::DoubleStranded @cl = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPairInEnzymeNotation @s = String @obj_1 = @t.new(@s.new('gata'), [1,2]) @obj_2 = @t.new('gata', [1,2]) @obj_3 = @t.new('garraxt', [1,2]) @obj_4 = @t.new('nnnnnnngarraxtnn', [1,2]) @obj_5 = @t.new('garraxt', @cl.new(3,2), @cl.new(-2,-1), @cl.new(9,11)) @obj_6 = @t.new('garraxt', @cl.new(3,2)) @obj_7 = @t.new('garraxt', @cl.new(3,2), @cl.new(9,11)) @obj_8 = @t.new('garraxt', 3..2, 9..11) @obj_9 = @t.new('garraxt', [3,2], [9,11]) @obj_10 = @t.new('garraxt', [3,2], [9,11]) @obj_11 = @t.new('n^ngar^raxtnn^n') @obj_12 = @t.new('nnnn^ngar^raxtnn^nnnn') @obj_13 = @t.new(Bio::RestrictionEnzyme.rebase['EcoRII']) @obj_14 = @t.new('EcoRII') @obj_15 = @t.new('ecorii') end def test_primary assert_equal('nngarraxtnnn', @obj_5.primary) end def test_primary_with_cut_symbols assert_equal('n^ngar^raxtnn^n', @obj_5.primary.with_cut_symbols) assert_equal('gar^raxt', @obj_6.primary.with_cut_symbols) assert_equal('gar^raxtnn^n', @obj_7.primary.with_cut_symbols) assert_equal('gar^raxtnn^n', @obj_8.primary.with_cut_symbols) assert_equal('gar^raxtnn^n', @obj_9.primary.with_cut_symbols) assert_equal('gar^raxtnn^n', @obj_10.primary.with_cut_symbols) assert_equal('n^ngar^raxtnn^n', @obj_11.primary.with_cut_symbols) assert_equal('n^ngar^raxtnn^n', @obj_12.primary.with_cut_symbols) assert_equal('n^ccwgg', @obj_13.primary.with_cut_symbols) assert_equal('n^ccwgg', @obj_14.primary.with_cut_symbols) assert_equal('n^ccwgg', @obj_15.primary.with_cut_symbols) end def test_complement_with_cut_symbols assert_equal('n^ct^yytxannnn^n', @obj_5.complement.with_cut_symbols) assert_equal('ct^yytxa', @obj_6.complement.with_cut_symbols) assert_equal('ct^yytxannnn^n', @obj_7.complement.with_cut_symbols) assert_equal('ct^yytxannnn^n', @obj_8.complement.with_cut_symbols) assert_equal('ct^yytxannnn^n', @obj_9.complement.with_cut_symbols) assert_equal('ct^yytxannnn^n', @obj_10.complement.with_cut_symbols) assert_equal('n^nnctyy^txan^n', @obj_11.complement.with_cut_symbols) assert_equal('n^nnctyy^txan^n', @obj_12.complement.with_cut_symbols) assert_equal('ggwcc^n', @obj_13.complement.with_cut_symbols) assert_equal('ggwcc^n', @obj_14.complement.with_cut_symbols) assert_equal('ggwcc^n', @obj_15.complement.with_cut_symbols) end def test_complement assert_equal('nctyytxannnnn', @obj_5.complement) end def test_cut_locations assert_equal([[4, 3], [0, 1], [10, 12]], @obj_5.cut_locations) end def test_cut_locations_in_enzyme_notation assert_equal([[3, 2], [-2, -1], [9, 11]], @obj_5.cut_locations_in_enzyme_notation) end def test_argument_error assert_raise(ArgumentError) { @t.new('garraxt', [3,2,9,11]) } assert_raise(ArgumentError) { @t.new(Bio::RestrictionEnzyme.rebase['ecorii'] )} assert_raise(ArgumentError) { @t.new(Bio::RestrictionEnzyme.rebase['EzzRII']) } end def test_index_error assert_raise(IndexError) { @t.new('EzzRII') } end # NOTE def test_to_re end end end --- NEW FILE: test_single_strand_complement.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/single_strand_complement' module Bio class TestSingleStrandComplement < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::SingleStrandComplement @cl = Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation @s = Bio::Sequence::NA @obj_1 = @t.new(@s.new('gata'), @cl.new(-2,1,3)) @obj_2 = @t.new('gata', -2, 1, 3) @obj_3 = @t.new('garraxt', [-2, 1, 7]) @obj_4 = @t.new('nnnnnnngarraxtnn', [-2, 1, 7]) @obj_5 = @t.new('ga^rr^axt') @obj_6 = @t.new('^ga^rr^axt') @obj_7 = @t.new('n^ngar^raxtnn^n') end def test_pattern_palindromic? assert_equal(true, @t.new('atgcat', 1).palindromic?) assert_equal(false, @t.new('atgcgta', 1).palindromic?) assert_equal(false, @obj_1.palindromic?) assert_equal(false, @obj_2.palindromic?) assert_equal(false, @obj_3.palindromic?) assert_equal(false, @obj_4.palindromic?) end def test_stripped assert_equal('gata', @obj_1.stripped) assert_equal('gata', @obj_2.stripped) assert_equal('garraxt', @obj_3.stripped) assert_equal('garraxt', @obj_4.stripped) end def test_pattern assert_equal('nngata', @obj_1.pattern) assert_equal('nngata', @obj_2.pattern) assert_equal('nngarraxtn', @obj_3.pattern) assert_equal('nngarraxtn', @obj_4.pattern) assert_equal('nngata', @obj_1) assert_equal('nngata', @obj_2) assert_equal('nngarraxtn', @obj_3) assert_equal('nngarraxtn', @obj_4) end def test_with_cut_symbols assert_equal('n^ng^at^a', @obj_1.with_cut_symbols) assert_equal('n^ng^at^a', @obj_2.with_cut_symbols) assert_equal('n^ng^arraxt^n', @obj_3.with_cut_symbols) assert_equal('n^ng^arraxt^n', @obj_4.with_cut_symbols) end def test_with_spaces assert_equal('n^n g^a t^a', @obj_1.with_spaces) assert_equal('n^n g^a t^a', @obj_2.with_spaces) assert_equal('n^n g^a r r a x t^n', @obj_3.with_spaces) assert_equal('n^n g^a r r a x t^n', @obj_4.with_spaces) end def test_cut_locations_in_enzyme_notation assert_equal([-2,1,3], @obj_1.cut_locations_in_enzyme_notation) assert_equal([-2,1,3], @obj_2.cut_locations_in_enzyme_notation) assert_equal([-2,1,7], @obj_3.cut_locations_in_enzyme_notation) assert_equal([-2,1,7], @obj_4.cut_locations_in_enzyme_notation) assert_equal([2,4], @obj_5.cut_locations_in_enzyme_notation) assert_equal([-1,2,4], @obj_6.cut_locations_in_enzyme_notation) assert_equal([-2,3,9], @obj_7.cut_locations_in_enzyme_notation) end def test_cut_locations assert_equal([0,2,4], @obj_1.cut_locations) assert_equal([0,2,4], @obj_2.cut_locations) assert_equal([0,2,8], @obj_3.cut_locations) assert_equal([0,2,8], @obj_4.cut_locations) assert_equal([1,3], @obj_5.cut_locations) assert_equal([0,2,4], @obj_6.cut_locations) assert_equal([0,4,10], @obj_7.cut_locations) end def test_orientation assert_equal([3,5], @obj_1.orientation) assert_equal([3,5], @obj_2.orientation) assert_equal([3,5], @obj_3.orientation) assert_equal([3,5], @obj_4.orientation) end def test_creation_with_no_cuts @obj_8 = @t.new('garraxt') assert_equal([3,5], @obj_8.orientation) assert_equal([], @obj_8.cut_locations) assert_equal([], @obj_8.cut_locations_in_enzyme_notation) assert_equal('garraxt', @obj_8.pattern) end # NOTE def test_to_re end def test_argument_error assert_raise(ArgumentError) { @t.new('a', [0,1,2]) } assert_raise(ArgumentError) { @t.new('a', 0,1,2,0) } assert_raise(ArgumentError) { @t.new('a', [nil,1,2]) } assert_raise(ArgumentError) { @t.new('a', nil,1,2,nil) } assert_raise(ArgumentError) { @t.new('a', [1,1,2]) } assert_raise(ArgumentError) { @t.new('a', 1,1,2,2) } assert_raise(ArgumentError) { @t.new(1, [1,2,3]) } assert_raise(ArgumentError) { @t.new('gaat^aca', [1,2,3]) } assert_raise(ArgumentError) { @t.new('gaat^^aca') } assert_raise(ArgumentError) { @t.new('z', [1,2,3]) } assert_raise(ArgumentError) { @t.new('g', [0,1,2]) } assert_raise(ArgumentError) { @t.new('g', 0,1,2,0) } assert_raise(ArgumentError) { @t.new('g', [0,1,1,2]) } assert_raise(ArgumentError) { @t.new('g', 0,1,1,2,2) } assert_raise(ArgumentError) { @t.new(1,2,3) } assert_raise(ArgumentError) { @t.new(1,2,'g') } end end end --- NEW FILE: test_single_strand.rb --- require 'pathname' libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s $:.unshift(libpath) unless $:.include?(libpath) require 'test/unit' require 'bio/util/restriction_enzyme/single_strand' module Bio class TestSingleStrand < Test::Unit::TestCase def setup @t = Bio::RestrictionEnzyme::SingleStrand @cl = Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation @s = Bio::Sequence::NA @obj_1 = @t.new(@s.new('gata'), @cl.new(-2,1,3)) @obj_2 = @t.new('gata', -2, 1, 3) @obj_3 = @t.new('garraxt', [-2, 1, 7]) @obj_4 = @t.new('nnnnnnngarraxtnn', [-2, 1, 7]) @obj_5 = @t.new('ga^rr^axt') @obj_6 = @t.new('^ga^rr^axt') @obj_7 = @t.new('n^ngar^raxtnn^n') end def test_pattern_palindromic? assert_equal(true, @t.new('atgcat', 1).palindromic?) assert_equal(false, @t.new('atgcgta', 1).palindromic?) assert_equal(false, @obj_1.palindromic?) assert_equal(false, @obj_2.palindromic?) assert_equal(false, @obj_3.palindromic?) assert_equal(false, @obj_4.palindromic?) end def test_stripped assert_equal('gata', @obj_1.stripped) assert_equal('gata', @obj_2.stripped) assert_equal('garraxt', @obj_3.stripped) assert_equal('garraxt', @obj_4.stripped) end def test_pattern assert_equal('nngata', @obj_1.pattern) assert_equal('nngata', @obj_2.pattern) assert_equal('nngarraxtn', @obj_3.pattern) assert_equal('nngarraxtn', @obj_4.pattern) assert_equal('nngata', @obj_1) assert_equal('nngata', @obj_2) assert_equal('nngarraxtn', @obj_3) assert_equal('nngarraxtn', @obj_4) end def test_with_cut_symbols assert_equal('n^ng^at^a', @obj_1.with_cut_symbols) assert_equal('n^ng^at^a', @obj_2.with_cut_symbols) assert_equal('n^ng^arraxt^n', @obj_3.with_cut_symbols) assert_equal('n^ng^arraxt^n', @obj_4.with_cut_symbols) end def test_with_spaces assert_equal('n^n g^a t^a', @obj_1.with_spaces) assert_equal('n^n g^a t^a', @obj_2.with_spaces) assert_equal('n^n g^a r r a x t^n', @obj_3.with_spaces) assert_equal('n^n g^a r r a x t^n', @obj_4.with_spaces) end def test_cut_locations_in_enzyme_notation assert_equal([-2,1,3], @obj_1.cut_locations_in_enzyme_notation) assert_equal([-2,1,3], @obj_2.cut_locations_in_enzyme_notation) assert_equal([-2,1,7], @obj_3.cut_locations_in_enzyme_notation) assert_equal([-2,1,7], @obj_4.cut_locations_in_enzyme_notation) assert_equal([2,4], @obj_5.cut_locations_in_enzyme_notation) assert_equal([-1,2,4], @obj_6.cut_locations_in_enzyme_notation) assert_equal([-2,3,9], @obj_7.cut_locations_in_enzyme_notation) end def test_cut_locations assert_equal([0,2,4], @obj_1.cut_locations) assert_equal([0,2,4], @obj_2.cut_locations) assert_equal([0,2,8], @obj_3.cut_locations) assert_equal([0,2,8], @obj_4.cut_locations) assert_equal([1,3], @obj_5.cut_locations) assert_equal([0,2,4], @obj_6.cut_locations) assert_equal([0,4,10], @obj_7.cut_locations) end def test_orientation assert_equal([5,3], @obj_1.orientation) assert_equal([5,3], @obj_2.orientation) assert_equal([5,3], @obj_3.orientation) assert_equal([5,3], @obj_4.orientation) end def test_creation_with_no_cuts @obj_8 = @t.new('garraxt') assert_equal([5,3], @obj_8.orientation) assert_equal([], @obj_8.cut_locations) assert_equal([], @obj_8.cut_locations_in_enzyme_notation) assert_equal('garraxt', @obj_8.pattern) end # NOTE def test_to_re end def test_argument_error assert_raise(ArgumentError) { @t.new('a', [0,1,2]) } assert_raise(ArgumentError) { @t.new('a', 0,1,2,0) } assert_raise(ArgumentError) { @t.new('a', [nil,1,2]) } assert_raise(ArgumentError) { @t.new('a', nil,1,2,nil) } assert_raise(ArgumentError) { @t.new('a', [1,1,2]) } assert_raise(ArgumentError) { @t.new('a', 1,1,2,2) } assert_raise(ArgumentError) { @t.new(1, [1,2,3]) } assert_raise(ArgumentError) { @t.new('gaat^aca', [1,2,3]) } assert_raise(ArgumentError) { @t.new('gaat^^aca') } assert_raise(ArgumentError) { @t.new('z', [1,2,3]) } assert_raise(ArgumentError) { @t.new('g', [0,1,2]) } assert_raise(ArgumentError) { @t.new('g', 0,1,2,0) } assert_raise(ArgumentError) { @t.new('g', [0,1,1,2]) } assert_raise(ArgumentError) { @t.new('g', 0,1,1,2,2) } assert_raise(ArgumentError) { @t.new(1,2,3) } assert_raise(ArgumentError) { @t.new(1,2,'g') } end end end From trevor at pub.open-bio.org Sat Feb 18 22:00:57 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Sat, 18 Feb 2006 22:00:57 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme analysis.rb, 1.1, 1.2 Message-ID: <200602182200.k1IM0vVL003435@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv3419/restriction_enzyme Modified Files: analysis.rb Log Message: Removal and replacement of permutation.rb Index: analysis.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** analysis.rb 1 Feb 2006 07:34:11 -0000 1.1 --- analysis.rb 18 Feb 2006 22:00:55 -0000 1.2 *************** *** 22,26 **** require 'bio/util/restriction_enzyme' require 'bio/util/restriction_enzyme/analysis/sequence_range.rb' - require 'bio/util/restriction_enzyme/analysis/permutation.rb' class Bio::RestrictionEnzyme --- 22,25 ---- *************** *** 71,75 **** end - def cut_without_permutations( sequence, *args ) sequence = Bio::Sequence::NA.new( sequence ) --- 70,73 ---- *************** *** 93,97 **** sequence = Bio::Sequence::NA.new( sequence ) enzyme_actions = create_enzyme_actions( sequence, *args ) ! permutations = Permutation.new(enzyme_actions.size).map { |p| p.value } # Indexed by permutation. --- 91,95 ---- sequence = Bio::Sequence::NA.new( sequence ) enzyme_actions = create_enzyme_actions( sequence, *args ) ! permutations = permute(enzyme_actions.size) # Indexed by permutation. *************** *** 168,171 **** --- 166,184 ---- protected ######### + + def permute(count, permutations = [[0]]) + return permutations if count <= 1 + new_arrays = [] + new_array = [] + + (permutations[0].size + 1).times do |n| + new_array.clear + permutations.each { |a| new_array << a.dup } + new_array.each { |e| e.insert(n, permutations[0].size) } + new_arrays += new_array + end + + permute(count-1, new_arrays) + end UniqueFragment = Struct.new(:primary, :complement) From trevor at pub.open-bio.org Sat Feb 18 22:00:57 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Sat, 18 Feb 2006 22:00:57 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util restriction_enzyme.rb,1.1,1.2 Message-ID: <200602182200.k1IM0vVL003431@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util In directory pub.open-bio.org:/tmp/cvs-serv3419 Modified Files: restriction_enzyme.rb Log Message: Removal and replacement of permutation.rb Index: restriction_enzyme.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** restriction_enzyme.rb 1 Feb 2006 07:30:19 -0000 1.1 --- restriction_enzyme.rb 18 Feb 2006 22:00:55 -0000 1.2 *************** *** 203,210 **** - == Notes - This module includes Florian Frank's permutation.rb licensed under the GPL. To prevent licensing issues - the source code to Bio::RestrictionEnzyme must be included whenever Bio::RestrictionEnzyme is distributed. - == Author Trevor Wennblom --- 203,206 ---- From trevor at pub.open-bio.org Sat Feb 18 22:02:53 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Sat, 18 Feb 2006 22:02:53 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/analysis permutation.rb, 1.1, NONE Message-ID: <200602182202.k1IM2rVL003497@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis In directory pub.open-bio.org:/tmp/cvs-serv3487 Removed Files: permutation.rb Log Message: Permutation LGPL'd library removed. --- permutation.rb DELETED --- From trevor at pub.open-bio.org Sat Feb 18 22:11:07 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Sat, 18 Feb 2006 22:11:07 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme test_analysis.rb, 1.1, 1.2 Message-ID: <200602182211.k1IMB7VL003530@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv3520 Modified Files: test_analysis.rb Log Message: Check for empty strings as input. Index: test_analysis.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/test_analysis.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_analysis.rb 1 Feb 2006 07:38:12 -0000 1.1 --- test_analysis.rb 18 Feb 2006 22:11:05 -0000 1.2 *************** *** 48,51 **** --- 48,54 ---- @obj_8d = @t.cut_without_permutations('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII', 'HincII') + @obj_98 = @t.cut('', 'EcoRII', 'HincII') + @obj_99 = @t.cut_without_permutations('', 'EcoRII', 'HincII') + end From trevor at pub.open-bio.org Sat Feb 18 22:11:38 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Sat, 18 Feb 2006 22:11:38 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme analysis.rb, 1.2, 1.3 Message-ID: <200602182211.k1IMBcVL003547@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv3537 Modified Files: analysis.rb Log Message: Check for empty strings as input and return nil if found. Index: analysis.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** analysis.rb 18 Feb 2006 22:00:55 -0000 1.2 --- analysis.rb 18 Feb 2006 22:11:35 -0000 1.3 *************** *** 71,74 **** --- 71,75 ---- def cut_without_permutations( sequence, *args ) + return nil if !sequence.kind_of?(String) or sequence.empty? sequence = Bio::Sequence::NA.new( sequence ) enzyme_actions = create_enzyme_actions( sequence, *args ) *************** *** 89,92 **** --- 90,94 ---- def cut_and_return_by_permutations( sequence, *args ) + return nil if !sequence.kind_of?(String) or sequence.empty? sequence = Bio::Sequence::NA.new( sequence ) enzyme_actions = create_enzyme_actions( sequence, *args ) *************** *** 159,162 **** --- 161,165 ---- def cut( sequence, *args ) + return nil if !sequence.kind_of?(String) or sequence.empty? hash_of_sequence_ranges_with_cuts = cut_and_return_by_permutations( sequence, *args ) unique_fragments_for_display( hash_of_sequence_ranges_with_cuts ) From k at pub.open-bio.org Mon Feb 27 11:16:25 2006 From: k at pub.open-bio.org (Katayama Toshiaki) Date: Mon, 27 Feb 2006 11:16:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/rails/public/javascripts controls.js, NONE, 1.1 dragdrop.js, NONE, 1.1 effects.js, NONE, 1.1 prototype.js, NONE, 1.1 Message-ID: <200602271116.k1RBGPVL002314@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/public/javascripts In directory pub.open-bio.org:/tmp/cvs-serv2240/public/javascripts Added Files: controls.js dragdrop.js effects.js prototype.js Log Message: * BioRuby shell on Rails kit * main original files are - app/controllers/shell_controller.rb, app/models/shell_connection.rb, app/views/layouts/shell.rhtml, app/views/shell/show.rhtml, (app/views/shell/history.rhtml), (config/database.yml), public/images/icon.png, public/stylesheets/main.css, script/server --- NEW FILE: prototype.js --- /* Prototype JavaScript framework, version 1.4.0 * (c) 2005 Sam Stephenson * * THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff * against the source tree, available from the Prototype darcs repository. * * Prototype is freely distributable under the terms of an MIT-style license. * * For details, see the Prototype web site: http://prototype.conio.net/ * /*--------------------------------------------------------------------------*/ var Prototype = { Version: '1.4.0', ScriptFragment: '(?:)((\n|\r|.)*?)(?:<\/script>)', emptyFunction: function() {}, K: function(x) {return x} } [...1746 lines suppressed...] } // Safari returns margins on body which is incorrect if the child is absolutely // positioned. For performance reasons, redefine Position.cumulativeOffset for // KHTML/WebKit only. if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) { Position.cumulativeOffset = function(element) { var valueT = 0, valueL = 0; do { valueT += element.offsetTop || 0; valueL += element.offsetLeft || 0; if (element.offsetParent == document.body) if (Element.getStyle(element, 'position') == 'absolute') break; element = element.offsetParent; } while (element); return [valueL, valueT]; } } --- NEW FILE: controls.js --- // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan) // (c) 2005 Jon Tirsen (http://www.tirsen.com) // Contributors: // Richard Livsey // Rahul Bhargava // Rob Wills // // See scriptaculous.js for full license. // Autocompleter.Base handles all the autocompletion functionality // that's independent of the data source for autocompletion. This // includes drawing the autocompletion menu, observing keyboard // and mouse events, and similar. // // Specific autocompleters need to provide, at the very least, // a getUpdatedChoices function that will be invoked every time // the text inside the monitored textbox changes. This method // should get the text for which to provide autocompletion by // invoking this.getToken(), NOT by directly accessing // this.element.value. This is to allow incremental tokenized // autocompletion. Specific auto-completion logic (AJAX, etc) // belongs in getUpdatedChoices. // // Tokenized incremental autocompletion is enabled automatically // when an autocompleter is instantiated with the 'tokens' option // in the options parameter, e.g.: // new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' }); // will incrementally autocomplete with a comma as the token. // Additionally, ',' in the above example can be replaced with // a token array, e.g. { tokens: [',', '\n'] } which // enables autocompletion on multiple tokens. This is most // useful when one of the tokens is \n (a newline), as it // allows smart autocompletion after linebreaks. var Autocompleter = {} Autocompleter.Base = function() {}; Autocompleter.Base.prototype = { baseInitialize: function(element, update, options) { this.element = $(element); this.update = $(update); this.hasFocus = false; this.changed = false; this.active = false; this.index = 0; this.entryCount = 0; if (this.setOptions) this.setOptions(options); else this.options = options || {}; this.options.paramName = this.options.paramName || this.element.name; this.options.tokens = this.options.tokens || []; this.options.frequency = this.options.frequency || 0.4; this.options.minChars = this.options.minChars || 1; this.options.onShow = this.options.onShow || function(element, update){ if(!update.style.position || update.style.position=='absolute') { update.style.position = 'absolute'; Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight}); } Effect.Appear(update,{duration:0.15}); }; this.options.onHide = this.options.onHide || function(element, update){ new Effect.Fade(update,{duration:0.15}) }; if (typeof(this.options.tokens) == 'string') this.options.tokens = new Array(this.options.tokens); this.observer = null; this.element.setAttribute('autocomplete','off'); Element.hide(this.update); Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this)); Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this)); }, show: function() { if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update); if(!this.iefix && (navigator.appVersion.indexOf('MSIE')>0) && (navigator.userAgent.indexOf('Opera')<0) && (Element.getStyle(this.update, 'position')=='absolute')) { new Insertion.After(this.update, ''); this.iefix = $(this.update.id+'_iefix'); } if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50); }, fixIEOverlapping: function() { Position.clone(this.update, this.iefix); this.iefix.style.zIndex = 1; this.update.style.zIndex = 2; Element.show(this.iefix); }, hide: function() { this.stopIndicator(); if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update); if(this.iefix) Element.hide(this.iefix); }, startIndicator: function() { if(this.options.indicator) Element.show(this.options.indicator); }, stopIndicator: function() { if(this.options.indicator) Element.hide(this.options.indicator); }, onKeyPress: function(event) { if(this.active) switch(event.keyCode) { case Event.KEY_TAB: case Event.KEY_RETURN: this.selectEntry(); Event.stop(event); case Event.KEY_ESC: this.hide(); this.active = false; Event.stop(event); return; case Event.KEY_LEFT: case Event.KEY_RIGHT: return; case Event.KEY_UP: this.markPrevious(); this.render(); if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); return; case Event.KEY_DOWN: this.markNext(); this.render(); if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); return; } else if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN) return; this.changed = true; this.hasFocus = true; if(this.observer) clearTimeout(this.observer); this.observer = setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000); }, onHover: function(event) { var element = Event.findElement(event, 'LI'); if(this.index != element.autocompleteIndex) { this.index = element.autocompleteIndex; this.render(); } Event.stop(event); }, onClick: function(event) { var element = Event.findElement(event, 'LI'); this.index = element.autocompleteIndex; this.selectEntry(); this.hide(); }, onBlur: function(event) { // needed to make click events working setTimeout(this.hide.bind(this), 250); this.hasFocus = false; this.active = false; }, render: function() { if(this.entryCount > 0) { for (var i = 0; i < this.entryCount; i++) this.index==i ? Element.addClassName(this.getEntry(i),"selected") : Element.removeClassName(this.getEntry(i),"selected"); if(this.hasFocus) { this.show(); this.active = true; } } else { this.active = false; this.hide(); } }, markPrevious: function() { if(this.index > 0) this.index-- else this.index = this.entryCount-1; }, markNext: function() { if(this.index < this.entryCount-1) this.index++ else this.index = 0; }, getEntry: function(index) { return this.update.firstChild.childNodes[index]; }, getCurrentEntry: function() { return this.getEntry(this.index); }, selectEntry: function() { this.active = false; this.updateElement(this.getCurrentEntry()); }, updateElement: function(selectedElement) { if (this.options.updateElement) { this.options.updateElement(selectedElement); return; } var value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal'); var lastTokenPos = this.findLastToken(); if (lastTokenPos != -1) { var newValue = this.element.value.substr(0, lastTokenPos + 1); var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/); if (whitespace) newValue += whitespace[0]; this.element.value = newValue + value; } else { this.element.value = value; } this.element.focus(); if (this.options.afterUpdateElement) this.options.afterUpdateElement(this.element, selectedElement); }, updateChoices: function(choices) { if(!this.changed && this.hasFocus) { this.update.innerHTML = choices; Element.cleanWhitespace(this.update); Element.cleanWhitespace(this.update.firstChild); if(this.update.firstChild && this.update.firstChild.childNodes) { this.entryCount = this.update.firstChild.childNodes.length; for (var i = 0; i < this.entryCount; i++) { var entry = this.getEntry(i); entry.autocompleteIndex = i; this.addObservers(entry); } } else { this.entryCount = 0; } this.stopIndicator(); this.index = 0; this.render(); } }, addObservers: function(element) { Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this)); Event.observe(element, "click", this.onClick.bindAsEventListener(this)); }, onObserverEvent: function() { this.changed = false; if(this.getToken().length>=this.options.minChars) { this.startIndicator(); this.getUpdatedChoices(); } else { this.active = false; this.hide(); } }, getToken: function() { var tokenPos = this.findLastToken(); if (tokenPos != -1) var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/,'').replace(/\s+$/,''); else var ret = this.element.value; return /\n/.test(ret) ? '' : ret; }, findLastToken: function() { var lastTokenPos = -1; for (var i=0; i lastTokenPos) lastTokenPos = thisTokenPos; } return lastTokenPos; } } Ajax.Autocompleter = Class.create(); Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), { initialize: function(element, update, url, options) { this.baseInitialize(element, update, options); this.options.asynchronous = true; this.options.onComplete = this.onComplete.bind(this); this.options.defaultParams = this.options.parameters || null; this.url = url; }, getUpdatedChoices: function() { entry = encodeURIComponent(this.options.paramName) + '=' + encodeURIComponent(this.getToken()); this.options.parameters = this.options.callback ? this.options.callback(this.element, entry) : entry; if(this.options.defaultParams) this.options.parameters += '&' + this.options.defaultParams; new Ajax.Request(this.url, this.options); }, onComplete: function(request) { this.updateChoices(request.responseText); } }); // The local array autocompleter. Used when you'd prefer to // inject an array of autocompletion options into the page, rather // than sending out Ajax queries, which can be quite slow sometimes. // // The constructor takes four parameters. The first two are, as usual, // the id of the monitored textbox, and id of the autocompletion menu. // The third is the array you want to autocomplete from, and the fourth // is the options block. // // Extra local autocompletion options: // - choices - How many autocompletion choices to offer // // - partialSearch - If false, the autocompleter will match entered // text only at the beginning of strings in the // autocomplete array. Defaults to true, which will // match text at the beginning of any *word* in the // strings in the autocomplete array. If you want to // search anywhere in the string, additionally set // the option fullSearch to true (default: off). // // - fullSsearch - Search anywhere in autocomplete array strings. // // - partialChars - How many characters to enter before triggering // a partial match (unlike minChars, which defines // how many characters are required to do any match // at all). Defaults to 2. // // - ignoreCase - Whether to ignore case when autocompleting. // Defaults to true. // // It's possible to pass in a custom function as the 'selector' // option, if you prefer to write your own autocompletion logic. // In that case, the other options above will not apply unless // you support them. Autocompleter.Local = Class.create(); Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), { initialize: function(element, update, array, options) { this.baseInitialize(element, update, options); this.options.array = array; }, getUpdatedChoices: function() { this.updateChoices(this.options.selector(this)); }, setOptions: function(options) { this.options = Object.extend({ choices: 10, partialSearch: true, partialChars: 2, ignoreCase: true, fullSearch: false, selector: function(instance) { var ret = []; // Beginning matches var partial = []; // Inside matches var entry = instance.getToken(); var count = 0; for (var i = 0; i < instance.options.array.length && ret.length < instance.options.choices ; i++) { var elem = instance.options.array[i]; var foundPos = instance.options.ignoreCase ? elem.toLowerCase().indexOf(entry.toLowerCase()) : elem.indexOf(entry); while (foundPos != -1) { if (foundPos == 0 && elem.length != entry.length) { ret.push("
  • " + elem.substr(0, entry.length) + "" + elem.substr(entry.length) + "
  • "); break; } else if (entry.length >= instance.options.partialChars && instance.options.partialSearch && foundPos != -1) { if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) { partial.push("
  • " + elem.substr(0, foundPos) + "" + elem.substr(foundPos, entry.length) + "" + elem.substr( foundPos + entry.length) + "
  • "); break; } } foundPos = instance.options.ignoreCase ? elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) : elem.indexOf(entry, foundPos + 1); } } if (partial.length) ret = ret.concat(partial.slice(0, instance.options.choices - ret.length)) return "
      " + ret.join('') + "
    "; } }, options || {}); } }); // AJAX in-place editor // // see documentation on http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor // Use this if you notice weird scrolling problems on some browsers, // the DOM might be a bit confused when this gets called so do this // waits 1 ms (with setTimeout) until it does the activation Field.scrollFreeActivate = function(field) { setTimeout(function() { Field.activate(field); }, 1); } Ajax.InPlaceEditor = Class.create(); Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99"; Ajax.InPlaceEditor.prototype = { initialize: function(element, url, options) { this.url = url; this.element = $(element); this.options = Object.extend({ okText: "ok", cancelText: "cancel", savingText: "Saving...", clickToEditText: "Click to edit", okText: "ok", rows: 1, onComplete: function(transport, element) { new Effect.Highlight(element, {startcolor: this.options.highlightcolor}); }, onFailure: function(transport) { alert("Error communicating with the server: " + transport.responseText.stripTags()); }, callback: function(form) { return Form.serialize(form); }, handleLineBreaks: true, loadingText: 'Loading...', savingClassName: 'inplaceeditor-saving', loadingClassName: 'inplaceeditor-loading', formClassName: 'inplaceeditor-form', highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor, highlightendcolor: "#FFFFFF", externalControl: null, ajaxOptions: {} }, options || {}); if(!this.options.formId && this.element.id) { this.options.formId = this.element.id + "-inplaceeditor"; if ($(this.options.formId)) { // there's already a form with that name, don't specify an id this.options.formId = null; } } if (this.options.externalControl) { this.options.externalControl = $(this.options.externalControl); } this.originalBackground = Element.getStyle(this.element, 'background-color'); if (!this.originalBackground) { this.originalBackground = "transparent"; } this.element.title = this.options.clickToEditText; this.onclickListener = this.enterEditMode.bindAsEventListener(this); this.mouseoverListener = this.enterHover.bindAsEventListener(this); this.mouseoutListener = this.leaveHover.bindAsEventListener(this); Event.observe(this.element, 'click', this.onclickListener); Event.observe(this.element, 'mouseover', this.mouseoverListener); Event.observe(this.element, 'mouseout', this.mouseoutListener); if (this.options.externalControl) { Event.observe(this.options.externalControl, 'click', this.onclickListener); Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener); Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener); } }, enterEditMode: function(evt) { if (this.saving) return; if (this.editing) return; this.editing = true; this.onEnterEditMode(); if (this.options.externalControl) { Element.hide(this.options.externalControl); } Element.hide(this.element); this.createForm(); this.element.parentNode.insertBefore(this.form, this.element); Field.scrollFreeActivate(this.editField); // stop the event to avoid a page refresh in Safari if (evt) { Event.stop(evt); } return false; }, createForm: function() { this.form = document.createElement("form"); this.form.id = this.options.formId; Element.addClassName(this.form, this.options.formClassName) this.form.onsubmit = this.onSubmit.bind(this); this.createEditField(); if (this.options.textarea) { var br = document.createElement("br"); this.form.appendChild(br); } okButton = document.createElement("input"); okButton.type = "submit"; okButton.value = this.options.okText; this.form.appendChild(okButton); cancelLink = document.createElement("a"); cancelLink.href = "#"; cancelLink.appendChild(document.createTextNode(this.options.cancelText)); cancelLink.onclick = this.onclickCancel.bind(this); this.form.appendChild(cancelLink); }, hasHTMLLineBreaks: function(string) { if (!this.options.handleLineBreaks) return false; return string.match(/
    /i); }, convertHTMLLineBreaks: function(string) { return string.replace(/
    /gi, "\n").replace(//gi, "\n").replace(/<\/p>/gi, "\n").replace(/

    /gi, ""); }, createEditField: function() { var text; if(this.options.loadTextURL) { text = this.options.loadingText; } else { text = this.getText(); } if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) { this.options.textarea = false; var textField = document.createElement("input"); textField.type = "text"; textField.name = "value"; textField.value = text; textField.style.backgroundColor = this.options.highlightcolor; var size = this.options.size || this.options.cols || 0; if (size != 0) textField.size = size; this.editField = textField; } else { this.options.textarea = true; var textArea = document.createElement("textarea"); textArea.name = "value"; textArea.value = this.convertHTMLLineBreaks(text); textArea.rows = this.options.rows; textArea.cols = this.options.cols || 40; this.editField = textArea; } if(this.options.loadTextURL) { this.loadExternalText(); } this.form.appendChild(this.editField); }, getText: function() { return this.element.innerHTML; }, loadExternalText: function() { Element.addClassName(this.form, this.options.loadingClassName); this.editField.disabled = true; new Ajax.Request( this.options.loadTextURL, Object.extend({ asynchronous: true, onComplete: this.onLoadedExternalText.bind(this) }, this.options.ajaxOptions) ); }, onLoadedExternalText: function(transport) { Element.removeClassName(this.form, this.options.loadingClassName); this.editField.disabled = false; this.editField.value = transport.responseText.stripTags(); }, onclickCancel: function() { this.onComplete(); this.leaveEditMode(); return false; }, onFailure: function(transport) { this.options.onFailure(transport); if (this.oldInnerHTML) { this.element.innerHTML = this.oldInnerHTML; this.oldInnerHTML = null; } return false; }, onSubmit: function() { // onLoading resets these so we need to save them away for the Ajax call var form = this.form; var value = this.editField.value; // do this first, sometimes the ajax call returns before we get a chance to switch on Saving... // which means this will actually switch on Saving... *after* we've left edit mode causing Saving... // to be displayed indefinitely this.onLoading(); new Ajax.Updater( { success: this.element, // don't update on failure (this could be an option) failure: null }, this.url, Object.extend({ parameters: this.options.callback(form, value), onComplete: this.onComplete.bind(this), onFailure: this.onFailure.bind(this) }, this.options.ajaxOptions) ); // stop the event to avoid a page refresh in Safari if (arguments.length > 1) { Event.stop(arguments[0]); } return false; }, onLoading: function() { this.saving = true; this.removeForm(); this.leaveHover(); this.showSaving(); }, showSaving: function() { this.oldInnerHTML = this.element.innerHTML; this.element.innerHTML = this.options.savingText; Element.addClassName(this.element, this.options.savingClassName); this.element.style.backgroundColor = this.originalBackground; Element.show(this.element); }, removeForm: function() { if(this.form) { if (this.form.parentNode) Element.remove(this.form); this.form = null; } }, enterHover: function() { if (this.saving) return; this.element.style.backgroundColor = this.options.highlightcolor; if (this.effect) { this.effect.cancel(); } Element.addClassName(this.element, this.options.hoverClassName) }, leaveHover: function() { if (this.options.backgroundColor) { this.element.style.backgroundColor = this.oldBackground; } Element.removeClassName(this.element, this.options.hoverClassName) if (this.saving) return; this.effect = new Effect.Highlight(this.element, { startcolor: this.options.highlightcolor, endcolor: this.options.highlightendcolor, restorecolor: this.originalBackground }); }, leaveEditMode: function() { Element.removeClassName(this.element, this.options.savingClassName); this.removeForm(); this.leaveHover(); this.element.style.backgroundColor = this.originalBackground; Element.show(this.element); if (this.options.externalControl) { Element.show(this.options.externalControl); } this.editing = false; this.saving = false; this.oldInnerHTML = null; this.onLeaveEditMode(); }, onComplete: function(transport) { this.leaveEditMode(); this.options.onComplete.bind(this)(transport, this.element); }, onEnterEditMode: function() {}, onLeaveEditMode: function() {}, dispose: function() { if (this.oldInnerHTML) { this.element.innerHTML = this.oldInnerHTML; } this.leaveEditMode(); Event.stopObserving(this.element, 'click', this.onclickListener); Event.stopObserving(this.element, 'mouseover', this.mouseoverListener); Event.stopObserving(this.element, 'mouseout', this.mouseoutListener); if (this.options.externalControl) { Event.stopObserving(this.options.externalControl, 'click', this.onclickListener); Event.stopObserving(this.options.externalControl, 'mouseover', this.mouseoverListener); Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener); } } }; // Delayed observer, like Form.Element.Observer, // but waits for delay after last key input // Ideal for live-search fields Form.Element.DelayedObserver = Class.create(); Form.Element.DelayedObserver.prototype = { initialize: function(element, delay, callback) { this.delay = delay || 0.5; this.element = $(element); this.callback = callback; this.timer = null; this.lastValue = $F(this.element); Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this)); }, delayedListener: function(event) { if(this.lastValue == $F(this.element)) return; if(this.timer) clearTimeout(this.timer); this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000); this.lastValue = $F(this.element); }, onTimerEvent: function() { this.timer = null; this.callback(this.element, $F(this.element)); } }; --- NEW FILE: dragdrop.js --- // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // // See scriptaculous.js for full license. /*--------------------------------------------------------------------------*/ var Droppables = { drops: [], remove: function(element) { this.drops = this.drops.reject(function(d) { return d.element==$(element) }); }, add: function(element) { element = $(element); var options = Object.extend({ greedy: true, hoverclass: null }, arguments[1] || {}); // cache containers if(options.containment) { options._containers = []; var containment = options.containment; if((typeof containment == 'object') && (containment.constructor == Array)) { containment.each( function(c) { options._containers.push($(c)) }); } else { options._containers.push($(containment)); } } if(options.accept) options.accept = [options.accept].flatten(); Element.makePositioned(element); // fix IE options.element = element; this.drops.push(options); }, isContained: function(element, drop) { var parentNode = element.parentNode; return drop._containers.detect(function(c) { return parentNode == c }); }, isAffected: function(point, element, drop) { return ( (drop.element!=element) && ((!drop._containers) || this.isContained(element, drop)) && ((!drop.accept) || (Element.classNames(element).detect( function(v) { return drop.accept.include(v) } ) )) && Position.within(drop.element, point[0], point[1]) ); }, deactivate: function(drop) { if(drop.hoverclass) Element.removeClassName(drop.element, drop.hoverclass); this.last_active = null; }, activate: function(drop) { if(drop.hoverclass) Element.addClassName(drop.element, drop.hoverclass); this.last_active = drop; }, show: function(point, element) { if(!this.drops.length) return; if(this.last_active) this.deactivate(this.last_active); this.drops.each( function(drop) { if(Droppables.isAffected(point, element, drop)) { if(drop.onHover) drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element)); if(drop.greedy) { Droppables.activate(drop); throw $break; } } }); }, fire: function(event, element) { if(!this.last_active) return; Position.prepare(); if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active)) if (this.last_active.onDrop) this.last_active.onDrop(element, this.last_active.element, event); }, reset: function() { if(this.last_active) this.deactivate(this.last_active); } } var Draggables = { drags: [], observers: [], register: function(draggable) { if(this.drags.length == 0) { this.eventMouseUp = this.endDrag.bindAsEventListener(this); this.eventMouseMove = this.updateDrag.bindAsEventListener(this); this.eventKeypress = this.keyPress.bindAsEventListener(this); Event.observe(document, "mouseup", this.eventMouseUp); Event.observe(document, "mousemove", this.eventMouseMove); Event.observe(document, "keypress", this.eventKeypress); } this.drags.push(draggable); }, unregister: function(draggable) { this.drags = this.drags.reject(function(d) { return d==draggable }); if(this.drags.length == 0) { Event.stopObserving(document, "mouseup", this.eventMouseUp); Event.stopObserving(document, "mousemove", this.eventMouseMove); Event.stopObserving(document, "keypress", this.eventKeypress); } }, activate: function(draggable) { window.focus(); // allows keypress events if window isn't currently focused, fails for Safari this.activeDraggable = draggable; }, deactivate: function(draggbale) { this.activeDraggable = null; }, updateDrag: function(event) { if(!this.activeDraggable) return; var pointer = [Event.pointerX(event), Event.pointerY(event)]; // Mozilla-based browsers fire successive mousemove events with // the same coordinates, prevent needless redrawing (moz bug?) if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return; this._lastPointer = pointer; this.activeDraggable.updateDrag(event, pointer); }, endDrag: function(event) { if(!this.activeDraggable) return; this._lastPointer = null; this.activeDraggable.endDrag(event); }, keyPress: function(event) { if(this.activeDraggable) this.activeDraggable.keyPress(event); }, addObserver: function(observer) { this.observers.push(observer); this._cacheObserverCallbacks(); }, removeObserver: function(element) { // element instead of observer fixes mem leaks this.observers = this.observers.reject( function(o) { return o.element==element }); this._cacheObserverCallbacks(); }, notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag' if(this[eventName+'Count'] > 0) this.observers.each( function(o) { if(o[eventName]) o[eventName](eventName, draggable, event); }); }, _cacheObserverCallbacks: function() { ['onStart','onEnd','onDrag'].each( function(eventName) { Draggables[eventName+'Count'] = Draggables.observers.select( function(o) { return o[eventName]; } ).length; }); } } /*--------------------------------------------------------------------------*/ var Draggable = Class.create(); Draggable.prototype = { initialize: function(element) { var options = Object.extend({ handle: false, starteffect: function(element) { new Effect.Opacity(element, {duration:0.2, from:1.0, to:0.7}); }, reverteffect: function(element, top_offset, left_offset) { var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; element._revert = new Effect.MoveBy(element, -top_offset, -left_offset, {duration:dur}); }, endeffect: function(element) { new Effect.Opacity(element, {duration:0.2, from:0.7, to:1.0}); }, zindex: 1000, revert: false, snap: false // false, or xy or [x,y] or function(x,y){ return [x,y] } }, arguments[1] || {}); this.element = $(element); if(options.handle && (typeof options.handle == 'string')) this.handle = Element.childrenWithClassName(this.element, options.handle)[0]; if(!this.handle) this.handle = $(options.handle); if(!this.handle) this.handle = this.element; Element.makePositioned(this.element); // fix IE this.delta = this.currentDelta(); this.options = options; this.dragging = false; this.eventMouseDown = this.initDrag.bindAsEventListener(this); Event.observe(this.handle, "mousedown", this.eventMouseDown); Draggables.register(this); }, destroy: function() { Event.stopObserving(this.handle, "mousedown", this.eventMouseDown); Draggables.unregister(this); }, currentDelta: function() { return([ parseInt(this.element.style.left || '0'), parseInt(this.element.style.top || '0')]); }, initDrag: function(event) { if(Event.isLeftClick(event)) { // abort on form elements, fixes a Firefox issue var src = Event.element(event); if(src.tagName && ( src.tagName=='INPUT' || src.tagName=='SELECT' || src.tagName=='BUTTON' || src.tagName=='TEXTAREA')) return; if(this.element._revert) { this.element._revert.cancel(); this.element._revert = null; } var pointer = [Event.pointerX(event), Event.pointerY(event)]; var pos = Position.cumulativeOffset(this.element); this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) }); Draggables.activate(this); Event.stop(event); } }, startDrag: function(event) { this.dragging = true; if(this.options.zindex) { this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0); this.element.style.zIndex = this.options.zindex; } if(this.options.ghosting) { this._clone = this.element.cloneNode(true); Position.absolutize(this.element); this.element.parentNode.insertBefore(this._clone, this.element); } Draggables.notify('onStart', this, event); if(this.options.starteffect) this.options.starteffect(this.element); }, updateDrag: function(event, pointer) { if(!this.dragging) this.startDrag(event); Position.prepare(); Droppables.show(pointer, this.element); Draggables.notify('onDrag', this, event); this.draw(pointer); if(this.options.change) this.options.change(this); // fix AppleWebKit rendering if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); Event.stop(event); }, finishDrag: function(event, success) { this.dragging = false; if(this.options.ghosting) { Position.relativize(this.element); Element.remove(this._clone); this._clone = null; } if(success) Droppables.fire(event, this.element); Draggables.notify('onEnd', this, event); var revert = this.options.revert; if(revert && typeof revert == 'function') revert = revert(this.element); var d = this.currentDelta(); if(revert && this.options.reverteffect) { this.options.reverteffect(this.element, d[1]-this.delta[1], d[0]-this.delta[0]); } else { this.delta = d; } if(this.options.zindex) this.element.style.zIndex = this.originalZ; if(this.options.endeffect) this.options.endeffect(this.element); Draggables.deactivate(this); Droppables.reset(); }, keyPress: function(event) { if(!event.keyCode==Event.KEY_ESC) return; this.finishDrag(event, false); Event.stop(event); }, endDrag: function(event) { if(!this.dragging) return; this.finishDrag(event, true); Event.stop(event); }, draw: function(point) { var pos = Position.cumulativeOffset(this.element); var d = this.currentDelta(); pos[0] -= d[0]; pos[1] -= d[1]; var p = [0,1].map(function(i){ return (point[i]-pos[i]-this.offset[i]) }.bind(this)); if(this.options.snap) { if(typeof this.options.snap == 'function') { p = this.options.snap(p[0],p[1]); } else { if(this.options.snap instanceof Array) { p = p.map( function(v, i) { return Math.round(v/this.options.snap[i])*this.options.snap[i] }.bind(this)) } else { p = p.map( function(v) { return Math.round(v/this.options.snap)*this.options.snap }.bind(this)) } }} var style = this.element.style; if((!this.options.constraint) || (this.options.constraint=='horizontal')) style.left = p[0] + "px"; if((!this.options.constraint) || (this.options.constraint=='vertical')) style.top = p[1] + "px"; if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering } } /*--------------------------------------------------------------------------*/ var SortableObserver = Class.create(); SortableObserver.prototype = { initialize: function(element, observer) { this.element = $(element); this.observer = observer; this.lastValue = Sortable.serialize(this.element); }, onStart: function() { this.lastValue = Sortable.serialize(this.element); }, onEnd: function() { Sortable.unmark(); if(this.lastValue != Sortable.serialize(this.element)) this.observer(this.element) } } var Sortable = { sortables: new Array(), options: function(element){ element = $(element); return this.sortables.detect(function(s) { return s.element == element }); }, destroy: function(element){ element = $(element); this.sortables.findAll(function(s) { return s.element == element }).each(function(s){ Draggables.removeObserver(s.element); s.droppables.each(function(d){ Droppables.remove(d) }); s.draggables.invoke('destroy'); }); this.sortables = this.sortables.reject(function(s) { return s.element == element }); }, create: function(element) { element = $(element); var options = Object.extend({ element: element, tag: 'li', // assumes li children, override with tag: 'tagname' dropOnEmpty: false, tree: false, // fixme: unimplemented overlap: 'vertical', // one of 'vertical', 'horizontal' constraint: 'vertical', // one of 'vertical', 'horizontal', false containment: element, // also takes array of elements (or id's); or false handle: false, // or a CSS class only: false, hoverclass: null, ghosting: false, format: null, onChange: Prototype.emptyFunction, onUpdate: Prototype.emptyFunction }, arguments[1] || {}); // clear any old sortable with same element this.destroy(element); // build options for the draggables var options_for_draggable = { revert: true, ghosting: options.ghosting, constraint: options.constraint, handle: options.handle }; if(options.starteffect) options_for_draggable.starteffect = options.starteffect; if(options.reverteffect) options_for_draggable.reverteffect = options.reverteffect; else if(options.ghosting) options_for_draggable.reverteffect = function(element) { element.style.top = 0; element.style.left = 0; }; if(options.endeffect) options_for_draggable.endeffect = options.endeffect; if(options.zindex) options_for_draggable.zindex = options.zindex; // build options for the droppables var options_for_droppable = { overlap: options.overlap, containment: options.containment, hoverclass: options.hoverclass, onHover: Sortable.onHover, greedy: !options.dropOnEmpty } // fix for gecko engine Element.cleanWhitespace(element); options.draggables = []; options.droppables = []; // make it so // drop on empty handling if(options.dropOnEmpty) { Droppables.add(element, {containment: options.containment, onHover: Sortable.onEmptyHover, greedy: false}); options.droppables.push(element); } (this.findElements(element, options) || []).each( function(e) { // handles are per-draggable var handle = options.handle ? Element.childrenWithClassName(e, options.handle)[0] : e; options.draggables.push( new Draggable(e, Object.extend(options_for_draggable, { handle: handle }))); Droppables.add(e, options_for_droppable); options.droppables.push(e); }); // keep reference this.sortables.push(options); // for onupdate Draggables.addObserver(new SortableObserver(element, options.onUpdate)); }, // return all suitable-for-sortable elements in a guaranteed order findElements: function(element, options) { if(!element.hasChildNodes()) return null; var elements = []; $A(element.childNodes).each( function(e) { if(e.tagName && e.tagName.toUpperCase()==options.tag.toUpperCase() && (!options.only || (Element.hasClassName(e, options.only)))) elements.push(e); if(options.tree) { var grandchildren = this.findElements(e, options); if(grandchildren) elements.push(grandchildren); } }); return (elements.length>0 ? elements.flatten() : null); }, onHover: function(element, dropon, overlap) { if(overlap>0.5) { Sortable.mark(dropon, 'before'); if(dropon.previousSibling != element) { var oldParentNode = element.parentNode; element.style.visibility = "hidden"; // fix gecko rendering dropon.parentNode.insertBefore(element, dropon); if(dropon.parentNode!=oldParentNode) Sortable.options(oldParentNode).onChange(element); Sortable.options(dropon.parentNode).onChange(element); } } else { Sortable.mark(dropon, 'after'); var nextElement = dropon.nextSibling || null; if(nextElement != element) { var oldParentNode = element.parentNode; element.style.visibility = "hidden"; // fix gecko rendering dropon.parentNode.insertBefore(element, nextElement); if(dropon.parentNode!=oldParentNode) Sortable.options(oldParentNode).onChange(element); Sortable.options(dropon.parentNode).onChange(element); } } }, onEmptyHover: function(element, dropon) { if(element.parentNode!=dropon) { var oldParentNode = element.parentNode; dropon.appendChild(element); Sortable.options(oldParentNode).onChange(element); Sortable.options(dropon).onChange(element); } }, unmark: function() { if(Sortable._marker) Element.hide(Sortable._marker); }, mark: function(dropon, position) { // mark on ghosting only var sortable = Sortable.options(dropon.parentNode); if(sortable && !sortable.ghosting) return; if(!Sortable._marker) { Sortable._marker = $('dropmarker') || document.createElement('DIV'); Element.hide(Sortable._marker); Element.addClassName(Sortable._marker, 'dropmarker'); Sortable._marker.style.position = 'absolute'; document.getElementsByTagName("body").item(0).appendChild(Sortable._marker); } var offsets = Position.cumulativeOffset(dropon); Sortable._marker.style.left = offsets[0] + 'px'; Sortable._marker.style.top = offsets[1] + 'px'; if(position=='after') if(sortable.overlap == 'horizontal') Sortable._marker.style.left = (offsets[0]+dropon.clientWidth) + 'px'; else Sortable._marker.style.top = (offsets[1]+dropon.clientHeight) + 'px'; Element.show(Sortable._marker); }, serialize: function(element) { element = $(element); var sortableOptions = this.options(element); var options = Object.extend({ tag: sortableOptions.tag, only: sortableOptions.only, name: element.id, format: sortableOptions.format || /^[^_]*_(.*)$/ }, arguments[1] || {}); return $(this.findElements(element, options) || []).map( function(item) { return (encodeURIComponent(options.name) + "[]=" + encodeURIComponent(item.id.match(options.format) ? item.id.match(options.format)[1] : '')); }).join("&"); } } --- NEW FILE: effects.js --- // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Contributors: // Justin Palmer (http://encytemedia.com/) // Mark Pilgrim (http://diveintomark.org/) // Martin Bialasinki // // See scriptaculous.js for full license. /* ------------- element ext -------------- */ // converts rgb() and #xxx to #xxxxxx format, // returns self (or first argument) if not convertable String.prototype.parseColor = function() { var color = '#'; if(this.slice(0,4) == 'rgb(') { var cols = this.slice(4,this.length-1).split(','); var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3); } else { if(this.slice(0,1) == '#') { if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase(); if(this.length==7) color = this.toLowerCase(); } } return(color.length==7 ? color : (arguments[0] || this)); } Element.collectTextNodesIgnoreClass = function(element, ignoreclass) { var children = $(element).childNodes; var text = ''; var classtest = new RegExp('^([^ ]+ )*' + ignoreclass+ '( [^ ]+)*$','i'); for (var i = 0; i < children.length; i++) { if(children[i].nodeType==3) { text+=children[i].nodeValue; } else { if((!children[i].className.match(classtest)) && children[i].hasChildNodes()) text += Element.collectTextNodesIgnoreClass(children[i], ignoreclass); } } return text; } Element.setStyle = function(element, style) { element = $(element); for(k in style) element.style[k.camelize()] = style[k]; } Element.setContentZoom = function(element, percent) { Element.setStyle(element, {fontSize: (percent/100) + 'em'}); if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); } Element.getOpacity = function(element){ var opacity; if (opacity = Element.getStyle(element, 'opacity')) return parseFloat(opacity); if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/)) if(opacity[1]) return parseFloat(opacity[1]) / 100; return 1.0; } Element.setOpacity = function(element, value){ element= $(element); if (value == 1){ Element.setStyle(element, { opacity: (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 0.999999 : null }); if(/MSIE/.test(navigator.userAgent)) Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')}); } else { if(value < 0.00001) value = 0; Element.setStyle(element, {opacity: value}); if(/MSIE/.test(navigator.userAgent)) Element.setStyle(element, { filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') + 'alpha(opacity='+value*100+')' }); } } Element.getInlineOpacity = function(element){ return $(element).style.opacity || ''; } Element.childrenWithClassName = function(element, className) { return $A($(element).getElementsByTagName('*')).select( function(c) { return Element.hasClassName(c, className) }); } Array.prototype.call = function() { var args = arguments; this.each(function(f){ f.apply(this, args) }); } /*--------------------------------------------------------------------------*/ var Effect = { tagifyText: function(element) { var tagifyStyle = 'position:relative'; if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1'; element = $(element); $A(element.childNodes).each( function(child) { if(child.nodeType==3) { child.nodeValue.toArray().each( function(character) { element.insertBefore( Builder.node('span',{style: tagifyStyle}, character == ' ' ? String.fromCharCode(160) : character), child); }); Element.remove(child); } }); }, multiple: function(element, effect) { var elements; if(((typeof element == 'object') || (typeof element == 'function')) && (element.length)) elements = element; else elements = $(element).childNodes; var options = Object.extend({ speed: 0.1, delay: 0.0 }, arguments[2] || {}); var masterDelay = options.delay; $A(elements).each( function(element, index) { new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay })); }); } }; var Effect2 = Effect; // deprecated /* ------------- transitions ------------- */ Effect.Transitions = {} Effect.Transitions.linear = function(pos) { return pos; } Effect.Transitions.sinoidal = function(pos) { return (-Math.cos(pos*Math.PI)/2) + 0.5; } Effect.Transitions.reverse = function(pos) { return 1-pos; } Effect.Transitions.flicker = function(pos) { return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; } Effect.Transitions.wobble = function(pos) { return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; } Effect.Transitions.pulse = function(pos) { return (Math.floor(pos*10) % 2 == 0 ? (pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10))); } Effect.Transitions.none = function(pos) { return 0; } Effect.Transitions.full = function(pos) { return 1; } /* ------------- core effects ------------- */ Effect.Queue = { effects: [], _each: function(iterator) { this.effects._each(iterator); }, interval: null, add: function(effect) { var timestamp = new Date().getTime(); switch(effect.options.queue) { case 'front': // move unstarted effects after this effect this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) { e.startOn += effect.finishOn; e.finishOn += effect.finishOn; }); break; case 'end': // start effect after last queued effect has finished timestamp = this.effects.pluck('finishOn').max() || timestamp; break; } effect.startOn += timestamp; effect.finishOn += timestamp; this.effects.push(effect); if(!this.interval) this.interval = setInterval(this.loop.bind(this), 40); }, remove: function(effect) { this.effects = this.effects.reject(function(e) { return e==effect }); if(this.effects.length == 0) { clearInterval(this.interval); this.interval = null; } }, loop: function() { var timePos = new Date().getTime(); this.effects.invoke('loop', timePos); } } Object.extend(Effect.Queue, Enumerable); Effect.Base = function() {}; Effect.Base.prototype = { position: null, setOptions: function(options) { this.options = Object.extend({ transition: Effect.Transitions.sinoidal, duration: 1.0, // seconds fps: 25.0, // max. 25fps due to Effect.Queue implementation sync: false, // true for combining from: 0.0, to: 1.0, delay: 0.0, queue: 'parallel' }, options || {}); }, start: function(options) { this.setOptions(options || {}); this.currentFrame = 0; this.state = 'idle'; this.startOn = this.options.delay*1000; this.finishOn = this.startOn + (this.options.duration*1000); this.event('beforeStart'); if(!this.options.sync) Effect.Queue.add(this); }, loop: function(timePos) { if(timePos >= this.startOn) { if(timePos >= this.finishOn) { this.render(1.0); this.cancel(); this.event('beforeFinish'); if(this.finish) this.finish(); this.event('afterFinish'); return; } var pos = (timePos - this.startOn) / (this.finishOn - this.startOn); var frame = Math.round(pos * this.options.fps * this.options.duration); if(frame > this.currentFrame) { this.render(pos); this.currentFrame = frame; } } }, render: function(pos) { if(this.state == 'idle') { this.state = 'running'; this.event('beforeSetup'); if(this.setup) this.setup(); this.event('afterSetup'); } if(this.state == 'running') { if(this.options.transition) pos = this.options.transition(pos); pos *= (this.options.to-this.options.from); pos += this.options.from; this.position = pos; this.event('beforeUpdate'); if(this.update) this.update(pos); this.event('afterUpdate'); } }, cancel: function() { if(!this.options.sync) Effect.Queue.remove(this); this.state = 'finished'; }, event: function(eventName) { if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this); if(this.options[eventName]) this.options[eventName](this); }, inspect: function() { return '#'; } } Effect.Parallel = Class.create(); Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), { initialize: function(effects) { this.effects = effects || []; this.start(arguments[1]); }, update: function(position) { this.effects.invoke('render', position); }, finish: function(position) { this.effects.each( function(effect) { effect.render(1.0); effect.cancel(); effect.event('beforeFinish'); if(effect.finish) effect.finish(position); effect.event('afterFinish'); }); } }); Effect.Opacity = Class.create(); Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), { initialize: function(element) { this.element = $(element); // make this work on IE on elements without 'layout' if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout)) Element.setStyle(this.element, {zoom: 1}); var options = Object.extend({ from: Element.getOpacity(this.element) || 0.0, to: 1.0 }, arguments[1] || {}); this.start(options); }, update: function(position) { Element.setOpacity(this.element, position); } }); Effect.MoveBy = Class.create(); Object.extend(Object.extend(Effect.MoveBy.prototype, Effect.Base.prototype), { initialize: function(element, toTop, toLeft) { this.element = $(element); this.toTop = toTop; this.toLeft = toLeft; this.start(arguments[3]); }, setup: function() { // Bug in Opera: Opera returns the "real" position of a static element or // relative element that does not have top/left explicitly set. // ==> Always set top and left for position relative elements in your stylesheets // (to 0 if you do not need them) Element.makePositioned(this.element); this.originalTop = parseFloat(Element.getStyle(this.element,'top') || '0'); this.originalLeft = parseFloat(Element.getStyle(this.element,'left') || '0'); }, update: function(position) { Element.setStyle(this.element, { top: this.toTop * position + this.originalTop + 'px', left: this.toLeft * position + this.originalLeft + 'px' }); } }); Effect.Scale = Class.create(); Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), { initialize: function(element, percent) { this.element = $(element) var options = Object.extend({ scaleX: true, scaleY: true, scaleContent: true, scaleFromCenter: false, scaleMode: 'box', // 'box' or 'contents' or {} with provided values scaleFrom: 100.0, scaleTo: percent }, arguments[2] || {}); this.start(options); }, setup: function() { this.restoreAfterFinish = this.options.restoreAfterFinish || false; this.elementPositioning = Element.getStyle(this.element,'position'); this.originalStyle = {}; ['top','left','width','height','fontSize'].each( function(k) { this.originalStyle[k] = this.element.style[k]; }.bind(this)); this.originalTop = this.element.offsetTop; this.originalLeft = this.element.offsetLeft; var fontSize = Element.getStyle(this.element,'font-size') || '100%'; ['em','px','%'].each( function(fontSizeType) { if(fontSize.indexOf(fontSizeType)>0) { this.fontSize = parseFloat(fontSize); this.fontSizeType = fontSizeType; } }.bind(this)); this.factor = (this.options.scaleTo - this.options.scaleFrom)/100; this.dims = null; if(this.options.scaleMode=='box') this.dims = [this.element.offsetHeight, this.element.offsetWidth]; if(/^content/.test(this.options.scaleMode)) this.dims = [this.element.scrollHeight, this.element.scrollWidth]; if(!this.dims) this.dims = [this.options.scaleMode.originalHeight, this.options.scaleMode.originalWidth]; }, update: function(position) { var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position); if(this.options.scaleContent && this.fontSize) Element.setStyle(this.element, {fontSize: this.fontSize * currentScale + this.fontSizeType }); this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale); }, finish: function(position) { if (this.restoreAfterFinish) Element.setStyle(this.element, this.originalStyle); }, setDimensions: function(height, width) { var d = {}; if(this.options.scaleX) d.width = width + 'px'; if(this.options.scaleY) d.height = height + 'px'; if(this.options.scaleFromCenter) { var topd = (height - this.dims[0])/2; var leftd = (width - this.dims[1])/2; if(this.elementPositioning == 'absolute') { if(this.options.scaleY) d.top = this.originalTop-topd + 'px'; if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px'; } else { if(this.options.scaleY) d.top = -topd + 'px'; if(this.options.scaleX) d.left = -leftd + 'px'; } } Element.setStyle(this.element, d); } }); Effect.Highlight = Class.create(); Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), { initialize: function(element) { this.element = $(element); var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {}); this.start(options); }, setup: function() { // Prevent executing on elements not in the layout flow if(Element.getStyle(this.element, 'display')=='none') { this.cancel(); return; } // Disable background image during the effect this.oldStyle = { backgroundImage: Element.getStyle(this.element, 'background-image') }; Element.setStyle(this.element, {backgroundImage: 'none'}); if(!this.options.endcolor) this.options.endcolor = Element.getStyle(this.element, 'background-color').parseColor('#ffffff'); if(!this.options.restorecolor) this.options.restorecolor = Element.getStyle(this.element, 'background-color'); // init color calculations this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this)); this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this)); }, update: function(position) { Element.setStyle(this.element,{backgroundColor: $R(0,2).inject('#',function(m,v,i){ return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) }); }, finish: function() { Element.setStyle(this.element, Object.extend(this.oldStyle, { backgroundColor: this.options.restorecolor })); } }); Effect.ScrollTo = Class.create(); Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), { initialize: function(element) { this.element = $(element); this.start(arguments[1] || {}); }, setup: function() { Position.prepare(); var offsets = Position.cumulativeOffset(this.element); if(this.options.offset) offsets[1] += this.options.offset; var max = window.innerHeight ? window.height - window.innerHeight : document.body.scrollHeight - (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight); this.scrollStart = Position.deltaY; this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart; }, update: function(position) { Position.prepare(); window.scrollTo(Position.deltaX, this.scrollStart + (position*this.delta)); } }); /* ------------- combination effects ------------- */ Effect.Fade = function(element) { var oldOpacity = Element.getInlineOpacity(element); var options = Object.extend({ from: Element.getOpacity(element) || 1.0, to: 0.0, afterFinishInternal: function(effect) { with(Element) { if(effect.options.to!=0) return; hide(effect.element); setStyle(effect.element, {opacity: oldOpacity}); }} }, arguments[1] || {}); return new Effect.Opacity(element,options); } Effect.Appear = function(element) { var options = Object.extend({ from: (Element.getStyle(element, 'display') == 'none' ? 0.0 : Element.getOpacity(element) || 0.0), to: 1.0, beforeSetup: function(effect) { with(Element) { setOpacity(effect.element, effect.options.from); show(effect.element); }} }, arguments[1] || {}); return new Effect.Opacity(element,options); } Effect.Puff = function(element) { element = $(element); var oldStyle = { opacity: Element.getInlineOpacity(element), position: Element.getStyle(element, 'position') }; return new Effect.Parallel( [ new Effect.Scale(element, 200, { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], Object.extend({ duration: 1.0, beforeSetupInternal: function(effect) { with(Element) { setStyle(effect.effects[0].element, {position: 'absolute'}); }}, afterFinishInternal: function(effect) { with(Element) { hide(effect.effects[0].element); setStyle(effect.effects[0].element, oldStyle); }} }, arguments[1] || {}) ); } Effect.BlindUp = function(element) { element = $(element); Element.makeClipping(element); return new Effect.Scale(element, 0, Object.extend({ scaleContent: false, scaleX: false, restoreAfterFinish: true, afterFinishInternal: function(effect) { with(Element) { [hide, undoClipping].call(effect.element); }} }, arguments[1] || {}) ); } Effect.BlindDown = function(element) { element = $(element); var oldHeight = Element.getStyle(element, 'height'); var elementDimensions = Element.getDimensions(element); return new Effect.Scale(element, 100, Object.extend({ scaleContent: false, scaleX: false, scaleFrom: 0, scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, restoreAfterFinish: true, afterSetup: function(effect) { with(Element) { makeClipping(effect.element); setStyle(effect.element, {height: '0px'}); show(effect.element); }}, afterFinishInternal: function(effect) { with(Element) { undoClipping(effect.element); setStyle(effect.element, {height: oldHeight}); }} }, arguments[1] || {}) ); } Effect.SwitchOff = function(element) { element = $(element); var oldOpacity = Element.getInlineOpacity(element); return new Effect.Appear(element, { duration: 0.4, from: 0, transition: Effect.Transitions.flicker, afterFinishInternal: function(effect) { new Effect.Scale(effect.element, 1, { duration: 0.3, scaleFromCenter: true, scaleX: false, scaleContent: false, restoreAfterFinish: true, beforeSetup: function(effect) { with(Element) { [makePositioned,makeClipping].call(effect.element); }}, afterFinishInternal: function(effect) { with(Element) { [hide,undoClipping,undoPositioned].call(effect.element); setStyle(effect.element, {opacity: oldOpacity}); }} }) } }); } Effect.DropOut = function(element) { element = $(element); var oldStyle = { top: Element.getStyle(element, 'top'), left: Element.getStyle(element, 'left'), opacity: Element.getInlineOpacity(element) }; return new Effect.Parallel( [ new Effect.MoveBy(element, 100, 0, { sync: true }), new Effect.Opacity(element, { sync: true, to: 0.0 }) ], Object.extend( { duration: 0.5, beforeSetup: function(effect) { with(Element) { makePositioned(effect.effects[0].element); }}, afterFinishInternal: function(effect) { with(Element) { [hide, undoPositioned].call(effect.effects[0].element); setStyle(effect.effects[0].element, oldStyle); }} }, arguments[1] || {})); } Effect.Shake = function(element) { element = $(element); var oldStyle = { top: Element.getStyle(element, 'top'), left: Element.getStyle(element, 'left') }; return new Effect.MoveBy(element, 0, 20, { duration: 0.05, afterFinishInternal: function(effect) { new Effect.MoveBy(effect.element, 0, -40, { duration: 0.1, afterFinishInternal: function(effect) { new Effect.MoveBy(effect.element, 0, 40, { duration: 0.1, afterFinishInternal: function(effect) { new Effect.MoveBy(effect.element, 0, -40, { duration: 0.1, afterFinishInternal: function(effect) { new Effect.MoveBy(effect.element, 0, 40, { duration: 0.1, afterFinishInternal: function(effect) { new Effect.MoveBy(effect.element, 0, -20, { duration: 0.05, afterFinishInternal: function(effect) { with(Element) { undoPositioned(effect.element); setStyle(effect.element, oldStyle); }}}) }}) }}) }}) }}) }}); } Effect.SlideDown = function(element) { element = $(element); Element.cleanWhitespace(element); // SlideDown need to have the content of the element wrapped in a container element with fixed height! var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom'); var elementDimensions = Element.getDimensions(element); return new Effect.Scale(element, 100, Object.extend({ scaleContent: false, scaleX: false, scaleFrom: 0, scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, restoreAfterFinish: true, afterSetup: function(effect) { with(Element) { makePositioned(effect.element); makePositioned(effect.element.firstChild); if(window.opera) setStyle(effect.element, {top: ''}); makeClipping(effect.element); setStyle(effect.element, {height: '0px'}); show(element); }}, afterUpdateInternal: function(effect) { with(Element) { setStyle(effect.element.firstChild, {bottom: (effect.dims[0] - effect.element.clientHeight) + 'px' }); }}, afterFinishInternal: function(effect) { with(Element) { undoClipping(effect.element); undoPositioned(effect.element.firstChild); undoPositioned(effect.element); setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }} }, arguments[1] || {}) ); } Effect.SlideUp = function(element) { element = $(element); Element.cleanWhitespace(element); var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom'); return new Effect.Scale(element, 0, Object.extend({ scaleContent: false, scaleX: false, scaleMode: 'box', scaleFrom: 100, restoreAfterFinish: true, beforeStartInternal: function(effect) { with(Element) { makePositioned(effect.element); makePositioned(effect.element.firstChild); if(window.opera) setStyle(effect.element, {top: ''}); makeClipping(effect.element); show(element); }}, afterUpdateInternal: function(effect) { with(Element) { setStyle(effect.element.firstChild, {bottom: (effect.dims[0] - effect.element.clientHeight) + 'px' }); }}, afterFinishInternal: function(effect) { with(Element) { [hide, undoClipping].call(effect.element); undoPositioned(effect.element.firstChild); undoPositioned(effect.element); setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }} }, arguments[1] || {}) ); } // Bug in opera makes the TD containing this element expand for a instance after finish Effect.Squish = function(element) { return new Effect.Scale(element, window.opera ? 1 : 0, { restoreAfterFinish: true, beforeSetup: function(effect) { with(Element) { makeClipping(effect.element); }}, afterFinishInternal: function(effect) { with(Element) { hide(effect.element); undoClipping(effect.element); }} }); } Effect.Grow = function(element) { element = $(element); var options = Object.extend({ direction: 'center', moveTransistion: Effect.Transitions.sinoidal, scaleTransition: Effect.Transitions.sinoidal, opacityTransition: Effect.Transitions.full }, arguments[1] || {}); var oldStyle = { top: element.style.top, left: element.style.left, height: element.style.height, width: element.style.width, opacity: Element.getInlineOpacity(element) }; var dims = Element.getDimensions(element); var initialMoveX, initialMoveY; var moveX, moveY; switch (options.direction) { case 'top-left': initialMoveX = initialMoveY = moveX = moveY = 0; break; case 'top-right': initialMoveX = dims.width; initialMoveY = moveY = 0; moveX = -dims.width; break; case 'bottom-left': initialMoveX = moveX = 0; initialMoveY = dims.height; moveY = -dims.height; break; case 'bottom-right': initialMoveX = dims.width; initialMoveY = dims.height; moveX = -dims.width; moveY = -dims.height; break; case 'center': initialMoveX = dims.width / 2; initialMoveY = dims.height / 2; moveX = -dims.width / 2; moveY = -dims.height / 2; break; } return new Effect.MoveBy(element, initialMoveY, initialMoveX, { duration: 0.01, beforeSetup: function(effect) { with(Element) { hide(effect.element); makeClipping(effect.element); makePositioned(effect.element); }}, afterFinishInternal: function(effect) { new Effect.Parallel( [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }), new Effect.MoveBy(effect.element, moveY, moveX, { sync: true, transition: options.moveTransition }), new Effect.Scale(effect.element, 100, { scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true}) ], Object.extend({ beforeSetup: function(effect) { with(Element) { setStyle(effect.effects[0].element, {height: '0px'}); show(effect.effects[0].element); }}, afterFinishInternal: function(effect) { with(Element) { [undoClipping, undoPositioned].call(effect.effects[0].element); setStyle(effect.effects[0].element, oldStyle); }} }, options) ) } }); } Effect.Shrink = function(element) { element = $(element); var options = Object.extend({ direction: 'center', moveTransistion: Effect.Transitions.sinoidal, scaleTransition: Effect.Transitions.sinoidal, opacityTransition: Effect.Transitions.none }, arguments[1] || {}); var oldStyle = { top: element.style.top, left: element.style.left, height: element.style.height, width: element.style.width, opacity: Element.getInlineOpacity(element) }; var dims = Element.getDimensions(element); var moveX, moveY; switch (options.direction) { case 'top-left': moveX = moveY = 0; break; case 'top-right': moveX = dims.width; moveY = 0; break; case 'bottom-left': moveX = 0; moveY = dims.height; break; case 'bottom-right': moveX = dims.width; moveY = dims.height; break; case 'center': moveX = dims.width / 2; moveY = dims.height / 2; break; } return new Effect.Parallel( [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }), new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}), new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: options.moveTransition }) ], Object.extend({ beforeStartInternal: function(effect) { with(Element) { [makePositioned, makeClipping].call(effect.effects[0].element) }}, afterFinishInternal: function(effect) { with(Element) { [hide, undoClipping, undoPositioned].call(effect.effects[0].element); setStyle(effect.effects[0].element, oldStyle); }} }, options) ); } Effect.Pulsate = function(element) { element = $(element); var options = arguments[1] || {}; var oldOpacity = Element.getInlineOpacity(element); var transition = options.transition || Effect.Transitions.sinoidal; var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) }; reverser.bind(transition); return new Effect.Opacity(element, Object.extend(Object.extend({ duration: 3.0, from: 0, afterFinishInternal: function(effect) { Element.setStyle(effect.element, {opacity: oldOpacity}); } }, options), {transition: reverser})); } Effect.Fold = function(element) { element = $(element); var oldStyle = { top: element.style.top, left: element.style.left, width: element.style.width, height: element.style.height }; Element.makeClipping(element); return new Effect.Scale(element, 5, Object.extend({ scaleContent: false, scaleX: false, afterFinishInternal: function(effect) { new Effect.Scale(element, 1, { scaleContent: false, scaleY: false, afterFinishInternal: function(effect) { with(Element) { [hide, undoClipping].call(effect.element); setStyle(effect.element, oldStyle); }} }); }}, arguments[1] || {})); } From trevor at pub.open-bio.org Tue Feb 28 21:21:06 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Tue, 28 Feb 2006 21:21:06 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db rebase.rb,1.3,1.4 Message-ID: <200602282121.k1SLL6VL012447@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory pub.open-bio.org:/tmp/cvs-serv12437 Modified Files: rebase.rb Log Message: Change 'reference' to 'bio/reference'. Index: rebase.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/rebase.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** rebase.rb 27 Feb 2006 13:22:05 -0000 1.3 --- rebase.rb 28 Feb 2006 21:21:03 -0000 1.4 *************** *** 118,122 **** module Bio ! autoload :Reference, 'reference' --- 118,122 ---- module Bio ! autoload :Reference, 'bio/reference' From trevor at pub.open-bio.org Tue Feb 28 21:45:58 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Tue, 28 Feb 2006 21:45:58 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util restriction_enzyme.rb,1.3,1.4 Message-ID: <200602282145.k1SLjwVL012531@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util In directory pub.open-bio.org:/tmp/cvs-serv12521 Modified Files: restriction_enzyme.rb Log Message: Fix for enzymes.yaml relative location Index: restriction_enzyme.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** restriction_enzyme.rb 27 Feb 2006 13:11:28 -0000 1.3 --- restriction_enzyme.rb 28 Feb 2006 21:45:56 -0000 1.4 *************** *** 214,218 **** # Returns a Bio::REBASE object loaded with all of the enzyme data on file. # ! def self.rebase(enzymes_yaml) @@rebase_enzymes ||= Bio::REBASE.load_yaml(enzymes_yaml) @@rebase_enzymes --- 214,219 ---- # Returns a Bio::REBASE object loaded with all of the enzyme data on file. # ! #def self.rebase(enzymes_yaml = '/home/trevor/tmp5/bioruby/lib/bio/util/restriction_enzyme/enzymes.yaml') ! def self.rebase(enzymes_yaml = File.dirname(__FILE__) + '/restriction_enzyme/enzymes.yaml') @@rebase_enzymes ||= Bio::REBASE.load_yaml(enzymes_yaml) @@rebase_enzymes From trevor at pub.open-bio.org Tue Feb 28 22:21:50 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Tue, 28 Feb 2006 22:21:50 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme analysis.rb, 1.3, 1.4 Message-ID: <200602282221.k1SMLoVL012608@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv12598 Modified Files: analysis.rb Log Message: Error handling for when a match isn't found. Index: analysis.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** analysis.rb 18 Feb 2006 22:11:35 -0000 1.3 --- analysis.rb 28 Feb 2006 22:21:48 -0000 1.4 *************** *** 93,96 **** --- 93,97 ---- sequence = Bio::Sequence::NA.new( sequence ) enzyme_actions = create_enzyme_actions( sequence, *args ) + return nil if enzyme_actions.empty? permutations = permute(enzyme_actions.size) *************** *** 201,204 **** --- 202,207 ---- def unique_fragments_for_display( hash_of_sequence_ranges_with_cuts ) uf_ary = UniqueFragments.new + return uf_ary if hash_of_sequence_ranges_with_cuts == nil or hash_of_sequence_ranges_with_cuts.empty? + hash_of_sequence_ranges_with_cuts.each do |permutation, sr_with_cuts| sr_with_cuts.fragments.for_display.each do |fragment| From trevor at pub.open-bio.org Tue Feb 28 22:22:52 2006 From: trevor at pub.open-bio.org (Trevor Wennblom) Date: Tue, 28 Feb 2006 22:22:52 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme test_analysis.rb, 1.2, 1.3 Message-ID: <200602282222.k1SMMqVL012625@pub.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme In directory pub.open-bio.org:/tmp/cvs-serv12615 Modified Files: test_analysis.rb Log Message: Test for case where no match is made. Index: test_analysis.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/test_analysis.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_analysis.rb 18 Feb 2006 22:11:05 -0000 1.2 --- test_analysis.rb 28 Feb 2006 22:22:50 -0000 1.3 *************** *** 31,34 **** --- 31,37 ---- @obj_8 = @t.cut('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII', 'HincII') + @obj_9 = @t.cut('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'EcoRII') + @obj_9 = @t.cut('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'EcoRII', 'HincII') + @obj_1d = @t.cut_without_permutations('cagagag', 'ag^ag') @obj_2d = @t.cut_without_permutations('agagag', 'ag^ag')