Closed ArthurDeclercq closed 1 month ago
List's .index(x)
returns the index of the passed value. I'm not sure how we could implement this for a list of PSM objects, as there is not a single identifier by which to search the PSM. This could be the peptidoform, the collection + run+ spectrum_id... Therefore, an .index
method it might be ambiguous. There is not a single expected behavior.
We could consider implementing a method that returns the first or all indices of PSMs with a certain peptidoform, run, or spectrum_id. Although that is, in a way, already possible through the indexing methods. For instance:
>>> psm_list[psm_list["peptidoform"] == Peptidoform("WGDIEFPPPFGR/2")]
PSMList(
psm_list=[
PSM(
peptidoform=Peptidoform('WGDIEFPPPFGR/2'),
...
Or:
>>> psm_list[psm_list["spectrum_id"] == "controllerType=0 controllerNumber=1 scan=9847"]
PSMList(
psm_list=[
PSM(
peptidoform=Peptidoform('WGDIEFPPPFGR/2'),
spectrum_id='controllerType=0 controllerNumber=1 scan=9847',
...
Closing the issue for now, but could be reopened if anyone has similar feature requests and/or solutions.
Add some index functionality to the psm_list object similar to .index() method of lists Also give each psm an internal index