Mercurial > repos > mingchen0919 > rmarkdown_fastq_dump
annotate fastq_dump_pe.Rmd @ 12:d330ce2d4663 draft
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
author | mingchen0919 |
---|---|
date | Wed, 27 Sep 2017 16:49:22 -0400 |
parents | d4a9c31d0046 |
children | 66bc1016ec2a |
rev | line source |
---|---|
11
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
1 --- |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
2 title: 'Fastq-dump: download and extract paired end reads into FASTQ/FASTA file' |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
3 output: |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
4 html_document: |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
5 number_sections: true |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
6 toc: true |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
7 theme: cosmo |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
8 highlight: tango |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
9 --- |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
10 |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
11 ```{r setup, include=FALSE, warning=FALSE, message=FALSE} |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
12 knitr::opts_chunk$set( |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
13 echo = ECHO |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
14 ) |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
15 ``` |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
16 |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
17 # Command line arguments |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
18 |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
19 ```{r 'command line arguments'} |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
20 str(opt) |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
21 ``` |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
22 |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
23 # Download and extract reads |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
24 |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
25 ```{r 'download and extract reads'} |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
26 # create a directory to store read files |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
27 dir.create('read_files_directory') |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
28 # download and extract reads |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
29 sra_accessions = strsplit(gsub(',', ' ', 'SRA_ACCESSION'), ' ')[[1]] |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
30 sra_accessions = sra_accessions[sra_accessions != ''] |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
31 # loop through SRA accessions to download and extract reads. |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
32 for(id in sra_accessions) { |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
33 if('FORMAT' == 'fasta') { |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
34 command = paste0('fastq-dump --fasta ', '-O read_files_directory ') |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
35 } else { |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
36 command = paste0('fastq-dump ', '-O read_files_directory ') |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
37 } |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
38 |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
39 if('SPLIT_FILES' == TRUE) { |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
40 command = paste0(command, '--split_files ', id) |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
41 } else { |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
42 command = paste0(command, id) |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
43 } |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
44 print(command) |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
45 system(command = command) |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
46 } |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
47 ``` |
d4a9c31d0046
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
0
diff
changeset
|
48 |
12
d330ce2d4663
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
11
diff
changeset
|
49 # Rename files |
d330ce2d4663
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
11
diff
changeset
|
50 |
d330ce2d4663
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
11
diff
changeset
|
51 ```{r} |
d330ce2d4663
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
11
diff
changeset
|
52 old_files = paste0('./read_files_directory/', list.files('./read_files_directory')) |
d330ce2d4663
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
11
diff
changeset
|
53 new_files = gsub('_1', '_forward', old_files) |
d330ce2d4663
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
11
diff
changeset
|
54 new_files = gsub('_2', '_reverse', new_files) |
d330ce2d4663
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
11
diff
changeset
|
55 file.copy('./read_files_directory/') |
d330ce2d4663
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
11
diff
changeset
|
56 ``` |
d330ce2d4663
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit affb362adeb095389646b0c51738d24c2de3838d-dirty
mingchen0919
parents:
11
diff
changeset
|
57 |