3
$\begingroup$

I am trying to download raw sequence data from the SRA database using the SRA toolkit (v.3.0.2). Unfortunately, the authors of the article I am reading gave SRA numbers (i.e. with the SRA prefix, not the SRR). This does not seem to work with the prefetch command:

prefetch --max-size 100000000 SRAxxxxxx -O downloads_SRAxxxxxx/

I ended up going on NCBI and manually finding the relevant SRR number for each sample; however, I was wondering if I could have done it programmatically. I appreciate your help.

Edit: Thank you for your comments, here are a couple of examples:

SRA030738 ; SRA030736 ;

Searching for them on SRA I found the SRR numbers, respectively:

SRR135604 ; SRR135602.

The paper is Hasan et al, 2012: DOI: 10.1073/pnas.1207359109

$\endgroup$
3
  • 2
    $\begingroup$ Please edit your question and add a couple of example SRAs so we can test our solutions out without needing to go and look one up. $\endgroup$
    – terdon
    Apr 29 at 14:03
  • 2
    $\begingroup$ SRA is an unusual prefix for an accession within SRA; I'm used to SRR (for runs), SRX (for experiements), SRS (for samples), and SRP (for projects). Can you please provide a link to the paper, or an alternative example? $\endgroup$
    – gringer
    Apr 29 at 23:19
  • $\begingroup$ Can confirm, Supplementary Document #1 has codes starting with SRA. Searched first one in NCBI and I get two runs (starting with SRR...) from the same BioProject that seem to be correct. Maybe the SRA-starting code is something mainly meant for the submitter? I wonder if there's a way to programmatically turn these codes into something more useful (BioProject code, run code...) $\endgroup$
    – Laura
    May 2 at 12:13

2 Answers 2

2
$\begingroup$

Using Entrez Direct E-utils, run the following command for your two examples:

esearch -db SRA -query 'SRA030738 OR SRA030736' | efetch -format docsum | xtract -pattern DocumentSummary -element Runs | xtract -pattern Run -element Run@acc

(I know, it seems strange to run xtract twice, but the formatting on the plain xml output is dodgy. The first pass parsed out the unwanted &gt or &lt or &quot characters. The second pass worked on the re-formatted stdout)

$\endgroup$
1
  • 1
    $\begingroup$ Perfect, the solution works. Thank you for taking the time to explain the double xtract 👍 $\endgroup$
    – Max_IT
    May 5 at 13:38
3
$\begingroup$

@Max_IT and @user3479780 Thanks for bringing this issue to our attention. It has been fixed in EDirect 19.5, which is now available on our public ftp site (See installation instructions here). Please update your installation and try again.

The problem was that using capitalized -db "SRA" bypassed normalization of the record. This was easily solved within EDirect by lower-casing the -db argument value to make it case-insensitive.

Normalization unescapes the XML-encoded ExpXml and Runs field contents to integrate them as regular XML within the docsum in situ, before passing them to the user. Thus:

efetch -db SRA -format docsum -id SRA030738,SRA030736 |
xtract -pattern DocumentSummary -element Run@acc

will now work properly, without the need for chaining two xtract commands together.

When creating structured records, NCBI internal software enforces conformation to the ASN.1 specification or XML document type definition. This is normally beneficial, blocking syntactically invalid records (and preventing new software bugs from silently corrupting production pipelines), but it limits the ability to add experimental structured data that is not (yet) in the spec.

Since xtract does not use a spec or DTD, it can find any element within the newly-unescaped contents by object name. (It still checks for properly-balanced opening and closing tags.)

Note also that you can skip the esearch step if you know the identifiers, and can instead pass them directly to efetch in an -id argument. For larger sets of identifiers, you can now pipe them from a file, one ID per line, without the need for an epost step.

EDirect has logic to split large lists into smaller chunks, sized appropriately for each database, and will internally loop through the fetch requests until all of the IDs have been processed, automatically retrying in the event of transient network or server failure.

$\endgroup$
1
  • $\begingroup$ Great, thank you, it sounds like this corrects the issue. The explanation on the usage of the new version is much appreciated. $\endgroup$
    – Max_IT
    May 9 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.