Skip to content

Commit

Permalink
Fix: invalid gtdbtk json documents can't be parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasjelonek committed Aug 31, 2023
1 parent 47b739c commit 4ce83ed
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"datatables.net-bs5": "^1.13.6",
"datatables.net-vue3": "^2.1.3",
"igv": "^2.15.10",
"json5": "^2.2.3",
"pako": "^2.1.0",
"vue": "^3.2.45",
"vue-chartjs": "^5.2.0",
Expand Down
3 changes: 2 additions & 1 deletion src/BakrepApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { DatasetSchema, type Dataset } from "./model/Dataset";
import { GtdbtkResultSchema, type GtdbtkResult } from "./model/GtdbtkResult";
import { MlstResultSchema, type MlstResult } from "./model/MlstResults";
import type { SearchInfo, SearchRequest } from "./model/Search";
import json5 from "json5";

let baseurl: string = "http://localhost:8080";
function initApi(url: string) {
Expand All @@ -33,7 +34,7 @@ class BakrepApiImpl implements BakrepApi {

toJson(r: Response): Promise<any> {
if (!r.ok) throw r.text().then((t) => Promise.reject(t));
return r.json();
return r.text().then(json5.parse);
}

getDataset(id: string): Promise<Dataset> {
Expand Down
2 changes: 1 addition & 1 deletion src/model/GtdbtkResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ClassfificationSchema = z.object({

const GtdbtkResultSchema = z.object({
classification: ClassfificationSchema,
fastani_reference: z.string(),
fastani_reference: z.union([z.string(), z.nan()]),
classification_method: z.string(),
warnings: z.string(),
});
Expand Down

0 comments on commit 4ce83ed

Please sign in to comment.