Skip to content

StructureTools#getGroupsWithingShell(Structure, Group,double,boolean) method should return Set<Group> #327

Closed

Description

@sroughley

The StructureTools#getGroupsWithinShell(Structure structure, Group group, double distance, boolean includeWater) currently returns a List.

As this method calls the StructureTools#getGroupsWithinShell(Structure structure, Atom atom, Set excludeResidues, double distance, boolean includeWater) repeatedly for each atom, the returned list can contain multiple copies of the same Group object as it may be within the threshold distance from more than 1 atom in the query group.

The method called also returns a Set, which makes sense, and it would therefore make more sense for both methods to return a Set.

However, changing the return type of this method may break other code elsewhere, so maybe a new method:

public static Set getUniqueGroupsWithinShell(Structure structure, Group group, double distance, boolean includeWater)

should be added?

If you let me know which is preferred, I will implement it.

Steve

Activity

  1. andreasprlic commented on Sep 17, 2015

    @andreasprlic
    Member

    I'd say let's change the signature of that method. I don't think it is widely used, as such this should be not too painful. Any patch for this is welcome! Please also update any other place in the code that is referring to this method. Thanks!

  2. sroughley commented on Sep 17, 2015

    @sroughley
    ContributorAuthor

    OK, I will check for anywhere in the code referring to that and unless it causes too many problems, submit a pull request in the next few days.

  3. josemduarte commented on Sep 17, 2015

    @josemduarte
    Contributor

    Just a note related to that method, there's some more code to calculate contacts and atoms within a distance in the org.biojava.nbio.structure.contact package. In the StructureTools class there's some methods making use of them, see for instance getAtomsInContact(Chain, Chain, String[], double, boolean). The return type of those ones is an AtomContactSet, which in turn contains AtomContacts (both classes from the org.biojava.nbio.structure.contact package).

  4. josemduarte commented on Sep 17, 2015

    @josemduarte
    Contributor

    The tutorial has something about contacts, have a look too:

    https://github.com/biojava/biojava-tutorial/blob/master/structure/contact-map.md

  5. sroughley commented on Sep 18, 2015

    @sroughley
    ContributorAuthor

    Thanks Jose. I will take a look at those.
    I have checked and the method here is not called anywhere else, so I see no problems with changing the signature. I have therefore changed the signature to return Set, and the implementation generates a LinkedHashSet as per the other #getGroupsWithinShell method, and submitted a pull request
    Steve

  6. added a commit that references this issue on Sep 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions