1 {- |
    2    Multiple alignments.
    3 
    4 -}
    5 
    6 module Bio.Alignment.Multiple
    7 
    8 where
    9 
   10 import Bio.Alignment.AlignData
   11 import Bio.Sequence
   12 import Bio.Clustering
   13 
   14 -- | Progressive multiple alignment.
   15 --   Calculate a tree from agglomerative clustering, then align
   16 --   at each branch going bottom up.  Returns a list of columns (rows?).
   17 progressive :: (Sequence -> Sequence -> (Double,EditList)) -> [Sequence] -> [String]
   18 progressive = undefined
   19 
   20 -- |  Derive alignments indirectly, i.e. calculate A|C using alignments A|B and B|C.
   21 --    This is central for 'Coffee' evaluation of alignments, and T-Coffee construction
   22 --    of alignments.
   23 indirect :: EditList -> EditList -> EditList
   24 indirect (Repl x1 x2:xs) (Repl y1 y2:ys) = Repl x1 y2 : indirect xs ys -- assert x2==y1
   25 indirect xs@(Repl _ _:_) (Ins y1:ys)     = Ins y1     : indirect xs ys
   26 indirect (Repl x1 _:xs) (Del y1:ys)      = Del x1     : indirect xs ys
   27 
   28 indirect (Del x1:xs) ys                  = Del x1     : indirect xs ys -- imply del+ins/=repl
   29 
   30 indirect (Ins x1:xs) (Repl _ y2:ys)      = Ins y2     : indirect xs ys -- assert x1==y1
   31 indirect (Ins x1:xs) (Del y1:ys)         = indirect xs ys -- assert x1 == y1
   32 indirect xs@(Ins _:_) (Ins y1:ys)        = Ins y1 : indirect xs ys
   33 
   34 indirect [] ys                           = ys -- assert: all Ins
   35 indirect xs []                           = xs -- assert: all Del
   36 
   37