Skip to content

Commit b000870

Browse files
Additional case where parsing can be not strict
1 parent 4d4b01e commit b000870

File tree

8 files changed

+44
-26
lines changed

8 files changed

+44
-26
lines changed

packages/apollo-collaboration-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"@apollo-annotation/shared": "workspace:^",
4545
"@emotion/react": "^11.10.6",
4646
"@emotion/styled": "^11.10.6",
47-
"@gmod/gff": "^2.0.0",
47+
"@gmod/gff": "^2.1.0",
4848
"@gmod/indexedfasta": "^5.0.2",
4949
"@jbrowse/core": "^4.1.1",
5050
"@jbrowse/mobx-state-tree": "^5.5.0",

packages/apollo-collaboration-server/src/files/files.service.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,25 @@ export class FilesService {
105105

106106
parseGFF3(
107107
stream: ReadableStream<Uint8Array>,
108-
options?: { bufferSize?: number },
108+
options?: {
109+
bufferSize?: number
110+
errorCallback?(erroreMessage: string): void
111+
},
109112
): ReadableStream<GFF3Feature> {
113+
// eslint-disable-next-line @typescript-eslint/unbound-method
114+
const { errorCallback } = options ?? {}
110115
return stream.pipeThrough(
111116
new TransformStream(
112117
new GFFTransformer({
113118
parseSequences: false,
114119
parseComments: false,
115120
parseDirectives: false,
116121
parseFeatures: true,
122+
errorCallback: errorCallback
123+
? (errorMessage: string) => {
124+
errorCallback(errorMessage)
125+
}
126+
: undefined,
117127
...options,
118128
}),
119129
),

packages/apollo-common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"devDependencies": {
2222
"@apollo-annotation/mst": "workspace:^",
23-
"@gmod/gff": "^2.0.0",
23+
"@gmod/gff": "^2.1.0",
2424
"@nestjs/common": "^10.1.0",
2525
"@nestjs/core": "^10.1.0",
2626
"@types/node": "^24.10.9",

packages/apollo-common/src/Operation.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ export interface ServerDataStore {
4747
getFileHandle(file: FileDocument): GenericFilehandle
4848
parseGFF3(
4949
stream: ReadableStream<Uint8Array>,
50-
parseOptions?: { bufferSize?: number },
50+
parseOptions?: {
51+
bufferSize?: number
52+
errorCallback?(errorMessage: string): void
53+
},
5154
): ReadableStream<GFF3Feature>
5255
create(createFileDto: CreateFileDto): void
5356
remove(id: string): void

packages/apollo-shared/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@apollo-annotation/common": "workspace:^",
1616
"@apollo-annotation/mst": "workspace:^",
1717
"@apollo-annotation/schemas": "workspace:^",
18-
"@gmod/gff": "^2.0.0",
18+
"@gmod/gff": "^2.1.0",
1919
"@gmod/indexedfasta": "^5.0.2",
2020
"@jbrowse/core": "^4.1.1",
2121
"bson-objectid": "^2.0.4",

packages/apollo-shared/src/Changes/AddFeaturesFromFileChange.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,28 @@ export class AddFeaturesFromFileChange extends FromFileBaseChange {
8888
}
8989
logger.debug?.(`FileId "${fileId}", checksum "${fileDoc.checksum}"`)
9090

91+
let errorCount = 0
92+
// eslint-disable-next-line unicorn/consistent-function-scoping
93+
const errorLogger = (error: unknown) => {
94+
if (errorCount <= 99) {
95+
logger.warn('Error parsing or adding feature')
96+
logger.warn(error)
97+
if (errorCount === 99) {
98+
logger.warn(
99+
'Reached 100 feature errors, omitting further warnings from log',
100+
)
101+
}
102+
}
103+
errorCount++
104+
}
105+
91106
// Read data from compressed file and parse the content
92107
const { bufferSize = 10_000, strict = true } = parseOptions ?? {}
93108
const featureStream = filesService.parseGFF3(
94109
filesService.getFileStream(fileDoc),
95-
{ bufferSize },
110+
{ bufferSize, errorCallback: strict ? undefined : errorLogger },
96111
)
97112
let featureCount = 0
98-
let errorCount = 0
99113
for await (const gff3Feature of featureStream) {
100114
// Add new feature into database
101115
try {
@@ -105,16 +119,7 @@ export class AddFeaturesFromFileChange extends FromFileBaseChange {
105119
if (strict || featureCount === 0) {
106120
throw error
107121
}
108-
if (errorCount <= 99) {
109-
logger.warn('Error parsing feature')
110-
logger.warn(error)
111-
if (errorCount === 99) {
112-
logger.warn(
113-
'Reached 100 parsing errors, omitting further warnings from log',
114-
)
115-
}
116-
}
117-
errorCount++
122+
errorLogger(error)
118123
}
119124
featureCount++
120125
if (featureCount % 1000 === 0) {

packages/jbrowse-plugin-apollo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"@apollo-annotation/shared": "workspace:^",
5252
"@emotion/react": "^11.10.6",
5353
"@emotion/styled": "^11.10.6",
54-
"@gmod/gff": "^2.0.0",
54+
"@gmod/gff": "^2.1.0",
5555
"@jbrowse/plugin-authentication": "^4.1.1",
5656
"@jbrowse/plugin-linear-genome-view": "^4.1.1",
5757
"@mui/icons-material": "^7.3.7",

yarn.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ __metadata:
372372
"@apollo-annotation/shared": "workspace:^"
373373
"@emotion/react": "npm:^11.10.6"
374374
"@emotion/styled": "npm:^11.10.6"
375-
"@gmod/gff": "npm:^2.0.0"
375+
"@gmod/gff": "npm:^2.1.0"
376376
"@gmod/indexedfasta": "npm:^5.0.2"
377377
"@jbrowse/core": "npm:^4.1.1"
378378
"@jbrowse/mobx-state-tree": "npm:^5.5.0"
@@ -453,7 +453,7 @@ __metadata:
453453
dependencies:
454454
"@apollo-annotation/mst": "workspace:^"
455455
"@apollo-annotation/schemas": "workspace:^"
456-
"@gmod/gff": "npm:^2.0.0"
456+
"@gmod/gff": "npm:^2.1.0"
457457
"@jbrowse/core": "npm:^4.1.1"
458458
"@nestjs/common": "npm:^10.1.0"
459459
"@nestjs/core": "npm:^10.1.0"
@@ -490,7 +490,7 @@ __metadata:
490490
"@babel/preset-env": "npm:^7.28.6"
491491
"@emotion/react": "npm:^11.10.6"
492492
"@emotion/styled": "npm:^11.10.6"
493-
"@gmod/gff": "npm:^2.0.0"
493+
"@gmod/gff": "npm:^2.1.0"
494494
"@jbrowse/cli": "npm:^4.1.1"
495495
"@jbrowse/core": "npm:^4.1.1"
496496
"@jbrowse/development-tools": "npm:^2.2.1"
@@ -617,7 +617,7 @@ __metadata:
617617
"@apollo-annotation/common": "workspace:^"
618618
"@apollo-annotation/mst": "workspace:^"
619619
"@apollo-annotation/schemas": "workspace:^"
620-
"@gmod/gff": "npm:^2.0.0"
620+
"@gmod/gff": "npm:^2.1.0"
621621
"@gmod/indexedfasta": "npm:^5.0.2"
622622
"@jbrowse/core": "npm:^4.1.1"
623623
"@jbrowse/mobx-state-tree": "npm:^5.5.0"
@@ -7186,10 +7186,10 @@ __metadata:
71867186
languageName: node
71877187
linkType: hard
71887188

7189-
"@gmod/gff@npm:^2.0.0":
7190-
version: 2.0.0
7191-
resolution: "@gmod/gff@npm:2.0.0"
7192-
checksum: 10c0/f8a40c0eb84eeffcea49aa65e0656a12e8810fb0525b61272be443c9d45790a00ae84ad19808c5f30acd8a69714b04bcaacd5c469a65e8f6ae36920bf6ccca00
7189+
"@gmod/gff@npm:^2.1.0":
7190+
version: 2.1.0
7191+
resolution: "@gmod/gff@npm:2.1.0"
7192+
checksum: 10c0/0f83d5cbbfe6338d89d5f0939c4c35f72d4f13085522d01e777e72ee614ea1aa9ccdca6a7df05bde4cccae99f8cd2b8d04b9c27197f88442810bda508e0ab6cc
71937193
languageName: node
71947194
linkType: hard
71957195

0 commit comments

Comments
 (0)