-
Notifications
You must be signed in to change notification settings - Fork 3
287 lines (251 loc) · 9.95 KB
/
Copy pathpython-app.yml
File metadata and controls
287 lines (251 loc) · 9.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python application
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov click
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# Install the package in development mode
pip install -e .
- name: Install 7-Zip
run: sudo apt-get update && sudo apt-get install -y p7zip-full
- name: Extract test data files
run: |
# Extract compressed mzML file from zip archives
cd data
if [ -f 1.zip ]; then
echo "Extracting 1.mzML from split zip archives..."
ls -lh 1.*
7z x 1.zip
ls -lh 1.mzML
echo "Extraction complete"
else
echo "Warning: 1.zip not found in data directory"
ls -la
fi
cd ..
- name: Verify test data files
run: |
# Verify that required test data files exist
if [ ! -f data/1_consensus_fdr_filter_pep.idXML ]; then
echo "Error: idXML file not found"
exit 1
fi
if [ ! -f data/1.mzML ]; then
echo "Error: mzML file not found"
exit 1
fi
echo "Test data files verified:"
ls -lh data/1_consensus_fdr_filter_pep.idXML
ls -lh data/1.mzML
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 onsite/ --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=__pycache__,.git,build,dist
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 onsite/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=__pycache__,.git,build,dist
- name: Test package imports
run: |
# Test that the package and all modules can be imported
python -c "import onsite; print('onsite package imported successfully')"
python -c "from onsite import AScore; print('AScore imported successfully')"
python -c "from onsite import calculate_phospho_localization_compomics_style; print('PhosphoRS imported successfully')"
python -c "from onsite.lucxor import cli; print('LucXor CLI imported successfully')"
- name: Test CLI commands availability
run: |
# Test that CLI commands are available
onsite --help
ascore --help || python -m onsite.ascore.cli --help
phosphors --help || python -m onsite.phosphors.cli --help
lucxor --help || python -m onsite.lucxor.cli --help
- name: Run unit tests with coverage
run: |
# Run all unit tests with pytest and generate coverage report
pytest tests/ -v --tb=short --color=yes --cov=onsite --cov-report=xml --cov-report=term
- name: Test AScore with real data
run: |
# Test AScore algorithm with real data
python -m onsite.ascore.cli \
-in data/1.mzML \
-id data/1_consensus_fdr_filter_pep.idXML \
-out test_ascore_output.idXML \
--fragment-mass-tolerance 0.05 \
--fragment-mass-unit Da \
--threads 1 \
--add-decoys
# Verify output file was created
if [ -f test_ascore_output.idXML ]; then
echo "AScore output file created successfully"
ls -lh test_ascore_output.idXML
else
echo "Warning: AScore output file not created (may be expected if no phosphorylated peptides)"
fi
- name: Test PhosphoRS with real data
run: |
# Test PhosphoRS algorithm with real data
python -m onsite.phosphors.cli \
-in data/1.mzML \
-id data/1_consensus_fdr_filter_pep.idXML \
-out test_phosphors_output.idXML \
--fragment-mass-tolerance 0.05 \
--fragment-mass-unit Da \
--threads 1 \
--add-decoys
# Verify output file was created
if [ -f test_phosphors_output.idXML ]; then
echo "PhosphoRS output file created successfully"
ls -lh test_phosphors_output.idXML
else
echo "Warning: PhosphoRS output file not created (may be expected if no phosphorylated peptides)"
fi
- name: Test LucXor with real data
run: |
# Test LucXor algorithm with real data
python -m onsite.lucxor.cli \
-in data/1.mzML \
-id data/1_consensus_fdr_filter_pep.idXML \
-out test_lucxor_output.idXML \
--fragment-method HCD \
--fragment-mass-tolerance 0.5 \
--fragment-error-units Da \
--threads 1 \
--min-num-psms-model 50
# Verify output file was created
if [ -f test_lucxor_output.idXML ]; then
echo "LucXor output file created successfully"
ls -lh test_lucxor_output.idXML
else
echo "Warning: LucXor output file not created (may be expected if no phosphorylated peptides)"
fi
- name: Test unified CLI with real data
run: |
# Test unified onsite CLI command
onsite ascore \
-in data/1.mzML \
-id data/1_consensus_fdr_filter_pep.idXML \
-out test_unified_ascore.idXML \
--fragment-mass-tolerance 0.05 \
--fragment-mass-unit Da \
--threads 1 \
--add-decoys
onsite phosphors \
-in data/1.mzML \
-id data/1_consensus_fdr_filter_pep.idXML \
-out test_unified_phosphors.idXML \
--fragment-mass-tolerance 0.05 \
--fragment-mass-unit Da \
--threads 1 \
--add-decoys
onsite lucxor \
-in data/1.mzML \
-id data/1_consensus_fdr_filter_pep.idXML \
-out test_unified_lucxor.idXML \
--fragment-method HCD \
--fragment-mass-tolerance 0.5 \
--threads 1 \
--min-num-psms-model 50
- name: Verify reference result files exist
run: |
# Verify that reference result files exist for comparison
echo "Checking reference result files..."
ls -lh data/1_lucxor_result.idXML || echo "Warning: LucXor reference file not found"
ls -lh data/1_ascore_result.idXML || echo "Warning: AScore reference file not found"
ls -lh data/1_phosphors_result.idXML || echo "Warning: PhosphoRS reference file not found"
- name: Run algorithm comparison tests
id: algorithm_comparison
run: |
set -o pipefail
# Run algorithm comparison tests to compare new results with reference results
# Tests compare at different thresholds:
# - LucXor: local_flr < 0.01, 0.05, 0.1 (with q-value < 0.01)
# - AScore: AScore >= 3, 15, 20 (with q-value < 0.01)
# - PhosphoRS: site probability > 75%, 90%, 99% (with q-value < 0.01)
pytest tests/test_algorithm_comparison.py -v -s --tb=short --color=no 2>&1 | tee algorithm_comparison_results.txt
- name: Post algorithm comparison results to PR
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const resultsFile = 'algorithm_comparison_results.txt';
if (!fs.existsSync(resultsFile)) {
console.log('Results file not found, skipping comment');
return;
}
let results = fs.readFileSync(resultsFile, 'utf8');
// Truncate if too long (GitHub comments have a limit)
const maxLength = 65000;
if (results.length > maxLength) {
results = results.substring(0, maxLength) + '\n\n... (truncated)';
}
const body = [
'## Algorithm Comparison Test Results',
'',
'<details>',
'<summary>Click to expand test results</summary>',
'',
'```',
results,
'```',
'',
'</details>'
].join('\n');
// Find and update existing comment or create new one
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.login === 'github-actions[bot]' &&
comment.body.includes('## Algorithm Comparison Test Results')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}
- name: Upload test outputs as artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-outputs
path: |
test_*.idXML
algorithm_comparison_results.txt
retention-days: 7
- name: Upload coverage to artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml
retention-days: 7