[BioRuby-cvs] bioruby/lib/bio/db go.rb,1.8,1.9
Mitsuteru C. Nakao
nakao at pub.open-bio.org
Mon Oct 31 13:32:38 EST 2005
Update of /home/repository/bioruby/bioruby/lib/bio/db
In directory pub.open-bio.org:/tmp/cvs-serv4279/lib/bio/db
Modified Files:
go.rb
Log Message:
* Updated RDoc.
Index: go.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/go.rb,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** go.rb 26 Sep 2005 13:00:06 -0000 1.8
--- go.rb 31 Oct 2005 18:32:36 -0000 1.9
***************
*** 1,6 ****
#
! # bio/db/go.rb - Classes for Gene Ontology
#
! # Copyright (C) 2003 Mitsuteru C. Nakao <n at bioruby.org>
#
# This library is free software; you can redistribute it and/or
--- 1,16 ----
#
! # = bio/db/go.rb - Classes for Gene Ontology
#
! # Copyright:: Copyright (C) 2003 Mitsuteru C. Nakao <n at bioruby.org>
! # License::
! #
! # $Id$
! #
! # == Gene Ontology
! #
! # == Example
! #
! # == References
! #--
#
# 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$
#
--- 28,32 ----
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
! #++
#
***************
*** 25,37 ****
module Bio
! # Bio::GO
class GO
! # Bio::GO::Ontology - Class for a DAG Edit format of Gene Ontology.
class Ontology < Bio::Pathway
# Bio::GO::Ontology.parse_ogids(line)
# Parsing GOID line in the DAGEdit format
! # GO:ID[ ; GO:ID...]
def self.parse_goids(line)
goids = []
--- 35,57 ----
module Bio
! # = Bio::GO
! # Classes for Gene Ontology http://www.geneontology.org
class GO
! # = Bio::GO::Ontology
! #
! # Container class for ontologies in the DAG Edit format.
! #
! # == Example
! #
! # c_data = File.open('component.oontology').read
! # go_c = Bio::GO::Ontology.new(c_data)
! # p go_c.bfs_shortest_path('0003673','0005632')
class Ontology < Bio::Pathway
# Bio::GO::Ontology.parse_ogids(line)
+ #
# Parsing GOID line in the DAGEdit format
! # GO:ID[ ; GO:ID...]
def self.parse_goids(line)
goids = []
***************
*** 51,61 ****
end
!
attr_reader :header_lines
attr_reader :id2term
attr_reader :id2id
# Bio::GO::Ontology.new(str)
def initialize(str)
@id2term = {}
--- 71,86 ----
end
! # Returns a Hash instance of the header lines in ontology flatfile.
attr_reader :header_lines
+
+ #
attr_reader :id2term
+
+ #
attr_reader :id2id
# Bio::GO::Ontology.new(str)
+ # The DAG Edit format ontology data parser.
def initialize(str)
@id2term = {}
***************
*** 67,71 ****
! # Bio::GO::Ontology.goid2term(goid)
def goid2term(goid)
term = id2term[goid]
--- 92,96 ----
! # Returns a GO_Term correspondig with the given GO_ID.
def goid2term(goid)
term = id2term[goid]
***************
*** 138,142 ****
! # Bio::GO::Ontology#parse_goids(line)
def parse_goids(line)
Ontology.parse_goids(line)
--- 163,168 ----
! # Returns an ary of GO IDs by parsing an entry line in the DAG Edit
! # format.
def parse_goids(line)
Ontology.parse_goids(line)
***************
*** 162,174 ****
! # Bio::GO::GeneAssociation
# $CVSROOT/go/gene-associations/gene_association.*
#
class GeneAssociation # < Bio::DB
! DELIMITER = RS = "\n"
! # Bio::GO::GeneAssociation.parser(str)
! # gene_association.* file parser
def self.parser(str)
if block_given?
--- 188,216 ----
! # = Bio::GO::GeneAssociation
# $CVSROOT/go/gene-associations/gene_association.*
#
+ # Data parser for the gene_association go annotation.
+ # See also the file format http://www.geneontology.org/doc/GO.annotation.html#file
+ #
+ # == Example
+ #
+ # mgi_data = File.open('gene_association.mgi').read
+ # mgi = Bio::GO::GeneAssociation.parser(mgi_data)
+ #
+ # Bio::GO::GeneAssociation.parser(mgi_data) do |entry|
+ # p [entry.entry_id, entry.evidence, entry.goid]
+ # end
+ #
class GeneAssociation # < Bio::DB
! # Delimiter
! DELIMITER = "\n"
! # Delimiter
! RS = DELIMITER
!
! # Retruns an Array of parsed gene_association flatfile.
! # Block is acceptable.
def self.parser(str)
if block_given?
***************
*** 187,208 ****
end
attr_reader :db # -> aStr
attr_reader :db_object_id # -> aStr
attr_reader :db_object_symbol
attr_reader :qualifier
attr_reader :db_reference # -> []
attr_reader :evidence
attr_reader :with # -> []
attr_reader :aspect
attr_reader :db_object_name
attr_reader :db_object_synonym # -> []
attr_reader :db_object_type
attr_reader :taxon
attr_reader :date
attr_reader :assigned_by
alias entry_id db_object_id
! # Bio::GO::GeneAssociation.new(entry)
def initialize(entry)
tmp = entry.chomp.split(/\t/)
--- 229,278 ----
end
+ # Returns DB variable.
attr_reader :db # -> aStr
+
+ # Returns Db_Object_Id variable. Alias to entry_id.
attr_reader :db_object_id # -> aStr
+
+ # Returns Db_Object_Symbol variable.
attr_reader :db_object_symbol
+
+ # Returns Db_Object_Name variable.
attr_reader :qualifier
+
+ # Returns Db_Reference variable.
attr_reader :db_reference # -> []
+
+ # Retruns Evidence code variable.
attr_reader :evidence
+
+ # Returns the entry is associated with this value.
attr_reader :with # -> []
+
+ # Returns Aspect valiable.
attr_reader :aspect
+
+ #
attr_reader :db_object_name
+
+ #
attr_reader :db_object_synonym # -> []
+
+ # Returns Db_Object_Type variable.
attr_reader :db_object_type
+
+ # Returns Taxon variable.
attr_reader :taxon
+
+ # Returns Date variable.
attr_reader :date
+
+ #
attr_reader :assigned_by
+
alias entry_id db_object_id
! # Parsing an entry (in a line) in the gene_association flatfile.
def initialize(entry)
tmp = entry.chomp.split(/\t/)
***************
*** 225,232 ****
! # Bio::GO::GeneAssociation#goid(org = nil) -> GO ID
#
! # Bio::GO::GeneAssociation#goid -> "001234"
! # Bio::GO::GeneAssociation#goid(true) -> "GO:001234"
def goid(org = nil)
if org
--- 295,303 ----
! # Returns GO_ID in /\d{7}/ format. Giving not nil arg, returns
! # /GO:\d{7}/ style.
#
! # * Bio::GO::GeneAssociation#goid -> "001234"
! # * Bio::GO::GeneAssociation#goid(true) -> "GO:001234"
def goid(org = nil)
if org
***************
*** 249,253 ****
! # Container class for files in geneontology.org/go/external2go/*2go.
#
# The line syntax is:
--- 320,324 ----
! # = Container class for files in geneontology.org/go/external2go/*2go.
#
# The line syntax is:
***************
*** 255,271 ****
# database:<identifier> > GO:<term> ; GO:<GO_id>
#
# == SAMPLE
! # !date: 2005/02/08 18:02:54
! # !Mapping of SWISS-PROT KEYWORDS to GO terms.
! # !Evelyn Camon, SWISS-PROT.
! # !
! # SP_KW:ATP synthesis > GO:ATP biosynthesis ; GO:0006754
! # ...
#
class External2go < Array
attr_reader :header
! # Bio::GO::External2go.parser(str)
! # Constructor
def self.parser(str)
e2g = self.new
--- 326,352 ----
# database:<identifier> > GO:<term> ; GO:<GO_id>
#
+ # == Example
+ #
+ # spkw2go = Bio::GO::External2go.new(File.read("spkw2go"))
+ # spkw2go.size
+ # spkw2go.each do |relation|
+ # relation # -> {:db => "", :db_id => "", :go_term => "", :go_id => ""}
+ # end
+ # spkw2go.dbs
+ #
# == SAMPLE
! # !date: 2005/02/08 18:02:54
! # !Mapping of SWISS-PROT KEYWORDS to GO terms.
! # !Evelyn Camon, SWISS-PROT.
! # !
! # SP_KW:ATP synthesis > GO:ATP biosynthesis ; GO:0006754
! # ...
#
class External2go < Array
+
+ # Returns aHash of the external2go header information
attr_reader :header
! # Constructor from parsing external2go file.
def self.parser(str)
e2g = self.new
***************
*** 285,289 ****
end
! # Bio::GO::External2go.new
def initialize
@header = {:date => '', :desc => []}
--- 366,372 ----
end
!
! # Constructor.
! # relation := {:db => aStr, :db_id => aStr, :go_term => aStr, :go_id => aStr}
def initialize
@header = {:date => '', :desc => []}
***************
*** 291,294 ****
--- 374,378 ----
end
+
# Bio::GO::External2go#set_date(value)
def set_date(value)
***************
*** 296,299 ****
--- 380,384 ----
end
+
# Bio::GO::External2go#set_desc(ary)
def set_desc(ary)
***************
*** 301,305 ****
--- 386,392 ----
end
+
# Bio::GO::External2go#to_str
+ # Returns the contents in the external2go format.
def to_str
["!date: #{@header[:date]}",
***************
*** 310,329 ****
! # Bio::GO::External2go#db
def dbs
self.map {|rel| rel[:db] }.uniq
end
! # Bio::GO::External2go#db_ids
def db_ids
self.map {|rel| rel[:db_id] }.uniq
end
! # Bio::GO::External2go#go_terms
def go_terms
self.map {|rel| rel[:go_term] }.uniq
end
! # Bio::GO::External2go#go_ids
def go_ids
self.map {|rel| rel[:go_id] }.uniq
--- 397,417 ----
! # Returns ary of databases.
def dbs
self.map {|rel| rel[:db] }.uniq
end
!
! # Returns ary of database IDs.
def db_ids
self.map {|rel| rel[:db_id] }.uniq
end
! # Returns ary of GO Terms.
def go_terms
self.map {|rel| rel[:go_term] }.uniq
end
! # Returns ary of GO IDs.
def go_ids
self.map {|rel| rel[:go_id] }.uniq
***************
*** 408,579 ****
end
-
-
-
-
- =begin
-
- = Bio::GO
-
- * Classes for ((<Gene Ontology|URL:http://www.geneontology.org>)).
-
-
- = Bio::GO::Ontology < Bio::Pathway
-
- * Container class for ontologies in the DAG Edit format.
-
- c_data = File.open('component.oontology').read
- go_c = Bio::GO::Ontology.new(c_data)
- p go_c.bfs_shortest_path('0003673','0005632')
-
-
- --- Bio::GO::Ontology.new(data)
-
- The DAG Edit format ontology data is allowed.
-
- --- Bio::GO::Ontology#hader_lines
-
- Returns a Hash instance of the header lines in ontology flatfile.
-
-
- --- Bio::GO::Ontology#goid2term(GO_ID)
-
- Returns a GO_Term correspondig with the given GO_ID.
-
- --- Bio::GO::Ontology.parse_goids(line)
-
- Returns an ary of GO IDs by parsing an entry line in the DAG Edit
- format.
-
-
- = Bio::GO::GeneAssociation
-
- * Data parser for the gene_association go annotation.
- See also ((<the file format|URL:http://www.geneontology.org/doc/GO.annotation.html#file>)).
-
-
- mgi_data = File.open('gene_association.mgi').read
- mgi = Bio::GO::GeneAssociation.parser(mgi_data)
-
- or
-
- Bio::GO::GeneAssociation.parser(mgi_data) {|entry|
- p [entry.entry_id, entry.evidence, entry.goid]
- }
-
-
- --- Bio::GO::GeneAssociation.parser(data)
-
- Retruns an Array of parsed gene_association flatfile.
- Block is acceptable.
-
- --- Bio::GO::GeneAssociation.new(line)
-
- Parsing an entry (in a line) in the gene_association flatfile.
-
- --- Bio::GO::GeneAssociation.DELIMITER
-
- The entry delimiter is "\n".
- alias as RS.
-
- --- Bio::GO::GeneAssociation#goid(arg = nil)
-
- Returns GO_ID in /\d{7}/ format. Giving not nil arg, returns
- /GO:\d{7}/ style.
-
- --- Bio::GO::GeneAssociation#db
-
- DB variable.
-
- --- Bio::GO::GeneAssociation#db_object_id
-
- Db_Object_Id variable. Alias to entry_id.
-
- --- Bio::GO::GeneAssociation#db_object_symbol
-
- Db_Object_Symbol variable.
-
- --- Bio::GO::GeneAssociation#db_object_name
-
- Db_Object_Name variable.
-
- --- Bio::GO::GeneAssociation#db_object_type
-
- Db_Object_Type variable.
-
- --- Bio::GO::GeneAssociation#db_reference
-
- Db_Reference variable.
-
- --- Bio::GO::GeneAssociation#evidence
-
- Evidence code variable.
-
- --- Bio::GO::GeneAssociation#with
-
- The entry is associated with this value.
-
- --- Bio::GO::GeneAssociation#aspect
-
- Aspect valiable.
-
- --- Bio::GO::GeneAssociation#taxon
-
- Taxon variable.
-
- --- Bio::GO::GeneAssociation#date
-
- Date variable.
-
-
-
- = Bio::GO::External2go < Array
-
- Class for files in geneontology.org/go/external2go/
-
-
- spkw2go = Bio::GO::External2go.new(File.read("spkw2go"))
- spkw2go.size
- spkw2go.each do |relation|
- relation # -> {:db => "", :db_id => "", :go_term => "", :go_id => ""}
- end
- spkw2go.dbs
-
- --- Bio::GO::External2go.parser(str)
-
- Constructor from parsing external2go file.
-
- --- Bio::GO::External2go.new
-
- Constructor.
- relation := {:db => aStr, :db_id => aStr, :go_term => aStr, :go_id => aStr}
-
- --- Bio::GO::External2go#[index] -> relation
-
- Index accessing to a list of external2go relations.
-
- --- Bio::GO::External2go#header -> {:date => "", :desc => ""}
-
- Hash of the header information.
-
- --- Bio::GO::External2go#dbs -> ary
-
- List of databases.
-
- --- Bio::GO::External2go#db_ids -> ary
-
- List of database IDs.
-
- --- Bio::GO::External2go#go_terms -> ary
-
- List of GO Terms.
-
- --- Bio::GO::External2go#go_ids -> ary
-
- List of GO IDs.
-
- --- Bio::GO::External2go#to_str -> str
-
- Formats the content in the external2go format.
-
- =end
--- 496,497 ----
More information about the bioruby-cvs
mailing list