bin/bel2rdf.rb in bel-0.6.0 vs bin/bel2rdf.rb in bel-0.7.0
- old
+ new
@@ -44,19 +44,39 @@
opts.on('-f', '--format FORMAT', 'RDF file format. The default output format is N-Triples.') do |format|
options[:format] = format.downcase
end
+
+ opts.on('-p', '--rdf-prefix-file FILE', "A YAML file mapping prefix containing key/value pairs. The key is an RDF prefix to use in the RDF output; the value is the RDF URI for that prefix. For example, belv: 'http://www.openbel.org/vocabulary/'.") do |prefix_file|
+ options[:rdf_prefix_file] = prefix_file
+ end
+
opts.on('-s', '--[no-]schema', 'Write BEL RDF schema? The default is to include the schema in the output.') do |schema|
options[:schema] = schema
end
+
+ opts.on('-r', '--remap-file FILE', 'A YAML file that remaps annotation and namespace definitions. Run "bel remapfile" to get an example of the YAML format.') do |remap_file|
+ options[:remap_file] = remap_file
+ end
end.parse!
if options[:bel] and not File.exists? options[:bel]
$stderr.puts "No file for bel, #{options[:bel]}"
exit 1
end
+
+if options[:rdf_prefix_file] and not File.exists? options[:rdf_prefix_file]
+ $stderr.puts "No file for rdf_prefix_file, #{options[:rdf_prefix_file]}"
+ exit 1
+end
+
+if options[:remap_file] and not File.exist? options[:remap_file]
+ $stderr.puts "No file for remap_file, #{options[:remap_file]}"
+ exit 1
+end
+
unless RDF_TRANSLATORS.include? options[:format]
$stderr.puts "Format must be one of: #{RDF_TRANSLATORS.join(', ')}"
exit 1
end
@@ -75,20 +95,22 @@
end
# read bel content
input_io =
if options[:bel]
- File.open(options[:bel], :external_encoding => 'UTF-8')
+ File.open(options[:bel], external_encoding: 'UTF-8')
else
$stdin
end
validate_translator!(:bel)
validate_translator!(options[:format])
begin
BEL.translate(input_io, :bel, options[:format], $stdout,
{
- :write_schema => options[:schema]
+ write_schema: options[:schema],
+ rdf_prefix_file: options[:rdf_prefix_file],
+ remap_file: options[:remap_file]
}
)
ensure
$stdout.close
end