-
Notifications
You must be signed in to change notification settings - Fork 3
251 lines (220 loc) · 9.57 KB
/
Copy pathpython-app.yml
File metadata and controls
251 lines (220 loc) · 9.57 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
# 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
issues: 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 pandas pyarrow
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# Install the package in development mode
pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 onsite/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=__pycache__,.git,build,dist,__init__.py
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 onsite/ tests/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=__pycache__,.git,build,dist,__init__.py
- 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/SF_200217_pPeptideLibrary_pool1_HCDnlETcaD_OT_rep1.mzML \
-id data/SF_200217_pPeptideLibrary_pool1_HCDnlETcaD_OT_rep1_comet_perc.idparquet \
-out test_ascore_output.idparquet \
--fragment-mass-tolerance 0.05 \
--fragment-mass-unit Da \
--threads 1
# Verify output directory was created
if [ -d test_ascore_output.idparquet ]; then
echo "AScore output created successfully"
ls -lh test_ascore_output.idparquet/
else
echo "Warning: AScore output not created"
fi
- name: Test PhosphoRS with real data
run: |
# Test PhosphoRS algorithm with real data
python -m onsite.phosphors.cli \
-in data/SF_200217_pPeptideLibrary_pool1_HCDnlETcaD_OT_rep1.mzML \
-id data/SF_200217_pPeptideLibrary_pool1_HCDnlETcaD_OT_rep1_comet_perc.idparquet \
-out test_phosphors_output.idparquet \
--fragment-mass-tolerance 0.05 \
--fragment-mass-unit Da \
--threads 1 \
--add-decoys
# Verify output file was created
if [ -d test_phosphors_output.idparquet ]; then
echo "PhosphoRS output created successfully"
ls -lh test_phosphors_output.idparquet/
else
echo "Warning: PhosphoRS output not created"
fi
- name: Test LucXor with real data
run: |
# Test LucXor algorithm with real data
python -m onsite.lucxor.cli \
-in data/SF_200217_pPeptideLibrary_pool1_HCDnlETcaD_OT_rep1.mzML \
-id data/SF_200217_pPeptideLibrary_pool1_HCDnlETcaD_OT_rep1_comet_perc.idparquet \
-out test_lucxor_output.idparquet \
--fragment-method HCD \
--fragment-mass-tolerance 0.5 \
--fragment-mass-unit Da \
--threads 1 \
--min-num-psms-model 5
# Verify output file was created
if [ -d test_lucxor_output.idparquet ]; then
echo "LucXor output created successfully"
ls -lh test_lucxor_output.idparquet/
else
echo "Warning: LucXor output not created"
fi
- name: Test unified CLI with real data
run: |
# Test unified onsite CLI command
onsite ascore \
-in data/SF_200217_pPeptideLibrary_pool1_HCDnlETcaD_OT_rep1.mzML \
-id data/SF_200217_pPeptideLibrary_pool1_HCDnlETcaD_OT_rep1_comet_perc.idparquet \
-out test_unified_ascore.idparquet \
--fragment-mass-tolerance 0.05 \
--fragment-mass-unit Da \
--threads 1 \
--add-decoys
onsite phosphors \
-in data/SF_200217_pPeptideLibrary_pool1_HCDnlETcaD_OT_rep1.mzML \
-id data/SF_200217_pPeptideLibrary_pool1_HCDnlETcaD_OT_rep1_comet_perc.idparquet \
-out test_unified_phosphors.idparquet \
--fragment-mass-tolerance 0.05 \
--fragment-mass-unit Da \
--threads 1 \
--add-decoys
onsite lucxor \
-in data/SF_200217_pPeptideLibrary_pool1_HCDnlETcaD_OT_rep1.mzML \
-id data/SF_200217_pPeptideLibrary_pool1_HCDnlETcaD_OT_rep1_comet_perc.idparquet \
-out test_unified_lucxor.idparquet \
--fragment-method HCD \
--fragment-mass-tolerance 0.5 \
--threads 1 \
--min-num-psms-model 5
- name: Verify reference result files exist
run: |
# Verify that reference result files exist for comparison
echo "Checking reference result files..."
ls -lh data/SF_200217_pPeptideLibrary_pool1_HCDnlETcaD_OT_rep1_comet_perc.idparquet || echo "Input idparquet directory 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()
continue-on-error: true
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
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_*.idparquet/
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