#NEWLINE# @ classonlymethod #NEWLINE# @ experimental ( as_of = '0.4.1' ) #NEWLINE# def concat( cls , sequences , how = 'strict' ) : #NEWLINE# #INDENT# 'Concatenate an iterable of ``Sequence`` objects.\n\n        Parameters\n        ----------\n        seqs : iterable (Sequence)\n            An iterable of ``Sequence`` objects or appropriate subclasses.\n        how : {\'strict\', \'inner\', \'outer\'}, optional\n            How to intersect the `positional_metadata` of the sequences.\n            If \'strict\': the `positional_metadata` must have the exact same\n            columns; \'inner\': an inner-join of the columns (only the shared set\n            of columns are used); \'outer\': an outer-join of the columns\n            (all columns are used: missing values will be padded with NaN).\n\n        Returns\n        -------\n        Sequence\n            The returned sequence will be an instance of the class which\n            called this class-method.\n\n        Raises\n        ------\n        ValueError\n            If `how` is not one of: \'strict\', \'inner\', or \'outer\'.\n        ValueError\n            If `how` is \'strict\' and the `positional_metadata` of each sequence\n            does not have the same columns.\n        TypeError\n            If the sequences cannot be cast as the calling class.\n\n        Notes\n        -----\n        The sequence-wide metadata (``Sequence.metadata``) is not retained\n        during concatenation.\n\n        Sequence objects can be cast to a different type only when the new\n        type is an ancestor or child of the original type. Casting between\n        sibling types is not allowed, e.g. ``DNA`` -> ``RNA`` is not\n        allowed, but ``DNA`` -> ``Sequence`` or ``Sequence`` -> ``DNA``\n        would be.\n\n        Examples\n        --------\n        Concatenate two DNA sequences into a new DNA object:\n\n        >>> from skbio import DNA, Sequence\n        >>> s1 = DNA("ACGT")\n        >>> s2 = DNA("GGAA")\n        >>> DNA.concat([s1, s2])\n        DNA\n        --------------------------\n        Stats:\n            length: 8\n            has gaps: False\n            has degenerates: False\n            has definites: True\n            GC-content: 50.00%\n        --------------------------\n        0 ACGTGGAA\n\n        Concatenate DNA sequences into a Sequence object (type coercion):\n\n        >>> Sequence.concat([s1, s2])\n        Sequence\n        -------------\n        Stats:\n            length: 8\n        -------------\n        0 ACGTGGAA\n\n        Positional metadata is conserved:\n\n        >>> s1 = DNA(\'AcgT\', lowercase=\'one\')\n        >>> s2 = DNA(\'GGaA\', lowercase=\'one\',\n        ...          positional_metadata={\'two\': [1, 2, 3, 4]})\n        >>> result = DNA.concat([s1, s2], how=\'outer\')\n        >>> result\n        DNA\n        ---------------------------\n        Positional metadata:\n            \'one\': <dtype: bool>\n            \'two\': <dtype: float64>\n        Stats:\n            length: 8\n            has gaps: False\n            has degenerates: False\n            has definites: True\n            GC-content: 50.00%\n        ---------------------------\n        0 ACGTGGAA\n        >>> result.positional_metadata\n             one  two\n        0  False  NaN\n        1   True  NaN\n        2   True  NaN\n        3  False  NaN\n        4  False    1\n        5  False    2\n        6   True    3\n        7  False    4\n\n        ' #NEWLINE# if ( how not in { 'strict' , 'inner' , 'outer' } ) : #NEWLINE# #INDENT# raise ValueError ( "`how` must be 'strict', 'inner', or 'outer'." ) #NEWLINE# #UNINDENT# seqs = list ( sequences ) #NEWLINE# if ( len ( seqs ) == 0 ) : #NEWLINE# #INDENT# return cls ( '' ) #NEWLINE# #UNINDENT# for seq in seqs : #NEWLINE# #INDENT# seq . _assert_can_cast_to ( cls ) #NEWLINE# #UNINDENT# if ( how == 'strict' ) : #NEWLINE# #INDENT# how = 'inner' #NEWLINE# cols = set ( ) #NEWLINE# for s in sequences : #NEWLINE# #INDENT# cols . add ( frozenset ( s . positional_metadata ) ) #NEWLINE# #UNINDENT# if ( len ( cols ) > 1 ) : #NEWLINE# #INDENT# raise ValueError ( "The positional metadata of the sequences do not have matching columns. Consider setting how='inner' or how='outer'" ) #NEWLINE# #UNINDENT# #UNINDENT# seq_data = [ ] #NEWLINE# pm_data = [ ] #NEWLINE# for seq in seqs : #NEWLINE# #INDENT# seq_data . append ( seq . _bytes ) #NEWLINE# pm_data . append ( seq . positional_metadata ) #NEWLINE# #UNINDENT# pm = pd . concat ( pm_data , join = how , ignore_index = True ) #NEWLINE# bytes_ = np . concatenate ( seq_data ) #NEWLINE# return cls ( bytes_ , positional_metadata = pm )