Skip to content

Commit

Permalink
fixes issue #323, addresses use of a deprecated call in isatab2w4m
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe Rocca-Serra authored and Philippe Rocca-Serra committed Oct 1, 2019
1 parent 064ff11 commit 7b06e5a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 1 addition & 2 deletions isatools/convert/isatab2w4m.py
Expand Up @@ -304,8 +304,7 @@ def make_variable_names(assay_df):

# Make variable names from data values
for col in ['mass_to_charge', 'retention_time', 'chemical_shift']:
# if assay_df.keys().contains(col):
if col in assay_df.keys():
if col in assay_df.keys():
for i, v in enumerate(assay_df[col].values):
if type(v) == str or not numpy.isnan(v):
x = var_names[i]
Expand Down
3 changes: 1 addition & 2 deletions isatools/isatab.py
Expand Up @@ -1791,8 +1791,7 @@ def _build_section_df(f):
:return: A DataFrame corresponding to the file section
"""
df = pd.read_csv(f, names=range(0, 128), sep='\t', engine='python',
encoding='utf-8', comment='#').dropna(
axis=1, how='all')
encoding='utf-8').dropna(axis=1, how='all')
df = df.T
df.replace(np.nan, '', regex=True, inplace=True)
# Strip out the nan entries
Expand Down
14 changes: 13 additions & 1 deletion tests/test_isatab.py
Expand Up @@ -18,7 +18,7 @@

def setUpModule():
if not os.path.exists(utils.DATA_DIR):
raise FileNotFoundError("Could not fine test data directory in {0}. Ensure you have cloned the ISAdatasets "
raise FileNotFoundError("Could not find test data directory in {0}. Ensure you have cloned the ISAdatasets "
"repository using "
"git clone -b tests --single-branch git@github.com:ISA-tools/ISAdatasets {0}"
.format(utils.DATA_DIR))
Expand Down Expand Up @@ -726,6 +726,18 @@ def setUp(self):
def tearDown(self):
shutil.rmtree(self._tmp_dir)

def test_isatab_load_issue323(self):
with open(os.path.join(self._tab_data_dir, 'issue323', 'i_05.txt')) as fp:
ISA = isatab.load(fp)
print(ISA.studies[0].protocols[0].description)
self.assertEqual(len(ISA.studies[0].protocols[0].description), 70)

protocol = Protocol(description="some description containing a # character that should not be picked up", name="", protocol_type=OntologyAnnotation(term=""))
print("test protocol description", protocol.description)

self.assertEqual(len(protocol.description),70)


def test_isatab_load_issue200(self):
with open(os.path.join(self._tab_data_dir, 'issue200', 'i_Investigation.txt')) as fp:
ISA = isatab.load(fp)
Expand Down

0 comments on commit 7b06e5a

Please sign in to comment.