# Path: ssbio/complex/oligomer.py
# class Oligomer(StructProp):
# 
#     """Methods to deal with a generic oligomeric structure, extends StructProp.
# 
#     The main utilities of this class are to:
# 
#     * Parse a structure file that represents an oligomeric structure
#     * Return stoichiometric coefficients of the chains in the bioassembly
#     * More to come...
# 
#     Args:
#         ident (str): Oligomer ID
#         description (str): Optional description for this bioassembly
#         is_experimental (bool): Flag to indicate if structure is an experimental or computational model
#         structure_path (str): Path to structure file
#         file_type (str): Type of structure file - ``pdb``, ``pdb.gz``, ``mmcif``, ``cif``, ``cif.gz``,
#             ``xml.gz``, ``mmtf``, ``mmtf.gz``
# 
#     Todo:
#         - Check out http://biopython.org/wiki/Interface_Analysis (Bio.PDB.NACCESS, Interface, InterfaceAnalysis modules)
# 
#     """
# 
#     def __init__(self, ident, description=None, is_experimental=False, structure_path=None, file_type=None):
#         StructProp.__init__(self, ident=ident, description=description, chains=None, mapped_chains=None,
#                             is_experimental=is_experimental, structure_path=structure_path, file_type=file_type)
#         self.subunits = None
#         """dict: Subunit composition defined as ``{chain_id: number_of_times_used_in_bioassembly}``"""
# 
#     def merge_models(self, store_in_memory=False, outdir=None, outname=None, force_rerun=False):
#         """Merge all existing models into a Structure's first_model attribute.
# 
#         This directly modifies the Biopython Structure object. Chains IDs will start from A and increment for each new
#         chain (which is a Model that is converted).
# 
#         Args:
#             store_in_memory (bool): If the modified Biopython Structure object should be stored in the attribute
#                 ``structure``
#             outdir (str): If ``store_in_memory`` is False, the structure file has to be written somewhere so an output
#                 directory must be specified here
#             outname (str): If ``store_in_memory`` is False, the structure file has to be written somewhere so an output
#                 filename must be specified here (i.e. 4BXI_bio1)
#             force_rerun (bool): If merged file should be overwritten if it already exists
# 
#         """
# 
#         if store_in_memory:
#             if self.structure:
#                 parsed = copy(self.structure)
#             else:
#                 parsed = self.parse_structure()
#             self.structure = merge_all_models_into_first_model(parsed)
#         else:
#             new_structure_path = write_merged_bioassembly(inpath=self.structure_path,
#                                                           outdir=outdir, outname=outname,
#                                                           force_rerun=force_rerun)
#             self.load_structure_path(new_structure_path, file_type='pdb')


from ssbio.complex.oligomer import Oligomer
from lxml import etree
        from Bio.PDB import PDBParser
import os.path as op
import requests
import os
import ssbio.utils
import xmltodict
import logging
"""
Bioassembly
===========
"""


log = logging.getLogger(__name__)



# Path: ssbio/complex/oligomer.py
# class Oligomer(StructProp):
# 
#     """Methods to deal with a generic oligomeric structure, extends StructProp.
# 
#     The main utilities of this class are to:
# 
#     * Parse a structure file that represents an oligomeric structure
#     * Return stoichiometric coefficients of the chains in the bioassembly
#     * More to come...
# 
#     Args:
#         ident (str): Oligomer ID
#         description (str): Optional description for this bioassembly
#         is_experimental (bool): Flag to indicate if structure is an experimental or computational model
#         structure_path (str): Path to structure file
#         file_type (str): Type of structure file - ``pdb``, ``pdb.gz``, ``mmcif``, ``cif``, ``cif.gz``,
#             ``xml.gz``, ``mmtf``, ``mmtf.gz``
# 
#     Todo:
#         - Check out http://biopython.org/wiki/Interface_Analysis (Bio.PDB.NACCESS, Interface, InterfaceAnalysis modules)
# 
#     """
# 
#     def __init__(self, ident, description=None, is_experimental=False, structure_path=None, file_type=None):
#         StructProp.__init__(self, ident=ident, description=description, chains=None, mapped_chains=None,
#                             is_experimental=is_experimental, structure_path=structure_path, file_type=file_type)
#         self.subunits = None
#         """dict: Subunit composition defined as ``{chain_id: number_of_times_used_in_bioassembly}``"""
# 
#     def merge_models(self, store_in_memory=False, outdir=None, outname=None, force_rerun=False):
#         """Merge all existing models into a Structure's first_model attribute.
# 
#         This directly modifies the Biopython Structure object. Chains IDs will start from A and increment for each new
#         chain (which is a Model that is converted).
# 
#         Args:
#             store_in_memory (bool): If the modified Biopython Structure object should be stored in the attribute
#                 ``structure``
#             outdir (str): If ``store_in_memory`` is False, the structure file has to be written somewhere so an output
#                 directory must be specified here
#             outname (str): If ``store_in_memory`` is False, the structure file has to be written somewhere so an output
#                 filename must be specified here (i.e. 4BXI_bio1)
#             force_rerun (bool): If merged file should be overwritten if it already exists
# 
#         """
# 
#         if store_in_memory:
#             if self.structure:
#                 parsed = copy(self.structure)
#             else:
#                 parsed = self.parse_structure()
#             self.structure = merge_all_models_into_first_model(parsed)
#         else:
#             new_structure_path = write_merged_bioassembly(inpath=self.structure_path,
#                                                           outdir=outdir, outname=outname,
#                                                           force_rerun=force_rerun)
#             self.load_structure_path(new_structure_path, file_type='pdb')


# Path: ssbio/complex/bioassembly.py
from ssbio.complex.oligomer import Oligomer
from lxml import etree
        from Bio.PDB import PDBParser
import os.path as op
import requests
import os
import ssbio.utils
import xmltodict
import logging

"""
Bioassembly
===========
"""


log = logging.getLogger(__name__)



class Bioassembly(Oligomer):