Skip to content

Commit

Permalink
#48: fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwoer committed May 22, 2024
1 parent 3aaebb0 commit 706837e
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ repos:
rev: v0.4.0
hooks:
- id: ruff-format
# - id: ruff
- id: ruff
12 changes: 6 additions & 6 deletions alpharaw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@


def register_readers():
from .ms_data_base import ms_reader_provider
from .legacy_msdata import mgf
from .mzml import MzMLReader
from .wrappers import alphapept_wrapper
from .ms_data_base import ms_reader_provider # noqa: F401 # TODO remove import side effect
from .legacy_msdata import mgf # noqa: F401 # TODO remove import side effect
from .mzml import MzMLReader # noqa: F401 # TODO remove import side effect
from .wrappers import alphapept_wrapper # noqa: F401 # TODO remove import side effect

try:
from .sciex import SciexWiffData
from .thermo import ThermoRawData
from .sciex import SciexWiffData # noqa: F401 # TODO remove import side effect
from .thermo import ThermoRawData # noqa: F401 # TODO remove import side effect
except (RuntimeError, ImportError):
print("[WARN] pythonnet is not installed")

Expand Down
5 changes: 3 additions & 2 deletions alpharaw/cli.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import click
import os

import alpharaw
from alpharaw.ms_data_base import ms_reader_provider
from alpharaw.legacy_msdata import mgf # noqa: F401 # TODO remove import side effect
from alpharaw.mzml import MzMLReader # noqa: F401 # TODO remove import side effect
from alpharaw.wrappers import alphapept_wrapper # noqa: F401 # TODO remove import side effect

try:
from alpharaw.sciex import SciexWiffData
from alpharaw.thermo import ThermoRawData
from alpharaw.sciex import SciexWiffData # noqa: F401 # TODO remove import side effect
from alpharaw.thermo import ThermoRawData # noqa: F401 # TODO remove import side effect
except (RuntimeError, ImportError):
print("[WARN] pythonnet is not installed")

Expand Down
1 change: 1 addition & 0 deletions alpharaw/feature/hills.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import pandas as pd
from alphatims.utils import threadpool
from numba import njit
from alpharaw.feature.centroids import connect_centroids
Expand Down
20 changes: 5 additions & 15 deletions alpharaw/feature/isotope_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,13 @@ def grow(

y = pattern[seed + relative_pos] # This is a reference peak

l = sortindex_[y]
ll = sortindex_[y]

mass2 = stats[y, 0]
delta_mass2 = stats[y, 1]

start = hill_ptrs[l]
end = hill_ptrs[l + 1]
start = hill_ptrs[ll]
end = hill_ptrs[ll + 1]
idx_ = hill_data[start:end]
int_2 = int_data[idx_]
scans_2 = scan_idx[idx_]
Expand Down Expand Up @@ -560,7 +560,6 @@ def plot_pattern(
pattern: np.ndarray,
sorted_hills: np.ndarray,
centroids: np.ndarray,
hill_data: np.ndarray,
):
"""Helper function to plot a pattern.
Expand All @@ -570,19 +569,17 @@ def plot_pattern(
centroids (np.ndarray): 1D Array containing the masses of the centroids.
hill_data (np.ndarray): Array containing the indices to hills.
"""
import matplotlib.pyplot as plt

f, (ax1, ax2) = plt.subplots(2, 1, sharex=True, figsize=(10, 10))
centroid_dtype = [("mz", float), ("int", float), ("scan_no", int), ("rt", float)]

mzs = []
rts = []
ints = []
for entry in pattern:
hill = sorted_hills[entry]
hill_data = np.array(
[centroids[_[0]][_[1]] for _ in hill], dtype=centroid_dtype
)

int_profile = hill_data["int"]
ax1.plot(hill_data["rt"], hill_data["int"])
ax2.scatter(hill_data["rt"], hill_data["mz"], s=hill_data["int"] / 5e5)

Expand Down Expand Up @@ -1102,13 +1099,6 @@ def report_(
int_max_idx = np.argmax(isotope_data[:, 2])
mz_most_abundant = isotope_data[:, 0][int_max_idx]

int_max = isotope_data[:, 2][int_max_idx]

rt_start = isotope_data[
int_max_idx, 4
] # This is the start of the most abundant trace
rt_end = isotope_data[int_max_idx, 5]

rt_min_ = min(isotope_data[:, 4])
rt_max_ = max(isotope_data[:, 5])

Expand Down
4 changes: 3 additions & 1 deletion alpharaw/match/psm_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from alpharaw import register_readers

register_readers()

from alphabase.peptide.fragment import (
create_fragment_mz_dataframe,
Expand All @@ -30,6 +29,9 @@
from alpharaw.dia.normal_dia import NormalDIAGrouper


register_readers() # TODO remove this import side effect


class PepSpecMatch:
"""
Extract fragment ions from MS2 data.
Expand Down
2 changes: 1 addition & 1 deletion alpharaw/mzml.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def parse_mzml_entry(item_dict: dict) -> tuple:
nce = float(filter_string.split("@cid")[1].split(" ")[0])
else:
nce = np.nan
except:
except Exception:
nce = np.nan
return (
rt,
Expand Down
4 changes: 3 additions & 1 deletion alpharaw/raw_access/clr_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import clr
# ruff: noqa: E402 #Module level import not at top of file
import os
import numpy as np

import clr

clr.AddReference("System")
# from System.Runtime.InteropServices import Marshal
# from System import IntPtr, Int64
Expand Down
2 changes: 2 additions & 0 deletions alpharaw/raw_access/pysciexwifffilereader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: E402 #Module level import not at top of file
import os
import numpy as np

Expand All @@ -7,6 +8,7 @@
import clr

clr.AddReference("System")

import System # noqa: F401
from System.Threading import Thread
from System.Globalization import CultureInfo
Expand Down
8 changes: 1 addition & 7 deletions alpharaw/raw_access/pythermorawfilereader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: E402 #Module level import not at top of file
import os
import warnings

Expand Down Expand Up @@ -308,13 +309,6 @@ def GetScanEventStringForScanNum(self, scanNumber):
"""This function returns scan event information as a string for the specified scan number."""
return self.source.GetScanEventStringForScanNumber(scanNumber)

def GetStatusLogForRetentionTime(self, rt):
logEntry = self.source.GetStatusLogForRetentionTime(rt)
return dict(zip(logEntry.Labels, logEntry.Values))

def GetStatusLogForScanNum(self, scan):
return self.GetStatusLogForRetentionTime(self.RTFromScanNum(scan))

def GetScanEventForScanNum(self, scanNumber):
return IScanEventBase(self.source.GetScanEventForScanNumber(scanNumber))

Expand Down

0 comments on commit 706837e

Please sign in to comment.