-
Notifications
You must be signed in to change notification settings - Fork 0
New Features #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Features #37
Changes from all commits
d848cbd
3bed97a
69ebc9a
0f17b20
b7cd8a9
8bbf104
83f67d4
181d183
e4ef45c
fda9a83
9a87fcf
866301b
406186b
1dfa9c5
a029399
85b620f
8da3b0f
a0a27c5
a3e7d9f
ad59416
045cc1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,22 +22,26 @@ def parseDeconv( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Create full sized version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| heatmap = getMSSignalDF(df) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Store full sized version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| file_manager.store_data( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dataset_id, f'ms1_{descriptor}_heatmap', heatmap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Store compressed versions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for size in reversed(compute_compression_levels(20000, len(heatmap), logger=logger)): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for ms_level in [1, 2]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Downsample iteratively | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| heatmap = downsample_heatmap(heatmap, max_datapoints=size) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Store compressed version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| relevant_heatmap = heatmap[heatmap['MSLevel'] == ms_level].drop(columns=['MSLevel']) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Store full sized version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| file_manager.store_data( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dataset_id, f'ms1_{descriptor}_heatmap_{size}', heatmap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dataset_id, f'ms{ms_level}_{descriptor}_heatmap', relevant_heatmap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+25
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainGuard against missing MSLevel column and empty partitions If MSLevel isn’t present (backward compatibility, older caches) the current code raises a KeyError on the filter. Also, empty per-level partitions should be handled explicitly to avoid downstream issues. - for ms_level in [1, 2]:
-
- relevant_heatmap = heatmap[heatmap['MSLevel'] == ms_level].drop(columns=['MSLevel'])
+ for ms_level in [1, 2]:
+ if 'MSLevel' in heatmap.columns:
+ relevant_heatmap = heatmap.loc[heatmap['MSLevel'] == ms_level].drop(columns=['MSLevel'])
+ else:
+ # Backward compatibility: treat all as MS1, make MS2 empty
+ relevant_heatmap = heatmap.copy() if ms_level == 1 else heatmap.iloc[0:0].copy()Additionally, consider short-circuiting when relevant_heatmap is empty to avoid unnecessary work (compression loop will be skipped already, but this improves clarity). 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Repository root: $(pwd)"
echo
echo "Checking for src/parse/deconv.py and nearby context..."
if [ -f src/parse/deconv.py ]; then
echo "=== src/parse/deconv.py (first 240 lines) ==="
nl -ba src/parse/deconv.py | sed -n '1,240p'
else
echo "src/parse/deconv.py not found. Searching for files named deconv.py..."
rg -n "deconv.py" || true
fi
echo
echo "Searching the repo for occurrences of MSLevel, heatmap, and relevant_heatmap..."
rg -n "MSLevel" || true
echo
rg -n "relevant_heatmap" || true
echo
rg -n "heatmap" || trueLength of output: 506 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Repository root: $(pwd)"
echo
FILE="src/parse/deconv.py"
echo "Looking for $FILE..."
if [ -f "$FILE" ]; then
echo "=== $FILE (first 240 lines) ==="
sed -n '1,240p' "$FILE" || true
else
echo "$FILE not found. Searching for deconv.py..."
rg -n "deconv.py" || true
fi
echo
echo "Searching the repo for occurrences of MSLevel, relevant_heatmap, and heatmap..."
rg -n "MSLevel" || true
echo
rg -n "relevant_heatmap" || true
echo
rg -n "heatmap" || trueLength of output: 293913 🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE="src/parse/masstable.py"
echo "Showing $FILE (first 400 lines):"
if [ -f "$FILE" ]; then
sed -n '1,400p' "$FILE" || true
else
echo "$FILE not found"
fi
echo
echo "Searching for getMSSignalDF and MSLevel occurrences:"
rg -n "def getMSSignalDF|getMSSignalDF|MSLevel" || trueLength of output: 80766 Guard MSLevel usage in src/parse/deconv.py (add defensive check and skip empty partitions) The pipeline normally adds MSLevel in src/parse/masstable.py (parseFLASHDeconvOutput / getMSSignalDF), but older caches or external inputs may omit it — add a defensive check and skip empty per-level partitions to avoid KeyError and needless storage. Files to update
Suggested change (replace the existing per-level loop with this): - for ms_level in [1, 2]:
-
- relevant_heatmap = heatmap[heatmap['MSLevel'] == ms_level].drop(columns=['MSLevel'])
-
- # Store full sized version
- file_manager.store_data(
- dataset_id, f'ms{ms_level}_{descriptor}_heatmap', relevant_heatmap
- )
+ for ms_level in [1, 2]:
+ # Defensive: some inputs/caches may not have MSLevel (backward compatibility)
+ if 'MSLevel' in heatmap.columns:
+ relevant_heatmap = heatmap.loc[heatmap['MSLevel'] == ms_level]
+ if 'MSLevel' in relevant_heatmap.columns:
+ relevant_heatmap = relevant_heatmap.drop(columns=['MSLevel'])
+ else:
+ # Treat all data as MS1; leave MS2 empty
+ relevant_heatmap = heatmap.copy() if ms_level == 1 else heatmap.iloc[0:0].copy()
+
+ # Short-circuit empty partitions to avoid storing/processing them
+ if relevant_heatmap.empty:
+ continue
+
+ # Store full sized version
+ file_manager.store_data(
+ dataset_id, f'ms{ms_level}_{descriptor}_heatmap', relevant_heatmap
+ )Tag: 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Store compressed versions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for size in reversed(compute_compression_levels(20000, len(relevant_heatmap), logger=logger)): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Downsample iteratively | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| relevant_heatmap = downsample_heatmap(relevant_heatmap, max_datapoints=size) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Store compressed version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| file_manager.store_data( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dataset_id, f'ms{ms_level}_{descriptor}_heatmap_{size}', relevant_heatmap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| spectra_df = getSpectraTableDF(deconv_df) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # scan_table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Combine nested context managers and fix MIME type for ZIP
📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.12.2)
39-40: Use a single
withstatement with multiple contexts instead of nestedwithstatementsCombine
withstatements(SIM117)
🤖 Prompt for AI Agents