Module: BioExominer::RDF
- Defined in:
- lib/bio-exominer/rdf.rb
Overview
FIXME: use bioruby-rdf modules instead! It is all there now.
Class Method Summary collapse
-
.make_identifier(s) ⇒ Object
An identifier is used for the subject and predicate in RDF.
- .valid_uri?(uri) ⇒ Boolean
Class Method Details
.make_identifier(s) ⇒ Object
An identifier is used for the subject and predicate in RDF. This is a case-sensitive (shortened) URI. You can change default behaviour for identifiers using the options –transform-ids (i.e. in the input side, rather than the output side)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/bio-exominer/rdf.rb', line 16 def RDF::make_identifier(s) id = s.strip.gsub(/[^[:print:]]/, '').gsub(/[#)(,]/,"").gsub(/[%]/,"perc").gsub(/(\s|\.|\$|\/|\\)+/,"_") # id = URI::escape(id) id = id.gsub(/\|/,'_') id = id.gsub(/\-|:/,'_') if id != s # logger = Bio::Log::LoggerPlus['bio-table'] $stderr.print "\nWARNING: Changed identifier <#{s}> to <#{id}>" end if not RDF::valid_uri?(id) raise "Invalid URI after mangling <#{s}> to <#{id}>!" end valid_id = if id =~ /^\d/ 'r' + id else id end valid_id end |
.valid_uri?(uri) ⇒ Boolean
8 9 10 |
# File 'lib/bio-exominer/rdf.rb', line 8 def RDF::valid_uri? uri uri =~ /^([!#$&-;=?_a-z~]|%[0-9a-f]{2})+$/i end |