Skip to content

Commit

Permalink
implemented all PR sent by ptth222 under a new branch
Browse files Browse the repository at this point in the history
  • Loading branch information
proccaserra committed Mar 11, 2024
1 parent 3692f71 commit 194911a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
22 changes: 11 additions & 11 deletions tests/isatab/test_isatab.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def test_isatab_dump_source_sample_char_quant(self):
s.process_sequence = [sample_collection_process]
s.samples.append(sample1)
i.studies = [s]
actual = replace_windows_newlines(isatab.dumps(i))
actual = isatab.dumps(i)
expected = """Source Name\tMaterial Type\tCharacteristics[organism]\tTerm Source REF\tTerm Accession Number\tCharacteristics[body weight]\tUnit\tTerm Source REF\tTerm Accession Number\tProtocol REF\tParameter Value[vessel]\tTerm Source REF\tTerm Accession Number\tParameter Value[storage temperature]\tUnit\tTerm Source REF\tTerm Accession Number\tSample Name\tCharacteristics[organism part]\tTerm Source REF\tTerm Accession Number\tCharacteristics[specimen mass]\tUnit\tTerm Source REF\tTerm Accession Number
source1\tspecimen\tHuman\tNCBITAXON\thttp://purl.bioontology.org/ontology/STY/T016\t72\tkilogram\tUO\thttp://purl.obolibrary.org/obo/UO_0000009\tsample collection\teppendorf tube\tOBI\tpurl.org\t-20\tdegree Celsius\tUO\thttp://purl.obolibrary.org/obo/UO_0000027\tsample1\tliver\tUBERON\thttp://purl.obolibrary.org/obo/UBERON_0002107\t450.5\tmilligram\tUO\thttp://purl.obolibrary.org/obo/UO_0000022"""
self.assertIn(expected, actual)
Expand Down Expand Up @@ -1076,7 +1076,7 @@ def test_source_protocol_ref_sample(self):
i.studies = [s]
expected = """Source Name\tProtocol REF\tSample Name
source1\tsample collection\tsample1"""
self.assertIn(expected, replace_windows_newlines(isatab.dumps(i)))
self.assertIn(expected, isatab.dumps(i))

def test_source_protocol_ref_sample_x2(self):
i = Investigation()
Expand Down Expand Up @@ -1174,7 +1174,7 @@ def test_source_protocol_ref_sample_with_characteristics(self):
i.studies = [s]
expected = """Source Name\tCharacteristics[reference descriptor]\tProtocol REF\tSample Name\tCharacteristics[organism part]
source1\tnot applicable\tsample collection\tsample1\tliver"""
self.assertIn(expected, replace_windows_newlines(isatab.dumps(i)))
self.assertIn(expected, isatab.dumps(i))

def test_source_protocol_ref_sample_with_parameter_values(self):
i = Investigation()
Expand All @@ -1195,7 +1195,7 @@ def test_source_protocol_ref_sample_with_parameter_values(self):
i.studies = [s]
expected = """Source Name\tProtocol REF\tParameter Value[temperature]\tSample Name
source1\tsample collection\t10\tsample1"""
self.assertIn(expected, replace_windows_newlines(isatab.dumps(i)))
self.assertIn(expected, isatab.dumps(i))

def test_source_protocol_ref_sample_with_factor_values(self):
i = Investigation()
Expand Down Expand Up @@ -1223,11 +1223,11 @@ def test_source_protocol_ref_sample_with_factor_values(self):
s.assays = [a]
expected_study_table = """Source Name\tProtocol REF\tSample Name\tFactor Value[study group]
source1\tsample collection\tsample1\tStudy group 1"""
self.assertIn(expected_study_table, replace_windows_newlines(isatab.dumps(i)))
self.assertIn(expected_study_table, isatab.dumps(i))
expected_assay_table = """Sample Name\tFactor Value[study group]\tProtocol REF
sample1\tStudy group 1\textraction"""
self.assertIn(expected_assay_table,
replace_windows_newlines(isatab.dumps(i, write_fvs_in_assay_table=True)))
isatab.dumps(i, write_fvs_in_assay_table=True))

def test_source_protocol_ref_protocol_ref_sample(self):
i = Investigation()
Expand All @@ -1246,7 +1246,7 @@ def test_source_protocol_ref_protocol_ref_sample(self):
i.studies = [s]
expected = """Source Name\tProtocol REF\tProtocol REF\tSample Name
source1\tsample collection\taliquoting\taliquot1"""
self.assertIn(expected, replace_windows_newlines(isatab.dumps(i)))
self.assertIn(expected, isatab.dumps(i))

def test_source_protocol_ref_sample_protocol_ref_sample(self):
i = Investigation()
Expand All @@ -1268,7 +1268,7 @@ def test_source_protocol_ref_sample_protocol_ref_sample(self):
i.studies = [s]
expected = """Source Name\tProtocol REF\tSample Name\tProtocol REF\tSample Name
source1\tsample collection\tsample1\taliquoting\taliquot1"""
self.assertIn(expected, replace_windows_newlines(isatab.dumps(i)))
self.assertIn(expected, isatab.dumps(i))

def test_sample_protocol_ref_material_protocol_ref_data2(self):
i = Investigation()
Expand Down Expand Up @@ -1302,7 +1302,7 @@ def test_sample_protocol_ref_material_protocol_ref_data2(self):
i.studies = [s]
expected = (f"""Sample Name\tProtocol REF\tExtract Name\tProtocol REF\tAssay Name\tRaw Data File\tComment[checksum type]\tComment[checksum]\n""" +
f"""sample1\textraction\textract1\tnucleic acid sequencing\tassay-1\tdatafile.raw\t{cs_comment1.value}\t{cs_comment2.value}""")
self.assertIn(expected, replace_windows_newlines(isatab.dumps(i)))
self.assertIn(expected, isatab.dumps(i))

def test_sample_protocol_ref_material_protocol_ref_data3(self):
i = Investigation()
Expand Down Expand Up @@ -1341,7 +1341,7 @@ def test_sample_protocol_ref_material_protocol_ref_data3(self):

# self.assertIn(expected_line1, dump_out)
# self.assertIn(expected_line2, dump_out)
self.assertIn(expected, replace_windows_newlines(isatab.dumps(i)))
self.assertIn(expected, isatab.dumps(i))

def test_sample_protocol_ref_material_protocol_ref_data4(self):
i = Investigation()
Expand Down Expand Up @@ -1380,7 +1380,7 @@ def test_sample_protocol_ref_material_protocol_ref_data4(self):

# self.assertIn(expected_line1, dump_out)
# self.assertIn(expected_line2, dump_out)
self.assertIn(expected, replace_windows_newlines(isatab.dumps(i)))
self.assertIn(expected, isatab.dumps(i))

def test_sample_protocol_ref_material_protocol_ref_data_x2(self):
i = Investigation()
Expand Down
4 changes: 1 addition & 3 deletions tests/isatab/validate/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ def test_b_ii_s_3(self):
data_path = path.join(path.dirname(path.abspath(__file__)), '..', '..', 'data', 'tab', 'BII-S-3')
with open(path.join(data_path, 'i_gilbert.txt'), 'r') as data_file:
r = validate(fp=data_file, config_dir=self.default_conf, origin="")
self.assertEqual(len(r['warnings']), 5)
self.assertEqual(len(r['warnings']), 10)
self.assertEqual(len(r['warnings']), 2)

def test_mtbls267(self):
Expand Down Expand Up @@ -84,7 +82,7 @@ def is_investigation(investigation_df):
data_path = path.join(path.dirname(path.abspath(__file__)), '..', '..', 'data', 'tab', 'BII-S-3')
with open(path.join(data_path, 'i_gilbert.txt'), 'r') as data_file:
r = validate(data_file, rules=rules)
self.assertEqual(len(r['warnings']), 10)
self.assertEqual(len(r['warnings']), 1)

rule = '12000'
expected_error = {
Expand Down

0 comments on commit 194911a

Please sign in to comment.