3
$\begingroup$

I previously asked a question about how to retrieve the Accession List associated with a SRA project. The answer was:

esearch -db sra -query 'PRJNA491191[bioproject]' | efetch -format runinfo

where PRJNA491191 is the bioproject that I'm interested in in this example. How can I do the same for the metadata file (the arrow in the picture below is pointing to accession list. It should point to metadata, which is what I'm interested in now)? enter image description here

$\endgroup$
1
$\begingroup$

Depending on exactly which information you seek, you can try:

esearch -db sra -query 'PRJNA491191[bioproject]' | efetch -format native -mode xml

This will return an XML with additional information that is not present in the runinfo table. You can use the Entrez Direct tool xtract to parse the output XML and extract the fields of interest into a tabular format.

Alternatively, you can try:

esearch -db sra -query 'PRJNA491191[bioproject]' | esummary

to retrieve a summary output that includes fewer fields than the efetch option shown above. Perhaps all of the fields that are of interest to you are present in the summary output... it will save you time and effort in parsing the XML and retrieving the information you want.

For example, you can use the following to retrieve some fields using xtract from the esummary output:

$ esearch -db sra -query 'PRJNA491191[bioproject]' \
  | esummary \
  | xtract -pattern DocumentSummary -element Summary/Title,Statistics@total_size,Study@acc 
GSM3391430: hsf-1(OE) rep3; Caenorhabditis elegans; RNA-Seq  731402855  SRP161795
GSM3391429: hsf-1(OE) rep2; Caenorhabditis elegans; RNA-Seq  703822418  SRP161795
GSM3391428: hsf-1(OE) rep1; Caenorhabditis elegans; RNA-Seq  715482490  SRP161795
...
$\endgroup$
3
  • $\begingroup$ Thank you. So I want to create a csv file from the output. Also, I'd like to keep all columns. How can I do this? I'm trying esearch -db sra -query 'PRJNA491191[bioproject]' | esummary | xtract -pattern DocumentSummary -sep "," -element but I'm not sure what should go after -element since I want to keep everything $\endgroup$ Jun 8 at 16:47
  • $\begingroup$ Also, I can't specify all columns because I don't know what they are beforehand (I know I can look them up from the output but I'm doing this for many projects so I practically can't do this manually) $\endgroup$ Jun 8 at 16:50
  • $\begingroup$ You have to specify the elements to be able to retrieve the fields you are interested in. Unfortunately, you cannot retrieve everything using xtract without knowing the field names. I will update my answer above with an example. $\endgroup$
    – vkkodali
    Jun 9 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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