Skip to content

Commit

Permalink
Fixed pin parsing when DefaultDirection is not present.
Browse files Browse the repository at this point in the history
  • Loading branch information
wfondrie committed Mar 11, 2021
1 parent 7919c04 commit b939d03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mokapot/parsers/pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def read_pin(pin_files, group_column=None, to_df=False, copy_data=False):
)

# Convert labels to the correct format.
print(pin_df[labels[0]])
pin_df[labels[0]] = pin_df[labels[0]].astype(int)
if any(pin_df[labels[0]] == -1):
pin_df[labels[0]] = ((pin_df[labels[0]] + 1) / 2).astype(bool)
Expand Down Expand Up @@ -142,10 +143,12 @@ def read_percolator(perc_file):
cols = perc.readline().rstrip().split("\t")
dir_line = perc.readline().rstrip().split("\t")[0]
if dir_line.lower() != "defaultdirection":
perc.seek(1)
perc.seek(0)
_ = perc.readline()

psms = pd.concat((c for c in _parse_in_chunks(perc, cols)), copy=False)

print(psms.head())
return psms


Expand Down
5 changes: 5 additions & 0 deletions tests/unit_tests/test_parser_pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ def test_pin_parsing(std_pin):

dat = mokapot.read_pin(std_pin)
pd.testing.assert_frame_equal(df.loc[:, ("sCore",)], dat.features)


def test_pin_wo_dir():
"""Test a PIN file without a DefaultDirection line"""
dat = mokapot.read_pin("data/scope2_FP97AA.pin")

0 comments on commit b939d03

Please sign in to comment.