SRX from SRR IDs
4
5
Entering edit mode
10.0 years ago
biorepine ★ 1.5k

Does any one know how to extract SRX ids from SRR ids. Thanks.

ex:

Input

SRR1294518

Output

SRR1294518  SRX549132
SRA • 8.1k views
ADD COMMENT
5
Entering edit mode
10.0 years ago

Have a look at the SRAdb package in Bioconductor. You do have to download the SRA database backup (I suspect there's a way to remotely query it, but perhaps not). Then you can use the sraConvert() command. This also allows you to download datasets associated with a run/sample/whatever easily.

ADD COMMENT
2
Entering edit mode
10.0 years ago

Same as Devon's suggestion. I was doing something similar a little while ago and I still have it fresh:

R
library(SRAdb)
## Get DB (might take few minutes)
sqlfile <- getSRAdbFile(destfile = paste(Sys.Date(), "SRAmetadb.sqlite.gz", sep= '.'))
sra_con<- dbConnect(SQLite(), sqlfile)

##  Get exp accession for run accession:
dbGetQuery(sra_con, "select run_accession, experiment_accession from sra where run_accession = 'SRR1294518'")
  run_accession experiment_accession
1    SRR1294518            SRX549132

## Get more info:
dbGetQuery(sra_con, "select * from sra where run_accession = 'SRR1294518'")

## Query for more than one run accession id:
dbGetQuery(sra_con, "select * from sra where run_accession in ('SRR1294518', 'SRR1294519')")
ADD COMMENT
2
Entering edit mode
7.5 years ago
James Ashmore ★ 3.5k

With E-utilities installed you can use the following command:

esearch -db sra -query SRR1294518 | esummary | xtract -pattern DocumentSummary -element Run@acc Experiment@acc
ADD COMMENT
0
Entering edit mode

Be careful though when converting larger number of accessions. When converting ca 500 Sample accessions to Run accessions, somewhere in the middle of the process, one conversion failed for me with "Can't fetch uids from history because of: Result not ready".

ADD REPLY
0
Entering edit mode
7.5 years ago
Shicheng Guo ★ 9.5k

I can share my perl script to collect SRR and SRX information together. You can make further adoption

#!/usr/bin/perl -w

# A perl script to build config file for SRS Bam Merge
# Version 1.3
# Go to http://sra.dnanexus.com/studies/SRP028600/samples
# Select SRS and Click Related RUNS then get the Table as the input

use strict;
use warnings;
use Cwd;

use strict;
use warnings;
use Cwd;

my $file=shift @ARGV;
my %SRA;
open F,$file;
while(<F>){
chomp;
if(/(SRR\d+)/){
    my $SRR=$1;
    if(/(SRX\d+)/){
        my $SRX=$1;
        print "$SRR\t$SRX\n";
        push @{$SRA{$SRX}},$SRR;
        }
    }
}

foreach my $SRS(sort keys %SRA){
        print "$SRS";
        foreach my $SRR (@{$SRA{$SRS}}){
                print "\t$SRR";
        }
        print "\n";
}
ADD COMMENT

Login before adding your answer.

Traffic: 2727 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6