From 09e3c81935e1f97159aa42a6589bd66edad60d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fa=CC=81bio=20Madeira?= Date: Sun, 4 Feb 2018 19:59:45 +0000 Subject: [PATCH 1/2] Minor fixes for pandas warnings: deprecated method `set_value`; expand=None meaning True instead of False; and explicit not working on a copy of a df. --- proteofav/structures.py | 3 ++- proteofav/variants.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/proteofav/structures.py b/proteofav/structures.py index 17a497e..5320e0d 100644 --- a/proteofav/structures.py +++ b/proteofav/structures.py @@ -326,6 +326,7 @@ def _add_mmcif_res_full(table): :return: returns a modified pandas DataFrame """ + table.is_copy = False # adds both 'label' and 'auth' entries if 'label_seq_id' in table: table['label_seq_id_full'] = (table['label_seq_id'] + @@ -410,7 +411,7 @@ def _remove_multiple_altlocs(table): altloc = table.loc[ix, 'label_alt_id'] if altloc != '.': # table.loc[ix, 'label_alt_id'] = '.' - table.set_value(ix, 'label_alt_id', '.') + table.at[ix, 'label_alt_id'] = '.' atomid = table.loc[ix, 'label_atom_id'] try: for nx in range(1, 100, 1): diff --git a/proteofav/variants.py b/proteofav/variants.py index f9350a8..c0d5ebe 100644 --- a/proteofav/variants.py +++ b/proteofav/variants.py @@ -911,7 +911,7 @@ def _fetch_icgc_variants(identifier): ' Duplicated index for {}.'.format(identifier)) else: data = data.join(consequence.apply(pd.Series), rsuffix='_protein') - transition = data.aaMutation.str.extract(transition_regex) + transition = data.aaMutation.str.extract(transition_regex, expand=False) data = data.join(transition) return data From ba7768aa7d2d15c567e8ddf5955d077a62f3af7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fa=CC=81bio=20Madeira?= Date: Sun, 4 Feb 2018 20:01:35 +0000 Subject: [PATCH 2/2] Minor fixes for tests that sometimes fail because of list being set with a different item order. --- tests/test_variants.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_variants.py b/tests/test_variants.py index f7e2477..43604b6 100644 --- a/tests/test_variants.py +++ b/tests/test_variants.py @@ -485,7 +485,8 @@ def test_fetch_ensembl_uniprot_mapping(self): r = self.fetch_ensembl_uniprot_mapping(self.ensembl_id2) self.assertTrue(r.ok) uniprots = self.get_uniprot_id_from_mapping(r.json()) - self.assertEqual(uniprots, ['A0A024RBG4', self.uniprot_id2]) + self.assertIn('A0A024RBG4', uniprots) + self.assertIn(self.uniprot_id2, uniprots) def test_to_table_uniprot_ensembl_mapping_full(self): """ @@ -534,7 +535,8 @@ def test_get_uniprot_id_from_mapping(self): r = self.get_uniprot_id_from_mapping(data.json(), full_entry=False, uniprot_id=None) - self.assertEqual(r, ['A0A024RBG4', self.uniprot_id2]) + self.assertIn('A0A024RBG4', r) + self.assertIn(self.uniprot_id2, r) r = self.get_uniprot_id_from_mapping(data.json(), full_entry=True, uniprot_id=None)