/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2012,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2012,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
void
_gmx_selelem_print_compare_info(FILE *fp, void *data);
+/*! \brief
+ * Returns whether the selection element is a default position keyword.
+ *
+ * \param[in] sel Selection element to query.
+ * \returns ``true`` if ``sel`` represents a position keyword evaluation that
+ * uses the default (implicit) position keyword.
+ *
+ * This method only works before the selection has been compiled.
+ */
+bool
+_gmx_selelem_is_default_kwpos(const gmx::SelectionTreeElement &sel);
/** Sets the position type for position keyword evaluation. */
void
_gmx_selelem_set_kwpos_type(gmx::SelectionTreeElement *sel, const char *type);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
// Check whether the actual selection given was from an external group,
// and if so, use the name of the external group.
SelectionTreeElementPointer child = this->child;
- while (child->type == SEL_MODIFIER)
- {
- if (!child->child || child->child->type != SEL_SUBEXPRREF
- || !child->child->child)
- {
- break;
- }
- child = child->child->child;
- }
- if (child->type == SEL_EXPRESSION
- && child->child && child->child->type == SEL_SUBEXPRREF
- && child->child->child)
+ if (_gmx_selelem_is_default_kwpos(*child) && child->child
+ && child->child->type == SEL_SUBEXPRREF && child->child->child)
{
if (child->child->child->type == SEL_CONST
&& child->child->child->v.type == GROUP_VALUE)
((t_methoddata_pos *)data)->pcc = pcc;
}
+bool
+_gmx_selelem_is_default_kwpos(const gmx::SelectionTreeElement &sel)
+{
+ if (sel.type != SEL_EXPRESSION || !sel.u.expr.method
+ || sel.u.expr.method->name != sm_keyword_pos.name)
+ {
+ return false;
+ }
+
+ t_methoddata_pos *d = static_cast<t_methoddata_pos *>(sel.u.expr.mdata);
+ return d->type == NULL;
+}
+
/*!
* \param[in,out] sel Selection element to initialize.
* \param[in] type One of the enum values acceptable for
<String Name="Text">group "GrpB" and resname RB</String>
<Bool Name="Dynamic">false</Bool>
</ParsedSelection>
+ <ParsedSelection Name="Selection5">
+ <String Name="Input">group "GrpA" permute 5 3 2 1 4</String>
+ <String Name="Name">group "GrpA" permute 5 3 2 1 4</String>
+ <String Name="Text">group "GrpA" permute 5 3 2 1 4</String>
+ <Bool Name="Dynamic">false</Bool>
+ </ParsedSelection>
+ <ParsedSelection Name="Selection6">
+ <String Name="Input">group "GrpA" plus group "GrpB"</String>
+ <String Name="Name">group "GrpA" plus group "GrpB"</String>
+ <String Name="Text">group "GrpA" plus group "GrpB"</String>
+ <Bool Name="Dynamic">false</Bool>
+ </ParsedSelection>
+ <ParsedSelection Name="Selection7">
+ <String Name="Input">res_cog of group "GrpA"</String>
+ <String Name="Name">res_cog of group "GrpA"</String>
+ <String Name="Text">res_cog of group "GrpA"</String>
+ <Bool Name="Dynamic">false</Bool>
+ </ParsedSelection>
</ParsedSelections>
<CompiledSelections Name="Compiled">
<Selection Name="Selection1">
<Int>5</Int>
</Sequence>
</Selection>
+ <Selection Name="Selection5">
+ <String Name="Name">group "GrpA" permute 5 3 2 1 4</String>
+ <Sequence Name="Atoms">
+ <Int Name="Length">5</Int>
+ <Int>3</Int>
+ <Int>2</Int>
+ <Int>1</Int>
+ <Int>4</Int>
+ <Int>0</Int>
+ </Sequence>
+ </Selection>
+ <Selection Name="Selection6">
+ <String Name="Name">group "GrpA" plus group "GrpB"</String>
+ <Sequence Name="Atoms">
+ <Int Name="Length">10</Int>
+ <Int>0</Int>
+ <Int>1</Int>
+ <Int>2</Int>
+ <Int>3</Int>
+ <Int>4</Int>
+ <Int>3</Int>
+ <Int>4</Int>
+ <Int>5</Int>
+ <Int>6</Int>
+ <Int>7</Int>
+ </Sequence>
+ </Selection>
+ <Selection Name="Selection7">
+ <String Name="Name">res_cog of group "GrpA"</String>
+ <Sequence Name="Atoms">
+ <Int Name="Length">5</Int>
+ <Int>0</Int>
+ <Int>1</Int>
+ <Int>2</Int>
+ <Int>3</Int>
+ <Int>4</Int>
+ </Sequence>
+ </Selection>
</CompiledSelections>
</ReferenceData>
</ParsedSelection>
<ParsedSelection Name="Selection4">
<String Name="Input">res_cog of group "GrpUnsorted"</String>
- <String Name="Name">GrpUnsorted</String>
+ <String Name="Name">res_cog of group "GrpUnsorted"</String>
<String Name="Text">res_cog of group "GrpUnsorted"</String>
<Bool Name="Dynamic">false</Bool>
</ParsedSelection>
<ParsedSelection Name="Selection5">
<String Name="Input">group "GrpUnsorted" permute 2 1</String>
- <String Name="Name">GrpUnsorted</String>
+ <String Name="Name">group "GrpUnsorted" permute 2 1</String>
<String Name="Text">group "GrpUnsorted" permute 2 1</String>
<Bool Name="Dynamic">false</Bool>
</ParsedSelection>
</Sequence>
</Selection>
<Selection Name="Selection4">
- <String Name="Name">GrpUnsorted</String>
+ <String Name="Name">res_cog of group "GrpUnsorted"</String>
<Sequence Name="Atoms">
<Int Name="Length">8</Int>
<Int>0</Int>
</Sequence>
</Selection>
<Selection Name="Selection5">
- <String Name="Name">GrpUnsorted</String>
+ <String Name="Name">group "GrpUnsorted" permute 2 1</String>
<Sequence Name="Atoms">
<Int Name="Length">8</Int>
<Int>2</Int>
"group \"GrpA\"",
"GrpB",
"1",
- "group \"GrpB\" and resname RB"
+ // These test that the name of the group is not too eagerly promoted to
+ // the name of the selection.
+ "group \"GrpB\" and resname RB",
+ "group \"GrpA\" permute 5 3 2 1 4",
+ "group \"GrpA\" plus group \"GrpB\"",
+ "res_cog of group \"GrpA\""
};
setFlags(TestFlags() | efTestSelectionNames);
ASSERT_NO_THROW_GMX(loadIndexGroups("simple.ndx"));