[BioRuby-cvs] bioruby/lib/bio map.rb, 1.8, 1.9 location.rb, 0.26, 0.27
Katayama Toshiaki
k at dev.open-bio.org
Sun Dec 24 10:10:10 UTC 2006
Update of /home/repository/bioruby/bioruby/lib/bio
In directory dev.open-bio.org:/tmp/cvs-serv1876/lib/bio
Modified Files:
map.rb location.rb
Log Message:
* Bio::Locations#equals? method is moved from bio/map.rb to bio/location.rb
* RDoc documents are reformatted to fit within 80 columns on terminal
Index: location.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/location.rb,v
retrieving revision 0.26
retrieving revision 0.27
diff -C2 -d -r0.26 -r0.27
*** location.rb 19 Sep 2006 06:13:54 -0000 0.26
--- location.rb 24 Dec 2006 10:10:08 -0000 0.27
***************
*** 3,7 ****
#
# Copyright:: Copyright (C) 2001, 2005 Toshiaki Katayama <k at bioruby.org>
! # 2006 Jan Aerts <jan.aerts at bbsrc.ac.uk>
# License:: Ruby's
#
--- 3,7 ----
#
# Copyright:: Copyright (C) 2001, 2005 Toshiaki Katayama <k at bioruby.org>
! # Copyright:: Copyright (C) 2006 Jan Aerts <jan.aerts at bbsrc.ac.uk>
# License:: Ruby's
#
***************
*** 13,19 ****
# == Description
#
! # The Bio::Location class describes the position of a genomic locus. Typically,
! # Bio::Location objects are created automatically when the user creates a
! # Bio::Locations object, instead of initialized directly.
#
# == Usage
--- 13,19 ----
# == Description
#
! # The Bio::Location class describes the position of a genomic locus.
! # Typically, Bio::Location objects are created automatically when the
! # user creates a Bio::Locations object, instead of initialized directly.
#
# == Usage
***************
*** 29,42 ****
#
class Location
include Comparable
# Parses a'location' segment, which can be 'ID:' + ('n' or 'n..m' or 'n^m'
# or "seq") with '<' or '>', and returns a Bio::Location object.
# location = Bio::Location.new('500..550')
#
# ---
# *Arguments*:
! # * (required) _str_: GenBank style position string (see Bio::Locations documentation)
! # *Returns*:: Bio::Location object
def initialize(location = nil)
--- 29,45 ----
#
class Location
+
include Comparable
# Parses a'location' segment, which can be 'ID:' + ('n' or 'n..m' or 'n^m'
# or "seq") with '<' or '>', and returns a Bio::Location object.
+ #
# location = Bio::Location.new('500..550')
#
# ---
# *Arguments*:
! # * (required) _str_: GenBank style position string (see Bio::Locations
! # documentation)
! # *Returns*:: the Bio::Location object
def initialize(location = nil)
***************
*** 55,59 ****
# s : start base, e : end base => from, to
case location
! when /^[<>]?(\d+)$/ # (A, I) n
s = e = $1.to_i
when /^[<>]?(\d+)\.\.[<>]?(\d+)$/ # (B, I) n..m
--- 58,62 ----
# s : start base, e : end base => from, to
case location
! when /^[<>]?(\d+)$/ # (A, I) n
s = e = $1.to_i
when /^[<>]?(\d+)\.\.[<>]?(\d+)$/ # (B, I) n..m
***************
*** 103,107 ****
# ---
# *Arguments*:
! # * (required) _sequence_: sequence to be used to replace the sequence at the location
# *Returns*:: the Bio::Location object
def replace(sequence)
--- 106,111 ----
# ---
# *Arguments*:
! # * (required) _sequence_: sequence to be used to replace the sequence
! # at the location
# *Returns*:: the Bio::Location object
def replace(sequence)
***************
*** 117,123 ****
# Check where a Bio::Location object is located compared to another
# Bio::Location object (mainly to facilitate the use of Comparable).
! # A location A is upstream of location B if the start position of location A
! # is smaller than the start position of location B. If they're the same, the
! # end positions are checked.
# ---
# *Arguments*:
--- 121,127 ----
# Check where a Bio::Location object is located compared to another
# Bio::Location object (mainly to facilitate the use of Comparable).
! # A location A is upstream of location B if the start position of
! # location A is smaller than the start position of location B. If
! # they're the same, the end positions are checked.
# ---
# *Arguments*:
***************
*** 147,151 ****
end
! end # class location
# == Description
--- 151,155 ----
end
! end # Location
# == Description
***************
*** 158,171 ****
#
# locations = Bio::Locations.new('join(complement(500..550), 600..625)')
! # locations.each do |location|
! # puts "class=" + location.class.to_s
! # puts "start=" + location.from.to_s + ";end=" + location.to.to_s \
! # + ";strand=" + location.strand.to_s
# end
! # # Output would be:
! # # class=Bio::Location
! # # start=500;end=550;strand=-1
! # # class=Bio::Location
! # # start=600;end=625;strand=1
#
# # For the following three location strings, print the span and range
--- 162,174 ----
#
# locations = Bio::Locations.new('join(complement(500..550), 600..625)')
! # locations.each do |loc|
! # puts "class = " + loc.class.to_s
! # puts "range = #{loc.from}..#{loc.to} (strand = #{loc.strand})"
# end
! # # Output would be:
! # # class = Bio::Location
! # # range = 500..550 (strand = -1)
! # # class = Bio::Location
! # # range = 600..625 (strand = 1)
#
# # For the following three location strings, print the span and range
***************
*** 178,229 ****
# end
#
! # == GenBank location descriptor classification
#
! # === Definition of the position notation of the GenBank location format
#
# According to the GenBank manual 'gbrel.txt', position notations were
# classified into 10 patterns - (A) to (J).
#
! # 3.4.12.2 Feature Location
! #
! # The second column of the feature descriptor line designates the
! # location of the feature in the sequence. The location descriptor
! # begins at position 22. Several conventions are used to indicate
! # sequence location.
! #
! # Base numbers in location descriptors refer to numbering in the entry,
! # which is not necessarily the same as the numbering scheme used in the
! # published report. The first base in the presented sequence is numbered
! # base 1. Sequences are presented in the 5 to 3 direction.
! #
! # Location descriptors can be one of the following:
#
# (A) 1. A single base;
! #
# (B) 2. A contiguous span of bases;
! #
# (C) 3. A site between two bases;
! #
# (D) 4. A single base chosen from a range of bases;
! #
# (E) 5. A single base chosen from among two or more specified bases;
! #
# (F) 6. A joining of sequence spans;
! #
# (G) 7. A reference to an entry other than the one to which the feature
! # belongs (i.e., a remote entry), followed by a location descriptor
! # referring to the remote sequence;
! #
# (H) 8. A literal sequence (a string of bases enclosed in quotation marks).
#
! #
# (C) A site between two residues, such as an endonuclease cleavage site, is
# indicated by listing the two bases separated by a carat (e.g., 23^24).
! #
# (D) A single residue chosen from a range of residues is indicated by the
# number of the first and last bases in the range separated by a single
# period (e.g., 23.79). The symbols < and > indicate that the end point
# (I) of the range is beyond the specified base number.
! #
# (B) A contiguous span of bases is indicated by the number of the first and
# last bases in the range separated by two periods (e.g., 23..79). The
--- 181,233 ----
# end
#
! # === GenBank location descriptor classification
#
! # ==== Definition of the position notation of the GenBank location format
#
# According to the GenBank manual 'gbrel.txt', position notations were
# classified into 10 patterns - (A) to (J).
#
! # 3.4.12.2 Feature Location
! #
! # The second column of the feature descriptor line designates the
! # location of the feature in the sequence. The location descriptor
! # begins at position 22. Several conventions are used to indicate
! # sequence location.
! #
! # Base numbers in location descriptors refer to numbering in the entry,
! # which is not necessarily the same as the numbering scheme used in the
! # published report. The first base in the presented sequence is numbered
! # base 1. Sequences are presented in the 5 to 3 direction.
! #
! # Location descriptors can be one of the following:
#
# (A) 1. A single base;
! #
# (B) 2. A contiguous span of bases;
! #
# (C) 3. A site between two bases;
! #
# (D) 4. A single base chosen from a range of bases;
! #
# (E) 5. A single base chosen from among two or more specified bases;
! #
# (F) 6. A joining of sequence spans;
! #
# (G) 7. A reference to an entry other than the one to which the feature
! # belongs (i.e., a remote entry), followed by a location descriptor
! # referring to the remote sequence;
! #
# (H) 8. A literal sequence (a string of bases enclosed in quotation marks).
#
! # ==== Description commented with pattern IDs.
! #
# (C) A site between two residues, such as an endonuclease cleavage site, is
# indicated by listing the two bases separated by a carat (e.g., 23^24).
! #
# (D) A single residue chosen from a range of residues is indicated by the
# number of the first and last bases in the range separated by a single
# period (e.g., 23.79). The symbols < and > indicate that the end point
# (I) of the range is beyond the specified base number.
! #
# (B) A contiguous span of bases is indicated by the number of the first and
# last bases in the range separated by two periods (e.g., 23..79). The
***************
*** 231,254 ****
# specified base number. Starting and ending positions can be indicated
# by base number or by one of the operators described below.
! #
# Operators are prefixes that specify what must be done to the indicated
# sequence to locate the feature. The following are the operators
# available, along with their most common format and a description.
! #
# (J) complement (location): The feature is complementary to the location
# indicated. Complementary strands are read 5 to 3.
! #
# (F) join (location, location, .. location): The indicated elements should
# be placed end to end to form one contiguous sequence.
! #
# (F) order (location, location, .. location): The elements are found in the
# specified order in the 5 to 3 direction, but nothing is implied about
# the rationality of joining them.
! #
# (F) group (location, location, .. location): The elements are related and
# should be grouped together, but no order is implied.
! #
# (E) one-of (location, location, .. location): The element can be any one,
! # but only one, of the items listed.
#
# === Reduction strategy of the position notations
--- 235,258 ----
# specified base number. Starting and ending positions can be indicated
# by base number or by one of the operators described below.
! #
# Operators are prefixes that specify what must be done to the indicated
# sequence to locate the feature. The following are the operators
# available, along with their most common format and a description.
! #
# (J) complement (location): The feature is complementary to the location
# indicated. Complementary strands are read 5 to 3.
! #
# (F) join (location, location, .. location): The indicated elements should
# be placed end to end to form one contiguous sequence.
! #
# (F) order (location, location, .. location): The elements are found in the
# specified order in the 5 to 3 direction, but nothing is implied about
# the rationality of joining them.
! #
# (F) group (location, location, .. location): The elements are related and
# should be grouped together, but no order is implied.
! #
# (E) one-of (location, location, .. location): The element can be any one,
! # but only one, of the items listed.
#
# === Reduction strategy of the position notations
***************
*** 257,404 ****
# * (B) Location n..m
# * (C) Location n^m
! # * (D) (n.m) => Location n
# * (E)
! # * one-of(n,m,..) => Location n
! # * one-of(n..m,..) => Location n..m
# * (F)
! # * order(loc,loc,..) => join(loc, loc,..)
! # * group(loc,loc,..) => join(loc, loc,..)
! # * join(loc,loc,..) => Sequence
! # * (G) ID:loc => Location with ID
! # * (H) "atgc" => Location only with Sequence
# * (I)
# * <n => Location n with lt flag
# * >n => Location n with gt flag
! # * <n..m => Location n..m with lt flag
! # * n..>m => Location n..m with gt flag
! # * <n..>m => Location n..m with lt, gt flag
! # * (J) complement(loc) => Sequence
# * (K) replace(loc, str) => Location with replacement Sequence
#
- # === GenBank location examples
- #
- # (C) n^m
- #
- # * [AB015179] 754^755
- # * [AF179299] complement(53^54)
- # * [CELXOL1ES] replace(4480^4481,"")
- # * [ECOUW87] replace(4792^4793,"a")
- # * [APLPCII] replace(1905^1906,"acaaagacaccgccctacgcc")
- #
- # (D) (n.m)
- #
- # * [HACSODA] 157..(800.806)
- # * [HALSODB] (67.68)..(699.703)
- # * [AP001918] (45934.45974)..46135
- # * [BACSPOJ] <180..(731.761)
- # * [BBU17998] (88.89)..>1122
- # * [ECHTGA] complement((1700.1708)..(1715.1721))
- # * [ECPAP17] complement(<22..(255.275))
- # * [LPATOVGNS] complement((64.74)..1525)
- # * [PIP404CG] join((8298.8300)..10206,1..855)
- # * [BOVMHDQBY4] join(M30006.1:(392.467)..575,M30005.1:415..681,M30004.1:129..410,M30004.1:907..1017,521..534)
- # * [HUMMIC2A] replace((651.655)..(651.655),"")
- # * [HUMSOD102] order(L44135.1:(454.445)..>538,<1..181)
- #
- # (E) one-of
- #
- # * [ECU17136] one-of(898,900)..983
- # * [CELCYT1A] one-of(5971..6308,5971..6309)
- # * [DMU17742] 8050..one-of(10731,10758,10905,11242)
- # * [PFU27807] one-of(623,627,632)..one-of(628,633,637)
- # * [BTBAINH1] one-of(845,953,963,1078,1104)..1354
- # * [ATU39449] join(one-of(969..1094,970..1094,995..1094,1018..1094),1518..1587,1726..2119,2220..2833,2945..3215)
- #
- # (F) join, order, group
- #
- # * [AB037374S2] join(AB037374.1:1..177,1..807)
- # * [AP000001] join(complement(1..61),complement(AP000007.1:252907..253505))
- # * [ASNOS11] join(AF130124.1:<2563..2964,AF130125.1:21..157,AF130126.1:12..174,AF130127.1:21..112,AF130128.1:21..162,AF130128.1:281..595,AF130128.1:661..842,AF130128.1:916..1030,AF130129.1:21..115,AF130130.1:21..165,AF130131.1:21..125,AF130132.1:21..428,AF130132.1:492..746,AF130133.1:21..168,AF130133.1:232..401,AF130133.1:475..906,AF130133.1:970..1107,AF130133.1:1176..1367,21..>128)
- #
- # * [AARPOB2] order(AF194507.1:<1..510,1..>871)
- # * [AF006691] order(912..1918,20410..21416)
- # * [AF024666] order(complement(18919..19224),complement(13965..14892))
- # * [AF264948] order(27066..27076,27089..27099,27283..27314,27330..27352)
- # * [D63363] order(3..26,complement(964..987))
- # * [ECOCURLI2] order(complement(1009..>1260),complement(AF081827.1:<1..177))
- # * [S72388S2] order(join(S72388.1:757..911,S72388.1:609..1542),1..>139)
- # * [HEYRRE07] order(complement(1..38),complement(M82666.1:1..140),complement(M82665.1:1..176),complement(M82664.1:1..215),complement(M82663.1:1..185),complement(M82662.1:1..49),complement(M82661.1:1..133))
- # * [COL11A1G34] order(AF101079.1:558..1307,AF101080.1:1..749,AF101081.1:1..898,AF101082.1:1..486,AF101083.1:1..942,AF101084.1:1..1734,AF101085.1:1..2385,AF101086.1:1..1813,AF101087.1:1..2287,AF101088.1:1..1073,AF101089.1:1..989,AF101090.1:1..5017,AF101091.1:1..3401,AF101092.1:1..1225,AF101093.1:1..1072,AF101094.1:1..989,AF101095.1:1..1669,AF101096.1:1..918,AF101097.1:1..1114,AF101098.1:1..1074,AF101099.1:1..1709,AF101100.1:1..986,AF101101.1:1..1934,AF101102.1:1..1699,AF101103.1:1..940,AF101104.1:1..2330,AF101105.1:1..4467,AF101106.1:1..1876,AF101107.1:1..2465,AF101108.1:1..1150,AF101109.1:1..1170,AF101110.1:1..1158,AF101111.1:1..1193,1..611)
- #
- # group() are found in the COMMENT field only (in GenBank 122.0)
- #
- # gbpat2.seq: FT repeat_region group(598..606,611..619)
- # gbpat2.seq: FT repeat_region group(8..16,1457..1464).
- # gbpat2.seq: FT variation group(t1,t2)
- # gbpat2.seq: FT variation group(t1,t3)
- # gbpat2.seq: FT variation group(t1,t2,t3)
- # gbpat2.seq: FT repeat_region group(11..202,203..394)
- # gbpri9.seq:COMMENT Residues reported = 'group(1..2145);'.
- #
- # (G) ID:location
- #
- # * [AARPOB2] order(AF194507.1:<1..510,1..>871)
- # * [AF178221S4] join(AF178221.1:<1..60,AF178222.1:1..63,AF178223.1:1..42,1..>90)
- # * [BOVMHDQBY4] join(M30006.1:(392.467)..575,M30005.1:415..681,M30004.1:129..410,M30004.1:907..1017,521..534)
- # * [HUMSOD102] order(L44135.1:(454.445)..>538,<1..181)
- # * [SL16SRRN1] order(<1..>267,X67092.1:<1..>249,X67093.1:<1..>233)
- #
- # (I) <, >
- #
- # * [A5U48871] <1..>318
- # * [AA23SRRNP] <1..388
- # * [AA23SRRNP] 503..>1010
- # * [AAM5961] complement(<1..229)
- # * [AAM5961] complement(5231..>5598)
- # * [AF043934] join(<1,60..99,161..241,302..370,436..594,676..887,993..1141,1209..1329,1387..1559,1626..1646,1708..>1843)
- # * [BACSPOJ] <180..(731.761)
- # * [BBU17998] (88.89)..>1122
- # * [AARPOB2] order(AF194507.1:<1..510,1..>871)
- # * [SL16SRRN1] order(<1..>267,X67092.1:<1..>249,X67093.1:<1..>233)
- #
- # (J) complement
- #
- # * [AF179299] complement(53^54) <= hoge insertion site etc.
- # * [AP000001] join(complement(1..61),complement(AP000007.1:252907..253505))
- # * [AF209868S2] order(complement(1..>308),complement(AF209868.1:75..336))
- # * [AP000001] join(complement(1..61),complement(AP000007.1:252907..253505))
- # * [CPPLCG] complement(<1..(1093.1098))
- # * [D63363] order(3..26,complement(964..987))
- # * [ECHTGA] complement((1700.1708)..(1715.1721))
- # * [ECOUXW] order(complement(1658..1663),complement(1636..1641))
- # * [LPATOVGNS] complement((64.74)..1525)
- # * [AF129075] complement(join(71606..71829,75327..75446,76039..76203,76282..76353,76914..77029,77114..77201,77276..77342,78138..78316,79755..79892,81501..81562,81676..81856,82341..82490,84208..84287,85032..85122,88316..88403))
- # * [ZFDYST2] join(AF137145.1:<1..18,complement(<1..99))
- #
- # (K) replace
- #
- # * [CSU27710] replace(64,"A")
- # * [CELXOL1ES] replace(5256,"t")
- # * [ANICPC] replace(1..468,"")
- # * [CSU27710] replace(67..68,"GC")
- # * [CELXOL1ES] replace(4480^4481,"") <= ? only one case in GenBank 122.0
- # * [ECOUW87] replace(4792^4793,"a")
- # * [CEU34893] replace(1..22,"ggttttaacccagttactcaag")
- # * [APLPCII] replace(1905^1906,"acaaagacaccgccctacgcc")
- # * [MBDR3S1] replace(1400..>9281,"")
- # * [HUMMHDPB1F] replace(complement(36..37),"ttc")
- # * [HUMMIC2A] replace((651.655)..(651.655),"")
- # * [LEIMDRPGP] replace(1..1554,"L01572")
- # * [TRBND3] replace(376..395,"atttgtgtgtggtaatta")
- # * [TRBND3] replace(376..395,"atttgtgtgggtaatttta")
- # * [TRBND3] replace(376..395,"attttgttgttgttttgttttgaatta")
- # * [TRBND3] replace(376..395,"atgtgtggtgaatta")
- # * [TRBND3] replace(376..395,"atgtgtgtggtaatta")
- # * [TRBND3] replace(376..395,"gatttgttgtggtaatttta")
- # * [MSU09460] replace(193, <= replace(193, "t")
- # * [HUMMAGE12X] replace(3002..3003, <= replace(3002..3003, "GC")
- # * [ADR40FIB] replace(510..520, <= replace(510..520, "taatcctaccg")
- # * [RATDYIIAAB] replace(1306..1443,"aagaacatccacggagtcagaactgggctcttcacgccggatttggcgttcgaggccattgtgaaaaagcaggcaatgcaccagcaagctcagttcctacccctgcgtggacctggttatccaggagctaatcagtacagttaggtggtcaagctgaaagagccctgtctgaaa")
- #
class Locations
include Enumerable
! # Parses a GenBank style position string and returns a Bio::Locations object,
! # which contains a list of Bio::Location objects.
# locations = Bio::Locations.new('join(complement(500..550), 600..625)')
#
--- 261,290 ----
# * (B) Location n..m
# * (C) Location n^m
! # * (D) (n.m) => Location n
# * (E)
! # * one-of(n,m,..) => Location n
! # * one-of(n..m,..) => Location n..m
# * (F)
! # * order(loc,loc,..) => join(loc, loc,..)
! # * group(loc,loc,..) => join(loc, loc,..)
! # * join(loc,loc,..) => Sequence
! # * (G) ID:loc => Location with ID
! # * (H) "atgc" => Location only with Sequence
# * (I)
# * <n => Location n with lt flag
# * >n => Location n with gt flag
! # * <n..m => Location n..m with lt flag
! # * n..>m => Location n..m with gt flag
! # * <n..>m => Location n..m with lt, gt flag
! # * (J) complement(loc) => Sequence
# * (K) replace(loc, str) => Location with replacement Sequence
#
class Locations
+
include Enumerable
! # Parses a GenBank style position string and returns a Bio::Locations
! # object, which contains a list of Bio::Location objects.
! #
# locations = Bio::Locations.new('join(complement(500..550), 600..625)')
#
***************
*** 419,422 ****
--- 305,320 ----
attr_accessor :locations
+ # Evaluate equality of Bio::Locations object.
+ def equals?(other)
+ if ! other.kind_of?(Bio::Locations)
+ return nil
+ end
+ if self.sort == other.sort
+ return true
+ else
+ return false
+ end
+ end
+
# Iterates on each Bio::Location object.
def each
***************
*** 479,482 ****
--- 377,381 ----
# puts loc.relative(13524) # => 10
# puts loc.relative(13506, :aa) # => 3
+ #
# ---
# *Arguments*:
***************
*** 509,516 ****
# puts loc.absolute(10) # => 13524
# puts loc.absolute(10, :aa) # => 13506
# ---
# *Arguments*:
# * (required) _position_: nucleotide position within locus
! # * _:aa_: flag to be used if _position_ is a aminoacid position rather than a nucleotide position
# *Returns*:: position within the whole of the sequence
def absolute(n, type = nil)
--- 408,417 ----
# puts loc.absolute(10) # => 13524
# puts loc.absolute(10, :aa) # => 13506
+ #
# ---
# *Arguments*:
# * (required) _position_: nucleotide position within locus
! # * _:aa_: flag to be used if _position_ is a aminoacid position rather than
! # a nucleotide position
# *Returns*:: position within the whole of the sequence
def absolute(n, type = nil)
***************
*** 540,546 ****
position.gsub!(/(\.{2})?\(?([<>\d]+)\.([<>\d]+)(?!:)\)?/) do |match|
if $1
! $1 + $3 # ..(n.m) => ..m
else
! $2 # (?n.m)? => n
end
end
--- 441,447 ----
position.gsub!(/(\.{2})?\(?([<>\d]+)\.([<>\d]+)(?!:)\)?/) do |match|
if $1
! $1 + $3 # ..(n.m) => ..m
else
! $2 # (?n.m)? => n
end
end
***************
*** 550,556 ****
position.gsub!(/(\.{2})?one-of\(([^,]+),([^)]+)\)/) do |match|
if $1
! $1 + $3.gsub(/.*,(.*)/, '\1') # ..one-of(n,m) => ..m
else
! $2 # one-of(n,m) => n
end
end
--- 451,457 ----
position.gsub!(/(\.{2})?one-of\(([^,]+),([^)]+)\)/) do |match|
if $1
! $1 + $3.gsub(/.*,(.*)/, '\1') # ..one-of(n,m) => ..m
else
! $2 # one-of(n,m) => n
end
end
***************
*** 670,678 ****
end
! end # class Locations
! end # module Bio
if __FILE__ == $0
puts "Test new & span methods"
--- 571,701 ----
end
! end # Locations
! end # Bio
+
+ # === GenBank location examples
+ #
+ # (C) n^m
+ #
+ # * [AB015179] 754^755
+ # * [AF179299] complement(53^54)
+ # * [CELXOL1ES] replace(4480^4481,"")
+ # * [ECOUW87] replace(4792^4793,"a")
+ # * [APLPCII] replace(1905^1906,"acaaagacaccgccctacgcc")
+ #
+ # (D) (n.m)
+ #
+ # * [HACSODA] 157..(800.806)
+ # * [HALSODB] (67.68)..(699.703)
+ # * [AP001918] (45934.45974)..46135
+ # * [BACSPOJ] <180..(731.761)
+ # * [BBU17998] (88.89)..>1122
+ # * [ECHTGA] complement((1700.1708)..(1715.1721))
+ # * [ECPAP17] complement(<22..(255.275))
+ # * [LPATOVGNS] complement((64.74)..1525)
+ # * [PIP404CG] join((8298.8300)..10206,1..855)
+ # * [BOVMHDQBY4] join(M30006.1:(392.467)..575,M30005.1:415..681,M30004.1:129..410,M30004.1:907..1017,521..534)
+ # * [HUMMIC2A] replace((651.655)..(651.655),"")
+ # * [HUMSOD102] order(L44135.1:(454.445)..>538,<1..181)
+ #
+ # (E) one-of
+ #
+ # * [ECU17136] one-of(898,900)..983
+ # * [CELCYT1A] one-of(5971..6308,5971..6309)
+ # * [DMU17742] 8050..one-of(10731,10758,10905,11242)
+ # * [PFU27807] one-of(623,627,632)..one-of(628,633,637)
+ # * [BTBAINH1] one-of(845,953,963,1078,1104)..1354
+ # * [ATU39449] join(one-of(969..1094,970..1094,995..1094,1018..1094),1518..1587,1726..2119,2220..2833,2945..3215)
+ #
+ # (F) join, order, group
+ #
+ # * [AB037374S2] join(AB037374.1:1..177,1..807)
+ # * [AP000001] join(complement(1..61),complement(AP000007.1:252907..253505))
+ # * [ASNOS11] join(AF130124.1:<2563..2964,AF130125.1:21..157,AF130126.1:12..174,AF130127.1:21..112,AF130128.1:21..162,AF130128.1:281..595,AF130128.1:661..842,AF130128.1:916..1030,AF130129.1:21..115,AF130130.1:21..165,AF130131.1:21..125,AF130132.1:21..428,AF130132.1:492..746,AF130133.1:21..168,AF130133.1:232..401,AF130133.1:475..906,AF130133.1:970..1107,AF130133.1:1176..1367,21..>128)
+ #
+ # * [AARPOB2] order(AF194507.1:<1..510,1..>871)
+ # * [AF006691] order(912..1918,20410..21416)
+ # * [AF024666] order(complement(18919..19224),complement(13965..14892))
+ # * [AF264948] order(27066..27076,27089..27099,27283..27314,27330..27352)
+ # * [D63363] order(3..26,complement(964..987))
+ # * [ECOCURLI2] order(complement(1009..>1260),complement(AF081827.1:<1..177))
+ # * [S72388S2] order(join(S72388.1:757..911,S72388.1:609..1542),1..>139)
+ # * [HEYRRE07] order(complement(1..38),complement(M82666.1:1..140),complement(M82665.1:1..176),complement(M82664.1:1..215),complement(M82663.1:1..185),complement(M82662.1:1..49),complement(M82661.1:1..133))
+ # * [COL11A1G34] order(AF101079.1:558..1307,AF101080.1:1..749,AF101081.1:1..898,AF101082.1:1..486,AF101083.1:1..942,AF101084.1:1..1734,AF101085.1:1..2385,AF101086.1:1..1813,AF101087.1:1..2287,AF101088.1:1..1073,AF101089.1:1..989,AF101090.1:1..5017,AF101091.1:1..3401,AF101092.1:1..1225,AF101093.1:1..1072,AF101094.1:1..989,AF101095.1:1..1669,AF101096.1:1..918,AF101097.1:1..1114,AF101098.1:1..1074,AF101099.1:1..1709,AF101100.1:1..986,AF101101.1:1..1934,AF101102.1:1..1699,AF101103.1:1..940,AF101104.1:1..2330,AF101105.1:1..4467,AF101106.1:1..1876,AF101107.1:1..2465,AF101108.1:1..1150,AF101109.1:1..1170,AF101110.1:1..1158,AF101111.1:1..1193,1..611)
+ #
+ # group() are found in the COMMENT field only (in GenBank 122.0)
+ #
+ # gbpat2.seq: FT repeat_region group(598..606,611..619)
+ # gbpat2.seq: FT repeat_region group(8..16,1457..1464).
+ # gbpat2.seq: FT variation group(t1,t2)
+ # gbpat2.seq: FT variation group(t1,t3)
+ # gbpat2.seq: FT variation group(t1,t2,t3)
+ # gbpat2.seq: FT repeat_region group(11..202,203..394)
+ # gbpri9.seq:COMMENT Residues reported = 'group(1..2145);'.
+ #
+ # (G) ID:location
+ #
+ # * [AARPOB2] order(AF194507.1:<1..510,1..>871)
+ # * [AF178221S4] join(AF178221.1:<1..60,AF178222.1:1..63,AF178223.1:1..42,1..>90)
+ # * [BOVMHDQBY4] join(M30006.1:(392.467)..575,M30005.1:415..681,M30004.1:129..410,M30004.1:907..1017,521..534)
+ # * [HUMSOD102] order(L44135.1:(454.445)..>538,<1..181)
+ # * [SL16SRRN1] order(<1..>267,X67092.1:<1..>249,X67093.1:<1..>233)
+ #
+ # (I) <, >
+ #
+ # * [A5U48871] <1..>318
+ # * [AA23SRRNP] <1..388
+ # * [AA23SRRNP] 503..>1010
+ # * [AAM5961] complement(<1..229)
+ # * [AAM5961] complement(5231..>5598)
+ # * [AF043934] join(<1,60..99,161..241,302..370,436..594,676..887,993..1141,1209..1329,1387..1559,1626..1646,1708..>1843)
+ # * [BACSPOJ] <180..(731.761)
+ # * [BBU17998] (88.89)..>1122
+ # * [AARPOB2] order(AF194507.1:<1..510,1..>871)
+ # * [SL16SRRN1] order(<1..>267,X67092.1:<1..>249,X67093.1:<1..>233)
+ #
+ # (J) complement
+ #
+ # * [AF179299] complement(53^54) <= hoge insertion site etc.
+ # * [AP000001] join(complement(1..61),complement(AP000007.1:252907..253505))
+ # * [AF209868S2] order(complement(1..>308),complement(AF209868.1:75..336))
+ # * [AP000001] join(complement(1..61),complement(AP000007.1:252907..253505))
+ # * [CPPLCG] complement(<1..(1093.1098))
+ # * [D63363] order(3..26,complement(964..987))
+ # * [ECHTGA] complement((1700.1708)..(1715.1721))
+ # * [ECOUXW] order(complement(1658..1663),complement(1636..1641))
+ # * [LPATOVGNS] complement((64.74)..1525)
+ # * [AF129075] complement(join(71606..71829,75327..75446,76039..76203,76282..76353,76914..77029,77114..77201,77276..77342,78138..78316,79755..79892,81501..81562,81676..81856,82341..82490,84208..84287,85032..85122,88316..88403))
+ # * [ZFDYST2] join(AF137145.1:<1..18,complement(<1..99))
+ #
+ # (K) replace
+ #
+ # * [CSU27710] replace(64,"A")
+ # * [CELXOL1ES] replace(5256,"t")
+ # * [ANICPC] replace(1..468,"")
+ # * [CSU27710] replace(67..68,"GC")
+ # * [CELXOL1ES] replace(4480^4481,"") <= ? only one case in GenBank 122.0
+ # * [ECOUW87] replace(4792^4793,"a")
+ # * [CEU34893] replace(1..22,"ggttttaacccagttactcaag")
+ # * [APLPCII] replace(1905^1906,"acaaagacaccgccctacgcc")
+ # * [MBDR3S1] replace(1400..>9281,"")
+ # * [HUMMHDPB1F] replace(complement(36..37),"ttc")
+ # * [HUMMIC2A] replace((651.655)..(651.655),"")
+ # * [LEIMDRPGP] replace(1..1554,"L01572")
+ # * [TRBND3] replace(376..395,"atttgtgtgtggtaatta")
+ # * [TRBND3] replace(376..395,"atttgtgtgggtaatttta")
+ # * [TRBND3] replace(376..395,"attttgttgttgttttgttttgaatta")
+ # * [TRBND3] replace(376..395,"atgtgtggtgaatta")
+ # * [TRBND3] replace(376..395,"atgtgtgtggtaatta")
+ # * [TRBND3] replace(376..395,"gatttgttgtggtaatttta")
+ # * [MSU09460] replace(193, <= replace(193, "t")
+ # * [HUMMAGE12X] replace(3002..3003, <= replace(3002..3003, "GC")
+ # * [ADR40FIB] replace(510..520, <= replace(510..520, "taatcctaccg")
+ # * [RATDYIIAAB] replace(1306..1443,"aagaacatccacggagtcagaactgggctcttcacgccggatttggcgttcgaggccattgtgaaaaagcaggcaatgcaccagcaagctcagttcctacccctgcgtggacctggttatccaggagctaatcagtacagttaggtggtcaagctgaaagagccctgtctgaaa")
+ #
+
if __FILE__ == $0
puts "Test new & span methods"
Index: map.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/map.rb,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** map.rb 27 Jun 2006 12:40:15 -0000 1.8
--- map.rb 24 Dec 2006 10:10:08 -0000 1.9
***************
*** 2,54 ****
# = bio/map.rb - biological mapping class
#
! # Copyright:: Copyright (C) 2006
! # Jan Aerts <jan.aerts at bbsrc.ac.uk>
# Licence:: Ruby's
#
# $Id$
require 'bio/location'
module Bio
! # Add a method to Bio::Locations class
! class Locations
! def equals?(other)
! if ! other.kind_of?(Bio::Locations)
! return nil
! end
! if self.sort == other.sort
! return true
! else
! return false
! end
! end
! end
!
! # = DESCRIPTION
! # The Bio::Module contains classes that describe mapping information and can
! # be used to contain linkage maps, radiation-hybrid maps, etc.
! # As the same marker can be mapped to more than one map, and a single map
! # typically contains more than one marker, the link between the markers and
! # maps is handled by Bio::Map::Mapping objects. Therefore, to link a map to
! # a marker, a Bio::Mapping object is added to that Bio::Map. See usage below.
#
! # Not only maps in the strict sense have map-like features (and similarly
! # not only markers in the strict sense have marker-like features). For example,
! # a microsatellite is something that can be mapped on a linkage map (and
! # hence becomes a 'marker'), but a clone can also be mapped to a cytogenetic
! # map. In that case, the clone acts as a marker and has marker-like properties.
! # That same clone can also be considered a 'map' when BAC-end sequences are
! # mapped to it. To reflect this flexibility, the modules Bio::Map::ActsLikeMap
! # and Bio::Map::ActsLikeMarker define methods that are typical for maps and
! # markers.
#
#--
! # In a certain sense, a biological sequence also has map- and marker-like
! # properties: things can be mapped to it at certain locations, and the sequence
! # itself can be mapped to something else (e.g. the BAC-end sequence example
! # above, or a BLAST-result).
#++
#
! # = USAGE
# my_marker1 = Bio::Map::Marker.new('marker1')
# my_marker2 = Bio::Map::Marker.new('marker2')
--- 2,44 ----
# = bio/map.rb - biological mapping class
#
! # Copyright:: Copyright (C) 2006 Jan Aerts <jan.aerts at bbsrc.ac.uk>
# Licence:: Ruby's
#
# $Id$
+
require 'bio/location'
module Bio
! # == Description
#
! # The Bio::Map contains classes that describe mapping information
! # and can be used to contain linkage maps, radiation-hybrid maps,
! # etc. As the same marker can be mapped to more than one map, and a
! # single map typically contains more than one marker, the link
! # between the markers and maps is handled by Bio::Map::Mapping
! # objects. Therefore, to link a map to a marker, a Bio::Map::Mapping
! # object is added to that Bio::Map. See usage below.
! #
! # Not only maps in the strict sense have map-like features (and
! # similarly not only markers in the strict sense have marker-like
! # features). For example, a microsatellite is something that can be
! # mapped on a linkage map (and hence becomes a 'marker'), but a
! # clone can also be mapped to a cytogenetic map. In that case, the
! # clone acts as a marker and has marker-like properties. That same
! # clone can also be considered a 'map' when BAC-end sequences are
! # mapped to it. To reflect this flexibility, the modules
! # Bio::Map::ActsLikeMap and Bio::Map::ActsLikeMarker define methods
! # that are typical for maps and markers.
#
#--
! # In a certain sense, a biological sequence also has map- and
! # marker-like properties: things can be mapped to it at certain
! # locations, and the sequence itself can be mapped to something else
! # (e.g. the BAC-end sequence example above, or a BLAST-result).
#++
#
! # == Usage
! #
# my_marker1 = Bio::Map::Marker.new('marker1')
# my_marker2 = Bio::Map::Marker.new('marker2')
***************
*** 62,101 ****
# my_marker3.add_mapping_as_marker(my_map1, '9')
#
! # puts "Does my_map1 contain marker3? => " + my_map1.contains_marker?(my_marker3).to_s
! # puts "Does my_map2 contain marker3? => " + my_map2.contains_marker?(my_marker3).to_s
#
# my_map1.mappings_as_map.sort.each do |mapping|
! # puts mapping.map.name + "\t" + mapping.marker.name + "\t" + mapping.location.from.to_s + ".." + mapping.location.to.to_s
# end
# puts my_map1.mappings_as_map.min.marker.name
# my_map2.mappings_as_map.each do |mapping|
! # puts mapping.map.name + "\t" + mapping.marker.name + "\t" + mapping.location.from.to_s + ".." + mapping.location.to.to_s
# end
module Map
! # = DESCRIPTION
! # The Bio::Map::ActsLikeMap module contains methods that are typical for
! # map-like things:
! # * add markers with their locations (through Bio::Map::Mappings)
! # * check if a given marker is mapped to it
! # , and can be mixed into other classes (e.g. Bio::Map::SimpleMap)
! #
! # Classes that include this mixin should provide an array property called mappings_as_map.
! # For example:
! # class MyMapThing
! # include Bio::Map::ActsLikeMap
! #
! # def initialize (name)
! # @name = name
! # @mappings_as_maps = Array.new
! # end
! # attr_accessor :name, :mappings_as_map
! # end
module ActsLikeMap
! # = DESCRIPTION
# Adds a Bio::Map::Mappings object to its array of mappings.
#
! # = USAGE
# # suppose we have a Bio::Map::SimpleMap object called my_map
# my_map.add_mapping_as_map(Bio::Map::Marker.new('marker_a'), '5')
# ---
# *Arguments*:
--- 52,112 ----
# my_marker3.add_mapping_as_marker(my_map1, '9')
#
! # print "Does my_map1 contain marker3? => "
! # puts my_map1.contains_marker?(my_marker3).to_s
! # print "Does my_map2 contain marker3? => "
! # puts my_map2.contains_marker?(my_marker3).to_s
#
# my_map1.mappings_as_map.sort.each do |mapping|
! # puts [ mapping.map.name,
! # mapping.marker.name,
! # mapping.location.from.to_s,
! # mapping.location.to.to_s ].join("\t")
# end
# puts my_map1.mappings_as_map.min.marker.name
+ #
# my_map2.mappings_as_map.each do |mapping|
! # puts [ mapping.map.name,
! # mapping.marker.name,
! # mapping.location.from.to_s,
! # mapping.location.to.to_s ].join("\t")
# end
+ #
module Map
!
! # == Description
! #
! # The Bio::Map::ActsLikeMap module contains methods that are typical for
! # map-like things:
! #
! # * add markers with their locations (through Bio::Map::Mappings)
! # * check if a given marker is mapped to it,
! # and can be mixed into other classes (e.g. Bio::Map::SimpleMap)
! #
! # Classes that include this mixin should provide an array property
! # called mappings_as_map.
! #
! # For example:
! #
! # class MyMapThing
! # include Bio::Map::ActsLikeMap
! #
! # def initialize (name)
! # @name = name
! # @mappings_as_maps = Array.new
! # end
! # attr_accessor :name, :mappings_as_map
! # end
! #
module ActsLikeMap
!
! # == Description
! #
# Adds a Bio::Map::Mappings object to its array of mappings.
#
! # == Usage
! #
# # suppose we have a Bio::Map::SimpleMap object called my_map
# my_map.add_mapping_as_map(Bio::Map::Marker.new('marker_a'), '5')
+ #
# ---
# *Arguments*:
***************
*** 126,131 ****
return self
end
!
! # Checks whether a Bio::Map::Marker is mapped to this Bio::Map::SimpleMap.
# ---
# *Arguments*:
--- 137,144 ----
return self
end
!
! # Checks whether a Bio::Map::Marker is mapped to this
! # Bio::Map::SimpleMap.
! #
# ---
# *Arguments*:
***************
*** 146,160 ****
end
! end #ActsLikeMap
! # = DESCRIPTION
! # The Bio::Map::ActsLikeMarker module contains methods that are typical for
! # marker-like things:
# * map it to one or more maps
# * check if it's mapped to a given map
! # , and can be mixed into other classes (e.g. Bio::Map::Marker)
#
! # Classes that include this mixin should provide an array property called mappings_as_marker.
# For example:
# class MyMarkerThing
# include Bio::Map::ActsLikeMarker
--- 159,178 ----
end
! end # ActsLikeMap
! # == Description
! #
! # The Bio::Map::ActsLikeMarker module contains methods that are
! # typical for marker-like things:
! #
# * map it to one or more maps
# * check if it's mapped to a given map
! # and can be mixed into other classes (e.g. Bio::Map::Marker)
#
! # Classes that include this mixin should provide an array property
! # called mappings_as_marker.
! #
# For example:
+ #
# class MyMarkerThing
# include Bio::Map::ActsLikeMarker
***************
*** 166,176 ****
# attr_accessor :name, :mappings_as_marker
# end
module ActsLikeMarker
! # = DESCRIPTION
# Adds a Bio::Map::Mappings object to its array of mappings.
#
! # = USAGE
# # suppose we have a Bio::Map::Marker object called marker_a
# marker_a.add_mapping_as_marker(Bio::Map::SimpleMap.new('my_map'), '5')
# ---
# *Arguments*:
--- 184,199 ----
# attr_accessor :name, :mappings_as_marker
# end
+ #
module ActsLikeMarker
!
! # == Description
! #
# Adds a Bio::Map::Mappings object to its array of mappings.
#
! # == Usage
! #
# # suppose we have a Bio::Map::Marker object called marker_a
# marker_a.add_mapping_as_marker(Bio::Map::SimpleMap.new('my_map'), '5')
+ #
# ---
# *Arguments*:
***************
*** 242,252 ****
! end #ActsLikeMarker
! # = DESCRIPTION
# Creates a new Bio::Map::Mapping object, which links Bio::Map::ActsAsMap-
# and Bio::Map::ActsAsMarker-like objects. This class is typically not
# accessed directly, but through map- or marker-like objects.
class Mapping
include Comparable
--- 265,277 ----
! end # ActsLikeMarker
! # == Description
! #
# Creates a new Bio::Map::Mapping object, which links Bio::Map::ActsAsMap-
# and Bio::Map::ActsAsMarker-like objects. This class is typically not
# accessed directly, but through map- or marker-like objects.
class Mapping
+
include Comparable
***************
*** 283,296 ****
end # Mapping
! # = DESCRIPTION
! # This class handles the essential storage of name, type and units of a map.
! # It includes Bio::Map::ActsLikeMap, and therefore supports the methods of
! # that module.
#
! # = USAGE
# my_map1 = Bio::Map::SimpleMap.new('RH_map_ABC (2006)', 'RH', 'cR')
# my_map1.add_marker(Bio::Map::Marker.new('marker_a', '17')
# my_map1.add_marker(Bio::Map::Marker.new('marker_b', '5')
class SimpleMap
include Bio::Map::ActsLikeMap
--- 308,325 ----
end # Mapping
! # == Description
! #
! # This class handles the essential storage of name, type and units
! # of a map. It includes Bio::Map::ActsLikeMap, and therefore
! # supports the methods of that module.
#
! # == Usage
! #
# my_map1 = Bio::Map::SimpleMap.new('RH_map_ABC (2006)', 'RH', 'cR')
# my_map1.add_marker(Bio::Map::Marker.new('marker_a', '17')
# my_map1.add_marker(Bio::Map::Marker.new('marker_b', '5')
+ #
class SimpleMap
+
include Bio::Map::ActsLikeMap
***************
*** 324,336 ****
end # SimpleMap
! # = DESCRIPTION
! # This class handles markers that are anchored to a Bio::Map::SimpleMap. It
! # includes Bio::Map::ActsLikeMarker, and therefore supports the methods of
! # that module.
#
! # = USAGE
# marker_a = Bio::Map::Marker.new('marker_a')
# marker_b = Bio::Map::Marker.new('marker_b')
class Marker
include Bio::Map::ActsLikeMarker
--- 353,369 ----
end # SimpleMap
! # == Description
! #
! # This class handles markers that are anchored to a Bio::Map::SimpleMap.
! # It includes Bio::Map::ActsLikeMarker, and therefore supports the
! # methods of that module.
#
! # == Usage
! #
# marker_a = Bio::Map::Marker.new('marker_a')
# marker_b = Bio::Map::Marker.new('marker_b')
+ #
class Marker
+
include Bio::Map::ActsLikeMarker
***************
*** 352,355 ****
--- 385,390 ----
end # Marker
+
end # Map
+
end # Bio
More information about the bioruby-cvs
mailing list