fn try_extend_kmer(&self, kmer: K, dir: Dir) -> ExtMode<K> {
        // metadata of start kmer
        let (exts, ref kmer_data) = self.get_kmer_data(&kmer);

        if exts.num_ext_dir(dir) != 1 || (!self.stranded && kmer.is_palindrome()) {
            ExtMode::Terminal(exts.single_dir(dir))
        } else {
            // Get the next kmer
            let ext_base = exts.get_unique_extension(dir).expect("should be unique");

            let mut next_kmer = kmer.extend(ext_base, dir);

            let mut do_flip = false;

            if !self.stranded {
                let flip_rc = next_kmer.min_rc_flip();
                do_flip = flip_rc.1;
                next_kmer = flip_rc.0;
            }

            let next_dir = dir.cond_flip(do_flip);
            let is_palindrome = !self.stranded && next_kmer.is_palindrome();

            // We can include this kmer in the line if:
            // a) it exists in the partition and is still unused
            // b) the kmer we go to has a unique extension back in our direction

            // Check condition a)
            match self.get_kmer_id(&next_kmer) {
                Some(id) if self.available_kmers.contains(id) => (),

                // This kmer isn't in this partition, or we've already used it
                _ => return ExtMode::Terminal(exts.single_dir(dir)),
            }

            // Check condition b)
            // Direction we're approaching the new kmer from
            let new_incoming_dir = dir.flip().cond_flip(do_flip);
            let next_kmer_r = self.get_kmer_data(&next_kmer);
            let (next_kmer_exts, ref next_kmer_data) = next_kmer_r;
            let incoming_count = next_kmer_exts.num_ext_dir(new_incoming_dir);
            let outgoing_exts = next_kmer_exts.single_dir(new_incoming_dir.flip());

            // Test if the spec let's us combine these into the same path
            let can_join = self.spec.join_test(kmer_data, next_kmer_data);

            if incoming_count == 0 && !is_palindrome {
                println!("{:?}, {:?}, {:?}", kmer, exts, kmer_data);
                println!(
                    "{:?}, {:?}, {:?}",
                    next_kmer, next_kmer_exts, next_kmer_data
                );
                panic!("unreachable");
            } else if can_join && incoming_count == 1 && !is_palindrome {
                // We have a unique path to next_kmer -- include it
                ExtMode::Unique(next_kmer, next_dir, outgoing_exts)
            } else {
                // there's more than one path
                // into the target kmer - don't include it
                ExtMode::Terminal(exts.single_dir(dir))
            }
        }
    }
/// Attempt to extend kmer v in direction dir. Return:
///  - Unique(nextKmer, nextDir) if a single unique extension
///    is possible.  nextDir indicates the direction to extend nextMker
///    to preserve the direction of the extension.
/// - Term(ext) no unique extension possible, indicating the extensions at this end of the line
Attempt to extend kmer v in direction dir. Return:
Unique(nextKmer, nextDir) if a single unique extension
is possible.  nextDir indicates the direction to extend nextMker
to preserve the direction of the extension.
Term(ext) no unique extension possible, indicating the extensions at this end of the line
Attempt to extend kmer v in direction dir . Return : Unique ( nextKmer nextDir ) if a single unique extension is possible . nextDir indicates the direction to extend nextMker to preserve the direction of the extension . Term ( ext ) no unique extension possible indicating the extensions at this end of the line
fn try_extend_kmer(&self, kmer: K, dir: Dir) -> ExtMode<K> {
        // metadata of start kmer
        let (exts, ref kmer_data) = self.get_kmer_data(&kmer);
        if exts.num_ext_dir(dir) != 1 || (!self.stranded && kmer.is_palindrome()) {
            ExtMode::Terminal(exts.single_dir(dir))
        } else {
            // Get the next kmer
            let ext_base = exts.get_unique_extension(dir).expect("should be unique");
            let mut next_kmer = kmer.extend(ext_base, dir);
            let mut do_flip = false;
            if !self.stranded {
                let flip_rc = next_kmer.min_rc_flip();
                do_flip = flip_rc.1;
                next_kmer = flip_rc.0;
            }
            let next_dir = dir.cond_flip(do_flip);
            let is_palindrome = !self.stranded && next_kmer.is_palindrome();
            // We can include this kmer in the line if:
            // a) it exists in the partition and is still unused
            // b) the kmer we go to has a unique extension back in our direction
            // Check condition a)
            match self.get_kmer_id(&next_kmer) {
                Some(id) if self.available_kmers.contains(id) => (),
                // This kmer isn't in this partition, or we've already used it
                _ => return ExtMode::Terminal(exts.single_dir(dir)),
            }
            // Check condition b)
            // Direction we're approaching the new kmer from
            let new_incoming_dir = dir.flip().cond_flip(do_flip);
            let next_kmer_r = self.get_kmer_data(&next_kmer);
            let (next_kmer_exts, ref next_kmer_data) = next_kmer_r;
            let incoming_count = next_kmer_exts.num_ext_dir(new_incoming_dir);
            let outgoing_exts = next_kmer_exts.single_dir(new_incoming_dir.flip());
            // Test if the spec let's us combine these into the same path
            let can_join = self.spec.join_test(kmer_data, next_kmer_data);
            if incoming_count == 0 && !is_palindrome {
                println!("{:?}, {:?}, {:?}", kmer, exts, kmer_data);
                println!(
                    "{:?}, {:?}, {:?}",
                    next_kmer, next_kmer_exts, next_kmer_data
                );
                panic!("unreachable");
            } else if can_join && incoming_count == 1 && !is_palindrome {
                // We have a unique path to next_kmer -- include it
                ExtMode::Unique(next_kmer, next_dir, outgoing_exts)
            } else {
                // there's more than one path
                // into the target kmer - don't include it
                ExtMode::Terminal(exts.single_dir(dir))
            }
        }
    }
fn try_extend_kmer ( & self , kmer : K , dir : Dir ) -> ExtMode < K > { // metadata of start kmer let ( exts , ref kmer_data ) = self . get_kmer_data ( & kmer ) ; if exts . num_ext_dir ( dir ) != 1 || ( ! self . stranded && kmer . is_palindrome ( ) ) { ExtMode :: Terminal ( exts . single_dir ( dir ) ) } else { // Get the next kmer let ext_base = exts . get_unique_extension ( dir ) . expect ( " " ) ; let mut next_kmer = kmer . extend ( ext_base , dir ) ; let mut do_flip = false ; if ! self . stranded { let flip_rc = next_kmer . min_rc_flip ( ) ; do_flip = flip_rc . 1 ; next_kmer = flip_rc . 0 ; } let next_dir = dir . cond_flip ( do_flip ) ; let is_palindrome = ! self . stranded && next_kmer . is_palindrome ( ) ; // We can include this kmer in the line if: // a) it exists in the partition and is still unused // b) the kmer we go to has a unique extension back in our direction // Check condition a) match self . get_kmer_id ( & next_kmer ) { Some ( id ) if self . available_kmers . contains ( id ) => ( ) , // This kmer isn't in this partition, or we've already used it _ => return ExtMode :: Terminal ( exts . single_dir ( dir ) ) , } // Check condition b) // Direction we're approaching the new kmer from let new_incoming_dir = dir . flip ( ) . cond_flip ( do_flip ) ; let next_kmer_r = self . get_kmer_data ( & next_kmer ) ; let ( next_kmer_exts , ref next_kmer_data ) = next_kmer_r ; let incoming_count = next_kmer_exts . num_ext_dir ( new_incoming_dir ) ; let outgoing_exts = next_kmer_exts . single_dir ( new_incoming_dir . flip ( ) ) ; // Test if the spec let's us combine these into the same path let can_join = self . spec . join_test ( kmer_data , next_kmer_data ) ; if incoming_count == 0 && ! is_palindrome { println ! ( " " kmer exts kmer_data ) ; println ! ( " " next_kmer next_kmer_exts next_kmer_data ) ; panic ! ( " " ) ; } else if can_join && incoming_count == 1 && ! is_palindrome { // We have a unique path to next_kmer -- include it ExtMode :: Unique ( next_kmer , next_dir , outgoing_exts ) } else { // there's more than one path // into the target kmer - don't include it ExtMode :: Terminal ( exts . single_dir ( dir ) ) } } }
Attempt to extend kmer v in direction dir.
Attempt to extend kmer v in direction dir .
&self
kmer
K
dir
Dir
&self
kmer
K
dir
Dir