Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What to do with selection tuples? #145

Open
cgreenberg opened this issue Jan 14, 2016 · 7 comments
Open

What to do with selection tuples? #145

cgreenberg opened this issue Jan 14, 2016 · 7 comments

Comments

@cgreenberg
Copy link
Collaborator

So in PMI1 a restraint is typically set up with:

x = Restraint(representation = r,
            selection_tuples=[('A',100,150),('B',200,235)],
             resolution=10)

Then the restraint internally does the selection. But now in PMI2 we have nice "handles" and also IMP Selection works great with all resolutions (including densities). We could now just have all restraints be set up like so:

x = Restraint(hiers = [molA[100:150],molB[200:235]],
            resolution=10)

So we'd get rid of selection tuples altogether. What do you think? @Pellarin ?

@Pellarin
Copy link
Collaborator

Yes, but we still need backcompatibility. How can we prevent to broke previous code?

@benmwebb
Copy link
Member

Why not just pass a Selection object to each PMI restraint, rather than passing Selection-like parameters (e.g. resolution, residue indices) to each one?

@cgreenberg
Copy link
Collaborator Author

I'm all for that. Only problem is that many PMI restraints do the selecting for you - they read in data and select within the passed hierarchy. E.g. crosslink data or elastic networks on SSE elements. Maybe the way to do it is have PMI helper functions which create a selection from input data?

@benmwebb
Copy link
Member

Perhaps... or we make Selection itself more flexible.

@cgreenberg
Copy link
Collaborator Author

Proposal after talking with @saltzberg : have all data parsers in IO (including CrosslinkDatabase, DSSPParser, ...) have a select(hier,**kwargs) function which: 1) selects particles in hier according to the underlying data (e.g. gives lists of lists of particle pairs for crosslinks) and 2) admits additional selection keywords. So you could, for example, create a customized XL selection with:

xldb = IMP.pmi.io.crosslink.CrossLinkDataBase()
xldb.create_set_from_file("xlinks.csv")
pps = xldb.select(hier,resolution=0,atom_type=IMP.atom.AtomType("NZ"))
r = IMP.pmi.restraints.CrossLinkingMassSpectrometryRestraint(particle_pair_lists=pps,
                                                             slope=0.0,
                                                             length=21.0,
                                                             label="XL")

Thoughts?

@benmwebb
Copy link
Member

  1. looks fine but 2) duplicates the existing Selection framework somewhat, so you'd end up writing a lot of duplicated code.

@cgreenberg
Copy link
Collaborator Author

I'd have it internally call IMP Selection and just pass the kwargs on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants