Esempio n. 1
0
    def __call__(self, f):
        try:
            xyz_reader = XYZReader(f)
            molecule = xyz_reader.get_first_molecule()
        except IOError:
            raise FilterError("Could not read the first frame from the XYZ file. Incorrect file format.")

        Universe = context.application.plugins.get_node("Universe")
        universe = Universe()
        Folder = context.application.plugins.get_node("Folder")
        folder = Folder()

        title = molecule.title.strip()
        if len(title) > 0:
            universe.name = title

        Atom = context.application.plugins.get_node("Atom")
        Point = context.application.plugins.get_node("Point")

        for index, number, symbol, coordinate in zip(xrange(molecule.size), molecule.numbers, xyz_reader.symbols, molecule.coordinates):
            extra = {"index": index}
            transl = Translation(coordinate)
            if number == 0:
                atom = Point(name=symbol, extra=extra, transformation=transl)
            else:
                atom = Atom(name=symbol, number=number, extra=extra, transformation=transl)
            universe.add(atom)

        geometries = []
        for title, coordinates in xyz_reader:
            geometries.append(coordinates)

        return [universe, folder]
Esempio n. 2
0
    def __call__(self, f):
        try:
            xyz_reader = XYZReader(f)
            molecule = xyz_reader.get_first_molecule()
        except IOError:
            raise FilterError(
                "Could not read the first frame from the XYZ file. Incorrect file format."
            )

        Universe = context.application.plugins.get_node("Universe")
        universe = Universe()
        Folder = context.application.plugins.get_node("Folder")
        folder = Folder()

        title = molecule.title.strip()
        if len(title) > 0:
            universe.name = title

        Atom = context.application.plugins.get_node("Atom")
        Point = context.application.plugins.get_node("Point")

        for index, number, symbol, coordinate in zip(xrange(molecule.size),
                                                     molecule.numbers,
                                                     xyz_reader.symbols,
                                                     molecule.coordinates):
            extra = {"index": index}
            transl = Translation(coordinate)
            if number == 0:
                atom = Point(name=symbol, extra=extra, transformation=transl)
            else:
                atom = Atom(name=symbol,
                            number=number,
                            extra=extra,
                            transformation=transl)
            universe.add(atom)

        geometries = []
        for title, coordinates in xyz_reader:
            geometries.append(coordinates)

        return [universe, folder]