Beispiel #1
0
def main():
    """
    Read in gaussian fchk file and create an xyz file 
    """

    #
    # Read options
    #
    options, args = get_options()
    #
    #  Initialize blank system
    #
    struc_o = StructureContainer()
    #struc_o.unset_verbose()
    param_o = ParameterContainer()

    struc_o.read_cply(options.in_cply)

    search_i = dict()
    search_i = create_search(search_i, options.symbol, options.label,
                             options.fftype, options.residue, options.resname,
                             options.chain, options.ring)

    if (len(search_i) > 0):

        if (options.verbose):
            log_line = "\n Searching group i {} {} ".format(
                search_i, len(search_i))
            #log_out.write(log_line)
            if (options.verbose): print log_line
        list_i = struc_o.ptclC.getParticlesWithTags(search_i)
        struc_i = struc_o.getSubStructure(list_i, particlesOnly=True)
    else:
        struc_i = struc_o

    print struc_i

    if (len(options.xyz) > 0):
        log_line = " Setting types to {} ".format(options.xyz)
        if (options.verbose):
            print log_line
        struc_i.set_type(options.xyz)

    comment = " From data file {} ".format(options.in_cply)
    append = False
    struc_i.ptclC.write_xmol("{}".format(options.out_xyz), comment, append)
Beispiel #2
0
def main():
    """
    Read in gaussian fchk file and create an xyz file 
    """

    #        
    # Read options 
    #
    options, args = get_options()
    #
    #  Initialize blank system 
    # 
    struc_o = StructureContainer()
    #struc_o.unset_verbose()
    param_o = ParameterContainer()

    struc_o.read_cply(options.in_cply)

    search_i = dict()
    search_i = create_search(search_i,options.symbol,options.label,options.fftype,options.residue,options.resname,options.chain,options.ring)

    if( len(search_i) > 0 ):


        if( options.verbose ):
            log_line = "\n Searching group i {} {} ".format(search_i,len(search_i))
            #log_out.write(log_line)
            if( options.verbose ): print log_line
        list_i = struc_o.ptclC.getParticlesWithTags(search_i)
        struc_i = struc_o.getSubStructure(list_i, particlesOnly=True )
    else:
        struc_i = struc_o
        
    print struc_i

    if( len( options.xyz) > 0 ):
        log_line = " Setting types to {} ".format(options.xyz)
        if( options.verbose ):
            print log_line
        struc_i.set_type(options.xyz)
        
    comment = " From data file {} ".format( options.in_cply)
    append = False 
    struc_i.ptclC.write_xmol("{}".format(options.out_xyz),comment,append)
Beispiel #3
0
def main():
    
    """
    This test shows how to set up Structure container with Particle/Bond-Containers
    and shows how IDs changed in StructureContainer propagate to values set in BondContainer for its
    held particle ID values
    Illustrates how a substructure method can return subgroup
    """
    print "*****************************************************************************************************"
    print " This test shows how to set up Structure container with Particle/Bond-Containers \n"
    print " and shows how IDs changed in StructureContainer propagate to values set in BondContainer for its "
    print "    held particle ID values \n"
    print " Illustrates how a substructure method can return subgroup"
    print "************************************************************************************ \n"

    p1 = Particle( [0.2, 1.3,  33.0], "Si", 2.0, 1.23)
    p2 = Particle( [5.0, 2.3, -22.1], "C",  1.0, 2.34)
    p3 = Particle( [5.0, 2.3, -20.1], "C",  1.0, 2.34)
    p4 = Particle( [0.0, 2.3, -20.1], "C",  1.0, 2.34)
    p5 = Particle( [0.2, 1.3,  33.0], "Si", 2.0, 1.23)

    b1 = Bond( 5, 2, 1.233, "hooke")  # This setup mimics earlier state of test
    b2 = Bond( 2, 3, 0.500, "hooke")  # Still matches with diagram
    b3 = Bond( 3, 4, 2.301, "hooke")
    b4 = Bond( 5, 3, 0.828, "hooke")

    atoms1 = ParticleContainer()
    atoms1.put(p1)
    atoms1.put(p2)
    atoms1.put(p3)
    atoms1.put(p4)
    atoms1.put(p5)

    del atoms1[1]  # This is to mimic state of container for an older test

    bonds = BondContainer()
    bonds.put(b1)
    bonds.put(b2)
    bonds.put(b3)
    bonds.put(b4)

    del p1, p2, p3, p4, b1, b2, b3, b4
    polymer1 = StructureContainer(atoms1, bonds)
    del atoms1, bonds

    print "********************************************************** \n"
    print polymer1
    print diagramAfter
    print "********************************************************** \n"

    print "-------------------------------------------------------------------------------- \n"

    print "********************************************************** \n"
    print "Testing polymer1.getSubStructure([5,2])"
    print "   currently ID's are reassigned in substructure \n"
    subpolymer = polymer1.getSubStructure([5,2])
    print subpolymer
    print diagramAfter
    print "********************************************************** \n"

    print "********************************************************** \n"
    print "polymer1 Struture after returning sub-structure"
    print polymer1
    print "********************************************************** \n"

    print "-------------------------------------------------------------------------------- \n"

    print "********************************************************** \n"
    print "Testing polymer1.getSubStructure([2,3,4])"
    print "   currently ID's are reassigned in substructure \n"
    subpolymer = polymer1.getSubStructure([2,3,4])
    print subpolymer
    print diagramAfter
    print "********************************************************** \n"
def main():
    """
    Illustrates how a substructure method returns subgroup with ONLY particle container included
    This is for speed considerations
    """
    print "**********************************************************************************************"
    print "Illustrates how a substructure method returns subgroup with ONLY particle container included"
    print "This is for speed considerations"
    print "**********************************************************************************************\n"

    p1 = Particle([1.1, 1.1, 1.1], "Si", 2.0, 1.23)
    p2 = Particle([2.2, 2.2, 2.2], "Si", 1.0, 2.34)
    p3 = Particle([3.3, 3.3, 3.3], "Si", 1.0, 2.34)
    p4 = Particle([4.4, 4.4, 4.4], "Si", 1.0, 2.34)
    p5 = Particle([5.5, 5.5, 5.5], "C", 1.0, 2.34)  # 1
    p6 = Particle([6.6, 6.6, 6.6], "C", 1.0, 2.34)  # 2
    p7 = Particle([7.7, 7.7, 7.7], "C", 1.0, 2.34)  # 3
    p8 = Particle([8.8, 8.8, 8.8], "C", 1.0, 2.34)  # 4

    b1 = Bond(1, 2, 1.11, "hooke")
    b2 = Bond(2, 3, 2.22, "hooke")
    b3 = Bond(3, 4, 3.33, "hooke")
    b4 = Bond(4, 5, 4.44, "hooke")
    b5 = Bond(5, 6, 5.55, "hooke")
    b6 = Bond(6, 7, 6.66, "hooke")
    b7 = Bond(7, 8, 7.77, "hooke")

    a1 = Angle(1, 2, 3, 1.11, "harmonic")
    a2 = Angle(2, 3, 4, 2.22, "harmonic")
    a3 = Angle(3, 4, 5, 3.33, "harmonic")
    a4 = Angle(4, 5, 6, 4.44, "harmonic")
    a5 = Angle(5, 6, 7, 5.55, "harmonic")
    a6 = Angle(6, 7, 8, 6.66, "harmonic")

    d1 = Dihedral(1, 2, 3, 4, 1.11, "stiff")
    d2 = Dihedral(2, 3, 4, 5, 2.22, "stiff")
    d3 = Dihedral(3, 4, 5, 6, 3.33, "stiff")
    d4 = Dihedral(4, 5, 6, 7, 4.44, "stiff")
    d5 = Dihedral(5, 6, 7, 8, 5.55, "stiff")

    atoms1 = ParticleContainer()
    atoms1.put(p1)
    atoms1.put(p2)
    atoms1.put(p3)
    atoms1.put(p4)
    atoms1.put(p5)
    atoms1.put(p6)
    atoms1.put(p7)
    atoms1.put(p8)

    bonds = BondContainer()
    bonds.put(b1)
    bonds.put(b2)
    bonds.put(b3)
    bonds.put(b4)
    bonds.put(b5)
    bonds.put(b6)
    bonds.put(b7)

    angles = AngleContainer()
    angles.put(a1)
    angles.put(a2)
    angles.put(a3)
    angles.put(a4)
    angles.put(a5)
    angles.put(a6)

    dihedrals = DihedralContainer()
    dihedrals.put(d1)
    dihedrals.put(d2)
    dihedrals.put(d3)
    dihedrals.put(d4)
    dihedrals.put(d5)

    del p1, p2, p3, p4, p5, p6, p7, p8
    del b1, b2, b3, b4, b5, b6, b7
    del a1, a2, a3, a4, a5, a6
    del d1, d2, d3, d4, d5

    polymer1 = StructureContainer(atoms1, bonds, angles, dihedrals)
    del atoms1, bonds, angles, dihedrals

    print "********************************************************** \n"
    print "polymer1 Structure before returning sub-structure"
    print polymer1
    print "********************************************************** \n"

    print "-------------------------------------------------------------------------------- \n"

    print "********************************************************** \n"
    print "Testing polymer1.getSubParticleContainer([2,3,4])"
    print "   currently ID's are reassigned in substructure \n"
    subPtclC = polymer1.getSubStructure([2, 3, 4], particlesOnly=True)
    print subPtclC
    print "********************************************************** \n"
def main():
    """
    This shows operations on empty StructureContainer objects for 'robustness'
    """
    print "************************************************************************************"
    print " This shows operations on empty StructureContainer objects for 'robustness'"
    print "************************************************************************************ \n"

    atoms1 = ParticleContainer()
    bonds1 = BondContainer()

    p1 = Particle([0.2, 1.3, 33.0], "Si", 2.0, 1.23)
    p2 = Particle([5.0, 2.3, -22.1], "C", 1.0, 2.34)
    p3 = Particle([5.0, 2.3, -20.1], "C", 1.0, 2.34)
    b1 = Bond(1, 2, 1.233, "hooke")
    b2 = Bond(2, 3, 0.500, "hooke")

    atoms1.put(p1)
    atoms1.put(p2)
    atoms1.put(p3)
    bonds1.put(b1)
    bonds1.put(b2)

    atoms2 = ParticleContainer()
    bonds2 = BondContainer()

    polymer1 = StructureContainer(atoms1, bonds1)  # Non-empty structure 1
    polymer2 = StructureContainer(atoms2, bonds2)  # Empty     structure 2

    # ------------------------------------------------------------------------------------------------------------------------

    print "Non-empty container", polymer1
    print "Empty container", polymer2

    print "Testing empty dump"
    polymer2.dump("empty")

    print "Testing empty compressPtclIDs"
    polymer2.compressPtclIDs()

    print "Testing empty getSubStructure"
    subStruc = polymer2.getSubStructure([])
    print "subStruc = ", subStruc

    print "Testing empty getPtclPositions"
    posList = polymer2.getPtclPositions()
    print "posList = ", posList

    print "------------------------------------------------------------------------------------ \n"

    print "Testing struc add --> non-empty (polymer1) += empty (polymer2)"
    polymer1 += polymer2
    print "polymer1 = ", polymer1
    print "------------------------------------------------------------------------------------ \n"
    print "polymer2 = ", polymer2

    print "------------------------------------------------------------------------------------ \n"

    print "Testing struc add --> empty (polymer2) += non-empty (polymer1)"
    polymer2 += polymer1
    print "polymer2 = ", polymer2
    print "------------------------------------------------------------------------------------ \n"
    print "polymer1 = ", polymer1

    print "------------------------------------------------------------------------------------ \n"

    print "Testing empty getSubStructure with non-zero id list (should return ERROR)"
    polymer3 = StructureContainer()
    subStruc = polymer3.getSubStructure([1, 2])
    print "subStruc = ", subStruc