def test_unequalMS2MatchesFtables(self): goodcsi = self.goodcsi.view(CSIDirFmt) goodcsi2 = self.goodcsi2.view(CSIDirFmt) ms2_match1 = pd.DataFrame(index=['2', '4'], columns=['Smiles']) msg = ("The MS2 match tables should have a one-to-one " "correspondance with feature tables and CSI results.") with self.assertRaisesRegex(ValueError, msg): make_hierarchy([goodcsi, goodcsi2], [self.features, self.features2], [ms2_match1])
def test_MS2NoSmiles(self): goodcsi = self.goodcsi.view(CSIDirFmt) goodcsi2 = self.goodcsi2.view(CSIDirFmt) ms2_match1 = pd.DataFrame(index=['2', '4'], columns=[]) ms2_match2 = pd.DataFrame(index=['10', '12'], columns=['Smiles']) msg = "MS2 match tables must contain the column `Smiles`" with self.assertRaisesRegex(ValueError, msg): make_hierarchy([goodcsi, goodcsi2], [self.features, self.features2], [ms2_match1, ms2_match2])
def test_MS2NoSmiles(self): goodcsi = self.goodcsi.view(CSIDirFmt) goodcsi2 = self.goodcsi2.view(CSIDirFmt) ms2_match1 = pd.DataFrame(index=['2', '4'], columns=[]) ms2_match2 = pd.DataFrame(index=['10', '12'], columns=['Smiles']) msg = ("MS2 match tables must contain the column `Smiles`. Please " "check if you have the correct input file for this command.") with self.assertRaisesRegex(ValueError, msg): make_hierarchy([goodcsi, goodcsi2], [self.features, self.features2], [ms2_match1, ms2_match2])
def test_Pipeline(self): goodcsi1 = self.goodcsi.view(CSIDirFmt) goodcsi2 = self.goodcsi2.view(CSIDirFmt) treeout, merged_fts, merged_fdata = make_hierarchy( [goodcsi1, goodcsi2], [self.features, self.features2]) tip_names = {node.name for node in treeout.tips()} self.assertEqual(tip_names, set(merged_fts._observation_ids))
def test_mergeFeatureDataSingle(self): goodcsi1 = self.goodcsi.view(CSIDirFmt) treeout, merged_fts, merged_fdata = make_hierarchy([goodcsi1], [self.features]) featrs = sorted(list(merged_fts.ids(axis='observation'))) fdata_featrs = sorted(list(merged_fdata.index)) self.assertEqual(len(featrs) == 3, True) self.assertEqual(fdata_featrs, featrs)
def test_mergeFeatureDataSingle(self): goodcsi1 = self.goodcsi.view(CSIDirFmt) treeout, merged_fts, merged_fdata = make_hierarchy( [goodcsi1], [self.features], [self.ms2_match]) featrs = sorted(list(merged_fts.ids(axis='observation'))) fdata_featrs = sorted(list(merged_fdata.index)) self.assertEqual('csi_smiles' in merged_fdata.columns, True) self.assertEqual('ms2_smiles' in merged_fdata.columns, True) self.assertEqual(len(merged_fdata[pd.notna( merged_fdata.ms2_smiles)]), 1) self.assertEqual(len(featrs) == 3, True) self.assertEqual(fdata_featrs, featrs)
def test_unequalFtablesCSI(self): goodcsi = self.goodcsi.view(CSIDirFmt) msg = ("The feature tables and CSI results should have a one-to-one" " correspondance.") with self.assertRaisesRegex(ValueError, msg): make_hierarchy([goodcsi], [self.features, self.features2])
def test_tipMatchSingle(self): goodcsi = self.goodcsi.view(CSIDirFmt) treeout, merged_fts, merged_fdata = make_hierarchy( [goodcsi], [self.features]) tip_names = {node.name for node in treeout.tips()} self.assertEqual(tip_names, set(merged_fts._observation_ids))
def test_emptyFeatures(self): goodcsi = self.goodcsi.view(CSIDirFmt) with self.assertRaises(ValueError): make_hierarchy([goodcsi], [self.emptyfeatures])