Mercurial > repos > mingchen0919 > rmarkdown_bdss_client
annotate bdss_client_sra_pe.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 | 
| rev | line source | 
|---|---|
| 
0
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
1 --- | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
2 title: 'Fastq-dump: download and extract paired end reads into FASTQ/FASTA file' | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
3 output: | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
4 html_document: | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
5 number_sections: true | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
6 toc: true | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
7 theme: cosmo | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
8 highlight: tango | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
9 --- | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
10 | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
11 ```{r setup, include=FALSE, warning=FALSE, message=FALSE} | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
12 knitr::opts_chunk$set( | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
13 echo = ECHO | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
14 ) | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
15 ``` | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
16 | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
17 # Command line arguments | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
18 | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
19 ```{r 'command line arguments'} | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
20 str(opt) | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
21 ``` | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
22 | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
23 # Download and extract reads | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
24 | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
25 ```{r 'download and extract reads'} | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
26 # create a directory to store read files | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
27 dir.create('read_files_directory') | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
28 # download and extract reads | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
29 sra_accessions = strsplit(gsub(',', ' ', 'SRA_ACCESSION'), ' ')[[1]] | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
30 sra_accessions = sra_accessions[sra_accessions != ''] | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
31 # loop through SRA accessions to download and extract reads. | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
32 for(id in sra_accessions) { | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
33 # build URL from SRA accession | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
34 url = paste0('ftp://ftp.ncbi.nlm.nih.gov/sra/sra-instant/reads/ByRun/sra/SRR/', | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
35 substr(id, 1, 6), '/', id, '/', id, '.sra') | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
36 # download sra file with bdss | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
37 bdss_command = paste0('/tool_deps/_conda/bin/bdss transfer -u ', url) | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
38 system(bdss_command, intern = TRUE) | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
39 # convert .sra to .fastq/.fasta | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
40 if('FORMAT' == 'fasta') { | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
41 command = paste0('fastq-dump --fasta --split-files ', '-O read_files_directory ', id) | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
42 } else { | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
43 command = paste0('fastq-dump --split-files ', '-O read_files_directory ', id) | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
44 } | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
45 # command line stdout | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
46 system(command = command, intern = TRUE) | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
47 } | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
48 # remove all .sra file | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
49 system('rm *.sra', intern = TRUE) | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
50 ``` | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
51 | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
52 | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
53 # Rename files | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
54 | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
55 ```{r} | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
56 old_files = paste0('./read_files_directory/', list.files('./read_files_directory')) | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
57 new_files = gsub('_1', '_forward', old_files) | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
58 new_files = gsub('_2', '_reverse', new_files) | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
59 file.rename(old_files, new_files) | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
60 ``` | 
| 
 
614e9553f366
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit 36de2ee9751d1ef5db0c76c217fd5ba262ca3739-dirty
 
mingchen0919 
parents:  
diff
changeset
 | 
61 | 
