[BioRuby-cvs] bioruby/lib/bio feature.rb,1.11,1.12
Jan Aerts
aerts at dev.open-bio.org
Tue May 9 11:52:32 UTC 2006
Update of /home/repository/bioruby/bioruby/lib/bio
In directory dev.open-bio.org:/tmp/cvs-serv19592
Modified Files:
feature.rb
Log Message:
Reverted to previous behaviour: new takes array of Bio::Feature::Qualifiers
instead of list of qualifier_key, qualifier_value pairs.
Index: feature.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/feature.rb,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** feature.rb 26 Apr 2006 11:05:50 -0000 1.11
--- feature.rb 9 May 2006 11:52:30 -0000 1.12
***************
*** 23,27 ****
# # /note="cytochrome P450 IID6; GOO-132-127"
# # /number="1"
! # feature = Bio::Feature.new('exon','1532..1799',['gene' => 'CYP2D6','note' => 'cytochrome P450 IID6; GOO-132-127','number' => '1'])
#
# # Print the feature
--- 23,37 ----
# # /note="cytochrome P450 IID6; GOO-132-127"
# # /number="1"
! # feature = Bio::Feature.new('exon','1532..1799')
! # feature.append(Bio::Feature::Qualifier.new('gene', 'CYP2D6'))
! # feature.append(Bio::Feature::Qualifier.new('note', 'cytochrome P450 IID6'))
! # feature.append(Bio::Feature::Qualifier.new('number', '1'))
! #
! # # or all in one go:
! # feature2 = Bio::Feature.new('exon','1532..1799',
! # [ Bio::Feature::Qualifier.new('gene', 'CYP2D6'),
! # Bio::Feature::Qualifier.new('note', 'cytochrome P450 IID6; GOO-132-127'),
! # Bio::Feature::Qualifier.new('number', '1')
! # ])
#
# # Print the feature
***************
*** 38,54 ****
# * (required) _feature_: type of feature (e.g. "exon")
# * (required) _position_: position of feature (e.g. "complement(1532..1799)")
! # * (optional) _qualifiers_: list of qualifiers (e.g. "['gene' => 'CYP2D6','number' => '1']")
# *Returns*:: Bio::Feature object
def initialize(feature = '', position = '', qualifiers = [])
! @feature, @position = feature, position
! @qualifiers = Array.new
! if qualifiers.length.modulo(2) > 0
! $stderr.puts "WARNING"
! end
! while qualifiers.length > 0
! key = qualifiers.shift
! value = qualifiers.shift || ''
! self.append(Qualifier.new(key, value))
! end
end
--- 48,55 ----
# * (required) _feature_: type of feature (e.g. "exon")
# * (required) _position_: position of feature (e.g. "complement(1532..1799)")
! # * (opt) _qualifiers_: list of Bio::Feature::Qualifier objects (default: [])
# *Returns*:: Bio::Feature object
def initialize(feature = '', position = '', qualifiers = [])
! @feature, @position, @qualifiers = feature, position, qualifiers
end
***************
*** 131,137 ****
attr_reader :value
! end
! end
--- 132,138 ----
attr_reader :value
! end #Qualifier
! end #Feature
***************
*** 141,148 ****
# = USAGE
# # First, create some Bio::Feature objects
! # feature1 = Bio::Feature.new('intron','3627..4059',['gene', 'CYP2D6', 'note', 'G00-132-127','number','4'])
! # feature2 = Bio::Feature.new('exon','4060..4236',['gene', 'CYP2D6', 'note', 'G00-132-127','number','5'])
! # feature3 = Bio::Feature.new('intron','4237..4426',['gene', 'CYP2D6', 'note', 'G00-132-127','number','5'])
! # feature4 = Bio::Feature.new('CDS','join(2538..3626,4060..4236)',['gene', 'CYP2D6','translation','MGXXTVMHLL...'])
#
# # And create a container for them
--- 142,152 ----
# = USAGE
# # First, create some Bio::Feature objects
! # feature1 = Bio::Feature.new('intron','3627..4059')
! # feature2 = Bio::Feature.new('exon','4060..4236')
! # feature3 = Bio::Feature.new('intron','4237..4426')
! # feature4 = Bio::Feature.new('CDS','join(2538..3626,4060..4236)',
! # [ Bio::Feature::Qualifier.new('gene', 'CYP2D6'),
! # Bio::Feature::Qualifier.new('translation','MGXXTVMHLL...')
! # ])
#
# # And create a container for them
***************
*** 217,257 ****
end
! end
end # Bio
- if __FILE__ == $0
- puts "---TESTING Bio::Feature"
- feature1 = Bio::Feature.new('exon','1532..1799',['gene','CYP2D6','note','cytochrome P450 IID6; GOO-132-127','number','1', 'note', 'a second note'])
-
- # Print the feature out
- puts feature1.feature + "\t" + feature1.position
- feature1.each do |qualifier|
- puts "- " + qualifier.qualifier + ": " + qualifier.value
- end
-
- feature2 = Bio::Feature.new('CDS','join(2538..3626,4060..4236)',['gene', 'CYP2D6','translation','MGXXTVMHLL...'])
-
- puts "---TESTING Bio::Features"
- feature3 = Bio::Feature.new('intron','3627..4059',['gene', 'CYP2D6', 'note', 'G00-132-127','number','4'])
- feature4 = Bio::Feature.new('exon','4060..4236',['gene', 'CYP2D6', 'note', 'G00-132-127','number','5'])
- feature5 = Bio::Feature.new('intron','4237..4426',['gene', 'CYP2D6', 'note', 'G00-132-127','number','5'])
- feature_container = Bio::Features.new([ feature1, feature2, feature3, feature4, feature5 ])
- feature_container.each do |feature|
- puts "-NEXT FEATURE"
- puts feature.feature + "\t" + feature.position
- feature.each do |qualifier|
- puts "- " + qualifier.qualifier + ": " + qualifier.value
- end
- end
-
- puts "---TESTING hash function"
- feature_container.each('CDS') do |feature|
- hash = feature.to_hash
- name = hash["gene"] || hash["product"] || hash["note"]
- aaseq = hash["translation"]
- pos = feature.position
- puts ">#{name} #{feature.position}"
- puts aaseq
- end
- end
--- 221,226 ----
end
! end # Features
end # Bio
More information about the bioruby-cvs
mailing list