style: apply rustfmt across all crates and demos
Consistent formatting pass: line wrapping, import sorting, trailing whitespace removal, let-chain indentation, merged derive attributes, and unsafe block reformatting. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This commit is contained in:
@@ -42,13 +42,11 @@ pub fn get_protein_by_id(protein_id: &str) -> Result<ProteinTarget, DrugBinderEr
|
||||
targets
|
||||
.into_iter()
|
||||
.find(|t| t.id == protein_id)
|
||||
.ok_or_else(|| {
|
||||
DrugBinderError::InvalidProtein(format!("Unknown protein ID: {protein_id}"))
|
||||
})
|
||||
.ok_or_else(|| DrugBinderError::InvalidProtein(format!("Unknown protein ID: {protein_id}")))
|
||||
}
|
||||
|
||||
/// Convert sequence to protein.
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn sequence_to_protein(sequence: &str, name: Option<String>) -> ProteinTarget {
|
||||
ProteinTarget {
|
||||
id: format!("seq_{}", hash_sequence(sequence)),
|
||||
@@ -181,13 +179,12 @@ fn parse_smiles(smiles: &str) -> Result<(Vec<Atom>, Vec<Bond>), DrugBinderError>
|
||||
|
||||
// Add bond to previous atom
|
||||
if let Some(prev_idx) = prev_atom {
|
||||
let bond_type = if is_aromatic_atom
|
||||
&& atoms.get(prev_idx).is_some_and(|a| a.is_aromatic)
|
||||
{
|
||||
BondType::Aromatic
|
||||
} else {
|
||||
pending_bond_type
|
||||
};
|
||||
let bond_type =
|
||||
if is_aromatic_atom && atoms.get(prev_idx).is_some_and(|a| a.is_aromatic) {
|
||||
BondType::Aromatic
|
||||
} else {
|
||||
pending_bond_type
|
||||
};
|
||||
|
||||
bonds.push(Bond {
|
||||
atom1: prev_idx,
|
||||
@@ -430,15 +427,15 @@ fn element_mass(element: &Element) -> f32 {
|
||||
}
|
||||
|
||||
fn hash_smiles(smiles: &str) -> u32 {
|
||||
smiles
|
||||
.bytes()
|
||||
.fold(0u32, |acc, b| acc.wrapping_mul(31).wrapping_add(u32::from(b)))
|
||||
smiles.bytes().fold(0u32, |acc, b| {
|
||||
acc.wrapping_mul(31).wrapping_add(u32::from(b))
|
||||
})
|
||||
}
|
||||
|
||||
fn hash_sequence(sequence: &str) -> u32 {
|
||||
sequence
|
||||
.bytes()
|
||||
.fold(0u32, |acc, b| acc.wrapping_mul(37).wrapping_add(u32::from(b)))
|
||||
sequence.bytes().fold(0u32, |acc, b| {
|
||||
acc.wrapping_mul(37).wrapping_add(u32::from(b))
|
||||
})
|
||||
}
|
||||
|
||||
/// Get protein database.
|
||||
|
||||
Reference in New Issue
Block a user