annotate fastq_dump_pe.Rmd @ 1:cd86400bbaed draft

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