Does any one know how to extract SRX ids from SRR ids. Thanks.
ex:
Input
SRR1294518
Output
SRR1294518 SRX549132
Does any one know how to extract SRX ids from SRR ids. Thanks.
ex:
Input
SRR1294518
Output
SRR1294518 SRX549132
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.
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')")
With E-utilities installed you can use the following command:
esearch -db sra -query SRR1294518 | esummary | xtract -pattern DocumentSummary -element Run@acc Experiment@acc
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";
}
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
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".