-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: import samples additional attributes - flash point and refractive index #2214
base: main
Are you sure you want to change the base?
Changes from all commits
610052f
a59becf
dc380ee
3fe1fca
4b54052
17dda99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,14 @@ def filter_with_permission_and_detail_level(sample) | |
string.split(',').join(' - ') | ||
elsif column == 'solvent' | ||
extract_label_from_solvent_column(sample[column]) || '' | ||
elsif column == 'refractive index' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/AbcSize: Assignment Branch Condition size for filter_with_permission_and_detail_level is too high. [<13, 34, 28> 45.92/25] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/CyclomaticComplexity: Cyclomatic complexity for filter_with_permission_and_detail_level is too high. [20/7] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/MethodLength: Method has too many lines. [32/30] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/PerceivedComplexity: Perceived complexity for filter_with_permission_and_detail_level is too high. [22/8] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/AbcSize: Assignment Branch Condition size for filter_with_permission_and_detail_level is too high. [<13, 35, 30> 47.9/25] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/CyclomaticComplexity: Cyclomatic complexity for filter_with_permission_and_detail_level is too high. [21/7] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/MethodLength: Method has too many lines. [34/30] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/PerceivedComplexity: Perceived complexity for filter_with_permission_and_detail_level is too high. [23/8] |
||
sample['refractive_index'] | ||
elsif column == 'flash point' | ||
flash_point_format(sample['flash_point']) | ||
elsif column == 'molarity' | ||
"#{sample['molarity_value']} #{sample['molarity_unit']}" | ||
elsif column == 'density' | ||
"#{sample['density']} g/ml" | ||
else | ||
sample[column] | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,28 @@ def read | |
|
||
private | ||
|
||
def concatenate_data(sample, data, headers = @headers) | ||
headers.each do |column| | ||
next unless column | ||
|
||
raw_value = case column | ||
when 'molarity' | ||
"#{sample['molarity_value']} #{sample['molarity_unit']}" | ||
when 'flash point' | ||
sample['flash_point'] | ||
when 'refractive index' | ||
sample['refractive_index'] | ||
when 'density' | ||
"#{sample['density']} g/mL" | ||
else | ||
sample[column] | ||
end | ||
column_data = format_field(column, raw_value) | ||
data.concat(column_data) | ||
end | ||
data | ||
end | ||
|
||
def filter_with_permission_and_detail_level(sample) | ||
if sample['shared_sync'] == 'f' || sample['shared_sync'] == false | ||
data = validate_molfile(sample['molfile']) | ||
|
@@ -44,10 +66,7 @@ def filter_with_permission_and_detail_level(sample) | |
end | ||
data = data.rstrip | ||
data += "\n" | ||
@headers.each do |column| | ||
column_data = format_field(column, sample[column]) | ||
data.concat(column_data) | ||
end | ||
data = concatenate_data(sample, data) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/AbcSize: Assignment Branch Condition size for filter_with_permission_and_detail_level is too high. [<12, 23, 12> 28.58/25] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/CyclomaticComplexity: Cyclomatic complexity for filter_with_permission_and_detail_level is too high. [10/7] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/PerceivedComplexity: Perceived complexity for filter_with_permission_and_detail_level is too high. [11/8] |
||
else | ||
# return no data if molfile not allowed | ||
return nil if sample['dl_s'].zero? | ||
|
@@ -62,12 +81,8 @@ def filter_with_permission_and_detail_level(sample) | |
# NB: as of now , only dl 0 and 10 are implemented | ||
dl = 10 if dl.positive? | ||
headers = instance_variable_get("headers#{sample['dl_s']}#{dl}") | ||
headers.each do |column| | ||
next unless column | ||
data = concatenate_data(sample, data, headers) | ||
|
||
column_data = format_field(column, sample[column]) | ||
data.concat(column_data) | ||
end | ||
end | ||
data.concat("\$\$\$\$\n") | ||
end | ||
|
@@ -81,11 +96,14 @@ def extract_reference_values(raw_value) | |
def format_field(column, raw_value) | ||
field = column.gsub(/\s+/, '_').upcase | ||
reference_values = ['melting pt', 'boiling pt'] | ||
flash_point = ['flash point', 'flash_point'] | ||
sample_column = | ||
if reference_values.include?(column) | ||
extract_reference_values(raw_value) | ||
elsif column == 'solvent' | ||
extract_label_from_solvent_column(raw_value) || '' | ||
elsif flash_point.include?(column) | ||
flash_point_format(raw_value) | ||
else | ||
raw_value | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/ModuleLength: Module has too many lines. [615/100]