SCM

SCM Repository

[batman] Annotation of /pkg/batman/R/createChemShiftPerSpec.R
ViewVC logotype

Annotation of /pkg/batman/R/createChemShiftPerSpec.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 120 - (view) (download)

1 : jie 120 createChemShiftPerSpec <-function(templateOption = 1, dirIP)
2 :     {
3 :     ## written by Dr. Jie Hao
4 :     if(missing(dirIP))
5 :     {
6 :     return("Please provide input to 'dirIP'.\n")
7 :     }
8 :     dirA <- dirIP
9 :    
10 :     dirCS<-paste(dirA,"/chemShiftPerSpec.csv",sep="")
11 :     dir1<-paste(dirA,"/batmanOptions.txt",sep="")
12 :     dir2<-paste(dirA,"/NMRdata.txt",sep="")
13 :     #dirL<-paste(dirA,"/metabolitesList.csv",sep="")
14 :     dirR<-paste(dirA,"/multi_data.csv",sep="")
15 :     dirRU<-paste(dirA,"/multi_data_user.csv",sep="")
16 :    
17 :     if (templateOption == 1)
18 :     {
19 :     cat("Copying multiplet list from multi_data.csv to chemShiftPerSpec.csv...\n")
20 :     b<-read.csv(dirR,header=T,stringsAsFactors=FALSE,colClasses="character")
21 :     } else if (templateOption == 2) {
22 :     cat("Copying multiplet list from multi_data_user.csv to chemShiftPerSpec.csv...\n")
23 :     b<-read.csv(dirRU,header=T,stringsAsFactors=FALSE,colClasses="character")
24 :     } else if (templateOption == 3) {
25 :     cat("Copying multiplet list from multi_data.csv and multi_data_user.csv to chemShiftPerSpec.csv...\n")
26 :     b1<-read.csv(dirR,header=T,stringsAsFactors=FALSE,colClasses="character")
27 :     b2<-read.csv(dirRU,header=T,stringsAsFactors=FALSE,colClasses="character")
28 :     b<-rbind(b1,b2)
29 :     }
30 :     ## prepare template file for c++
31 :     bn<-nrow(b)
32 :     ind <-6:8
33 :     for (i in ind)
34 :     {
35 :     check<-b[,i]=='n'
36 :     b[check,i]=-50
37 :     }
38 :     ##D<-order(b[,1])
39 :     tempData<-b
40 :    
41 :     ## read in batman optitons
42 :     con <- file(dir1, open = "r")
43 :     oneLine <- readLines(con, n = 30, warn = FALSE)
44 :     fL<-substr(oneLine,1,1)
45 :     nL<-which(is.na(match(fL,"%")))
46 :     myVector <- strsplit(oneLine[nL[2]], ":")
47 :     ranges <- strsplit(myVector[[1]][2],",")
48 :     sno <- NULL
49 :     sno <-getSpectraRange(myVector)
50 :     ## sNo <- as.numeric(myVector[[1]][2])
51 :     close(con)
52 :     sNo <- length(sno)
53 :    
54 :     sa<-read.table(dir2, header=TRUE,sep="\t",comment.char = "")
55 :     if ((ncol(sa)-1)<sNo)
56 :     return(cat("No. of spectra included smaller than input spectra.\n"))
57 :     if (!is.null(colnames(sa))) {
58 :     saname<-colnames(sa)
59 :     saname<-saname[2:length(saname)]
60 :     sTitle<-rbind(1:length(saname),saname)
61 :     } else {
62 :     sTitle<-rbind(1:(ncol(sa)-1),1:(ncol(sa)-1))
63 :     }
64 :    
65 :    
66 :     chemlist <- NULL
67 :     #for (n in 1:length(metaList))
68 :     #{
69 :     #chemlist<-rbind(chemlist,tempData[which(tempData[,1] == metaList[n,]),1:2])
70 :     #}
71 :     chemlist<-tempData[,1:2]
72 :     #dim(chemlist)<-c(length(chemlist),1)
73 :     nlist <- matrix("n", dim(chemlist)[1], 1)
74 :     for (n in 1:dim(sTitle)[2])
75 :     {
76 :     chemlist<-cbind(chemlist, nlist)
77 :     }
78 :     #return(list(chemlist = chemlist, sTitle = sTitle[2,]))
79 :     names(chemlist)<-c("multiplets","pos_in_ppm", sTitle[2,])
80 :     write.table(chemlist,file=dirCS,sep = ",",row.names = FALSE,col.names = TRUE)
81 :    
82 :     }

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge