Code Monkey home page Code Monkey logo

Comments (9)

eurydice76 avatar eurydice76 commented on June 2, 2024

Hi @RastislavTuranyi @sanghamitra-mukhopadhyay , I made a lof of changes in the protos branch. This branch allows now to:

  • convert trajectories to HDF5 format (only works for DL_POLY converter right now)
  • run MSD analysis
  • produce a HDF file as output format
  • view the molecules with the molecular viewer

Could you please review the code and play a bit with and tell me if it is OK for you. Your participation is important because this may be the basis for the future of MDANSE. I also need #61 to be merged in order to continue. Could you please proceed to merge if it this branch is OK for you ? Many thanks

from mdanse.

RastislavTuranyi avatar RastislavTuranyi commented on June 2, 2024

I was testing various things from the command line using Python 3 and this branch, and I got this error when importing CASTEPConverter:

>>> from MDANSE.Framework.Jobs.Castep import CASTEPConverter
Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.2.1\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\Framework\Jobs\Castep.py", line 32, in <module>
    HBAR = measure(1.05457182e-34,'kg m2/s').toval('uma nm2/ps')
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\Framework\Units.py", line 749, in measure
    unit = _str_to_unit(iunit)
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\Framework\Units.py", line 112, in _str_to_unit
    unit /= _parse_unit(u)
TypeError: unsupported operand type(s) for /=: '_Unit' and '_Unit'

from mdanse.

RastislavTuranyi avatar RastislavTuranyi commented on June 2, 2024

I tried running the GromacsConverter from the command line and got a bug due to b'something' == 'something' being false. I fixed this and pushed the change, but then this error appeared:

>>> g = GromacsConverter()
>>> g.run({'pdb_file': r'C:\Users\dni83241\Documents\MDANSE\MDANSE\Data\Trajectories\Gromacs\cobrotoxin.pdb', 'xtc_file': r'C:\Users\dni83241\Documents\MDANSE\MDANSE\Data\Trajectories\Gromacs\cobrotoxin.trr', 'fold': False, 'output_file': (r'C:\Users\dni83241\Downloads\test', 'hdf')})
Traceback (most recent call last):
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\Framework\Jobs\IJob.py", line 304, in run
    self.initialize()
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\Framework\Jobs\Gromacs.py", line 89, in initialize
    pdb_reader = PDBReader(self.configuration['pdb_file']['filename'])
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\IO\PDBReader.py", line 25, in __init__
    self._struct = Structure(filename)
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\IO\PDB.py", line 1135, in __init__
    self.parseFile(PDBFile(file_or_filename))
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\IO\PDB.py", line 1221, in parseFile
    type, data = file.readLine()
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\IO\PDB.py", line 161, in readLine
    line = self.file.readline()
AttributeError: 'bytes' object has no attribute 'readline'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\Framework\Jobs\IJob.py", line 326, in run
    raise JobError(self,tb)
MDANSE.Framework.Jobs.IJob.JobError: Traceback (most recent call last):
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\Framework\Jobs\IJob.py", line 304, in run
    self.initialize()
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\Framework\Jobs\Gromacs.py", line 89, in initialize
    pdb_reader = PDBReader(self.configuration['pdb_file']['filename'])
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\IO\PDBReader.py", line 25, in __init__
    self._struct = Structure(filename)
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\IO\PDB.py", line 1135, in __init__
    self.parseFile(PDBFile(file_or_filename))
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\IO\PDB.py", line 1221, in parseFile
    type, data = file.readLine()
  File "C:\Users\dni83241\Documents\Virtualenvs\python3\lib\site-packages\MDANSE\IO\PDB.py", line 161, in readLine
    line = self.file.readline()
AttributeError: 'bytes' object has no attribute 'readline'

from mdanse.

eurydice76 avatar eurydice76 commented on June 2, 2024

OK, I check this. Thanks for the feedback Rastislav

from mdanse.

eurydice76 avatar eurydice76 commented on June 2, 2024

OK, the two regressions are fixed. We will have hard times to track and solve all the regression induced by switching from python2 to python3.

from mdanse.

RastislavTuranyi avatar RastislavTuranyi commented on June 2, 2024

By the way, last week I updated the CI for protos, so it should be running correctly. As far as I am aware, the currently failing test fails legitimately, and I'm not sure what's the best way to fix it. The CD is still not operational, but I think that can wait for now.

from mdanse.

RastislavTuranyi avatar RastislavTuranyi commented on June 2, 2024

Hi @eurydice76, as I was looking through the code, I noticed that when a Trajectory object is instantiated, the HDF5 file used is opened twice, once in Trajectory.__init__ and once in ChemicalSystem.load(), and I was wondering if it would be possible to pass in the file that's opened in Trajectory.__init__ into ChemicalSystem.load(), rather than passing in the file name string and opening the file again. That way, everything should be faster and more easily testable. If some other pat of the code requires to pass in a string to ChemicalSystem.load(), it shouldn't be difficult to make the method accept both. What do you think?

from mdanse.

RastislavTuranyi avatar RastislavTuranyi commented on June 2, 2024

@eurydice76 another thing I have noticed is that the reorder_atoms() method in the AtomCluster class does not work because the _atoms property is a list while the method treats it as a dictionary:

class AtomCluster(_ChemicalEntity):

    def __init__(self, name, atoms, parentless=False):

        super(AtomCluster,self).__init__()

        self._name = name

        self._parentless = parentless

        self._atoms = []
        for at in atoms:
            if not parentless:
                at._parent = self
            self._atoms.append(at)

    def reorder_atoms(self, atoms):

        if set(atoms) != set([at.name for at in self._atoms]):
            raise InconsistentAtomNamesError('The set of atoms to reorder is inconsistent with molecular contents')

        reordered_atoms = []
        for at in atoms:
            reordered_atoms[at] = self._atoms[at]
        
        self._atoms = reordered_atoms

I have been thinking about it, but I can't decide what the best thing to do is. I think the best way would be to change the AtomCluster._atoms property to be a dict, so that it works the same as the Molecule class, but unlike Molecule, AtomCluster does not have a guarantee that the atom names will be different, so a check for that would have to be implemented as well.

What do you think?

from mdanse.

eurydice76 avatar eurydice76 commented on June 2, 2024

Good point. Thanks for the comment. I will have to think about.

from mdanse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.