ensemble_hic/analysis_functions.py
def load_ensemble_from_pdb(filename):
    """Loads a structure ensemble from a PDB file

    :param filename: file name of PDB file
    :type filename: str

    :returns: atom coordinates of structure ensemble
    :rtype: :class:`numpy.ndarray`
    """
    if False:
        ## Insanely slow
        from csb.bio.io.wwpdb import StructureParser
        ensemble = StructureParser(filename).parse_models()

        return np.array([m.get_coordinates(['CA']) for m in ensemble])
    else:
        ## Hacky
        ip = open(filename)
        lines = ip.readlines()
        ip.close()
        nres = 0
        for l in lines:
            w = l[:4]
            if nres > 0 and w != 'ATOM':
                break
            if l[:4] == 'ATOM':
                nres += 1

        import re
        atoms = []
        for l in lines:
            if 'ATOM' in l: atoms.append(l)
        atoms = [x.split() for x in atoms]
        atoms = [x[6:9] for x in atoms]
        atoms = np.array([np.array(x).astype(np.float) for x in atoms])
        atoms = np.array(np.split(atoms, nres))
        atoms = atoms.reshape(len(filter(lambda x: 'MODEL' in x, lines)), -1, 3)

        return atoms
Loads a structure ensemble from a PDB file

    :param filename: file name of PDB file
    :type filename: str

    :returns: atom coordinates of structure ensemble
    :rtype: :class:`numpy.ndarray`
    
Loads a structure ensemble from a PDB file
Loads a structure ensemble from a PDB file
def load_ensemble_from_pdb(filename):
    if False:
        from csb.bio.io.wwpdb import StructureParser
        ensemble = StructureParser(filename).parse_models()
        return np.array([m.get_coordinates(['CA']) for m in ensemble])
    else:
        ip = open(filename)
        lines = ip.readlines()
        ip.close()
        nres = 0
        for l in lines:
            w = l[:4]
            if nres > 0 and w != 'ATOM':
                break
            if l[:4] == 'ATOM':
                nres += 1
        import re
        atoms = []
        for l in lines:
            if 'ATOM' in l: atoms.append(l)
        atoms = [x.split() for x in atoms]
        atoms = [x[6:9] for x in atoms]
        atoms = np.array([np.array(x).astype(np.float) for x in atoms])
        atoms = np.array(np.split(atoms, nres))
        atoms = atoms.reshape(len(filter(lambda x: 'MODEL' in x, lines)), -1, 3)
        return atoms
def load_ensemble_from_pdb ( filename ) : if False : from csb . bio . io . wwpdb import StructureParser ensemble = StructureParser ( filename ) . parse_models ( ) return np . array ( [ m . get_coordinates ( [ 'CA' ] ) for m in ensemble ] ) else : ip = open ( filename ) lines = ip . readlines ( ) ip . close ( ) nres = 0 for l in lines : w = l [ : 4 ] if nres > 0 and w != 'ATOM' : break if l [ : 4 ] == 'ATOM' : nres += 1 import re atoms = [ ] for l in lines : if 'ATOM' in l : atoms . append ( l ) atoms = [ x . split ( ) for x in atoms ] atoms = [ x [ 6 : 9 ] for x in atoms ] atoms = np . array ( [ np . array ( x ) . astype ( np . float ) for x in atoms ] ) atoms = np . array ( np . split ( atoms , nres ) ) atoms = atoms . reshape ( len ( filter ( lambda x : 'MODEL' in x , lines ) ) , - 1 , 3 ) return atoms
Loads a structure ensemble from a PDB file
Loads a structure ensemble from a PDB file
"""Loads a structure ensemble from a PDB file

    :param filename: file name of PDB file
    :type filename: str

    :returns: atom coordinates of structure ensemble
    :rtype: :class:`numpy.ndarray`
    """ ## Insanely slow ## Hacky
atom coordinates of structure ensemble
atom coordinates of structure ensemble
:class:`numpy.ndarray`
filename
file name of PDB file
file name of PDB file