From 57ba460929e54ee37b0faa3c55c527ec288aa0f2 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Tue, 20 Sep 2022 22:03:44 +0200 Subject: [PATCH] add the obi_mutation attribute to the sequences --- pkg/obitools/obiclean/obiclean.go | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/pkg/obitools/obiclean/obiclean.go b/pkg/obitools/obiclean/obiclean.go index 50afa8d..63bcc67 100644 --- a/pkg/obitools/obiclean/obiclean.go +++ b/pkg/obitools/obiclean/obiclean.go @@ -160,6 +160,41 @@ func SingletonCount(sequence *obiseq.BioSequence) int { return value } +func GetMutation(sequence *obiseq.BioSequence) map[string]string { + annotation := sequence.Annotations() + imutation, ok := annotation["obiclean_mutation"] + var mutation map[string]string + + if ok { + switch imutation := imutation.(type) { + case map[string]string: + mutation = imutation + case map[string]interface{}: + mutation = make(map[string]string) + for k, v := range imutation { + mutation[k] = fmt.Sprint(v) + } + } + } else { + mutation = make(map[string]string) + annotation["obiclean_mutation"] = mutation + } + + return mutation +} + +func Mutation(sample map[string]*([]*seqPCR)) { + for _, graph := range sample { + for _, s := range *graph { + for _, f := range s.Edges { + id := (*graph)[f.Father].Sequence.Id() + GetMutation(s.Sequence)[id] = fmt.Sprintf("(%c)->(%c)@%d", + f.From, f.To, f.Pos + 1) + } + } + } +} + func Status(sequence *obiseq.BioSequence) map[string]string { annotation := sequence.Annotations() iobistatus, ok := annotation["obiclean_status"] @@ -251,6 +286,8 @@ func IOBIClean(itertator obiiter.IBioSequenceBatch) obiiter.IBioSequenceBatch { SaveGMLGraphs(GraphFilesDirectory(), samples, MinCountToEvalMutationRate()) } + Mutation(samples) + pbopt := make([]progressbar.Option, 0, 5) pbopt = append(pbopt, progressbar.OptionSetWriter(os.Stderr),