bio-location-rdfize 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e790f241f369b6259cc3673b417a50bfd083c7a0
4
+ data.tar.gz: 5c55e227f676456077aa813aa2ee7cfa8033f2c3
5
+ SHA512:
6
+ metadata.gz: 9840ea8658624ba6d8697cf45803800729b60cccf62d535e3a250ca4158fc4cb1112ff985f757a67e168b97e093be1cb18cafab355760180de5589f8b5c2f166
7
+ data.tar.gz: 8b3e29e9aa7f13555d1d4f1f1e60cac37a27c9daed004c809bcb10ed7813909d416d03add1e8ade5645c483cd6ec0f637bfd99cb3d72bcad7e560d216e4c4b02
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - jruby-19mode # JRuby in 1.9 mode
6
+
7
+ # - rbx-19mode
8
+ # - 1.8.7
9
+ # - jruby-18mode # JRuby in 1.8 mode
10
+ # - rbx-18mode
11
+
12
+ # uncomment this line if your project needs to run something other than `rake`:
13
+ # script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem "bio", ">= 1.4.2"
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "rake"
12
+ gem "rdoc"
13
+ gem "jeweler"
14
+ gem "bundler", ">= 1.0.21"
15
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Naohisa Goto
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ # bio-location-rdfize
2
+
3
+ [![Build Status](https://secure.travis-ci.org/ngoto/bioruby-location-rdfize.png)](http://travis-ci.org/ngoto/bioruby-location-rdfize)
4
+
5
+ Full description goes here
6
+
7
+ Note: this software is under active development!
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ gem install bio-location-rdfize
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```ruby
18
+ require 'bio-location-rdfize'
19
+ ```
20
+
21
+ The API doc is online. For more code examples see the test files in
22
+ the source tree.
23
+
24
+ ## Project home page
25
+
26
+ Information on the source tree, documentation, examples, issues and
27
+ how to contribute, see
28
+
29
+ http://github.com/ngoto/bioruby-location-rdfize
30
+
31
+ The BioRuby community is on IRC server: irc.freenode.org, channel: #bioruby.
32
+
33
+ ## Cite
34
+
35
+ If you use this software, please cite one of
36
+
37
+ * [BioRuby: bioinformatics software for the Ruby programming language](http://dx.doi.org/10.1093/bioinformatics/btq475)
38
+ * [Biogem: an effective tool-based approach for scaling up open source software development in bioinformatics](http://dx.doi.org/10.1093/bioinformatics/bts080)
39
+
40
+ ## Biogems.info
41
+
42
+ This Biogem is published at (http://biogems.info/index.html#bio-location-rdfize)
43
+
44
+ ## Copyright
45
+
46
+ Copyright (c) 2014 Naohisa Goto. See LICENSE.txt for further details.
47
+
@@ -0,0 +1,48 @@
1
+ = bio-location-rdfize
2
+
3
+ {<img
4
+ src="https://secure.travis-ci.org/ngoto/bioruby-location-rdfize.png"
5
+ />}[http://travis-ci.org/#!/ngoto/bioruby-location-rdfize]
6
+
7
+ Full description goes here
8
+
9
+ Note: this software is under active development!
10
+
11
+ == Installation
12
+
13
+ gem install bio-location-rdfize
14
+
15
+ == Usage
16
+
17
+ == Developers
18
+
19
+ To use the library
20
+
21
+ require 'bio-location-rdfize'
22
+
23
+ The API doc is online. For more code examples see also the test files in
24
+ the source tree.
25
+
26
+ == Project home page
27
+
28
+ Information on the source tree, documentation, issues and how to contribute, see
29
+
30
+ http://github.com/ngoto/bioruby-location-rdfize
31
+
32
+ The BioRuby community is on IRC server: irc.freenode.org, channel: #bioruby.
33
+
34
+ == Cite
35
+
36
+ If you use this software, please cite one of
37
+
38
+ * [BioRuby: bioinformatics software for the Ruby programming language](http://dx.doi.org/10.1093/bioinformatics/btq475)
39
+ * [Biogem: an effective tool-based approach for scaling up open source software development in bioinformatics](http://dx.doi.org/10.1093/bioinformatics/bts080)
40
+
41
+ == Biogems.info
42
+
43
+ This Biogem is published at http://biogems.info/index.html#bio-location-rdfize
44
+
45
+ == Copyright
46
+
47
+ Copyright (c) 2014 Naohisa Goto. See LICENSE.txt for further details.
48
+
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "bio-location-rdfize"
18
+ gem.homepage = "http://github.com/ngoto/bioruby-location-rdfize"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{FALDO location output method for Bio::Location in BioRuby}
21
+ gem.description = %Q{This is a BioRuby plugin providing FALDO location RDF output method for Bio::Location objects. A method Bio::Location#rdfize is added.}
22
+ gem.email = "ng@bioruby.org"
23
+ gem.authors = [ "Joachim Baran", "Naohisa Goto" ]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ desc "Code coverage detail"
36
+ task :simplecov do
37
+ ENV['COVERAGE'] = "true"
38
+ Rake::Task['test'].execute
39
+ end
40
+
41
+ task :default => :test
42
+
43
+ require 'rdoc/task'
44
+ Rake::RDocTask.new do |rdoc|
45
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
+
47
+ rdoc.rdoc_dir = 'rdoc'
48
+ rdoc.title = "bio-location-rdfize #{version}"
49
+ rdoc.rdoc_files.include('README*')
50
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,13 @@
1
+ # Please require your code below, respecting the naming conventions in the
2
+ # bioruby directory tree.
3
+ #
4
+ # For example, say you have a plugin named bio-plugin, the only uncommented
5
+ # line in this file would be
6
+ #
7
+ # require 'bio/bio-plugin/plugin'
8
+ #
9
+ # In this file only require other files. Avoid other source code.
10
+
11
+ require 'bio'
12
+ require 'bio-location-rdfize/location-rdfize.rb'
13
+
@@ -0,0 +1,127 @@
1
+ #
2
+ # Copyright:: Copyright (C) 2014 Joachim Baran <joachim.baran@gmail.com>
3
+ # License:: The Ruby License
4
+
5
+ module Bio
6
+
7
+ # Bio::Location is a class in BioRuby.
8
+ # For adding methods, the module Bio::Location::RDFize is included.
9
+ class Location
10
+
11
+ # Bio::Location::RDFize is a module for providing
12
+ # Bio::Location#rdfize method.
13
+ # For the usage of the method, see the documentation of
14
+ # Bio::Location::RDFize#rdfize.
15
+ #
16
+ module RDFize
17
+
18
+ # Base URI of FALDO for use with rdfize and rdfize_positions:
19
+ FALDO = 'http://biohackathon.org/resource/faldo#'.freeze
20
+
21
+ # Returns a FALDO based representation of the location
22
+ # in RDF Turtle format.
23
+ # *Arguments*:
24
+ # * (required) _prefix_: URI prefix of the location's URIs
25
+ # *Returns*::
26
+ # * a string containing the location formatted using FALDO
27
+ # in RDF Turtle format; the URI prefix will be prepended
28
+ # before either xref ID or a composite string that captures
29
+ # the location uniquely
30
+ def rdfize(prefix)
31
+ # Less-than/greater-than (@lt, @gt) are currently not holding
32
+ # enough information to determine whether a single seq. position
33
+ # is affected, or whether start/end positions are targeted by
34
+ # the relation.
35
+ # For example, "<500..>1000" and ">500..<1000" are both encoded
36
+ # as:
37
+ # @lt = @gt = true
38
+ # @from = 500
39
+ # @to = 1000
40
+ # It is an ambiguous representation and the original meaning
41
+ # can no longer be determined.
42
+ if @lt or @gt
43
+ raise "Error: cannot RDFize locations with < or > in them. Sorry."
44
+ end
45
+
46
+ if @strand == 1
47
+ faldo_begin, faldo_end = @from, @to
48
+ else
49
+ # Reverse begin/end, if on the reverse strand (5'-3' FALDO requirement)
50
+ faldo_end, faldo_begin = faldo_begin, faldo_end
51
+ end
52
+
53
+ id = @xref_id
54
+ unless id
55
+ id = "Location#{faldo_begin}-#{faldo_end}:#{@strand}"
56
+ end
57
+
58
+ if @caret
59
+ return """<#{prefix}#{id}> a <#{FALDO}InBetweenPosition> ;
60
+ <#{FALDO}after> <#{prefix}#{id}:begin> ;
61
+ <#{FALDO}before> <#{prefix}#{id}:end> .
62
+
63
+ #{rdfize_positions("#{prefix}#{id}", faldo_begin, faldo_end)}
64
+ """
65
+ end
66
+
67
+ if @from == @to
68
+ begin_uri_suffix = 'position'
69
+ end_uri_suffix = 'position'
70
+ else
71
+ begin_uri_suffix = 'begin'
72
+ end_uri_suffix = 'end'
73
+ end
74
+
75
+ return """<#{prefix}#{id}> a <#{FALDO}Region> ;
76
+ <#{FALDO}begin> <#{prefix}#{id}:#{begin_uri_suffix}> ;
77
+ <#{FALDO}end> <#{prefix}#{id}:#{end_uri_suffix}> .
78
+
79
+ #{rdfize_positions("#{prefix}#{id}", faldo_begin, faldo_end, begin_uri_suffix, end_uri_suffix)}
80
+ """
81
+ end
82
+
83
+ private
84
+
85
+ # Returns FALDO ExactPosition RDF Turtle for @from and @to. Will only
86
+ # serialize a single position if begin/end URI suffixes coincide.
87
+ #
88
+ # *Arguments*:
89
+ # * (required) _location_prefix_: URI prefix of the location object
90
+ # whose positions are being described here
91
+ # * (required) _faldo_begin_: start coordinate of the location
92
+ # * (required) _faldo_end_: end coordinate of the location
93
+ # * (optional) _begin_suffix_ : URI suffix that should be used for faldo_begin coodinate
94
+ # * (optional) _end_suffix_ : URI suffix that should be used for faldo_end coodinate
95
+ # *Returns*::
96
+ # * a string containing FALDO ExactPosition instances that represent
97
+ # the location's start/end coordinates.
98
+ def rdfize_positions(location_prefix, faldo_begin, faldo_end, begin_suffix = 'begin', end_suffix = 'end')
99
+ if @strand == 1
100
+ strandtype = "<#{FALDO}ForwardStrandedPosition>"
101
+ else
102
+ strandtype = "<#{FALDO}ReverseStrandedPosition>"
103
+ end
104
+
105
+ begin_uri = """<#{location_prefix}:#{begin_suffix}> a <#{FALDO}ExactPosition>, #{strandtype} ;
106
+ <#{FALDO}position> #{faldo_begin} .
107
+ """
108
+
109
+ if begin_suffix == end_suffix
110
+ end_uri = ''
111
+ else
112
+ end_uri = """<#{location_prefix}:#{end_suffix}> a <#{FALDO}ExactPosition>, #{strandtype} ;
113
+ <#{FALDO}position> #{faldo_end} .
114
+ """
115
+ end
116
+
117
+ return begin_uri + end_uri
118
+ end
119
+
120
+ end #module RDFize
121
+
122
+ # adding the above methods to Bio::Locations
123
+ include RDFize
124
+
125
+ end # Locations
126
+
127
+ end # Bio
@@ -0,0 +1,36 @@
1
+ #
2
+ #require 'simplecov'
3
+ #
4
+ #module SimpleCov::Configuration
5
+ # def clean_filters
6
+ # @filters = []
7
+ # end
8
+ #end
9
+ #
10
+ #SimpleCov.configure do
11
+ # clean_filters
12
+ # load_adapter 'test_frameworks'
13
+ #end
14
+ #
15
+ #ENV["COVERAGE"] && SimpleCov.start do
16
+ # add_filter "/.rvm/"
17
+ #end
18
+ #
19
+ require 'rubygems'
20
+ #require 'bundler'
21
+ #begin
22
+ # Bundler.setup(:default, :development)
23
+ #rescue Bundler::BundlerError => e
24
+ # $stderr.puts e.message
25
+ # $stderr.puts "Run `bundle install` to install missing gems"
26
+ # exit e.status_code
27
+ #end
28
+ require 'test/unit'
29
+ #require 'shoulda'
30
+
31
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
32
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
33
+ require 'bio-location-rdfize'
34
+
35
+ class Test::Unit::TestCase
36
+ end
@@ -0,0 +1,51 @@
1
+
2
+ # To run this test,
3
+ # % bundle exec rake test
4
+ # or
5
+ # % rake test
6
+ #
7
+
8
+ require 'helper'
9
+ require 'bio'
10
+
11
+ class TestBioLocationRdfize < Test::Unit::TestCase
12
+
13
+ PREFIX = "http://localhost/test#".freeze
14
+
15
+ def test_forward
16
+ loc = Bio::Locations.new("123..456")[0]
17
+
18
+ expected = <<EXPECTED
19
+ <http://localhost/test#Location123-456:1> a <http://biohackathon.org/resource/faldo#Region> ;
20
+ <http://biohackathon.org/resource/faldo#begin> <http://localhost/test#Location123-456:1:begin> ;
21
+ <http://biohackathon.org/resource/faldo#end> <http://localhost/test#Location123-456:1:end> .
22
+
23
+ <http://localhost/test#Location123-456:1:begin> a <http://biohackathon.org/resource/faldo#ExactPosition>, <http://biohackathon.org/resource/faldo#ForwardStrandedPosition> ;
24
+ <http://biohackathon.org/resource/faldo#position> 123 .
25
+ <http://localhost/test#Location123-456:1:end> a <http://biohackathon.org/resource/faldo#ExactPosition>, <http://biohackathon.org/resource/faldo#ForwardStrandedPosition> ;
26
+ <http://biohackathon.org/resource/faldo#position> 456 .
27
+
28
+ EXPECTED
29
+
30
+ assert_equal(expected, loc.rdfize(PREFIX))
31
+ end
32
+
33
+ def test_reverse
34
+ loc = Bio::Locations.new("complement(123..456)")[0]
35
+
36
+ expected = <<EXPECTED
37
+ <http://localhost/test#Location-:-1> a <http://biohackathon.org/resource/faldo#Region> ;
38
+ <http://biohackathon.org/resource/faldo#begin> <http://localhost/test#Location-:-1:begin> ;
39
+ <http://biohackathon.org/resource/faldo#end> <http://localhost/test#Location-:-1:end> .
40
+
41
+ <http://localhost/test#Location-:-1:begin> a <http://biohackathon.org/resource/faldo#ExactPosition>, <http://biohackathon.org/resource/faldo#ReverseStrandedPosition> ;
42
+ <http://biohackathon.org/resource/faldo#position> .
43
+ <http://localhost/test#Location-:-1:end> a <http://biohackathon.org/resource/faldo#ExactPosition>, <http://biohackathon.org/resource/faldo#ReverseStrandedPosition> ;
44
+ <http://biohackathon.org/resource/faldo#position> .
45
+
46
+ EXPECTED
47
+
48
+ assert_equal(expected, loc.rdfize(PREFIX))
49
+ end
50
+
51
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bio-location-rdfize
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Joachim Baran
8
+ - Naohisa Goto
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-11-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bio
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 1.4.2
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: 1.4.2
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rdoc
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: jeweler
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: bundler
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 1.0.21
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 1.0.21
84
+ description: This is a BioRuby plugin providing FALDO location RDF output method for
85
+ Bio::Location objects. A method Bio::Location#rdfize is added.
86
+ email: ng@bioruby.org
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files:
90
+ - LICENSE.txt
91
+ - README.md
92
+ - README.rdoc
93
+ files:
94
+ - ".document"
95
+ - ".travis.yml"
96
+ - Gemfile
97
+ - LICENSE.txt
98
+ - README.md
99
+ - README.rdoc
100
+ - Rakefile
101
+ - VERSION
102
+ - lib/bio-location-rdfize.rb
103
+ - lib/bio-location-rdfize/location-rdfize.rb
104
+ - test/helper.rb
105
+ - test/test_bio-location-rdfize.rb
106
+ homepage: http://github.com/ngoto/bioruby-location-rdfize
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.2.2
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: FALDO location output method for Bio::Location in BioRuby
130
+ test_files: []