comparison bdss_client_sra_se.Rmd @ 0:614e9553f366 draft

planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
author mingchen0919
date Tue, 10 Oct 2017 20:19:52 -0400
parents
children c707a4178832
comparison
equal deleted inserted replaced
-1:000000000000 0:614e9553f366
1 ---
2 title: 'Fastq-dump: download and extract single end reads into FASTQ/FASTA file'
3 output:
4 html_document:
5 number_sections: true
6 toc: true
7 theme: cosmo
8 highlight: tango
9 ---
10
11 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
12 knitr::opts_chunk$set(
13 echo = ECHO
14 )
15 ```
16
17 # Command line arguments
18
19 ```{r 'command line arguments'}
20 str(opt)
21 ```
22
23 # BDSS configuration file
24
25 First, we create a bdss configuration file `bdss.cfg` in the current directory.
26
27 ```{r}
28 system('echo "[metadata_repository]" > bdss.cfg')
29 system('echo url=http://bdss.bioinfo.wsu.edu/ >> bdss.cfg')
30 ```
31
32 # Download and extract reads
33
34 ```{r 'download and extract reads'}
35 # create a directory to store read files
36 dir.create('read_files_directory')
37 # download and extract reads
38 sra_accessions = strsplit(gsub(',', ' ', 'SRA_ACCESSION'), ' ')[[1]]
39 sra_accessions = sra_accessions[sra_accessions != '']
40 # loop through SRA accessions to download and extract reads.
41 for(id in sra_accessions) {
42 # build URL from SRA accession
43 url = paste0('ftp://ftp.ncbi.nlm.nih.gov/sra/sra-instant/reads/ByRun/sra/SRR/',
44 substr(id, 1, 6), '/', id, '/', id, '.sra')
45 # download sra file with bdss
46 bdss_command = paste0('/tool_deps/_conda/bin/bdss transfer -u ', url)
47 system(bdss_command, intern = TRUE)
48 # convert .sra to .fastq/.fasta
49 if('FORMAT' == 'fasta') {
50 command = paste0('fastq-dump --fasta ', '-O read_files_directory ', id)
51 } else {
52 command = paste0('fastq-dump ', '-O read_files_directory ', id)
53 }
54 }
55
56 # remove all .sra file
57 system('rm *.sra', intern = TRUE)
58 ```
59
60 * `fastq-dump` command
61 ```{r}
62 print(command)
63 ```
64
65 * `command line stdout`
66
67 ```{r}
68 system(command = command, intern = TRUE)
69 ```
70