Skip to content

Commit

Permalink
renaming some functions in the new operations files
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Apr 20, 2024
1 parent ad16740 commit fdc43b5
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 71 deletions.
2 changes: 2 additions & 0 deletions lib/ontologies_linked_data/models/class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ def index_doc(to_set=nil)
puts "Exception getting paths to root for search for #{self.id.to_s}: #{e.class}: #{e.message}\n#{e.backtrace.join("\n")}"
end

self.submission.ontology.bring(:ontologyType) if self.submission.ontology.bring?(:ontologyType)

doc[:ontologyId] = self.submission.id.to_s
doc[:submissionAcronym] = self.submission.ontology.acronym
doc[:submissionId] = self.submission.submissionId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def process_submission(logger, options = {})
LinkedData::Services::OntologyProcessor.new(self).process(logger, options)
end

def generate_missing_label(logger)
def generate_missing_labels(logger)
puts 'Start generate_mission_label'
time = Benchmark.realtime do
LinkedData::Services::GenerateMissingLabels.new(self).process(logger, file_path: self.master_file_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ class OntologySubmissionArchiver < OntologySubmissionProcess
FILE_SIZE_ZIPPING_THRESHOLD = 100 * 1024 * 1024 # 100MB

def process
submission_archive
archive_submission
end

private

def submission_archive
def archive_submission
@submission.ontology.bring(:submissions)
submissions = @submission.ontology.submissions
return if submissions.nil?
Expand All @@ -26,6 +26,8 @@ def submission_archive
status = LinkedData::Models::SubmissionStatus.find("ARCHIVED").first
@submission.add_submission_status(status)

@submission.unindex

# Delete everything except for original ontology file.
delete_old_submission_files
@submission.uploadFilePath = zip_submission_uploaded_file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ def process_indexation(logger, options)
begin
index(logger, options[:commit], false)
@submission.add_submission_status(status)
rescue Exception => e
rescue StandardError => e
logger.error("#{e.class}: #{e.message}\n#{e.backtrace.join("\n\t")}")
logger.flush
@submission.add_submission_status(status.get_error_status)
if File.file?(@submission.csv_path)
FileUtils.rm(@submission.csv_path)
end
FileUtils.rm(@submission.csv_path) if File.file?(@submission.csv_path)
ensure
@submission.save
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ def generate_metrics_file(class_count, indiv_count, prop_count)
end
end

# TODO to find usage in NCBO code
def generate_metrics_file2(class_count, indiv_count, prop_count, max_depth)
CSV.open(self.metrics_path, "wb") do |csv|
csv << ["Class Count", "Individual Count", "Property Count", "Max Depth"]
csv << [class_count, indiv_count, prop_count, max_depth]
end
end

end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -76,57 +76,6 @@ def generate_obsolete_classes(logger, file_path)
mime_type = "application/x-turtle")
end
end

def generate_rdf(logger, file_path, reasoning: true)
mime_type = nil

if @submission.hasOntologyLanguage.umls?
triples_file_path = @submission.triples_file_path
logger.info("Using UMLS turtle file found, skipping OWLAPI parse")
logger.flush
mime_type = LinkedData::MediaTypes.media_type_from_base(LinkedData::MediaTypes::TURTLE)
SubmissionMetricsCalculator.new(@submission).generate_umls_metrics_file(triples_file_path)
else
output_rdf = @submission.rdf_path

if File.exist?(output_rdf)
logger.info("deleting old owlapi.xrdf ..")
deleted = FileUtils.rm(output_rdf)

if deleted.length > 0
logger.info("deleted")
else
logger.info("error deleting owlapi.rdf")
end
end
owlapi = LinkedData::Parser::OWLAPICommand.new(
File.expand_path(file_path),
File.expand_path(@submission.data_folder.to_s),
master_file: @submission.masterFileName)

owlapi.disable_reasoner unless reasoning
triples_file_path, missing_imports = owlapi.parse

if missing_imports && missing_imports.length > 0
@submission.missingImports = missing_imports

missing_imports.each do |imp|
logger.info("OWL_IMPORT_MISSING: #{imp}")
end
else
@submission.missingImports = nil
end
logger.flush
end
delete_and_append(triples_file_path, logger, mime_type)
end

def delete_and_append(triples_file_path, logger, mime_type = nil)
Goo.sparql_data_client.delete_graph(@submission.id)
Goo.sparql_data_client.put_triples(@submission.id, triples_file_path, mime_type)
logger.info("Triples #{triples_file_path} appended in #{@submission.id.to_ntriples}")
logger.flush
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def index_properties(logger, commit: true, optimize: true)
@submission.ontology.bring(:acronym) if @submission.ontology.bring?(:acronym)
logger.info("Indexing ontology properties: #{@submission.ontology.acronym}...")
t0 = Time.now
@submission.ontology.unindex_all_data(commit)
@submission.ontology.unindex_properties(commit)
logger.info("Removed ontology properties index in #{Time.now - t0} seconds."); logger.flush

props = @submission.ontology.properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class SubmissionRDFGenerator < OntologySubmissionProcess

def process(logger, options)
reasoning = options[:reasoning]

# Remove processing status types before starting RDF parsing etc.
@submission.submissionStatus = nil
status = LinkedData::Models::SubmissionStatus.find('UPLOADED').first
Expand All @@ -27,7 +27,7 @@ def process(logger, options)
generate_rdf(logger, reasoning: reasoning)
@submission.add_submission_status(status)
@submission.save
rescue Exception => e
rescue StandardError => e
logger.error("#{e.class}: #{e.message}\n#{e.backtrace.join("\n\t")}")
logger.flush
@submission.add_submission_status(status.get_error_status)
Expand Down Expand Up @@ -64,7 +64,7 @@ def generate_rdf(logger, reasoning: true)

owlapi = @submission.owlapi_parser(logger: logger)
owlapi.disable_reasoner unless reasoning

triples_file_path, missing_imports = owlapi.parse

if missing_imports && !missing_imports.empty?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,43 +79,43 @@ def process_archive?(options)
end

def process_rdf?(options)
options[:process_rdf].nil? || options[:process_rdf].eql?(true)
options.empty? || options[:process_rdf].eql?(true)
end

def generate_missing_labels?(options)
options[:generate_missing_labels].nil? || options[:generate_missing_labels].eql?(true)
options[:generate_missing_labels].nil? && process_rdf?(options) || options[:generate_missing_labels].eql?(true)
end

def generate_obsolete_classes?(options)
options[:generate_obsolete_classes].nil? || options[:generate_obsolete_classes].eql?(true)
options[:generate_obsolete_classes].nil? && process_rdf?(options) || options[:generate_obsolete_classes].eql?(true)
end

def index_search?(options)
options[:index_search].nil? || options[:index_search].eql?(true)
options.empty? || options[:index_search].eql?(true)
end

def index_properties?(options)
options[:index_properties].nil? || options[:index_properties].eql?(true)
options.empty? || options[:index_properties].eql?(true)
end

def process_index_commit?(options)
index_search?(options) || index_properties?(options)
end

def process_diff?(options)
options[:diff].nil? || options[:diff].eql?(true)
options.empty? || options[:diff].eql?(true)
end

def process_metrics?(options)
options[:run_metrics].nil? || options[:run_metrics].eql?(true)
options.empty? || options[:run_metrics].eql?(true)
end

def process_reasoning?(options)
options[:reasoning].nil? && options[:reasoning].eql?(true)
options.empty? && options[:reasoning].eql?(true)
end

def extract_metadata?(options)
options[:extract_metadata].nil? || options[:extract_metadata].eql?(true)
options.empty? || options[:extract_metadata].eql?(true)
end

end
Expand Down

0 comments on commit fdc43b5

Please sign in to comment.