Commit ffd0bc20 authored by eric pellegrini's avatar eric pellegrini

Bug fix in AtomSelectionPlugin

Slight change in atom selection selectors name
parent 9f8c10a8
......@@ -139,12 +139,13 @@ class Query(object):
return []
try:
selection = self._parser(self.get_expression(),True)
expression = self.get_expression()
selection = self._parser.parse(expression)
except AtomSelectionParserError:
selection = ("",[])
return selection
return ("",[])
else:
return (expression,selection)
def pop(self):
return self._list.pop()
......@@ -178,7 +179,7 @@ class AtomSelectionPlugin(ComponentPlugin):
self._mainPanel = wx.Panel(self, wx.ID_ANY, size=self.GetSize())
self._notebook = wxaui.AuiNotebook(self._mainPanel, wx.ID_ANY, style=wxaui.AUI_NB_DEFAULT_STYLE^wxaui.AUI_NB_TAB_MOVE)
self._notebook = wxaui.AuiNotebook(self._mainPanel, wx.ID_ANY, style=wxaui.AUI_NB_DEFAULT_STYLE&~wxaui.AUI_NB_CLOSE_ON_ACTIVE_TAB&~wxaui.AUI_NB_TAB_MOVE)
settingsPanel = wx.Panel(self._mainPanel,wx.ID_ANY)
......@@ -321,7 +322,7 @@ class AtomSelectionPlugin(ComponentPlugin):
self._selectionSummary.AppendText("List of selected atoms:\n")
for idx in self._selection:
self._selectionSummary.AppendText("\t%s\n" % self._atoms[idx].fullName())
self._selectionSummary.AppendText("\t%s (MMTK index: %d)\n" % self._atoms[idx].fullName(),self._atoms[idx].index)
def insert_keyword_values(self, keyword, values):
......@@ -378,7 +379,7 @@ class AtomSelectionPlugin(ComponentPlugin):
return
if not self._selectors.has_key(selectionFilter):
self._selectors[selectionFilter] = [str(v) for v in REGISTRY["selector"](selectionFilter, self._parent.trajectory.universe).choices]
self._selectors[selectionFilter] = [str(v) for v in REGISTRY["selector"][selectionFilter](self._parent.trajectory.universe).choices]
self.values.Set(self._selectors[selectionFilter])
......
......@@ -207,6 +207,7 @@ https://github.com/eurydyce/MDANSE/tree/master/MDANSE
for any other request, please send an email to:
\tpellegrini@ill.fr
\tgonzalezm@ill.fr
\tjohnson@ill.fr
or directly to the MDANSE mailing list:
......
......@@ -41,9 +41,9 @@ class AtomSelectionParserError(Error):
class AtomSelectionParser(object):
def __init__(self, trajectory):
def __init__(self, universe):
self._universe = trajectory.universe
self._universe = universe
def operator_and(self, token):
......
......@@ -92,7 +92,7 @@ class AtomSelectionConfigurator(IConfigurator):
ud = UD_STORE[trajConfig["basename"],"atom_selection",value]
# The input value is an atom selection string: parse it and update the configuration
except UserDefinitionError:
parser = AtomSelectionParser(trajConfig["instance"])
parser = AtomSelectionParser(trajConfig["instance"].universe)
self["indexes"] = parser.parse(value)
self["expression"] = value
else:
......
......@@ -89,7 +89,7 @@ class AtomTransmutationConfigurator(IConfigurator):
trajConfig = configuration[self._dependencies['trajectory']]
parser = AtomSelectionParser(trajConfig["instance"])
parser = AtomSelectionParser(trajConfig["instance"].universe)
# If the input value is a dictionary, it must have a selection string as key and the element
# to be transmutated to as value
......
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Jun 4, 2015
@author: Eric C. Pellegrini
'''
from MDANSE.Framework.Jobs.Converters.Discover import DiscoverConverter
class DMolConverter(DiscoverConverter):
"""
Converts a DMol trajectory to a MMTK trajectory.
"""
type = 'dmol'
label = "DMol"
\ No newline at end of file
......@@ -34,12 +34,12 @@ from MDANSE.Framework.Selectors.ISelector import ISelector
class AtomFullName(ISelector):
type = "atomfullname"
type = "atom_fullname"
section = "atoms"
def __init__(self, universe):
ISelector.__init__(self,universe)
self._choices.extend(sorted(set([at.fullName().strip().lower() for at in self._universe.atomList()])))
......
......@@ -34,7 +34,7 @@ from MDANSE.Framework.Selectors.ISelector import ISelector
class AtomIndex(ISelector):
type = "atomindex"
type = "atom_index"
section = "atoms"
......
......@@ -34,7 +34,7 @@ from MDANSE.Framework.Selectors.ISelector import ISelector
class AtomName(ISelector):
type = "atomname"
type = "atom_name"
section = "atoms"
......
......@@ -34,6 +34,6 @@ from MDANSE.Framework.Selectors.AtomIndex import AtomIndex
class AtomPicked(AtomIndex):
type = "atompicked"
type = "atom_picked"
section = "miscellaneous"
......@@ -34,7 +34,7 @@ from MDANSE.Framework.Selectors.ISelector import ISelector
class AtomSymbol(ISelector):
type = "atomsymbol"
type = "atom_symbol"
section = "atoms"
......
......@@ -34,7 +34,7 @@ from MDANSE.Framework.Selectors.ISelector import ISelector
class AtomType(ISelector):
type = "atomtype"
type = "atom_type"
section = "atoms"
......
......@@ -34,7 +34,7 @@ from MDANSE.Framework.Selectors.ISelector import ISelector
class CarboHydrogen(ISelector):
type = "carbohydrogen"
type = "carbo_hydrogen"
section = "hydrogens"
......
......@@ -36,7 +36,7 @@ from MDANSE.Framework.Selectors.ISelector import ISelector
class ChainName(ISelector):
type = "chainname"
type = "chain_name"
section = "proteins"
......
......@@ -34,7 +34,7 @@ from MDANSE.Framework.Selectors.ISelector import ISelector
class HeteroHydrogenBound(ISelector):
type = "heterohydrogen"
type = "hetero_hydrogen"
section = "hydrogens"
......
......@@ -27,7 +27,7 @@
'''
Created on Mar 27, 2015
@author: pellegrini
:author: Eric C. Pellegrini
'''
from MDANSE.Framework.Selectors.ISelector import ISelector
......
......@@ -34,7 +34,7 @@ from MDANSE.Framework.Selectors.ISelector import ISelector
class NitroHydrogen(ISelector):
type = "nitrohydrogen"
type = "nitro_hydrogen"
section = "hydrogens"
......
......@@ -34,7 +34,7 @@ from MDANSE.Framework.Selectors.ISelector import ISelector
class OxyHydrogen(ISelector):
type = "O-H"
type = "oxy_hydrogen"
section = "hydrogens"
......
......@@ -34,7 +34,7 @@ from MDANSE.Framework.Selectors.ISelector import ISelector
class PythonScript(ISelector):
type = "pythonscript"
type = "python_script"
section = None
......
......@@ -36,7 +36,7 @@ from MDANSE.Framework.Selectors.ISelector import ISelector
class ResType(ISelector):
type = "restype"
type = "residue_type"
section = "proteins"
......
......@@ -265,7 +265,7 @@ class TestConfigurator(UnitTest):
# Test a valid atom selection string
self._parameters["trajectory"] = self._validTrajectory.filename
self._parameters["atom_selection"] = 'atomtype carbon'
self._parameters["atom_selection"] = 'atom_type carbon'
self.assertNotRaises(configurable.setup,self._parameters)
self.assertEqual(configurable['atom_selection']['n_selected_atoms'],sum([True for at in configurable['trajectory']['instance'].universe.atomList() if at.symbol=='C']))
......@@ -291,7 +291,7 @@ class TestConfigurator(UnitTest):
# Test that an empty selection selection raises a SelectionParserError
self._parameters["trajectory"] = self._validTrajectory.filename
self._parameters["atom_transmutation"] = 'atomtype(["fsfsd"])'
self._parameters["atom_transmutation"] = 'atom_type(["fsfsd"])'
self.assertRaises(ConfiguratorError,configurable.setup,self._parameters)
# Test that None parameters selects everything
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment