pub fn trim_sequence<'a>(
        seq: &'a [u8],
        start: usize,
        end: usize,
        frame: &str,
        spliced: bool,
    ) -> &'a [u8] {
        // start and end non inclusive
        let mut trimmed: &'a [u8] = seq.get(start - 1..end).unwrap_or(b"");

        // is this right? keeping CDS separate means we want to be in phase & frame
        // otherwise ignore this in spliced CDS

        match spliced {
            false => {
                if frame == "1" {
                    trimmed = trimmed.get(1..).unwrap_or(b"");
                } else if frame == "2" {
                    trimmed = trimmed.get(2..).unwrap_or(b"");
                } else {
                    trimmed = trimmed;
                }

                if trimmed.len() % 3 == 0 {
                    return trimmed;
                } else if trimmed.len() % 3 == 1 {
                    return trimmed.get(..trimmed.len() - 1).unwrap_or(b"");
                } else if trimmed.len() % 3 == 2 {
                    return trimmed.get(..trimmed.len() - 2).unwrap_or(b"");
                } else {
                    return trimmed;
                }
            }
            true => trimmed,
        }
    }
// from the fasta sequence iteration, get the subsequence
// and trim the sequence depending on the frame.
// if the sequence is not modulo 3, force it to be so.
from the fasta sequence iteration, get the subsequence
and trim the sequence depending on the frame.
if the sequence is not modulo 3, force it to be so.
from the fasta sequence iteration get the subsequence and trim the sequence depending on the frame . if the sequence is not modulo 3 force it to be so .
pub fn trim_sequence<'a>(
        seq: &'a [u8],
        start: usize,
        end: usize,
        frame: &str,
        spliced: bool,
    ) -> &'a [u8] {
        // start and end non inclusive
        let mut trimmed: &'a [u8] = seq.get(start - 1..end).unwrap_or(b"");
        // is this right? keeping CDS separate means we want to be in phase & frame
        // otherwise ignore this in spliced CDS
        match spliced {
            false => {
                if frame == "1" {
                    trimmed = trimmed.get(1..).unwrap_or(b"");
                } else if frame == "2" {
                    trimmed = trimmed.get(2..).unwrap_or(b"");
                } else {
                    trimmed = trimmed;
                }
                if trimmed.len() % 3 == 0 {
                    return trimmed;
                } else if trimmed.len() % 3 == 1 {
                    return trimmed.get(..trimmed.len() - 1).unwrap_or(b"");
                } else if trimmed.len() % 3 == 2 {
                    return trimmed.get(..trimmed.len() - 2).unwrap_or(b"");
                } else {
                    return trimmed;
                }
            }
            true => trimmed,
        }
    }
pub fn trim_sequence < ' a > ( seq : & ' a [ u8 ] , start : usize , end : usize , frame : & str , spliced : bool , ) -> & ' a [ u8 ] { // start and end non inclusive let mut trimmed : & ' a [ u8 ] = seq . get ( start - 1 .. end ) . unwrap_or ( b" " ) ; // is this right? keeping CDS separate means we want to be in phase & frame // otherwise ignore this in spliced CDS match spliced { false => { if frame == " " { trimmed = trimmed . get ( 1 .. ) . unwrap_or ( b" " ) ; } else if frame == " " { trimmed = trimmed . get ( 2 .. ) . unwrap_or ( b" " ) ; } else { trimmed = trimmed ; } if trimmed . len ( ) % 3 == 0 { return trimmed ; } else if trimmed . len ( ) % 3 == 1 { return trimmed . get ( .. trimmed . len ( ) - 1 ) . unwrap_or ( b" " ) ; } else if trimmed . len ( ) % 3 == 2 { return trimmed . get ( .. trimmed . len ( ) - 2 ) . unwrap_or ( b" " ) ; } else { return trimmed ; } } true => trimmed , } }
from the fasta sequence iteration, get the subsequence
and trim the sequence depending on the frame.
from the fasta sequence iteration get the subsequence and trim the sequence depending on the frame .
seq
&'a [u8]
start
usize
end
usize
frame
&str
spliced
bool
seq
&'a [u8]
start
usize
end
usize
frame
&str
spliced
bool