comparison fastq_dump_pe.Rmd @ 0:1a11c4fd13d0 draft

planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastq_dump commit 65063d5b207a70df38a0bcb6fb57a8f9170d9e9b
author mingchen0919
date Wed, 27 Sep 2017 21:41:29 -0400
parents
children 58d48d1157ed
comparison
equal deleted inserted replaced
-1:000000000000 0:1a11c4fd13d0
1 ---
2 title: 'Fastq-dump: download and extract paired 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 # Download and extract reads
24
25 ```{r 'download and extract reads'}
26 # create a directory to store read files
27 dir.create('read_files_directory')
28 # download and extract reads
29 sra_accessions = strsplit(gsub(',', ' ', 'SRA_ACCESSION'), ' ')[[1]]
30 sra_accessions = sra_accessions[sra_accessions != '']
31 # loop through SRA accessions to download and extract reads.
32 for(id in sra_accessions) {
33 if('FORMAT' == 'fasta') {
34 command = paste0('fastq-dump --fasta --split-files ', '-O read_files_directory ', id)
35 } else {
36 command = paste0('fastq-dump --split-files ', '-O read_files_directory ', id)
37 }
38 # fastq-dump command
39 print(command)
40 # command line stdout
41 system(command = command, intern = TRUE)
42 }
43 ```
44
45
46 # Rename files
47
48 ```{r}
49 old_files = paste0('./read_files_directory/', list.files('./read_files_directory'))
50 new_files = gsub('_1', '_forward', old_files)
51 new_files = gsub('_2', '_reverse', new_files)
52 file.rename(old_files, new_files)
53 ```
54