Skip to content

Commit

Permalink
Merge pull request #49 from UCLOrengoGroup/48-get-protein-length-from…
Browse files Browse the repository at this point in the history
…-alphafold-api

48 get protein length from alphafold api
  • Loading branch information
sillitoe authored Oct 8, 2024
2 parents 2d8e6c4 + 759c734 commit 750c422
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"uniprot_entry": {
"ac": "A0A6P4PER7",
"id": "A0A6P4PER7_GOSAR",
"uniprot_checksum": "E5BF4AF471D8B238",
"sequence_length": 960,
"segment_start": 1,
"segment_end": 960
},
"structures": [
{
"summary": {
"model_identifier": "AF-A0A6P4PER7-F1",
"model_category": "AB-INITIO",
"model_url": "https://alphafold.ebi.ac.uk/files/AF-A0A6P4PER7-F1-model_v4.cif",
"model_format": "MMCIF",
"model_type": null,
"model_page_url": "https://alphafold.ebi.ac.uk/entry/A0A6P4PER7",
"provider": "AlphaFold DB",
"number_of_conformers": null,
"ensemble_sample_url": null,
"ensemble_sample_format": null,
"created": "2022-06-01",
"sequence_identity": 1,
"uniprot_start": 1,
"uniprot_end": 960,
"coverage": 1,
"experimental_method": null,
"resolution": null,
"confidence_type": "pLDDT",
"confidence_version": null,
"confidence_avg_local_score": 79.38,
"oligomeric_state": null,
"preferred_assembly_id": null,
"entities": [
{
"entity_type": "POLYMER",
"entity_poly_type": "POLYPEPTIDE(L)",
"identifier": "A0A6P4PER7",
"identifier_category": "UNIPROT",
"description": "probable disease resistance protein At1g58602",
"chain_ids": [
"A"
]
}
]
}
}
]
}
16 changes: 16 additions & 0 deletions frontend/src/components/AlphaFoldService/service.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { expect, test } from 'vitest'

import { convertWebToModel } from './service'

import data_A0A6P4PER7 from './service.test.A0A6P4PER7.json'

test('gets correct UniProt data from A0A6P4PER7', () => {
expect(data_A0A6P4PER7.uniprot_entry.ac).toBe('A0A6P4PER7')

const up_data = convertWebToModel(data_A0A6P4PER7)
expect(up_data.ac).toBe('A0A6P4PER7')
expect(up_data.id).toBe('A0A6P4PER7_GOSAR')
expect(up_data.uniprot_checksum).toBe('E5BF4AF471D8B238')
expect(up_data.sequence_length).toBe(960)
})

28 changes: 28 additions & 0 deletions frontend/src/components/AlphaFoldService/service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import axios from "axios";

import { UniprotEntry } from "../../client/models/UniprotEntry"

const http = axios.create({
baseURL: "https://alphafold.ebi.ac.uk/api/uniprot/summary/",
headers: {
"Content-type": "application/json"
}
});

export const convertWebToModel = (data: any): UniprotEntry => {
return data.uniprot_entry;
}

const get = (id: any): Promise<UniprotEntry> => {
return http.get(`/${id}.json`)
.then((response) => {
// console.log("AlphaFold.API.response.data: ", response.data)
return convertWebToModel(response.data);
});
};

const AlphaFoldUniprotEntryDataService = {
get,
};

export default AlphaFoldUniprotEntryDataService;
2 changes: 1 addition & 1 deletion frontend/src/components/Utils/uniprotAccUtils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test('render_cath_label_single_label', () => {
const cath_label = '1.10.8.10,2.40.60.10'
const expected = render(
<>
{ cath_label.split(",").map((cath_id) => {
{ [cath_label.split(",")[0]].map((cath_id) => {
return <Link href={`${CATH_BASE_URL}/version/latest/cathnode/${cath_id}`} isExternal>
{cath_id} <ExternalLinkIcon mx={"2px"}/>
</Link>
Expand Down
24 changes: 20 additions & 4 deletions frontend/src/routes/_layout/uniprot/$uniprotAcc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const Route = createFileRoute("/_layout/uniprot/$uniprotAcc")({
import { getQueryParamsFromChoppingString, getDomainAnnotationFromDomainSummary } from "../../../components/Utils/DomainSummary"
import UniprotEntryDataService from "../../../components/UniprotService/service"
import { UniprotData } from "../../../components/UniprotService/model"
import { UniprotEntry } from "../../../client/models/UniprotEntry"
import classes from './$uniprotAcc.module.css'
import ProteinSummaryFigure, { ProteinSummaryFigureProps } from "../../../components/Common/ProteinSummaryFigure"

Expand All @@ -54,6 +55,7 @@ import {
get_chainparse_data_link,
get_domainsummary_data_link
} from "../../../components/Utils/uniprotAccUtils"
import AlphaFoldUniprotEntryDataService from "../../../components/AlphaFoldService/service"


function UniprotAcc() {
Expand All @@ -64,6 +66,8 @@ function UniprotAcc() {
const [ selectedDomainId, setSelectedDomainId ] = useState<string | null>(null)
const [ uniprotEntry, setUniprotEntry ] = useState<UniprotData | null>(null)
const [ uniprotDidLoad, setUniprotDidLoad ] = useState<boolean>(false)
const [ afUniProtEntry, setAFUniprotEntry ] = useState<UniprotEntry | null>(null)
const [ afDidLoad, setAFDidLoad ] = useState<boolean>(false)
const domainSummaryResult = useQuery(["domainsummary", uniprotAcc], () => {
return UniprotService.readUniprotSummary({
uniprotAcc: uniprotAcc,
Expand Down Expand Up @@ -102,6 +106,16 @@ function UniprotAcc() {
})
setUniprotDidLoad(true)
}
if (!afDidLoad) {
// console.log("useEffect.UPDATE: ", uniprotAcc)
AlphaFoldUniprotEntryDataService.get(uniprotAcc).then((up_entry: UniprotEntry) => {
// console.log("afuniprot.data: ", up_entry);
setAFUniprotEntry(up_entry);
}).catch((err) => {
console.error("Error fetching AF UniProt entry: ", err)
})
setAFDidLoad(true)
}
}, [uniprotAcc])

const selectChopping = (dom: DomainSummaryPublicWithInteractions) => {
Expand Down Expand Up @@ -143,11 +157,11 @@ function UniprotAcc() {
let structureFigure = null
if (domain_summary_entries) {
const domain_annotations = domain_summary_entries.data.map((d) => getDomainAnnotationFromDomainSummary(d))
if (uniprotEntry) {
if (afUniProtEntry && afUniProtEntry.sequence_length) {
const opts: ProteinSummaryFigureProps = {
width: 500,
height: 30,
totalResidues: uniprotEntry.sequence.length,
totalResidues: afUniProtEntry.sequence_length,
domainAnnotations: domain_annotations,
}
if (highlightedDomainId) {
Expand All @@ -168,11 +182,13 @@ function UniprotAcc() {
<dl>
<dt>Accession</dt>
<dd>{uniprotAcc}</dd>
{afUniProtEntry && (<>
<dt>Length</dt>
<dd>{afUniProtEntry.sequence_length} Residues</dd>
</>)}
{uniprotEntry ? (<>
<dt>Name</dt>
<dd>{uniprotEntry.proteinDescription.fullName}</dd>
<dt>Length</dt>
<dd>{uniprotEntry.sequence.length} Residues</dd>
<dt>Organism</dt>
<dd>{uniprotEntry.organism.scientificName}</dd>
<dt>Lineage</dt>
Expand Down

0 comments on commit 750c422

Please sign in to comment.