[BioRuby-cvs] bioruby/lib/bio feature.rb,1.13,1.13.2.1
Naohisa Goto
ngoto at dev.open-bio.org
Tue Mar 4 10:12:24 UTC 2008
Update of /home/repository/bioruby/bioruby/lib/bio
In directory dev.open-bio.org:/tmp/cvs-serv7351/lib/bio
Modified Files:
Tag: BRANCH-biohackathon2008
feature.rb
Log Message:
Bio::Features is moved to lib/bio/compat/features.rb, and a module to
keep backward compatibility (Bio::Features::BackwardCompatibility) is added.
Index: feature.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/feature.rb,v
retrieving revision 1.13
retrieving revision 1.13.2.1
diff -C2 -d -r1.13 -r1.13.2.1
*** feature.rb 5 Apr 2007 23:35:39 -0000 1.13
--- feature.rb 4 Mar 2008 10:12:22 -0000 1.13.2.1
***************
*** 136,226 ****
end #Feature
-
- # = DESCRIPTION
- # Container for a list of Feature objects.
- #
- # = 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
- # feature_container = Bio::Features.new([ feature1, feature2, feature3, feature4 ])
- #
- # # Iterate over all features and print
- # feature_container.each do |feature|
- # puts feature.feature + "\t" + feature.position
- # feature.each do |qualifier|
- # puts "- " + qualifier.qualifier + ": " + qualifier.value
- # end
- # end
- #
- # # Iterate only over CDS features and extract translated amino acid sequences
- # features.each("CDS") do |feature|
- # hash = feature.to_hash
- # name = hash["gene"] || hash["product"] || hash["note"]
- # aaseq = hash["translation"]
- # pos = feature.position
- # if name and seq
- # puts ">#{gene} #{feature.position}"
- # puts aaseq
- # end
- # end
- class Features
- # Create a new Bio::Features object.
- #
- # *Arguments*:
- # * (optional) _list of features_: list of Bio::Feature objects
- # *Returns*:: Bio::Features object
- def initialize(ary = [])
- @features = ary
- end
-
- # Returns an Array of Feature objects.
- attr_accessor :features
-
- # Appends a Feature object to Features.
- #
- # *Arguments*:
- # * (required) _feature_: Bio::Feature object
- # *Returns*:: Bio::Features object
- def append(a)
- @features.push(a) if a.is_a? Feature
- return self
- end
-
- # Iterates on each feature object.
- #
- # *Arguments*:
- # * (optional) _key_: if specified, only iterates over features with this key
- def each(arg = nil)
- @features.each do |x|
- next if arg and x.feature != arg
- yield x
- end
- end
-
- # Short cut for the Features#features[n]
- def [](*arg)
- @features[*arg]
- end
-
- # Short cut for the Features#features.first
- def first
- @features.first
- end
-
- # Short cut for the Features#features.last
- def last
- @features.last
- end
-
- end # Features
-
end # Bio
--- 136,139 ----
More information about the bioruby-cvs
mailing list