コード例 #1
0
## its license.  Please see the LICENSE file that should have been
## included as part of this package.
"""This example uses the Python code profiler to load a file with mmLib.
We use this to help performance tune mmLib.
"""

## Python
import sys

## pymmlib
import test_util
from mmLib import FileIO


def main(path):
    print "mmLib.LoadStructure(fil=%s)" % (path)
    struct = FileIO.LoadStructure(fil=path)


if __name__ == "__main__":
    import os

    try:
        path = sys.argv[1]
    except IndexError:
        print "usage: load_test.py <PDB/mmCIF file or directory of files>"
        sys.exit(1)

    for pathx in test_util.walk_pdb_cif(path):
        main(pathx)
コード例 #2
0
ファイル: load_test.py プロジェクト: masci/mmLib
## This code is part of the PyMMLib distribution and governed by
## its license.  Please see the LICENSE file that should have been
## included as part of this package.
"""This example uses the Python code profiler to load a file with mmLib.
We use this to help performance tune mmLib.
"""

## Python
import sys

## pymmlib
import test_util
from mmLib import FileIO


def main(path):
    print "mmLib.LoadStructure(fil=%s)" % (path)
    struct = FileIO.LoadStructure(fil=path)

if __name__ == "__main__":
    import os

    try:
        path = sys.argv[1]
    except IndexError:
        print "usage: load_test.py <PDB/mmCIF file or directory of files>"
        sys.exit(1)

    for pathx in test_util.walk_pdb_cif(path):
        main(pathx)
コード例 #3
0
ファイル: mmlib_test.py プロジェクト: Sree-Inventrust/pymmlib
def main(walk_path, start_path):
    print "Running Python Macromolecular Library Test Program"
    print "--------------------------------------------------"
    print "This program will throw a AssertionError (or worse!) if it"
    print "runs into any problems."
    print

    for path in test_util.walk_pdb_cif(walk_path, start_path):
        print "[%s]" % (path)
        time1 = time.time()

        stats = Stats()
        struct = FileIO.LoadStructure(fil=path,
                                      build_properties=("library_bonds", ))

        ## track memory leaks
        sref = weakref.ref(struct, weakref_callback)
        WEAKREF_PATH[sref] = path
        WEAKREF_LIST.append(sref)

        ## test the mmLib.Structure object API and
        ## with massive sanity checking
        print "[loaded struct]"
        try:
            run_structure_tests(struct, stats)
        except AssertionError:
            print "*** AssertionError while testing: %s ***" % (str(
                stats["testing"]))
            raise
        except:
            print "*** Error while testing: %s ***" % (str(stats["testing"]))
            raise
        stats.print_stats()

        ## copy the structure and re-run those tests
        print "[copy struct]"
        struct_cp = copy.deepcopy(struct)
        cmp_struct(struct, struct_cp)

        ## verify the number of atoms in the mmLib.Structure object
        ## matches the number of atoms in the source file
        file_verify(path, struct, stats)

        ## test file saving
        from mmLib.CIF import DataBlock
        if (hasattr(struct, "cif_data")
                and isinstance(struct.cif_data, DataBlock)):
            print "[save verify skipped]"
        else:
            print "[save verify]"
            save_verify(struct, stats)

        time2 = time.time()
        print "Tests Time (sec)-----:", int(time2 - time1)

        ## dereference!
        struct = None
        struct_cp = None
        stats = None
        stats_cp = None

        ## force garbage collection
        gc.collect()
        print
コード例 #4
0
ファイル: mmlib_test.py プロジェクト: masci/mmLib
def main(walk_path, start_path):
    print "Running Python Macromolecular Library Test Program"
    print "--------------------------------------------------"
    print "This program will throw a AssertionError (or worse!) if it"
    print "runs into any problems."
    print

    for path in test_util.walk_pdb_cif(walk_path, start_path):
        print "[%s]" % (path)
        time1 = time.time()

        stats  = Stats()
        struct = FileIO.LoadStructure(
            fil              = path,
            build_properties = ("library_bonds",))   

        ## track memory leaks
        sref = weakref.ref(struct, weakref_callback)
        WEAKREF_PATH[sref] = path
        WEAKREF_LIST.append(sref)

        ## test the mmLib.Structure object API and
        ## with massive sanity checking
        print "[loaded struct]"
        try:
            run_structure_tests(struct, stats)
        except AssertionError:
            print "*** AssertionError while testing: %s ***" % (
                str(stats["testing"]))
            raise
        except:
            print "*** Error while testing: %s ***" % (
                str(stats["testing"]))
            raise
        stats.print_stats()

        ## copy the structure and re-run those tests
        print "[copy struct]"
        struct_cp = copy.deepcopy(struct)
        cmp_struct(struct, struct_cp)

        ## verify the number of atoms in the mmLib.Structure object
        ## matches the number of atoms in the source file 
        file_verify(path, struct, stats)

        ## test file saving
        from mmLib.CIF import DataBlock
        if (hasattr(struct, "cif_data")
                and isinstance(struct.cif_data, DataBlock)):
            print "[save verify skipped]"
        else:
            print "[save verify]"
            save_verify(struct, stats)

        time2 = time.time()
        print "Tests Time (sec)-----:",int(time2-time1)

        ## dereference!
        struct    = None
        struct_cp = None
        stats     = None
        stats_cp  = None

        ## force garbage collection
        gc.collect()
        print