Skip to content

Commit

Permalink
cleaned up some pandas deprication
Browse files Browse the repository at this point in the history
  • Loading branch information
crosenth committed Jun 25, 2024
1 parent ebf3364 commit b7c0d20
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
3 changes: 1 addition & 2 deletions deenurp/subcommands/filter_outliers.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ def parse_usearch_allpairs(filename, seqnames):
# for each sequence pair, select the longest alignment if there is
# more than one (chooses first occurrence if there are two the same
# length).
maxidx = data.groupby(['query', 'target']).apply(
lambda x: x['align_len'].idxmax())
maxidx = data.groupby(['query', 'target'])['align_len'].idxmax()
data = data.iloc[maxidx]

if set(seqnames) != set(data['query']) | set(data['target']):
Expand Down
3 changes: 2 additions & 1 deletion deenurp/test/test_outliers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import io
import os
import unittest

Expand Down Expand Up @@ -95,7 +96,7 @@ def test_choose_clusters(self):
"medoid":{"0":238.0,"1":null,"2":284.0},
"dist":{"0":0.0,"1":null,"2":0.089}}"""

df = pd.read_json(s)
df = pd.read_json(io.StringIO(s))
# output is a set of cluster names (not indices)
self.assertSetEqual(set(outliers.choose_clusters(df, 2, 0.015)), {0})
self.assertSetEqual(set(outliers.choose_clusters(df, 2, 0.1)), {0, 1})
Expand Down
8 changes: 4 additions & 4 deletions deenurp/wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import os.path
import subprocess
import re
from distutils.version import LooseVersion
from packaging.version import Version
from io import StringIO

import pandas as pd
Expand Down Expand Up @@ -227,10 +227,10 @@ def cmalign_scores(text):
return pd.read_csv(
StringIO(text),
comment="#",
delim_whitespace=True,
dtype=dtypes,
index_col='seq_name',
names=dtypes.keys()
names=dtypes.keys(),
sep='\s+'
)


Expand Down Expand Up @@ -281,7 +281,7 @@ def _require_vsearch_version(vsearch=VSEARCH, version=VSEARCH_VERSION):
vsearch = re.search(r'^vsearch v(?P<vstr>\d+\.\d+\.[^_]+)', output.stderr)
ver = vsearch.groupdict()['vstr']

if LooseVersion(ver) < LooseVersion(version):
if Version(ver) < Version(version):
raise MissingDependencyError(
'vsearch version >= v{} is required, got v{}'.format(version, ver))

Expand Down

0 comments on commit b7c0d20

Please sign in to comment.