forked from 3dbionotes-community/3DBIONOTES
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #231 from EyeSeeTea/feature/api-structural-hub
Replace covid19-data json for Django API endpoint
- Loading branch information
Showing
104 changed files
with
10,254 additions
and
433,831 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
app/assets/javascripts/3dbio_viewer/src/data/NMRScreening.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import _ from "lodash"; | ||
import { Codec, GetType, nullType, number, oneOf, string } from "purify-ts"; | ||
import { NMRFragmentTarget } from "../domain/entities/Protein"; | ||
import { commonLigand, pdbLigandC } from "./PdbLigands"; | ||
|
||
const featureTypeCodec = Codec.interface({ | ||
dataSource: string, | ||
name: string, // binding | not binding | ||
description: string, | ||
externalLink: string, | ||
}); | ||
|
||
export const nmrFragmentCodec = Codec.interface({ | ||
name: string, | ||
description: string, | ||
externalLink: string, | ||
pdbentry: nullType, | ||
uniprotentry: string, | ||
ligandentity: oneOf([Codec.interface(commonLigand), pdbLigandC]), | ||
details: Codec.interface({ | ||
type: string, // binding | notbinding | ||
entity: string, // NMR target | ||
}), | ||
start: number, | ||
end: number, | ||
featureType: featureTypeCodec, | ||
}); | ||
|
||
export type NMRScreeningFragment = GetType<typeof nmrFragmentCodec>; | ||
|
||
export function getNMR(nmrScreenings: NMRScreeningFragment[]): NMRFragmentTarget[] { | ||
const fragments = nmrScreenings.map(nmr => ({ | ||
...nmr, | ||
binding: !nmr.details.type.toLowerCase().includes("not"), | ||
})); | ||
|
||
const targets = _(fragments) | ||
.groupBy(i => i.details.entity) | ||
.toPairs() | ||
.value(); | ||
|
||
return targets.flatMap(([name, targetFragments]) => { | ||
const fragments = targetFragments.map( | ||
({ name, description, externalLink, binding, ligandentity, start, end }) => ({ | ||
name, | ||
description, | ||
externalLink, | ||
binding, | ||
ligand: { | ||
...ligandentity, | ||
inChI: ligandentity.IUPACInChIkey, | ||
smiles: ligandentity.canonicalSMILES, | ||
pubchemId: ligandentity.pubChemCompoundId, | ||
formula: ligandentity.formula, | ||
imageDataResource: undefined, | ||
}, | ||
start, | ||
end, | ||
}) | ||
); | ||
|
||
const start = _.first(fragments.map(({ start }) => start)); | ||
const end = _.first(fragments.map(({ end }) => end)); | ||
const uniprotId = _.first(targetFragments.map(({ uniprotentry }) => uniprotentry)); | ||
if (!start || !end || !uniprotId) return []; | ||
|
||
return [ | ||
{ | ||
name, | ||
uniprotId, | ||
fragments, | ||
bindingCount: fragments.filter(({ binding }) => binding).length, | ||
notBindingCount: fragments.filter(({ binding }) => !binding).length, | ||
start, | ||
end, | ||
}, | ||
]; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import _ from "lodash"; | ||
import { Codec, GetType, number, string } from "purify-ts"; | ||
|
||
export const nmrTargetCodec = Codec.interface({ | ||
entity: string, | ||
start: number, | ||
end: number, | ||
uniprot_acc: string, | ||
}); | ||
|
||
export type NMRTarget = GetType<typeof nmrTargetCodec>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/assets/javascripts/3dbio_viewer/src/data/codec-utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Codec, array, nullable, number, optional, string } from "purify-ts"; | ||
|
||
export function paginationCodec<Data>(type: Codec<Data>): Codec<Pagination<Data>> { | ||
return Codec.interface({ | ||
count: number, | ||
next: optional(nullable(string)), | ||
previous: optional(nullable(string)), | ||
results: array(type), | ||
}); | ||
} | ||
|
||
export function getResults<Data>(pagination?: Pagination<Data>) { | ||
return pagination?.results ?? []; | ||
} | ||
|
||
export type Pagination<K> = { | ||
count: number; | ||
next: string | null | undefined; | ||
previous: string | null | undefined; | ||
results: K[]; | ||
}; |
Oops, something went wrong.