O v e r v i e w : 
 T h e   M u l t i p l e   S e q u e n c e   A l i g n m e n t   ( M S A )   R e a l i g n e r   i s   d e s i g n e d   t o   c o n s u m e   o n e   o r   m o r e   B A M   f i l e s 
 a n d   t o   f i x   r e a d s   w h i c h   a r e   m i s a l i g n e d   d u e   t o   t h e   p r e s e n c e   o f   i n s e r t i o n s / d e l e t i o n s   ( i n d e l s ) 
 w i t h i n   o r   n e a r   t h e m .     W h i l e   t h i s   i s n ' t   t h e   f o r u m   f o r   a   d e t a i l e d   e x p l a n a t i o n   o f   w h y   i n d e l - 
 c o n t a i n i n g   r e a d s   g e t   m i s a l i g n e d ,   i t   i s   i m p o r t a n t   t o   n o t e   t h a t   a n   a r t i f a c t   o f   t h e s e   m i s a l i g n m e n t s 
 i s   w h a t   l o o k   t o   b e   S N P s   n e a r   t h e   s i t e   o f   t h e   i n d e l   ( h o w e v e r ,   s i n c e   t h e y   a r e n ' t   r e a l l y   S N P s ,   I 
 o f t e n   r e f e r   t o   t h e m   a s   c o l u m n s   o f   m i s m a t c h e s   a t   a   p o s i t i o n   i n   a   p i l e u p ) .     T h e s e   p a r t i c u l a r   f a l s e 
 p o s i t i v e   S N P s   u s u a l l y   o c c u r   i n   c l u s t e r s   ( g e n e r a l l y   d e f i n e d   a s   2   o r   m o r e   m i s m a t c h   c o l u m n s   w i t h i n 
 n   b a s e   p a i r s ,   w h e r e   n   i s   u s u a l l y   l e s s   t h a n   o r   e q u a l   t o   1 0 ) .     I t   i s   o f t e n   t h e   c a s e   t h a t   a n   a l i g n e r 
 w i l l   d e t e c t   t h e   i n d e l   i n   s o m e   o f   t h e   r e a d s   a n d   w i l l   f a i l   t o   d e t e c t   i t   i n   o t h e r s ;   t h a t   i s   b e c a u s e 
 t h e   a l i g n e r s   d o n ' t   u s e   k n o w l e d g e   a b o u t   t h e   o t h e r   r e a d s   m a p p i n g   t o   t h e   s a m e   l o c a t i o n   w h e n   p l a c i n g   a n 
 i n d i v i d u a l   r e a d .     I t   i s   t h e   r e a l i g n e r ' s   j o b   t o   u s e   a l l   o f   t h e   r e a d s   m a p p i n g   t o   a   g i v e n   l o c a t i o n   t o 
 f i n d   a   c o n s e n s u s   i n d e l   w h i c h   b e s t   e x p l a i n s   t h e   d a t a   a n d   w h i c h   m i n i m i z e s   e n t r o p y   w i t h i n   t h e   r e a d s . 
 
 T h e r e   a r e   3 - 4   m a j o r   s t e p s   t o   t h e   r e a l i g n m e n t   p r o c e s s : 
 S t e p   1 :   D e t e r m i n i n g   ( s m a l l )   s u s p i c i o u s   i n t e r v a l s   w h i c h   a r e   l i k e l y   i n   n e e d   o f   r e a l i g n m e n t 
 S t e p   2 :   M e r g i n g   t h e   i n t e r v a l s 
 S t e p   3 :   R u n n i n g   t h e   r e a l i g n e r   o v e r   t h o s e   i n t e r v a l s 
 O p t i o n a l   S t e p   4 :   R e b u i l d   y o u r   o r i g i n a l   B A M   w i t h   c l e a n e d   r e a d s 
 
 A   m o r e   d e t a i l e d   e x p l a n a t i o n   f o l l o w s . 
 
 - - - - - 
 
 S t e p   1 :   D e t e r m i n i n g   ( s m a l l )   s u s p i c i o u s   i n t e r v a l s   w h i c h   a r e   l i k e l y   i n   n e e d   o f   r e a l i g n m e n t 
 
 T h e r e   a r e   s e v e r a l   m e t h o d s   f o r   f i n d i n g   t h e s e   i n t e r v a l s ,   w h i c h   c a n   b e   u s e d   i n   c o n j u n c t i o n   w i t h   o n e 
 a n o t h e r   o r   s e p a r a t e l y . 
 
 A .   I n   t h e   c a s e   t h a t   a l i g n e r s   d o   f i n d   s o m e   r e a d s   w i t h   i n d e l s   i n   t h e m ,   o n e   w o u l d   w a n t   t o   m a k e   s u r e 
 t h a t   t h e   o t h e r   i n d e l - c o n t a i n i n g   r e a d s   i n   t h e   p i l e u p   a r e   a l i g n e d   c o r r e c t l y .     N o t e   t h a t   w h e n   u s i n g 
 a l i g n e r s   w h i c h   d o n ' t   a l l o w   f o r   g a p p e d   a l i g n m e n t s   ( e . g .   M A Q   w i t h   s i n g l e - e n d   r e a d s )   t h i s   m e t h o d   i s 
 n o t   u s e f u l . 
 
 U s a g e : 
 j a v a   - j a r   d i s t / G e n o m e A n a l y s i s T K . j a r   - I   < i n p u t . b a m >   - R   < r e f . f a s t a >   - T   I n d e l I n t e r v a l s 
 - L   < r e g i o n s T o C h e c k . t x t >   - S   S I L E N T   - o   < i n t e r v a l s O u t p u t 1 . t x t > 
 
 O p t i o n a l   A r g u m e n t s : 
 - - m i n I n d e l s P e r I n t e r v a l   N   [ t h e   m i n i m u m   n u m b e r   o f   i n d e l s   a t   a   g i v e n   p o s i t i o n   n e c e s s a r y   f o r   e m i s s i o n ;   d e f a u l t = 1 ] 
 
 - - a l l o w 4 5 4 R e a d s   [ d o n ' t   f i l t e r   o u t   4 5 4   r e a d s   ( w h i c h   i n h e r e n t l y   h a v e   f a l s e   i n d e l s ) ;   d e f a u l t = f a l s e ] 
 
 
 B .   O c c a s i o n a l l y   i t   i s   t h e   c a s e   t h a t   y o u   h a v e   a   S N P   c a l l   s e t   f o r   y o u r   f i l e   t h a t   y o u ' d   l i k e   t o   u s e 
 i n   s e a r c h i n g   f o r   c l u s t e r e d   S N P S   ( w h i c h   a r e   s u s p i c i o u s ) .     N o t e   t h a t   t h e   r e a l i g n e r   w o r k s   b e s t   w i t h 
 a n   u n f i l t e r e d   S N P   l i s t   i f   a t   a l l   p o s s i b l e .     T h e   f o l l o w i n g   m e t h o d   o u t p u t s   c l u s t e r e d   S N P   i n t e r v a l s .   
 
 U s a g e : 
 j a v a   - j a r   d i s t / G e n o m e A n a l y s i s T K . j a r   - R   < r e f . f a s t a >   - T   S N P C l u s t e r s 
 - B   d b s n p , d b s n p , < i n p u t . r o d > , e v a l , 1 K G S N P s , < S N P l i s t . t x t >   - o   < i n t e r v a l s O u t p u t 2 . t x t > 
 
 O p t i o n a l   A r g u m e n t s : 
 - - w i n d o w S i z e   N   [ m i s m a t c h   c o l u m n s   a r e   c o n s i d e r e d   c l u s t e r e d   w h e n   t h e y   o c c u r   n o   m o r e   t h a n   N   b p   a p a r t ;   d e f a u l t = 1 0 ] 
 
 
 C .   W h e n   y o u   d o   n o t   h a v e   ( o r   d o   n o t   w a n t   t o   u s e )   a n   a v a i l a b l e   S N P   c a l l   s e t ,   t h e   f o l l o w i n g   m e t h o d 
 o u t p u t s   i n t e r v a l s   o f   c l u s t e r e d   m i s m a t c h i n g   i n t e r v a l s .     G e n e r a l l y ,   o n e   w o u l d   u s e   m e t h o d   B   o r 
 m e t h o d   C ,   b u t   n o t   b o t h . 
 
 U s a g e : 
 j a v a   - j a r   d i s t / G e n o m e A n a l y s i s T K . j a r   - I   < i n p u t . b a m >   - R   < r e f . f a s t a >   - T   M i s m a t c h I n t e r v a l s 
 - L   < r e g i o n s T o C h e c k . t x t >   - S   S I L E N T   - o   < i n t e r v a l s O u t p u t 3 . t x t > 
 
 O p t i o n a l   A r g u m e n t s : 
 - - w i n d o w S i z e   N   [ m i s m a t c h   c o l u m n s   a r e   c o n s i d e r e d   c l u s t e r e d   w h e n   t h e y   o c c u r   n o   m o r e   t h a n   N   b p   a p a r t ;   d e f a u l t = 1 0 ] 
 
 - - a l l o w 4 5 4 R e a d s   [ d o n ' t   f i l t e r   o u t   4 5 4   r e a d s   ( w h i c h   i n h e r e n t l y   h a v e   f a l s e   i n d e l s ) ;   d e f a u l t = f a l s e ] 
 
 - - m i s m a t c h F r a c t i o n   f   [ f r a c t i o n   o f   r e a d s   t h a t   n e e d   t o   m i s m a t c h   f o r   t h e   p o s i t i o n   t o   b e   c o n s i d e r e d   m i s m a t c h i n g ;   d e f a u l t = 0 . 1 5 ] 
 N o t e   t h a t   t h i s   f r a c t i o n   s h o u l d   b e   a d j u s t e d   b a s e d   o n   y o u r   p a r t i c u l a r   d a t a   s e t .     F o r   D E E P   c o v e r a g e   a n d / o r 
 w h e n   l o o k i n g   f o r   i n d e l s   w i t h   l o w   a l l e l e   f r e q u e n c y ,   t h i s   n u m b e r   s h o u l d   b e   s m a l l e r . 
 
 
 S t e p   2 :   M e r g i n g   t h e   i n t e r v a l s 
 
 A t   t h i s   p o i n t ,   y o u   n e e d   t o   c o m b i n e   a n y   i n t e r v a l s   f i l e s   y o u   h a v e   i n t o   a 
 m a s t e r   l i s t .     F i r s t ,   c o m b i n e   t h e m   a l l   i n t o   o n e   f i l e ,   u s i n g   ( f o r 
 e x a m p l e )   t h e   f o l l o w i n g   c o m m a n d : 
 c a t   i n t e r v a l s O u t p u t 1 . t x t   i n t e r v a l s O u t p u t 2 . t x t   i n t e r v a l s O u t p u t 3 . t x t   >   a l l I n t e r v a l s . t x t 
 
 T h e n   y o u   n e e d   t o   r u n   t h e   i n t e r v a l   m e r g e r . 
 U s a g e :   j a v a   - j a r   d i s t / G e n o m e A n a l y s i s T K . j a r   - I   < i n p u t . b a m >   - R   < r e f . f a s t a >   - T   I n t e r v a l M e r g e r 
 - - i n t e r v a l s T o M e r g e   a l l I n t e r v a l s . t x t   >   m e r g e d I n t e r v a l L i s t . t x t 
 
 O p t i o n a l   A r g u m e n t s : 
 - - a l l o w 4 5 4 R e a d s   [ d o n ' t   f i l t e r   o u t   4 5 4   r e a d s   ( w h i c h   i n h e r e n t l y   h a v e   f a l s e   i n d e l s ) ;   d e f a u l t = f a l s e ] 
 
 - - m a x I n t e r v a l S i z e   [ m a x   s i z e   i n   b p   o f   m e r g e d   i n t e r v a l s   t h a t   w e ' l l   p a s s   t o   t h e   r e a l i g n e r ;   d e f a u l t = 5 0 0 ] 
 
 
 S t e p   3 :   R u n n i n g   t h e   r e a l i g n e r   o v e r   y o u r   i n t e r v a l s 
 U s a g e :   j a v a   - j a r   d i s t / G e n o m e A n a l y s i s T K . j a r   - I   < i n p u t . b a m >   - R   < r e f . f a s t a >   - T   I n t e r v a l C l e a n e r 
 - L   m e r g e d I n t e r v a l L i s t . t x t   - S   S I L E N T 
 
 O p t i o n a l   A r g u m e n t s : 
 - - a l l o w 4 5 4 R e a d s   [ d o n ' t   f i l t e r   o u t   4 5 4   r e a d s   ( w h i c h   i n h e r e n t l y   h a v e   f a l s e   i n d e l s ) ;   d e f a u l t = f a l s e ] 
 
 - - O u t p u t C l e a n e d   < o u t p u t . b a m >   [ t h e   o u t p u t   B A M   f i l e   t o   e m i t   t h e   r e a d s ;   b y   d e f a u l t   i t   w r i t e s   a l l   r e a d s   -   w h e t h e r   o r 
 n o t   t h e y   w e r e   r e a l i g n e d   -   w h i c h   a t   a l l   o v e r l a p   t h e   i n p u t   i n t e r v a l s   ( b u t   n o t   t h o s e   o u t s i d e   t h e   i n t e r v a l s ) ] 
 - - O u t p u t C l e a n e d R e a d s O n l y   [ w h e n   u s e d   w i t h   O u t p u t C l e a n e d   i t   i n s t r u c t s   t h e   r e a l i g n e r   t o   e m i t   O N L Y   r e a l i g n e d   r e a d s ] 
 - - b a m _ c o m p r e s s i o n   N   [ w h e n   u s e d   w i t h   O u t p u t C l e a n e d   i t   d e t e r m i n e s   t h e   B A M   c o m p r e s s i o n ;   d e f a u l t = 5 ,   r e c o m m e n d e d = 1 ] 
 
 - - O u t p u t I n d e l s   < i n d e l s . t x t >   [ t h e   o u t p u t   f i l e   ( t e x t )   f o r   t h e   i n d e l s   f o u n d ] 
 
 - - L O D T h r e s h o l d F o r C l e a n i n g   d   [ L O D   t h r e s h o l d   a b o v e   w h i c h   t h e   r e a l i g n e r   w i l l   p r o c e e d   t o   r e a l i g n ;   d e f a u l t = 5 . 0 ] 
 T h i s   t e r m   i s   e q u i v a l e n t   t o   " s i g n i f i c a n c e "   -   i . e .   i s   t h e   i m p r o v e m e n t   s i g n i f i c a n t   e n o u g h   t o   m e r i t   r e a l i g n m e n t ? 
 N o t e   t h a t   t h i s   n u m b e r   s h o u l d   b e   a d j u s t e d   b a s e d   o n   y o u r   p a r t i c u l a r   d a t a   s e t .     F o r   L O W   c o v e r a g e   a n d / o r 
 w h e n   l o o k i n g   f o r   i n d e l s   w i t h   l o w   a l l e l e   f r e q u e n c y ,   t h i s   n u m b e r   s h o u l d   b e   s m a l l e r . 
 
 - - E n t r o p y T h r e s h o l d   f   [ p e r c e n t a g e   o f   m i s m a t c h e s   a t   a   p o s i t i o n   t o   b e   c o n s i d e r e d   h a v i n g   h i g h   e n t r o p y ;   d e f a u l t = 0 . 1 5 ] 
 T h i s   i s   s i m i l a r   t o   t h e   a r g u m e n t   i n   t h e   M i s m a t c h I n t e r v a l s   m e t h o d .     T h e   p o i n t   h e r e   i s   t h a t   t h e   r e a l i g n e r 
 w i l l   o n l y   p r o c e e d   w i t h   t h e   r e a l i g n m e n t   ( e v e n   a b o v e   t h e   g i v e n   t h r e s h o l d )   i f   i t   m i n i m i z e s   e n t r o p y   a m o n g 
 t h e   r e a d s   ( a n d   d o e s n ' t   s i m p l y   p u s h   t h e   m i s m a t c h   c o l u m n   t o   a n o t h e r   p o s i t i o n ) .     T h i s   p a r a m e t e r   i s   j u s t 
 a   h e u r i s t i c   a n d   s h o u l d   b e   a d j u s t e d   b a s e d   o n   y o u r   p a r t i c u l a r   d a t a   s e t . 
 
 - - m a x C o n s e n s u s e s   N   [ m a x   a l t e r n a t e   c o n s e n s u s e s   t o   t r y   ( n e c e s s a r y   t o   i m p r o v e   p e r f o r m a n c e   i n   d e e p   c o v e r a g e ) ;   d e f a u l t = 3 0 ] 
 I f   y o u   n e e d   t o   f i n d   t h e   o p t i m a l   s o l u t i o n   r e g a r d l e s s   o f   r u n n i n g   t i m e ,   u s e   a   h i g h e r   n u m b e r . 
 
 - - m a x R e a d s F o r C o n s e n s u s e s   N   [ m a x   r e a d s   ( c h o s e n   r a n d o m l y )   u s e d   f o r   f i n d i n g   t h e   p o t e n t i a l   a l t e r n a t e   c o n s e n s u s e s 
 ( n e c e s s a r y   t o   i m p r o v e   p e r f o r m a n c e   i n   d e e p   c o v e r a g e ) ;   d e f a u l t = 1 2 0 ] 
 I f   y o u   n e e d   t o   f i n d   t h e   o p t i m a l   s o l u t i o n   r e g a r d l e s s   o f   r u n n i n g   t i m e ,   u s e   a   h i g h e r   n u m b e r . 
 
 
 O p t i o n a l   S t e p   4 :   R e b u i l d   y o u r   o r i g i n a l   B A M   w i t h   c l e a n e d   r e a d s 
 I f   y o u   w a n t   y o u r   c l e a n e d   r e a d   B A M   t o   c o n t a i n   A L L   o f   t h e   o r i g i n a l   r e a d s 
 t o o   ( r e g a r d l e s s   o f   w h e t h e r   t h e y   w e r e   c l e a n e d   o r   f e l l   w i t h i n   o n e   o f   t h e 
 t a r g e t   i n t e r v a l s ) ,   y o u   c a n   d o   s o   i n   t h i s   l a s t   o p t i o n a l   s t e p . 
 I m p o r t a n t   n o t e :   t h i s   o p t i o n   w o r k s   b e s t   w i t h   t h e 
 " - O u t p u t C l e a n e d R e a d s O n l y "   o p t i o n   i n   S t e p   3 . 
 
 F i r s t ,   b e   s u r e   t o   i n d e x   y o u r   c l e a n e d   o u t p u t   B A M   f r o m   S t e p   3 : 
 s a m t o o l s   i n d e x   < o u t p u t . b a m > 
 
 U s a g e :   j a v a   - j a r   d i s t / G e n o m e A n a l y s i s T K . j a r   - I   < o r i g i n a l I n p u t . b a m >   - R   < r e f . f a s t a >   - T   C l e a n e d R e a d I n j e c t o r 
 - - c l e a n e d _ i n t e r v a l s   m e r g e d I n t e r v a l L i s t . t x t   - - c l e a n e d _ r e a d s 
 < p r e v i o u s O u t p u t . b a m >   - S   S I L E N T   - - o u t p u t _ b a m   < f u l l O u t p u t . b a m > 
 
 O p t i o n a l   A r g u m e n t s : 
 - - b a m _ c o m p r e s s i o n   N   [ w h e n   u s e d   w i t h   O u t p u t C l e a n e d   i t   d e t e r m i n e s   t h e   B A M   c o m p r e s s i o n ;   d e f a u l t = 5 ,   r e c o m m e n d e d = 1 ] 
 
 
 Q u e s t i o n s   o r   c o m m e n t s : 
 E m a i l   E r i c   B a n k s   -   e b a n k s @ b r o a d i n s t i t u t e . o r g 
 