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

Fix upper bound #17

Merged
merged 4 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rustdoc-args = [ "--html-in-header", "./src/docs-header.html" ]
[dependencies]
quick-xml = { version = "0.23.0-alpha3", features = ["serialize"] }
serde = { version = "1.0", features = [ "derive" ] }
pyo3 = { version = "0.14.1", optional = true }
pyo3 = { version = "0.22.3", optional = true }
itertools = "0.10"

[features]
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "rust_sbml"
version = "0.6.1"
description = "Python Bindings to rust_sbml"
readme = "README.md"
requires-python = ">=3.6"
requires-python = ">=3.7"
keywords = ["parser", "sbml", "science", "bioinformatics"]
authors = [
{email = "[email protected]"},
Expand All @@ -17,7 +17,6 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand Down
2 changes: 1 addition & 1 deletion src/annotation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use itertools::Itertools;
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, convert::From};

#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
#[derive(Debug, Deserialize, Serialize, PartialEq, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Annotation {
#[serde(rename = "$unflatten=rdf:RDF")]
Expand Down
6 changes: 4 additions & 2 deletions src/base_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ pub struct KineticLaw {
/// use rust_sbml::Reaction;
///
/// let reactions: Reaction = from_str(
/// "<reaction id='J1' reversible='false' fbc:lowerFluxBound='-20'>
/// "<reaction id='J1' reversible='false' fbc:lowerFluxBound='this_lower_bound' fbc:upperFluxBound='this_upper_bound'>
/// <listOfReactants>
/// <speciesReference species='X0' stoichiometry='2' constant='true'/>
/// </listOfReactants>
Expand All @@ -258,6 +258,8 @@ pub struct KineticLaw {
/// .species_references
/// .iter()
/// .any(|specref| specref.species == "X0"));
/// assert_eq!(reactions.lower_bound, Some(String::from("this_lower_bound")));
/// assert_eq!(reactions.upper_bound, Some(String::from("this_upper_bound")));
/// ```
#[cfg_attr(feature = "default", pyclass)]
#[derive(Debug, Deserialize, Serialize, PartialEq, Clone, Default)]
Expand All @@ -275,7 +277,7 @@ pub struct Reaction {
pub kinetic_law: Option<KineticLaw>,
#[serde(rename = "fbc:lowerFluxBound")]
pub lower_bound: Option<String>,
#[serde(rename = "fbc:lowerUpperBound")]
#[serde(rename = "fbc:upperFluxBound")]
pub upper_bound: Option<String>,
pub annotation: Option<Annotation>,
}
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ pub use base_types::{
pub use unit::{Unit, UnitSId, UnitSIdRef};

pub use model::{parse_document, Model, ModelRaw, ModelUnits};
#[cfg(feature = "default")]
pub use pyo::*;

#[cfg(test)]
mod tests {
Expand Down
8 changes: 4 additions & 4 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl Model {
/// println!("{:?}", document.get_list_of_compartments())
/// ```
pub fn get_list_of_compartments(&self) -> Vec<&Compartment> {
self.compartments.iter().map(|(_key, val)| val).collect()
self.compartments.values().collect()
}
/// Emulating the API of libSBML
///
Expand All @@ -175,7 +175,7 @@ impl Model {
/// println!("{:?}", document.get_list_of_species())
/// ```
pub fn get_list_of_species(&self) -> Vec<&Species> {
self.species.iter().map(|(_key, val)| val).collect()
self.species.values().collect()
}
/// Emulating the API of libSBML
///
Expand All @@ -190,7 +190,7 @@ impl Model {
/// println!("{:?}", document.get_list_of_reactions())
/// ```
pub fn get_list_of_reactions(&self) -> Vec<&Reaction> {
self.reactions.iter().map(|(_key, val)| val).collect()
self.reactions.values().collect()
}
/// Use [`ModelRaw`] to parse the SBML document
/// and then format it into `Model`.
Expand Down Expand Up @@ -259,7 +259,7 @@ impl Model {
objs.objectives
.iter()
.flat_map(|n| {
(*n).list_of_flux_objectives
n.list_of_flux_objectives
.flux_objectives
.iter()
.map(|fr| fr.reaction.to_owned().unwrap())
Expand Down
11 changes: 4 additions & 7 deletions src/pyo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,13 @@ impl Model {
}
}
fn getListOfCompartments(&self) -> Vec<Compartment> {
self.compartments
.iter()
.map(|(_, n)| n.to_owned())
.collect()
self.compartments.values().cloned().collect()
}
fn getListOfSpecies(&self) -> Vec<Species> {
self.species.iter().map(|(_, n)| n.to_owned()).collect()
self.species.values().cloned().collect()
}
fn getListOfReactions(&self) -> Vec<Reaction> {
self.reactions.iter().map(|(_, n)| n.to_owned()).collect()
self.reactions.values().cloned().collect()
}
fn getParameter(&self, query: String) -> Option<Parameter> {
self.parameters.get(&query).cloned()
Expand All @@ -126,7 +123,7 @@ impl Model {
}

#[pymodule]
fn rust_sbml(_py: Python, m: &PyModule) -> PyResult<()> {
fn rust_sbml(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<Model>()?;
m.add_class::<Reaction>()?;
m.add_class::<Species>()?;
Expand Down
Loading