Skip to content

Commit

Permalink
fix: Pubtator3 new API responses adaptation (#643) (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
gromdimon authored Apr 18, 2024
1 parent a323f5d commit 73436d9
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/api/pubtator/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ export class PubtatorClient {
if (!exportRes.ok) {
throw new StatusCodeNotOk(`Error running PubTator 3 export: ${exportRes.statusText}`)
}
const exportDataText = await exportRes.text()
const exportDataLines = exportDataText.split(/\n/)
const exportData = (await exportRes.json())['PubTator3']

// Zip search results and exports into searchResults
const searchResults: { [key: string]: SearchResult } = {}
Expand All @@ -61,12 +60,9 @@ export class PubtatorClient {
abstract: undefined
}
}
for (const exportDataLine of exportDataLines) {
for (const record of exportData) {
try {
if (exportDataLine) {
const exportDataRecord = JSON.parse(exportDataLine)
searchResults[exportDataRecord.pmid].abstract = exportDataRecord
}
searchResults[record.id].abstract = record
} catch (e) {
throw new InvalidResponseContent(`failed to parse PubTator 3 export: ${e}`)
}
Expand Down

0 comments on commit 73436d9

Please sign in to comment.