29.07.2013 Views

Computational tools and Interoperability in Comparative ... - CBS

Computational tools and Interoperability in Comparative ... - CBS

Computational tools and Interoperability in Comparative ... - CBS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Appendix: Software<br />

109 m y ( $ m i n , $ m a x , $ c e n t e r ) = ( $ s e t u p { $ p r e v _ p w m }{ m i n } ,<br />

110 $ s e t u p { $ p r e v _ p w m }{ m a x } , $ s e t u p { $ p r e v _ p w m }{ c e n t e r }) ;<br />

111<br />

112 m y $ o p t _ s p a c e r ;<br />

113 m y $ o p t _ u n i t _ s c o r e ;<br />

114<br />

115 # c a l c u l a t e u n i t s c o r e s f o r each o f the s p a c i n g c o n f i g u r a t i o n s<br />

116 # A u n i t i s the s p a c e r <strong>and</strong> the f o l l o w i n g matrix . We s e a r c h f o r the<br />

117 # s p a c e r g i v i n g r i s e t o the h i g h e s t u n i t s c o r e<br />

118<br />

119 p r i n t f " # a d j u s t i n g s p a c e r d o w n s t r a m o f ’ $ p w m ’\ n " ;<br />

120<br />

121 f o r e a c h m y $ s p a c e r ( $ m i n . . $ m a x ) {<br />

122 # don ’ t c o n t i n u e , o f the o f f s e t g o e s beyond z e r o . . .<br />

123 l a s t i f $ o f f s e t − $ L E N { $ p w m } − $ s p a c e r < 0 ;<br />

124 n e x t i f $ B I T { $ p w m } [ $ o f f s e t − $ L E N { $ p w m } − $ s p a c e r ] ∗ $ w < $ s e t u p { $ p w m }{ t h r e s h o l d } a n d<br />

d e f i n e d $ s e t u p { $ p w m }{ t h r e s h o l d } ;<br />

125<br />

126 # i f no o p t i m a l s p a c e r i s d e c l a r e d y e t ( e . g . b e c a u s e t h i s i s<br />

127 # the f i r s t round ) then do i t now<br />

128 $ o p t _ s p a c e r = $ s p a c e r u n l e s s d e f i n e d $ o p t _ s p a c e r ;<br />

129 m y $ t e s t _ u n i t _ s c o r e = $ B I T { $ p w m } [ $ o f f s e t − $ L E N { $ p w m } − $ s p a c e r ] ∗ $ w + $ S P A C E R _ L O O K U P {<br />

$ s p a c e r }{ $ m i n }{ $ m a x }{ $ c e n t e r } ;<br />

130 p r i n t f " # s p a c e r : % d , s c o r e : % 0 . 1 f ( % 0 . 1 f + % 0 . 1 f ) \ n " , $ s p a c e r , $ t e s t _ u n i t _ s c o r e ,<br />

$ B I T { $ p w m } [ $ o f f s e t − $ L E N { $ p w m } − $ s p a c e r ] , $ S P A C E R _ L O O K U P { $ s p a c e r }{ $ m i n }{ $ m a x }{<br />

$ c e n t e r } ;<br />

131 $ o p t _ u n i t _ s c o r e = $ t e s t _ u n i t _ s c o r e u n l e s s d e f i n e d $ o p t _ u n i t _ s c o r e ;<br />

132 i f ( $ t e s t _ u n i t _ s c o r e > $ o p t _ u n i t _ s c o r e ) {<br />

133 $ o p t _ s p a c e r = $ s p a c e r ;<br />

134 $ o p t _ u n i t _ s c o r e = $ t e s t _ u n i t _ s c o r e ;<br />

135 }<br />

136 } # f o r e a c h my $ s p a c e r<br />

137<br />

138 # o f f s e t i s where the c u r r e n t pwm s t a r t s<br />

139 $ o f f s e t = $ o f f s e t − $ L E N { $ p w m } − $ o p t _ s p a c e r ;<br />

140<br />

141 p r i n t f " # n e w o f f s e t % d \ n " , $ o f f s e t ;<br />

142<br />

143 i f ( ! d e f i n e d $ o p t _ u n i t _ s c o r e ) {<br />

144 p r i n t f " # u n a b l e t o d e t e r m i n e s p a c e r \ n " ;<br />

145 $ s .= s p r i n t f " \ t - \ t % s \ t - " , ( ’ - ’ x $ L E N { $ p w m }) ;<br />

146 n e x t ;<br />

147 } e l s e {<br />

148 p r i n t f " # s p a c e r $ o p t _ s p a c e r c h o s e n , u n i t ’% s ’ g i v e s s c o r e % 0 . 1 f \ n " , $ p w m ,<br />

$ o p t _ u n i t _ s c o r e ;<br />

149 $ f s i += $ o p t _ u n i t _ s c o r e ;<br />

150 m y $ s i g n a l = s u b s t r ( $ s e q , $ o f f s e t , $ L E N { $ p w m }) ;<br />

151 $ s .= s p r i n t f " \ t % d \ t % s \ t % 0 . 2 f " , $ o p t _ s p a c e r , $ s i g n a l , $ f s i ;<br />

152 }<br />

153 } # f o r e a c h my $pwm <strong>in</strong>dex<br />

154 # p r i n t the f i n a l b i t s c o r e<br />

155 p r i n t f " % d \ t % 0 . 2 f \ t % s \ t \ n " , ( $ p +1) , $ f s i , $ s ;<br />

156 } # my $p = 0<br />

157 } # f o r ( $s = 0 . . . .<br />

158<br />

159<br />

160 #######################################<br />

161 # HELPER FUNCTIONS<br />

162 #######################################<br />

163<br />

164<br />

165 # scan u s i n g a matrix o f i n f o r m a t i o n<br />

166 s u b s c a n {<br />

167 m y @ a ;<br />

168 m y ( $s ,% m ) = @ _ ;<br />

169 m y $ m a = $#{$ m { A } } ;<br />

170 f o r e a c h m y $ p ( 0 . . ( l e n g t h ( $ s )−$#{$ m { A }} −1 ) ) {<br />

171 m y $ R i = 0 ;<br />

172 $ R i += $ m { s u b s t r ( $s , $ p+$_ , 1 ) } [ $ _ ] f o r e a c h ( 0 . . $ m a ) ;<br />

173 p u s h @ a , $ R i ;<br />

174 }<br />

175 # r e t u r n a l i s t hav<strong>in</strong>g n−l +1 e l e m e n t s e h e r e n i s the s e q u e n c e l e n g t h ,<br />

176 # n i s the matrix s i z e ( f o r −10 ( hexamer , n=6)<br />

177 r e t u r n @ a ;<br />

178 }<br />

179<br />

180 ###############################################################<br />

181 # s p a c e r b i t s c o r e c a l c u l a t i o n s c o o r d i n a t e s a r e s h i f t e d 6bp<br />

182 ###############################################################<br />

183<br />

184 s u b r e a d _ m o d {<br />

185 m y @ r e t ;<br />

186 m y $ f n = $ _ [ 0 ] ;<br />

187 m y $ i ;<br />

188 o p e n $ i , $ f n o r e r r ( " u n a b l e t o o p e n f i l e ’ $ f n ’: $ ! \ n " ) ;<br />

189 w h i l e ( r e a d l i n e ( $ i ) ) {<br />

190 c h o m p ;<br />

191 i f (/ˆ#\ s ∗ i n c l u d e \ s ∗ ( . ∗ ) /) {<br />

192 m y @ a = r e a d _ m o d ( $ 1 ) ;<br />

193 p u s h @ r e t , @ a ;<br />

194 } e l s e {<br />

195 n e x t i f / ˆ [ \ s \#] + / ;<br />

196 n e x t u n l e s s /ˆ\ S +/;<br />

197 p u s h @ r e t , $ _ ;<br />

198 }<br />

199 }<br />

200 c l o s e $ i ;<br />

171

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!