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

Add default implementations for MsBackend methods #338

Open
2 tasks
jorainer opened this issue Oct 25, 2024 · 0 comments
Open
2 tasks

Add default implementations for MsBackend methods #338

jorainer opened this issue Oct 25, 2024 · 0 comments
Labels

Comments

@jorainer
Copy link
Member

jorainer commented Oct 25, 2024

Add default implementations for most MsBackend methods to simplify developments of new backends extending the MsBackend class. These methods are listed in R/MsBackend.R and their current implementation just throws and error (see e.g. collisionEnergy,MsBackend()). Thus, for each new backend extending MsBackend the method must be implemented to avoid the error gets thrown. A cleaner, and more developer-friendly alternative would be to replace these default implementations with a meaningful alternative, that would work without an error if other mandatory methods, such as $, spectraData() and peaksData() (which must be implemented by each backend) are used. For the collisionEnergy() method, a possible implementation could be:

setMethod("collisionEnergy", "MsBackend", function(object) {
    object$collisionEnergy
})

or

setMethod("collisionEnergy", "MsBackend", function(object) {
    spectraData(object, "collisionEnergy")[, 1L]
})

Given that for a new backend extending MsBackend the $ or spectraData() method is implemented, the collisionEnergy() method would no longer have to be implemented in addition, since the collisionEnergy,MsBackend would work correctly.

Adding these default implementations would thus reduce the burden to define implementations for every MsBackend method for new backend classes.

See also our contribution guidelines, coding style and code of conduct.

  • Add default implementations for methods in R/MsBackend.R
  • Update the documentation in R/MsBackend.R and vignettes/MsBackend.Rmd vignette to clarify which methods are mandatory to implement and which optional (depending on availability of a working/existing default implementation).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant