annotate all stuff/Difference finderMADE 7 TO 7 fastversion 2-14-2019.R @ 7:f2dd4121a4f1 draft

Uploaded
author jfb
date Fri, 19 Apr 2019 16:47:27 -0400
parents 74ada21ceb70
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
1 #I should make an SOP for this. Problems we encountered: no x in the xY motif, and the kilodemon
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
2 #the output files have both Y and xY, they shouldn't why is that happening? make it not happen
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
3 #make sure that accession numbers stay locked to each motif, somehow
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
4 #output should look just like the KALIP input
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
5 #S2 is negatives
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
6 #ff you want ONLY FULL MOTIFS, put "YES" here, please use all caps
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
7 FullMotifsOnly_questionmark<-"NO"
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
8 #If you want ONLY TRUNCATED MOTIFS, put "YES" here, please use all caps
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
9 TruncatedMotifsOnly_questionmark<-"NO"
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
10 #if you want to find the overlap, put a "YES" here (all caps), if you want to find the non-overlap, put "NO" (all caps)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
11 Are_You_Looking_For_Commonality<-"NO"
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
12
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
13
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
14 #put the names of your input files here
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
15 FirstSubstrateSet<- read.csv("Substrates 1A TiO2 and FeNTA no duplicates.csv", stringsAsFactors=FALSE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
16 Firstsubbackfreq<- read.csv("SBF 1A TiO2 and FeNTA no duplicates.csv", header=FALSE, stringsAsFactors=FALSE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
17
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
18 SecondSubstrateSet<- read.csv("Substrates 1B TiO2 and FeNTA no duplicates.csv", stringsAsFactors=FALSE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
19 Secondsubbackfreq<- read.csv("SBF 1B TiO2 and FeNTA no duplicates.csv", header=FALSE, stringsAsFactors=FALSE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
20
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
21 # ThirdSubstrateSet<- read.csv("Galaxy69-BTK_PLUS_R3_Substrates.csv", stringsAsFactors=FALSE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
22 # Thirdsubbackfreq<- read.csv("Galaxy70-BTK_PLUS_R3_SubstrateBackgroundFrequency.csv", header=FALSE, stringsAsFactors=FALSE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
23
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
24 #then put the names of your output files here
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
25 # Shared_motifs_table<-"180719_GALAXY-BTK-plus-rep-OVLP-7to7-substrates.csv"
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
26 # Shared_subbackfreq_table<-"180719_GALAXY-BTK-plus-rep-OVLP-7to7-SubBackFreq.csv"
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
27
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
28 # Shared_motifs_table<-"Shared motifs 7-27-17.csv"
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
29 # Shared_subbackfreq_table<-"SubstrateBackgrounFrequency-for-shared-motifs 4 7-27-17.csv"
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
30
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
31 First_unshared_motifs_table<-"pka_minus_wo-plus_wo_vector_subs.csv"
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
32 First_unshared_subbackfreq<-"pka_minus_wo-plus_wo_vector_sbf.csv"
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
33
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
34 Second_unshared_motifs_table<-"pka_plus_wo-minus_wo_vector_subs.csv"
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
35 Second_unshared_subbackfreq<-"pka_plus_wo-minus_wo_vector_sbf.csv"
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
36
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
37 # Third_unshared_motifs_table<-"R3 subs.csv"
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
38 # Third_unshared_subbackfreq<-"R3 SBF.csv"
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
39
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
40 #final note, this code is going to be unworkable if you want to make a Venn diagram of more than 3 circles. I think I'll poke around
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
41 #other languages to see if any of them can do it.
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
42 ####################################################################################################################################
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
43
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
44
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
45
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
46
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
47
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
48 # grepl(pattern = "S", x=asdf, ignore.case = TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
49
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
50 FirstCentralLetters<-FirstSubstrateSet[,11]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
51 SecondCentralLetters<-SecondSubstrateSet[,11]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
52
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
53 FirstEsses<-sapply(FirstCentralLetters, grepl, pattern="S", ignore.case=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
54 FirstTees<-sapply(FirstCentralLetters, grepl, pattern="T", ignore.case=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
55 FirstWys<-sapply(FirstCentralLetters, grepl, pattern="Y", ignore.case=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
56
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
57 SecondEsses<-sapply(SecondCentralLetters, grepl, pattern="S", ignore.case=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
58 SecondTees<-sapply(SecondCentralLetters, grepl, pattern="T", ignore.case=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
59 SecondWys<-sapply(SecondCentralLetters, grepl, pattern="Y", ignore.case=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
60
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
61 FirstCentralLetters<-replace(FirstCentralLetters,FirstEsses,"xS")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
62 FirstCentralLetters<-replace(FirstCentralLetters,FirstTees,"xT")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
63 FirstCentralLetters<-replace(FirstCentralLetters,FirstWys,"xY")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
64
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
65 SecondCentralLetters<-replace(SecondCentralLetters,SecondEsses,"xS")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
66 SecondCentralLetters<-replace(SecondCentralLetters,SecondTees,"xT")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
67 SecondCentralLetters<-replace(SecondCentralLetters,SecondWys,"xY")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
68
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
69 FirstCentralLetters->FirstSubstrateSet[,11]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
70 SecondCentralLetters->SecondSubstrateSet[,11]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
71
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
72 ####################################################################################################################################
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
73 ####################################################################################################################################
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
74 # better version of this code written in C: what happens when two kinases share a motif, but they found that motif in two
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
75 # separate proteins thus two separate accession numbers?
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
76 # It should actually output the shared motif and BOTH accession numbers. Right now it does not, it only maps out the second
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
77 # accession number. So that needs to be fixed BUT you need to keep the commonality between a motif and its accession number
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
78 ####################################################################################################################################
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
79 ####################################################################################################################################
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
80 ####################################################################################################################################
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
81 ####################################################################################################################################
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
82
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
83 #Create the motif sets, deciding wether or not you're looking for truncated or full here
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
84 #full only
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
85
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
86
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
87 if (Are_You_Looking_For_Commonality=="NO"){
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
88
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
89 ###############################################
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
90 #ALL motifs, full and truncated
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
91
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
92 if (FullMotifsOnly_questionmark!="YES"&&TruncatedMotifsOnly_questionmark!="YES"){
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
93 # FTLwtmotifs=matrix(,nrow = nrow(FirstSubstrateSet),ncol=1)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
94 # FTLwtAccessionNumbers=matrix(,nrow = nrow(FirstSubstrateSet),ncol=1)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
95
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
96 #so what this does is
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
97 #find the central phospho position and add spaces to either side of it
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
98 #create a pasted together motif which will be used for difference finding
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
99 #keep motifs and accession numbers in the same index position of two vectors
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
100
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
101 #so instead just take the FLTwt[i,4:18], and replace "" with "O"
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
102 #then perform paste function
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
103 #then FLTwt with "O" can be the motif that will get printed to the CSV (after re-removing the "O") and the pasted motif is in its own vector that follows the A #s
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
104
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
105 FTLwtmotifs<-FirstSubstrateSet[,4:18]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
106 # FTLwtmotifs<-sapply(FTLwtmotifs, gsub, pattern=" ", replacement="O",ignore.case=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
107 FTLwtmotifs<-replace(FTLwtmotifs, FTLwtmotifs=="", "O")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
108 FTLwtmotifs<-apply(FTLwtmotifs, 1, paste, sep="", collapse="")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
109 FTLwtAccessionNumbers<-FirstSubstrateSet[,3]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
110
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
111 # D835Ymotifs=matrix(,nrow = nrow(SecondSubstrateSet),ncol=1)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
112 # D835YAccessionNumbers<-matrix(,nrow = nrow(SecondSubstrateSet),ncol = 1)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
113
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
114 D835Ymotifs<-SecondSubstrateSet[,4:18]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
115 # D835Ymotifs<-sapply(D835Ymotifs, gsub, patter="", replacement="O",ignore.case=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
116 D835Ymotifs<-replace(D835Ymotifs, D835Ymotifs=="", "O")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
117 D835Ymotifs<-replace(D835Ymotifs, D835Ymotifs=="", "O")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
118 D835Ymotifs<-apply(D835Ymotifs, 1, paste, sep="", collapse="")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
119 D835YAccessionNumbers<-SecondSubstrateSet[,3]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
120
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
121 names(FTLwtmotifs)<-FTLwtAccessionNumbers
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
122 names(D835Ymotifs)<-D835YAccessionNumbers
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
123
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
124 }
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
125
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
126
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
127 FTLwtmotifsFINAL<-FTLwtmotifs[!FTLwtmotifs %in% D835Ymotifs]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
128 FTLwtmotifsFINAL<-FTLwtmotifsFINAL[!duplicated(FTLwtmotifsFINAL)]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
129
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
130 D835YmotifsFINAL<-D835Ymotifs[!D835Ymotifs %in% FTLwtmotifs]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
131 D835YmotifsFINAL<-D835YmotifsFINAL[!duplicated(D835YmotifsFINAL)]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
132
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
133
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
134
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
135 # columnalheader<-c(rep(NA,36))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
136 # FTLFinalMatrix<-matrix(data =columnalheader,nrow = 1)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
137 #
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
138 #how to make this an apply
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
139 #actual first turn names(motifsFINAL) into a vector, then gsub to replace all "|" pipe characters with "*" star characters
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
140 #first take the accession numbers as Firstsubbackfreq[1,], then gsub to replace all "|" pipe characters with "*" star characters
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
141 #then use AccessionNumbers as a vector and use
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
142 #matches <- unique (grep(paste(toMatch,collapse="|"), names(motifsFINAL), value=TRUE))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
143
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
144 FLTwtNames<-names(FTLwtmotifsFINAL)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
145 FLTwtNames<-FLTwtNames[!duplicated(FLTwtNames)]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
146 #the problem is the names includes a lot of things that are multi names separated by ;
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
147 #I need to do soem paper writing and poster writing
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
148
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
149 FLTwtNames<-gsub(pattern = '\\|', replacement = "*", x=FLTwtNames)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
150 FLTwtNames<-paste(FLTwtNames,collapse = "|")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
151
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
152 AccNums<-as.character(Firstsubbackfreq[1,])
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
153 AccNums<-gsub(pattern = "\\|", replacement = "*", x=AccNums)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
154
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
155
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
156 firstthree123<-gsub(pattern = "\\|", replacement = "", x=FLTwtNames)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
157 lastthree123<-gsub(pattern = "\\|", replacement = "", x=AccNums)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
158
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
159 pasty<-paste(lastthree123,collapse = "|")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
160
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
161 my_matches<-unique(grep(pattern = FLTwtNames, x=AccNums, value = TRUE))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
162 # matches <- unique (grep(paste(FLTwtNames,collapse="|"), AccNums, value=TRUE))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
163 My_matches<- AccNums %in% FLTwtNames #use apply grep function
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
164 My_matches<-grep(pattern = pasty, x=firstthree123, ignore.case = TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
165 sensation<-firstthree123[My_matches]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
166 what<-firstthree123[!firstthree123 %in% sensation]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
167
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
168 #my matches are which columns in the SBF file still have a motif with them
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
169 FirstFINALSBF<-Firstsubbackfreq[My_matches]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
170 FTLFinalMatrix<-FirstFINALSBF
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
171 duped<-FTLFinalMatrix[1,]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
172 duped<-duped[!duplicated(duped)]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
173 names(duped)<-NULL
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
174 duped<-unlist(duped)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
175 unduped<-FTLFinalMatrix[,!duplicated(duped)]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
176 FTLFinalMatrix<-unduped
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
177 # FTLFinalMatrix<-FTLFinalMatrix[2:nrow(FTLFinalMatrix),]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
178
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
179 # columnalheader<-c(rep(NA,36))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
180 # D835YFinalMatrix<-matrix(data =columnalheader,nrow = 1)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
181
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
182 D835names<-names(D835YmotifsFINAL)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
183 D835names<-D835names[!duplicated(D835names)]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
184 AccNums<-as.character(Secondsubbackfreq[1,])
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
185 My_matches<-AccNums %in% D835names
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
186 SecondFINALSBF<-Secondsubbackfreq[My_matches]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
187 D835YFinalMatrix<-SecondFINALSBF
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
188 duped<-D835YFinalMatrix[1,]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
189 duped<-duped[!duplicated(duped)]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
190 names(duped)<-NULL
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
191 duped<-unlist(duped)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
192 unduped<-D835YFinalMatrix[,!duplicated(duped)]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
193 D835YFinalMatrix<-unduped
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
194 #there's a problem, accession numbers are duplicated
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
195
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
196 # FTLoutputmatrix<-matrix(data=c(FTLwtmotifsFINAL,names(FTLwtmotifsFINAL)),ncol = 2)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
197
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
198 FTLwtmotifsFINAL<-gsub(pattern = "O", replacement = " ", x=FTLwtmotifsFINAL)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
199 FTLwtmotifsFINAL<-gsub(pattern = "x", replacement = "", x=FTLwtmotifsFINAL)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
200 FTLoutputmatrix<-matrix(data = c(FTLwtmotifsFINAL,names(FTLwtmotifsFINAL)), ncol=2)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
201
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
202 # FTLwtmotifsFINAL<-gsub(pattern = "O", replacement = " ", x=FTLwtmotifsFINAL)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
203 # FTLwtmotifsFINAL<-gsub(pattern = "x", replacement = "", x=FTLwtmotifsFINAL)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
204 # FTLoutputmatrix<-matrix(data = c(FTLwtmotifsFINAL,names(FTLwtmotifsFINAL)), ncol=2)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
205
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
206 FLTheader<-c("Substrate","Species","Reference","-7","-6","-5","-4","-3","-2","-1","0","1","2","3","4","5","6","7","Phosphite")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
207 # FLTheader<-unlist(FLTheader)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
208 lefthandFLT<-matrix(data = rep(NA,times=2*nrow(FTLoutputmatrix)),nrow=nrow(FTLoutputmatrix))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
209 righthandFLT<-matrix(data = rep(NA,times=1*nrow(FTLoutputmatrix)),nrow=nrow(FTLoutputmatrix))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
210 FLTaccessionset<-FTLoutputmatrix[,2]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
211 FTLmeat<-sapply(FTLoutputmatrix[,1], strsplit, "")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
212 FTLmeat<-sapply(FTLmeat, unlist)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
213 colnames(FTLmeat)<-NULL
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
214 FTLmeat<-t(FTLmeat)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
215
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
216 FTLoutputmatrix2<-cbind(lefthandFLT,FLTaccessionset,FTLmeat,righthandFLT)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
217 colnames(FTLoutputmatrix2)<-NULL
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
218 rownames(FTLoutputmatrix2)<-NULL
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
219 colnames(FLTheader)<-NULL
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
220 rownames(FLTheader)<-NULL
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
221
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
222
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
223 FirstCentralLettersAGAIN<-FTLoutputmatrix2[,11]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
224
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
225 FirstEsses<-sapply(FirstCentralLettersAGAIN, grepl, pattern="S", ignore.case=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
226 FirstTees<-sapply(FirstCentralLettersAGAIN, grepl, pattern="T", ignore.case=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
227 FirstWys<-sapply(FirstCentralLettersAGAIN, grepl, pattern="Y", ignore.case=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
228
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
229 FirstCentralLettersAGAIN<-replace(FirstCentralLettersAGAIN,FirstEsses,"xS")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
230 FirstCentralLettersAGAIN<-replace(FirstCentralLettersAGAIN,FirstTees,"xT")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
231 FirstCentralLettersAGAIN<-replace(FirstCentralLettersAGAIN,FirstWys,"xY")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
232
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
233 FirstCentralLettersAGAIN->FTLoutputmatrix2[,11]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
234
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
235 FTLoutputmatrix2<-rbind(FLTheader,FTLoutputmatrix2)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
236
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
237 write.table(x=FTLoutputmatrix2,
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
238 file=First_unshared_motifs_table,
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
239 quote=FALSE, sep=",",
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
240 row.names=FALSE,col.names = FALSE, na="", append=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
241
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
242 columnalheader<-c("Accession Numbers",as.character(Firstsubbackfreq[1:35,1]))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
243 columnalheader<-matrix(columnalheader,ncol = 1)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
244 # write.table(x=columnalheader,
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
245 # file=First_unshared_subbackfreq,
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
246 # quote=FALSE, sep=",",
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
247 # row.names=FALSE,col.names = FALSE, na="", append=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
248
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
249 FTLFinalMatrix<-cbind(columnalheader,FTLFinalMatrix)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
250
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
251 write.table(x=FTLFinalMatrix,
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
252 file=First_unshared_subbackfreq,
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
253 quote=FALSE, sep=",",
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
254 row.names=FALSE,col.names = FALSE, na="", append=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
255
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
256 ############################################################################################################
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
257
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
258 D835YmotifsFINAL<-gsub(pattern = "O", replacement = " ", x=D835YmotifsFINAL)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
259 D835YmotifsFINAL<-gsub(pattern = "x", replacement = "", x=D835YmotifsFINAL)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
260 D835Youtputmatrix<-matrix(data = c(D835YmotifsFINAL,names(D835YmotifsFINAL)), ncol=2)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
261
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
262 # D835YmotifsFINAL<-gsub(pattern = "O", replacement = " ", x=D835YoutputmatrixL)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
263 # D835YmotifsFINAL<-gsub(pattern = "x", replacement = "", x=D835Youtputmatrix)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
264 # D835Youtputmatrix<-matrix(data = c(D835Youtputmatrix,names(D835Youtputmatrix)), ncol=2)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
265 #
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
266
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
267 # D835Youtputmatrix<-matrix(data=c(D835YmotifsFINAL,names(D835YmotifsFINAL)),ncol = 2)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
268
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
269 D835Yheader<-c("Substrate","Species","Reference","-7","-6","-5","-4","-3","-2","-1","0","1","2","3","4","5","6","7","Phosphite")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
270 # D835Yheader<-unlist(D835Yheader)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
271 lefthandD835<-matrix(data = rep(NA,times=2*nrow(D835Youtputmatrix)),nrow=nrow(D835Youtputmatrix))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
272 righthandD835<-matrix(data = rep(NA,times=1*nrow(D835Youtputmatrix)),nrow=nrow(D835Youtputmatrix))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
273 D835Yaset<-D835Youtputmatrix[,2]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
274 D835meat<-sapply(D835Youtputmatrix[,1], strsplit, "")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
275 D835meat<-sapply(D835meat, unlist)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
276 colnames(D835meat)<-NULL
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
277 D835meat<-t(D835meat)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
278
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
279 # FTLmeat<-sapply(FTLoutputmatrix[,1], strsplit, "")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
280 # FTLmeat<-sapply(FTLmeat, unlist)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
281 # colnames(FTLmeat)<-NULL
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
282 # FTLmeat<-t(FTLmeat)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
283
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
284
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
285 D835Youtputmatrix2<-cbind(lefthandD835,D835Yaset,D835meat,righthandD835)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
286 colnames(D835Youtputmatrix2)<-NULL
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
287 rownames(D835Youtputmatrix2)<-NULL
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
288 colnames(D835Yheader)<-NULL
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
289 rownames(D835Yheader)<-NULL
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
290
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
291
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
292 SecondCentralLettersAGAIN<-D835Youtputmatrix2[,11]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
293
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
294 SecondEsses<-sapply(SecondCentralLettersAGAIN, grepl, pattern="S", ignore.case=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
295 SecondTees<-sapply(SecondCentralLettersAGAIN, grepl, pattern="T", ignore.case=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
296 SecondWys<-sapply(SecondCentralLettersAGAIN, grepl, pattern="Y", ignore.case=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
297
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
298 SecondCentralLettersAGAIN<-replace(SecondCentralLettersAGAIN,SecondEsses,"xS")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
299 SecondCentralLettersAGAIN<-replace(SecondCentralLettersAGAIN,SecondTees,"xT")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
300 SecondCentralLettersAGAIN<-replace(SecondCentralLettersAGAIN,SecondWys,"xY")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
301
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
302 SecondCentralLettersAGAIN->D835Youtputmatrix2[,11]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
303
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
304 D835Youtputmatrix2<-rbind(D835Yheader,D835Youtputmatrix2)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
305
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
306 write.table(x=D835Youtputmatrix2,
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
307 file=Second_unshared_motifs_table,
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
308 quote=FALSE, sep=",",
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
309 row.names=FALSE,col.names = FALSE, na="", append=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
310
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
311 columnalheader<-c("Accession Numbers",as.character(Firstsubbackfreq[1:35,1]))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
312 columnalheader<-matrix(columnalheader,ncol = 1)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
313 # write.table(x=columnalheader,
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
314 # file=Second_unshared_subbackfreq,
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
315 # quote=FALSE, sep=",",
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
316 # row.names=FALSE,col.names = FALSE, na="", append=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
317
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
318 D835YFinalMatrix<-cbind(columnalheader,D835YFinalMatrix)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
319
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
320 write.table(x=D835YFinalMatrix,
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
321 file=Second_unshared_subbackfreq,
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
322 quote=FALSE, sep=",",
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
323 row.names=FALSE,col.names = FALSE, na="", append=TRUE)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
324 }
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
325
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
326
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
327
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
328 # for (i in 1:nrow(FirstSubstrateSet)){
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
329 # FTLwtletters<-FirstSubstrateSet[i,4:18]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
330 # FTLwtletters<-FTLwtletters[FTLwtletters !="XXXXX"]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
331 # FTLwtletters<-paste(FTLwtletters, sep="", collapse="")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
332 # leftspaces<-c()
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
333 # rightspaces<-c()
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
334 #
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
335 # YYYmotif <- unlist(strsplit(FTLwtletters, split = ""))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
336 # YYYposition <- match(x = "x", table = YYYmotif)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
337 # #position itself tells me how much is to the left of that X by what it's number is. x at position 4 tells me that there are
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
338 # #just 3 letters to the left of x
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
339 #
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
340 # YYYLettersToTheLeft <- YYYposition - 1
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
341 # #how many letters to the right SHOULD just be length(motif)-position-1 if it's 5 long and x is at 3 then Y is at 4 and there is
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
342 # #just 1 spot to the right of Y so LettersToTheRight<-1 because 5-3-1=1
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
343 # YYYLettersToTheRight <- length(YYYmotif) - YYYposition - 1
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
344 # #then sanity check, we're currently looking only at +/-4, but this spot allows for up to +/- 7 as well, just depends on what the
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
345 # #variable the user puts in is
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
346 #
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
347 #
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
348 # if (YYYLettersToTheLeft < 7 | YYYLettersToTheRight < 7) {
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
349 # leftspaces<-rep(" ",times=(7-YYYLettersToTheLeft))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
350 # rightspaces<-rep(" ",times=7-(YYYLettersToTheRight))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
351 # #add blank spaces if the motif has less than 4 letters to the left/right
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
352 # motif<-c(leftspaces,YYYmotif,rightspaces)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
353 # #save that motif, which is the Y and +/- 4 amino acids, including truncation
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
354 # motif<-motif[!motif %in% "x"]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
355 # motif<-paste(motif, sep="", collapse="")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
356 # FTLwtletters<-motif
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
357 # FTLwtmotifs[i,1]<-FTLwtletters
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
358 # FTLwtAccessionNumbers[i,1]<-FirstSubstrateSet[i,3]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
359 # }
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
360 #
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
361 # if(YYYLettersToTheLeft>6 && YYYLettersToTheRight>6){
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
362 # motif<-YYYmotif
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
363 # #add blank spaces if the motif has less than 4 letters to the left/right
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
364 # motif<-c(leftspaces,YYYmotif,rightspaces)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
365 # #save that motif, which is the Y and +/- 4 amino acids, including truncation
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
366 # motif<-motif[!motif %in% "x"]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
367 # motif<-paste(motif, sep="", collapse="")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
368 # FTLwtletters<-motif
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
369 # FTLwtmotifs[i,1]<-FTLwtletters
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
370 # FTLwtAccessionNumbers[i,1]<-FirstSubstrateSet[i,3]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
371 #
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
372 #
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
373 # }
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
374 #
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
375 # }
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
376
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
377
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
378
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
379 # for (i in 1:nrow(SecondSubstrateSet)){
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
380 # D835letters<-SecondSubstrateSet[i,4:18]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
381 # D835letters<-D835letters[D835letters !="XXXXX"]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
382 # D835letters<-paste(D835letters, sep="", collapse="")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
383 # leftspaces<-c()
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
384 # rightspaces<-c()
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
385 #
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
386 # YYYmotif <- unlist(strsplit(D835letters, split = ""))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
387 # YYYposition <- match(x = "x", table = YYYmotif)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
388 # #position itself tells me how much is to the left of that X by what it's number is. x at position 4 tells me that there are
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
389 # #just 3 letters to the left of x
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
390 #
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
391 # YYYLettersToTheLeft <- YYYposition - 1
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
392 # #how many letters to the right SHOULD just be length(motif)-position-1 if it's 5 long and x is at 3 then Y is at 4 and there is
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
393 # #just 1 spot to the right of Y so LettersToTheRight<-1 because 5-3-1=1
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
394 # YYYLettersToTheRight <- length(YYYmotif) - YYYposition - 1
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
395 # #then sanity check, we're currently looking only at +/-4, but this spot allows for up to +/- 7 as well, just depends on what the
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
396 # #variable the user puts in is
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
397 # if (YYYLettersToTheLeft < 7 | YYYLettersToTheRight < 7) {
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
398 # leftspaces<-rep(" ",times=(7-YYYLettersToTheLeft))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
399 # rightspaces<-rep(" ",times=7-(YYYLettersToTheRight))
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
400 # #add blank spaces if the motif has less than 4 letters to the left/right
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
401 # motif<-c(leftspaces,YYYmotif,rightspaces)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
402 # #save that motif, which is the Y and +/- 4 amino acids, including truncation
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
403 # motif<-motif[!motif %in% "x"]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
404 # motif<-paste(motif, sep="", collapse="")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
405 # D835letters<-motif
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
406 # D835Ymotifs[i,1]<-D835letters
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
407 # D835YAccessionNumbers[i,1]<-FirstSubstrateSet[i,3]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
408 # }
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
409 #
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
410 # if(YYYLettersToTheLeft>6 && YYYLettersToTheRight>6){
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
411 # motif<-YYYmotif
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
412 # #add blank spaces if the motif has less than 4 letters to the left/right
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
413 # motif<-c(leftspaces,YYYmotif,rightspaces)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
414 # #save that motif, which is the Y and +/- 4 amino acids, including truncation
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
415 # motif<-motif[!motif %in% "x"]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
416 # motif<-paste(motif, sep="", collapse="")
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
417 # D835letters<-motif
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
418 # D835Ymotifs[i,1]<-D835letters
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
419 # D835YAccessionNumbers[i,1]<-FirstSubstrateSet[i,3]
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
420 # }
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
421 # }
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
422
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
423 # for (k in 1:length(FTLwtmotifsFINAL)) {
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
424 # AN<-00000
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
425 # #I don't remember why, but I felt it necessary to destroy the accession number multiple times to ensure it is
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
426 # #destroyed immediately after use
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
427 # for (m in 1:ncol(Firstsubbackfreq)) {
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
428 # AN <- as.character(Firstsubbackfreq[1, m])
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
429 # if (grepl(pattern = AN,
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
430 # x = names(FTLwtmotifsFINAL[k]),
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
431 # fixed = TRUE) == TRUE) {
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
432 # outputmatrix <- as.character(Firstsubbackfreq[, m])
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
433 # outputmatrix <- matrix(outputmatrix, nrow = 1)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
434 # #with that accession number, find a match in the subbackfreq file and save it here
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
435 # FTLFinalMatrix<-rbind(FTLFinalMatrix,outputmatrix)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
436 # }
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
437 # }
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
438 # }
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
439 # for (k in 1:length(D835YmotifsFINAL)) {
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
440 # #I don't remember why, but I felt it necessary to destroy the accession number multiple times to ensure it is
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
441 # #destroyed immediately after use
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
442 # for (m in 1:ncol(Secondsubbackfreq)) {
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
443 # AN <- as.character(Secondsubbackfreq[1, m])
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
444 # if (grepl(pattern = AN,
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
445 # x = names(D835YmotifsFINAL[k]),
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
446 # fixed = TRUE) == TRUE) {
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
447 # outputmatrix <- as.character(Secondsubbackfreq[, m])
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
448 # outputmatrix <- matrix(outputmatrix, nrow = 1)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
449 # #with that accession number, find a match in the subbackfreq file and save it here
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
450 # D835YFinalMatrix<-rbind(D835YFinalMatrix,outputmatrix)
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
451 # }
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
452 # }
74ada21ceb70 Uploaded
jfb
parents:
diff changeset
453 # }