Skip to content

Commit

Permalink
Added more conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
douweschulte committed Nov 16, 2023
1 parent 2a4b40f commit 6939abf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/complex_peptide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,24 @@ impl ComplexPeptide {
}
}

impl<Item> From<Item> for ComplexPeptide
where
Item: Into<LinearPeptide>,
{
fn from(value: Item) -> Self {
Self::Singular(value.into())
}
}

impl<Item> FromIterator<Item> for ComplexPeptide
where
Item: Into<SequenceElement>,
{
fn from_iter<T: IntoIterator<Item = Item>>(iter: T) -> Self {
Self::Singular(LinearPeptide::from(iter))
}
}

/// A list of found modifications, with the newly generated ambiguous lookup alongside the index into the chars index from where parsing can be continued
type UnknownPositionMods = (usize, Vec<ReturnModification>, AmbiguousLookup);
/// If the text is recognised as a unknown mods list it is Some(..), if it has errors during parsing Some(Err(..))
Expand Down
9 changes: 9 additions & 0 deletions src/linear_peptide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,15 @@ where
}
}

impl<Item> FromIterator<Item> for LinearPeptide
where
Item: Into<SequenceElement>,
{
fn from_iter<T: IntoIterator<Item = Item>>(iter: T) -> Self {
Self::from(iter)
}
}

/// One block in a sequence meaning an aminoacid and its accompanying modifications
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SequenceElement {
Expand Down

0 comments on commit 6939abf

Please sign in to comment.