# Path: ssbio/biopython/bp_mmcif2dict.py
# class MMCIF2DictFix(MMCIF2Dict):
#     """Fixes for MMCIF2Dict according to biopython#481 and biopython#523. Methods override parent.
#     """
# 
#     def __init__(self, filename):
#         super(MMCIF2DictFix, self).__init__(filename=filename)
# 
#     def _tokenize(self, handle):
#         for line in handle:
#             if line.startswith("#"):
#                 continue
#             elif line.startswith(";"):
#                 token = line[1:].strip()
#                 for line in handle:
#                     line = line.strip()
#                     if line == ';':
#                         break
#                     token += line
#                 yield token
#             else:
#                 try:
#                     tokens = shlex.split(line)
#                 except ValueError:
#                     # error "No closing quotation"
#                     line = line.replace("'",'"')
#                     # if odd - add a closing " to that line
#                     if not line.count('"') % 2 == 0:
#                         line = '{}"'.format(line)
#                     tokens = shlex.split(line)
#                 for token in tokens:
#                     yield token


import warnings
import numpy
from Bio.PDB.MMCIFParser import MMCIFParser
from Bio.PDB.PDBExceptions import PDBConstructionException
from Bio.PDB.PDBExceptions import PDBConstructionWarning
from ssbio.biopython.bp_mmcif2dict import MMCIF2DictFix




class MMCIFParserFix(MMCIFParser):
    """Fixes for MMCIFParser according to biopython#481 and biopython#523. Methods override parent.
    """

    def __init__(self, QUIET=True):
        super(MMCIFParserFix, self).__init__(QUIET=QUIET)

    def get_structure(self, structure_id, filename):
        with warnings.catch_warnings():
            if self.QUIET:
                warnings.filterwarnings("ignore", category=PDBConstructionWarning)

# Path: ssbio/biopython/bp_mmcif2dict.py
# class MMCIF2DictFix(MMCIF2Dict):
#     """Fixes for MMCIF2Dict according to biopython#481 and biopython#523. Methods override parent.
#     """
# 
#     def __init__(self, filename):
#         super(MMCIF2DictFix, self).__init__(filename=filename)
# 
#     def _tokenize(self, handle):
#         for line in handle:
#             if line.startswith("#"):
#                 continue
#             elif line.startswith(";"):
#                 token = line[1:].strip()
#                 for line in handle:
#                     line = line.strip()
#                     if line == ';':
#                         break
#                     token += line
#                 yield token
#             else:
#                 try:
#                     tokens = shlex.split(line)
#                 except ValueError:
#                     # error "No closing quotation"
#                     line = line.replace("'",'"')
#                     # if odd - add a closing " to that line
#                     if not line.count('"') % 2 == 0:
#                         line = '{}"'.format(line)
#                     tokens = shlex.split(line)
#                 for token in tokens:
#                     yield token


# Path: ssbio/biopython/bp_mmcifparser.py
import warnings
import numpy
from Bio.PDB.MMCIFParser import MMCIFParser
from Bio.PDB.PDBExceptions import PDBConstructionException
from Bio.PDB.PDBExceptions import PDBConstructionWarning
from ssbio.biopython.bp_mmcif2dict import MMCIF2DictFix





class MMCIFParserFix(MMCIFParser):
    """Fixes for MMCIFParser according to biopython#481 and biopython#523. Methods override parent.
    """

    def __init__(self, QUIET=True):
        super(MMCIFParserFix, self).__init__(QUIET=QUIET)

    def get_structure(self, structure_id, filename):
        with warnings.catch_warnings():
            if self.QUIET:
                warnings.filterwarnings("ignore", category=PDBConstructionWarning)

        self._mmcif_dict = MMCIF2DictFix(filename)