Ejemplo n.º 1
0
    def read(self, string):
        doc = minidom.parseString(string)
        elements = doc.getElementsByTagName("atom")
        atomlist = []
        for atom in elements:
            sym = atom.getAttribute("elementType")
            atno = sym2no[sym]
            x = float(atom.getAttribute("x3"))
            y = float(atom.getAttribute("y3"))
            z = float(atom.getAttribute("z3"))
            atomlist.append((atno, (x, y, z)))

        data = Data()
        data.build_molecule(atomlist=atomlist)
        return data
Ejemplo n.º 2
0
    def read(self, string):
        doc = minidom.parseString(string)
        elements = doc.getElementsByTagName("atom")
        atomlist=[]
        for atom in elements:
            sym = atom.getAttribute("elementType")
            atno = sym2no[sym]
            x = float(atom.getAttribute("x3"))
            y = float(atom.getAttribute("y3"))
            z = float(atom.getAttribute("z3"))
            atomlist.append((atno,(x,y,z)))

        data = Data()
        data.build_molecule(atomlist = atomlist)
        return data
Ejemplo n.º 3
0
 def read(self,string):
     """
     Arguments:
     
     - string: String to parse
     
     Return:
     
     - data: Data object, with a molecule and a molecules
       attribute.
     """
     from PyQuante.Element import sym2no
     from PyQuante.Molecule import Molecule
     geometries = []
     igeo = 1
     lines = string.splitlines()
     while 1:  
         try: 
             line = lines.pop(0)
         except IndexError:
             break
         if not line: break
         nat = int(line.split()[0])
         title = lines.pop(0)
         atoms = []
         for i in xrange(nat):
             line = lines.pop(0)
             words = line.split()
             atno = sym2no[words[0]]
             x,y,z = map(float,words[1:])
             atoms.append((atno,(x,y,z)))
         atoms = Molecule("XYZ geometry #%d" % igeo,atoms)
         igeo += 1
         geometries.append(atoms)
     
     data = Data()
     data.molecule = geometries[0] # First geometry
     data.molecules = geometries
     return data
Ejemplo n.º 4
0
    def read(self, string):
        """
        Arguments:
        
        - string: String to parse
        
        Return:
        
        - data: Data object, with a molecule and a molecules
          attribute.
        """
        from PyQuante.Element import sym2no
        from PyQuante.Molecule import Molecule
        geometries = []
        igeo = 1
        lines = string.splitlines()
        while 1:
            try:
                line = lines.pop(0)
            except IndexError:
                break
            if not line: break
            nat = int(line.split()[0])
            title = lines.pop(0)
            atoms = []
            for i in xrange(nat):
                line = lines.pop(0)
                words = line.split()
                atno = sym2no[words[0]]
                x, y, z = map(float, words[1:])
                atoms.append((atno, (x, y, z)))
            atoms = Molecule("XYZ geometry #%d" % igeo, atoms)
            igeo += 1
            geometries.append(atoms)

        data = Data()
        data.molecule = geometries[0]  # First geometry
        data.molecules = geometries
        return data
Ejemplo n.º 5
0
 def dump(self, filename, format=None):
     from PyQuante.IO.Data import Data
     data = Data()
     data.molecule = self
     hand = FileHandler()
     hand.write(filename, data, format)
Ejemplo n.º 6
0
 def as_string(self, format="xyz"):
     from PyQuante.IO.Data import Data
     data = Data()
     data.molecule = self
     hand = StringHandler()
     return hand.write(data, format)
Ejemplo n.º 7
0
 def dump(self,filename, format=None):
     from PyQuante.IO.Data import Data
     data = Data()
     data.molecule = self
     hand = FileHandler()
     hand.write(filename,data,format)
Ejemplo n.º 8
0
 def as_string(self,format="xyz"):
     from PyQuante.IO.Data import Data
     data = Data()
     data.molecule = self
     hand = StringHandler()
     return hand.write(data, format)
Ejemplo n.º 9
0
 def testWriteString(self):
     sh = SH()
     data = Data(molecule=PYQ)
     sh.write(data, format="cml")