-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added some functions to periodic table, fixed problem with getValence…
…List.
- Loading branch information
Showing
7 changed files
with
130 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,42 @@ | ||
use cxx::{CxxVector, UniquePtr}; | ||
use ffi::PeriodicTable; | ||
|
||
#[cxx::bridge(namespace = "RDKit")] | ||
pub mod ffi { | ||
unsafe extern "C++" { | ||
type PeriodicTable; | ||
include!("wrapper/include/periodic_table.h"); | ||
pub fn get_periodic_table() -> UniquePtr<PeriodicTable>; | ||
pub fn get_valence_list(atomic_number: u32) -> &'static CxxVector<i32>; | ||
pub fn getAtomicWeight(self: &PeriodicTable, atomic_number: u32) -> f64; | ||
pub fn getAtomicNumber(self: &PeriodicTable, atom: &CxxString) -> i32; | ||
pub fn getElementSymbol(atomic_number: u32) -> String; | ||
pub fn getElementName(atomic_number: u32) -> String; | ||
pub fn getRvdw(self: &PeriodicTable, atomic_number: u32) -> f64; | ||
pub fn getRcovalent(self: &PeriodicTable, atomic_number: u32) -> f64; | ||
pub fn getRb0(self: &PeriodicTable, atomic_number: u32) -> f64; | ||
pub fn getDefaultValence(self: &PeriodicTable, atomic_number: u32) -> i32; | ||
fn getValenceList(atomic_number: u32) -> &'static CxxVector<i32>; | ||
pub fn getNouterElecs(self: &PeriodicTable, atomic_number: u32) -> i32; | ||
pub fn getMostCommonIsotope(self: &PeriodicTable, atomic_number: u32) -> i32; | ||
pub fn getMostCommonIsotopeMass(self: &PeriodicTable, atom: &CxxString) -> f64; | ||
} | ||
} | ||
|
||
pub trait PeriodicTableOps { | ||
fn getElementSymbol(self, atomic_number: u32) -> String; | ||
fn getElementName(self, atomic_number: u32) -> String; | ||
fn getValenceList(self, atomic_number: u32) -> &'static CxxVector<i32>; | ||
} | ||
impl<'a> PeriodicTableOps for UniquePtr<PeriodicTable> { | ||
fn getElementSymbol(self, atomic_number: u32) -> String { | ||
ffi::getElementSymbol(atomic_number) | ||
} | ||
|
||
fn getElementName(self, atomic_number: u32) -> String { | ||
ffi::getElementName(atomic_number) | ||
} | ||
|
||
fn getValenceList(self, atomic_number: u32) -> &'static CxxVector<i32> { | ||
ffi::getValenceList(atomic_number) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
use cxx::{let_cxx_string, CxxVector}; | ||
use rdkit_sys::PeriodicTableOps; | ||
|
||
pub struct PeriodicTable {} | ||
|
||
impl PeriodicTable { | ||
pub fn get_valence_list(atomic_number: u32) -> &'static CxxVector<i32> { | ||
rdkit_sys::periodic_table_ffi::get_valence_list(atomic_number) | ||
rdkit_sys::periodic_table_ffi::get_periodic_table().getValenceList(atomic_number) | ||
} | ||
|
||
pub fn get_most_common_isotope_mass(atom: &str) -> f64 { | ||
let_cxx_string!(atom_cxx_string = atom); | ||
rdkit_sys::periodic_table_ffi::get_most_common_isotope_mass(&atom_cxx_string) | ||
rdkit_sys::periodic_table_ffi::get_periodic_table() | ||
.getMostCommonIsotopeMass(&atom_cxx_string) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters