-
Notifications
You must be signed in to change notification settings - Fork 11
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
Changes from 3 commits
1e734b8
cda1a5d
08cc654
fbbbdd3
a987472
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,21 +12,27 @@ pub struct SqlReader { | |
} | ||
|
||
impl SqlReader { | ||
fn read_column_from_table< | ||
T: rusqlite::types::FromSql + std::default::Default, | ||
>( | ||
fn read_column_from_table<T: rusqlite::types::FromSql + Default>( | ||
&self, | ||
column_name: &str, | ||
table_name: &str, | ||
) -> Vec<T> { | ||
let connection: Connection = get_sql_connection(&self.path); | ||
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 | ||
); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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! |
||
self.get_data_from_sql(&query) | ||
} | ||
|
||
fn get_data_from_sql<T: rusqlite::types::FromSql + Default>( | ||
&self, | ||
query: &String, | ||
) -> Vec<T> { | ||
let connection: Connection = get_sql_connection(&self.path); | ||
let mut stmt: Statement = connection.prepare(&query).unwrap(); | ||
let rows = stmt | ||
.query_map( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ pub struct PasefFrameMsMsTable { | |
pub mz_width: Vec<f64>, | ||
pub collision_energy: Vec<f64>, | ||
pub precursor: Vec<usize>, | ||
pub collision_energy_by_precursor: Vec<f64>, | ||
} | ||
|
||
impl ReadableFromSql for PasefFrameMsMsTable { | ||
|
@@ -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()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make this plural There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably yhe place to do |
||
let precursors: Vec<Precursor> = (0..precursor_table.mz.len()) | ||
.into_par_iter() | ||
.map(|index| { | ||
|
@@ -42,6 +43,7 @@ impl PrecursorReader { | |
intensity: precursor_table.intensity[index], | ||
index: index + 1, //TODO? | ||
frame_index: frame_id, | ||
collision_energy: collision_energy[index], | ||
} | ||
}) | ||
.collect(); | ||
|
There was a problem hiding this comment.
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 runcargo fmt
automatically on saving)