def group_chain_go

bend-prot@0.1.0.0 · pdb.bend:409

import bend-prot@0.1.0.0/pdb.bend as Pdb
import Base
import bend-prot@0.1.0.0/protein.bend as P

409# Pass 2: consecutive equal chains merge into Chain.
410def group_chain_go(items: List<&1, U32 & P.Residue>, +cur_c: U32, +cur_rs: List<&2, P.Residue>, +acc: List<&2, P.Chain>) -> List<&2, P.Chain>:
411  match items:
412    case Nil{}:
413      List.reverse(&2, P.Chain, P.Chain{cur_c, List.reverse(&2, P.Residue, cur_rs)} <> acc)
414    case (c, r) <> t:
415      +c2 = c
416      +same = U32.is_eq(c2, cur_c)
417      group_chain_go(t, Bool.pick(U32, same, cur_c, c2), r <> Bool.pick(List<&2, P.Residue>, same, cur_rs, Nil{}), Bool.pick(List<&2, P.Chain>, same, acc, P.Chain{cur_c, List.reverse(&2, P.Residue, cur_rs)} <> acc))

Uses (9)

Used by (1)