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

Adding collision energy in precursor. #12

Conversation

vijay-gnanasambandan-bruker
Copy link
Contributor

Hi @swillems ,

I have made the necessary modifications to the precursor object by adjusting the collision energy. Kindly take a moment to review and provide any feedback or suggestions for further changes.

Thanks,
-Vijay

@@ -29,6 +29,7 @@ impl PrecursorReader {
let precursor_table: PrecursorTable =
PrecursorTable::from_sql(&tdf_reader.tdf_sql_reader);
let retention_times: Vec<f64> = tdf_reader.frame_table.rt.clone();
let collision_energy = &pasef_frames.collision_energy_by_precursor;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this plural collision_energies to improve readability

@@ -28,6 +29,7 @@ impl ReadableFromSql for PasefFrameMsMsTable {
.read_column_from_table("CollisionEnergy", table_name),
precursor: sql_reader
.read_column_from_table("Precursor", table_name),
collision_energy_by_precursor: sql_reader.get_data_from_sql(&"select CollisionEnergy from PasefFrameMsMsInfo group by Precursor".to_string()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this conflicts with the setup of this class. It should just use the read_from_table structure to ensure the length of the array and the order is consistent with the rest of the table. Parsing it for a specific use case should happen at the appropriate spot, not here.

@sander-willems-bruker sander-willems-bruker changed the base branch from main to develop December 20, 2023 08:33
@@ -29,6 +29,7 @@ impl PrecursorReader {
let precursor_table: PrecursorTable =
PrecursorTable::from_sql(&tdf_reader.tdf_sql_reader);
let retention_times: Vec<f64> = tdf_reader.frame_table.rt.clone();
let collision_energy = &pasef_frames.collision_energy_by_precursor;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably yhe place to do group by precursor you currently do in the table loading.

let column_names: Vec<String> =
self.get_table_columns(table_name).unwrap();
let order_by: String = column_names.join(", ");
let query: String = format!(
"SELECT {} FROM {} ORDER BY {}",
column_name, table_name, order_by
);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you adhere to the boy scout rule here and leave things better than you found them. Good addition to improve code readability, thanks!

fn read_column_from_table<
T: rusqlite::types::FromSql + std::default::Default,
>(
fn read_column_from_table<T: rusqlite::types::FromSql + Default>(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minimal change, check if if it formatted right by running cargo fmt. Normally thse kind sof changes are done automaticaly. (I evne set up my editor (VSCode with rust-analyzer extension) to run cargo fmt automatically on saving)

@sander-willems-bruker
Copy link
Collaborator

Test seem to be failing, we need to add collision enegries to them, or even add a default to simplify things...

@vijay-gnanasambandan-bruker
Copy link
Contributor Author

vijay-gnanasambandan-bruker commented Dec 22, 2023

Test seem to be failing, we need to add collision enegries to them, or even add a default to simplify things...

Added default value in the Precursor object. test cases are working now.

@sander-willems-bruker sander-willems-bruker merged commit be40423 into MannLabs:develop Jan 3, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants