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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

iscan source code<br />

13 i f ( d e f i n e d $ A R G V [ 0 ] ) {<br />

14 @ L I N E S = r e a d _ m o d ( $ A R G V [ 0 ] ) ;<br />

15 } e l s e {<br />

16 w h i l e (< D A T A >) {<br />

17 p r i n t ;<br />

18 }<br />

19 c l o s e D A T A ;<br />

20 d i e " n o m o d e l p r o v i d e d . t e m p l a t e m o d e l d u m p e d \ n " ;<br />

21 }<br />

22<br />

23 m y $ p w m i d = −1;<br />

24 p r i n t " # t h i s i s t h e m o d e l : \ n " ;<br />

25 f o r e a c h ( @ L I N E S ) {<br />

26 p r i n t " # $ _ \ n " ;<br />

27 i f ( / ˆ \ [ p w m \ ] \ s∗=\s ∗ ( . ∗ ) /) {<br />

28 $ p w m i d ++;<br />

29 p u s h @ P W M , " $ p w m i d : $ 1 " ;<br />

30 }<br />

31 m y $ p w m = $ P W M [$# P W M ] ;<br />

32 $ s e t u p { $ p w m }{ $ 1 } = $ 2 i f /ˆ(\ w+)\ s∗=\s ∗([\.\ −0 −9]+) / ;<br />

33 n e x t u n l e s s / ˆ \ [ ( [ A T G C ]+) \ ] / ;<br />

34 m y @ F = s p l i t / [ \ s \ t ] + / ;<br />

35 s h i f t @ F ;<br />

36 e r r ( " p w m n o t d e f i n e d " ) u n l e s s d e f i n e d $ p w m ;<br />

37 @ { $ m a t r i x { $ p w m }{ $ 1 }} = @ F ;<br />

38 $ m a t r i x { $ p w m }{ c o u n t } [ $ _ ] += $ F [ $ _ ] f o r e a c h ( 0 . . $#F ) ;<br />

39 }<br />

40<br />

41 # make a lookup t a b l e o f d i s t a n c e i n f o r m a t i o n measure<br />

42 m y %S P A C E R _ L O O K U P ;<br />

43 f o r e a c h m y $ s p a c e r ( k e y s %s e t u p ) {<br />

44 m y $ m i n = $ s e t u p { $ s p a c e r }{ m i n } ;<br />

45 m y $ m a x = $ s e t u p { $ s p a c e r }{ m a x } ;<br />

46 m y $ c e n t e r = $ s e t u p { $ s p a c e r }{ c e n t e r } ;<br />

47 p r i n t f " # p a r s i n g a c c e s s i b i l i t y f o r $ s p a c e r ( m i n = $ m i n , m a x = $ m a x , c e n t e r = $ c e n t e r ) \ n " ;<br />

48 m y $ n = 0 ;<br />

49 $ n += 1 + c o s ( ( ( 2 ∗ $ p i ) / 1 0 . 6 ) ∗ ( $ _ − $ c e n t e r ) ) f o r e a c h ( $ m i n . . $ m a x ) ;<br />

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

51 i f ( $ c e n t e r e q " " ) {<br />

52 $ S P A C E R _ L O O K U P { $ d }{ $ m i n }{ $ m a x }{ $ c e n t e r } = 0 ;<br />

53 } e l s e {<br />

54 $ S P A C E R _ L O O K U P { $ d }{ $ m i n }{ $ m a x }{ $ c e n t e r } = −(−l o g ( ( 1 + c o s ( ( ( 2 ∗ $ p i ) / 1 0 . 6 ) ∗ ( $ d<br />

− $ c e n t e r ) ) ) / $ n ) / l o g ( 2 ) ) ;<br />

55 }<br />

56 p r i n t f " # d = % d , s c o r e = % 0 . 2 f \ n " , $d , $ S P A C E R _ L O O K U P { $ d }{ $ m i n }{ $ m a x }{ $ c e n t e r } ;<br />

57 }<br />

58 }<br />

59<br />

60 # compute matrix based o f f r e q u e n c i e s<br />

61 f o r e a c h m y $ p w m ( k e y s %m a t r i x ) {<br />

62 p r i n t " # p r e p a r i n g m a t r i x ’ $ p w m ’\ n " ; ;<br />

63 f o r e a c h m y $ l e t t e r ( q w / A T G C /) {<br />

64 p r i n t " # [ $ l e t t e r ] " ;<br />

65 f o r e a c h m y $ i ( 0 . . $#{ $ m a t r i x { $ p w m }{ A }} ) {<br />

66 m y $ i 1 = " - " ;<br />

67 m y $ i 2 = s p r i n t f ( ’ % 5 s ’ , ’ - ’ ) ;<br />

68 i f ( $ m a t r i x { $ p w m }{ $ l e t t e r } [ $ i ] > 0 ) {<br />

69 $ i 1 = 2 + l o g ( $ m a t r i x { $ p w m }{ $ l e t t e r } [ $ i ] / $ m a t r i x { $ p w m }{ c o u n t } [ $ i ] ) / l o g ( 2 ) − 0 ;<br />

70 $ i 2 = s p r i n t f ( ’ % 5 s ’ , s p r i n t f ( ’ % 0 . 2 f ’ , $ i 1 ) ) ;<br />

71 }<br />

72 $ m a t r i x { $ p w m }{ $ l e t t e r } [ $ i ] = $ i 1 i f $ i 1 n e " - " ;<br />

73 p r i n t " \ t $ i 2 " ;<br />

74 }<br />

75 p r i n t " \ n " ;<br />

76 }<br />

77 }<br />

78<br />

79 # l o o p o v e r a l l s e q u e n c e s i n i n p u t<br />

80 m y @ i n p = &r e a d _ f a s t a ;<br />

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

82 m y $ s e q = $ i n p [ $ s ]−>{ s e q } ;<br />

83 p r i n t f " # S E Q U E N C E % s \ n " , $ i n p [ $ s ]−>{ i d } ;<br />

84 p r i n t f " # % d b p \ n " , l e n g t h ( $ s e q ) ;<br />

85 m y %L E N ;<br />

86 m y %B I T ;<br />

87 f o r e a c h m y $ p w m ( @ P W M ) {<br />

88 p r i n t " # g e n e r a t i n g b i t s c o r e s f o r m a t r i x ’ $ p w m ’\ n " ;<br />

89 @ { $ B I T { $ p w m }} = &s c a n ( $ s e q ,%{ $ m a t r i x { $ p w m }}) ;<br />

90 $ L E N { $ p w m } = s c a l a r ( @ { $ m a t r i x { $ p w m }{ A }}) ;<br />

91 p r i n t f " # % d e l e m e n t s i n a r r a y \ n " , s c a l a r ( @ { $ B I T { $ p w m }} ) ;<br />

92 }<br />

93 f o r e a c h m y $ p ( 0 . . ( l e n g t h ( $ s e q ) − $ L E N { $ P W M [ 0 ] } ) ) {<br />

94 p r i n t f " # c o n s i d e r i n g p o s i t i o n % d ( r o o t m o d e l ) \ n " , $ p + 1 ;<br />

95 # f i n d the s c o r e o f the i n i t i a l matrix , f o r t h i s g i v e n p o s i t i o n<br />

96 m y $ w = $ s e t u p { $ P W M [ 0 ] } { w e i g h t } ;<br />

97 m y $ f s i = $ B I T { $ P W M [ 0 ] } [ $ p ] ∗ $ w ;<br />

98 m y $ o f f s e t = $ p ;<br />

99 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 [ 0 ] } ) ;<br />

100 m y $ s = s p r i n t f " % s \ t % 0 . 2 f " , $ s i g n a l , $ f s i ;<br />

101<br />

102 f o r e a c h m y $ p w m _ i n d e x (1 . . $#P W M ) {<br />

103 m y $ p w m = $ P W M [ $ p w m _ i n d e x ] ;<br />

104 m y $ w = $ s e t u p { $ p w m }{ w e i g h t } ;<br />

105<br />

106 # g e t the s p a c i n g d e t a i l s f o r the upstream s p a c e r<br />

107 m y $ p r e v _ p w m = $ P W M [ $ p w m _ i n d e x − 1 ] ;<br />

108<br />

170

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

Saved successfully!

Ooh no, something went wrong!