OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to remove members of a group with libSBML file in python

  • Thread starter Thread starter Clément Raspail
  • Start date Start date
C

Clément Raspail

Guest
I cannot remove members of a ListOfMembers() in a group in an SBML file.

I try to remove some species of an sbml file. So I delet them, and store their IDs in a set removed_species :

Code:
plugin = model.getPlugin("groups")
if plugin is not None:
    for group in plugin.getListOfGroups():
        num = group.getNumMembers()
        for member in group.getListOfMembers():
            if member.getIdRef() in removed_species:
                print("Member removed from group", group.getId(), member.getIdRef())
                group.removeMember(member.getIdRef())
        if group.getNumMembers() == num:
            print("No member removed from group", group.getId())

Members are deleted in the last loop. I checked with print but when it come back at the group loop everything is like at the start.

This is the output :

Code:
Member removed from group Sos_471_0_ Sos_dot_Ras_GEF_cplx_486_0_
Member removed from group Sos_471_0_ Sos_dot_Ras_GEF_cplx_486_0_
No member removed from group Sos_471_0_
No member removed from group Ras_548_0_
Member removed from group EGFR_560_0_ phosph_Shc_cplx_575_0_
Member removed from group EGFR_560_0_ phosph_Shc_cplx_575_0_
No member removed from group EGFR_560_0_
<p>I cannot remove members of a <code>ListOfMembers()</code> in a group in an SBML file.</p>
<p>I try to remove some species of an sbml file. So I delet them, and store their IDs in a set <code>removed_species</code> :</p>
<pre class="lang-py prettyprint-override"><code>plugin = model.getPlugin("groups")
if plugin is not None:
for group in plugin.getListOfGroups():
num = group.getNumMembers()
for member in group.getListOfMembers():
if member.getIdRef() in removed_species:
print("Member removed from group", group.getId(), member.getIdRef())
group.removeMember(member.getIdRef())
if group.getNumMembers() == num:
print("No member removed from group", group.getId())
</code></pre>
<p>Members are deleted in the last loop. I checked with print but when it come back at the group loop everything is like at the start.</p>
<p>This is the output :</p>
<pre class="lang-bash prettyprint-override"><code>Member removed from group Sos_471_0_ Sos_dot_Ras_GEF_cplx_486_0_
Member removed from group Sos_471_0_ Sos_dot_Ras_GEF_cplx_486_0_
No member removed from group Sos_471_0_
No member removed from group Ras_548_0_
Member removed from group EGFR_560_0_ phosph_Shc_cplx_575_0_
Member removed from group EGFR_560_0_ phosph_Shc_cplx_575_0_
No member removed from group EGFR_560_0_
</code></pre>
 
Top