Skip to content

Commit

Permalink
feat: progress parsing pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
dbolotin committed Oct 7, 2024
1 parent da061d5 commit f398d7c
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
68 changes: 68 additions & 0 deletions model/src/progress.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { test } from 'vitest';
import { ProgressPattern } from './progress';

// Applying correction & sorting alignments by UMI: 0%
// Alignment: 0%
// Alignment: 30.2% ETA: 00:00:02
// Alignment: 60.4% ETA: 00:00:01
//
//
// Applying correction & sorting alignments by UMI: 15.2%
// Writing result: 0%
//

test.for([
{
input: 'Applying correction & sorting alignments by UMI: 0%',
expected: {
stage: 'Applying correction & sorting alignments by UMI',
progress: '0',
eta: undefined
}
},
{
input: 'Alignment: 0%',
expected: {
stage: 'Alignment',
progress: '0',
eta: undefined
}
},
{
input: 'Alignment: 60.4% ETA: 00:00:01',
expected: {
stage: 'Alignment',
progress: '60.4',
eta: '00:00:01'
}
},
{
input: 'Alignment: 100% ETA: 00:00:00',
expected: {
stage: 'Alignment',
progress: '100',
eta: '00:00:00'
}
},
{
input: 'Final sorting: 95.2%',
expected: {
stage: 'Final sorting',
progress: '95.2',
eta: undefined
}
},
{
input: 'Initialization: progress unknown',
expected: {
stage: 'Initialization',
progress: undefined,
eta: undefined
}
}
])('parsing progress for: $input', ({ input, expected }, { expect }) => {
const match = input.match(ProgressPattern);
expect(match).toBeDefined();
const { stage, progress, eta } = match?.groups!;
expect({ stage, progress, eta }).toMatchObject(expected);
});
2 changes: 2 additions & 0 deletions model/src/progress.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const ProgressPattern =
/(?<stage>[^:]*)\:(?: *(?<progress>[0-9.]+)\%)?(?: *ETA\: *(?<eta>.+))?/;
2 changes: 1 addition & 1 deletion test/assets/expected_results/mixcr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set -e
mixcr exportPreset --preset-name milab-human-dna-xcr-7genes-multiplex -f preset.json

# --add-step assembleContigs
mixcr analyze milab-human-dna-xcr-7genes-multiplex -f ../small_data_R1.fastq.gz ../small_data_R2.fastq.gz result
mixcr analyze milab-human-dna-xcr-7genes-multiplex -f ../small_data_R1.fastq.gz ../small_data_R2.fastq.gz result > log.txt

0 comments on commit f398d7c

Please sign in to comment.