Mercurial > repos > louise > export_to_fastq
comparison export_to_fastq/export_to_fastq_past.R @ 0:97792524cc9c default tip
Migrated tool version 0.1 from old tool shed archive to new tool shed repository
author | louise |
---|---|
date | Tue, 07 Jun 2011 17:21:49 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:97792524cc9c |
---|---|
1 my.args <- commandArgs(trailingOnly = TRUE) | |
2 # ----- Check input and output directories ----- | |
3 if(!file.exists(my.args[1])){ | |
4 stop("The provided project directory does not exist!") | |
5 } | |
6 inputDirectory=my.args[1] #Directory where input data are. (e.g export or fastq ...) | |
7 | |
8 output_file = my.args[3] | |
9 | |
10 threshold=as.numeric(my.args[2]) #threshold for nFilter | |
11 | |
12 #print(my.args) | |
13 | |
14 library(ShortRead) | |
15 #source('/home/galaxy/galaxy_dev/tools/EMBL_tools/HTS_helper_src_for_export_to_fastq.R') | |
16 | |
17 ####Solution temporaire, chastityFilter sera dans le RNASeq package | |
18 chastityFilter <- function(.name="Illumina Chastity Filter") | |
19 { | |
20 srFilter(function(x){ | |
21 if(any(rownames(varMetadata(alignData(x))) == "filtering")){ | |
22 keep<-alignData(x)$filtering=="Y" | |
23 } else { | |
24 warning(paste("The '",.name,"' filter is only valid for Illumina reads.",sep="")) | |
25 keep<-rep(TRUE,length(x)) | |
26 } | |
27 return(keep) | |
28 },name=.name) | |
29 } | |
30 | |
31 "summarize.by.transcripts" <- function(sample,annotation){ | |
32 | |
33 transcripts <- do.call(rbind,lapply(names(sample),function(chr,sample,annotation){ | |
34 counts<-stats:::aggregate(sample[[chr]],list(transcript=annotation[chr]$transcript),sum) | |
35 },sample,annotation)) | |
36 | |
37 colnames(transcripts)[2] <- "counts" | |
38 | |
39 return(transcripts) | |
40 } | |
41 ### | |
42 | |
43 #----- FILTER ---- | |
44 filter<- compose(chastityFilter(),nFilter(threshold=threshold)) | |
45 | |
46 #----- ALIGN ---- | |
47 # call the readAligned function with this filter | |
48 aln<-readAligned(inputDirectory, type='SolexaExport',filter=filter, withAll=TRUE ) | |
49 writeFastq(aln,file=output_file,mode='a') |