deinterleave           package:ComPairWise           R Documentation

_C_o_n_v_e_r_t _i_n_t_e_r_l_e_a_v_e_d _a_l_i_g_n_m_e_n_t_s _t_o _s_e_q_u_e_n_t_i_a_l

_D_e_s_c_r_i_p_t_i_o_n:

     Takes an interleaved alignment and turns it into a sequential one.

_U_s_a_g_e:

     deinterleave(alignment)

_A_r_g_u_m_e_n_t_s:

alignment: An alignment object, presumably one with every taxon split
          into more than one sequence

_D_e_t_a_i_l_s:

     This is a workaround function for reading alignments.  It
     re-assembles interleaved alignments, which otherwise would come
     out with every line of sequence as a different taxon.

     deinterleave requires that all the parts of one sequence have the
     same taxon name, and that otherwise no taxon names be duplicate. 
     It concatenates sequences based only on their taxon names.

_V_a_l_u_e:

     ~Describe the value returned An alignment object with the input
     sequences reassembled. 

      nb: Number of sequences in the alignment

     nam: Names of the sequences

     seq: The sequences themselves

     com: Currently NA; comment

_N_o_t_e:

     Designed as an internal function but works as a standalone. 
     Called by 'read.nexus'

_A_u_t_h_o_r(_s):

     TER

_S_e_e _A_l_s_o:

     'read.nexus'

_E_x_a_m_p_l_e_s:

     ##---- Should be DIRECTLY executable !! ----
     ##-- ==>  Define data, use random,
     ##--    or do  help(data=index)  for the standard data sets.

     ## The function is currently defined as
     function (alignment) 
     {
         taxa <- unique(alignment$nam)
         deint <- function(taxon, alignment) paste(alignment$seq[alignment$nam == 
             taxon], sep = "", collapse = "")
         x <- unlist(lapply(taxa, deint, alignment))
         newaln <- list(nb = length(taxa), nam = taxa, seq = x, com = NA)
         class(newaln) <- "alignment"
         return(newaln)
       }

