Skip to content

feat: api used to query ENA REST API for data #310 #402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Smeds
Copy link
Collaborator

@Smeds Smeds commented Mar 19, 2025

This pull-request introduces API calls for accessing the ENA REST API. I placed them here because ENA requires cross-site validation, and I encountered errors when making the calls directly from the component. From what I understand, this issue arises because the component runs on the client side rather than the server. There may be alternative solutions, but this approach resolves the problem for now.

Spin up dev environment

npm run dev

Perform request against api

curl -d '{"filter":"tax_id=65658"}' -X POST http://127.0.0.1:3000/apis/interface/ena  | jq
curl -d '{"filter":"sample_accession=SAMN09946140"}' -X POST http://127.0.0.1:3000/apis/interface/ena  | jq
curl -d '{"filter":"accession=GCA_009859065.2"}' -X POST http://127.0.0.1:3000/apis/interface/ena  | jq

Once this is merged, I will submit a pull request with the component that constructs the query string and displays the data.

There's one change that I would like to do and that is to make the following part configurable:

const assembly_fields = [
  "accession",
  "sra_md5",
  "base_count",
  "study_accession",
  "sample_accession",
  "instrument_platform",
  "instrument_model",
  "library_layout",
  "fastq_ftp",
  "fastq_md5",
];
const ena_url = "https://www.ebi.ac.uk/ena/portal/api/search";
const items_limit = 1000;
const number_of_retries = 3;
const sleep_before_retry = 1000;

How would I implement this to make it fit into how brc-analytics is configured?

Example of return data

command: curl -d '{"filter":"tax_id=65658"}' -X POST http://127.0.0.1:3000/apis/interface/ena | jq

{
  "count": 1,
  "data": [
    {
      "accession": "SRR29779594",
      "sra_md5": "dc8ca138c152e2d440b59389d1915b98",
      "base_count": "42550146",
      "study_accession": "PRJNA1133725",
      "sample_accession": "SAMN42396386",
      "instrument_platform": "CAPILLARY",
      "instrument_model": "AB 3730xL Genetic Analyzer",
      "library_layout": "PAIRED",
      "fastq_ftp": "ftp.sra.ebi.ac.uk/vol1/fastq/SRR297/094/SRR29779594/SRR29779594.fastq.gz",
      "fastq_md5": "d5178e40b12df73c9ba35bd57862ea47"
    }
  ]
}

@Smeds Smeds requested a review from NoopDog March 19, 2025 18:37
@Smeds Smeds mentioned this pull request Mar 19, 2025
@Smeds Smeds changed the title feat: api used to query ENA REST API for data feat: api used to query ENA REST API for data #310 Mar 19, 2025
@NoopDog NoopDog requested a review from hunterckx March 19, 2025 22:29
@dannon dannon added the feat label May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants