Exemple #1
0
func joinOne(m, am seq.Sequence, where int) error {
	switch m.(type) {
	case *linear.Seq:
		_, ok := am.(*linear.Seq)
		if !ok {
			goto MISMATCH
		}
		return sequtils.Join(m, am, where)
	case *linear.QSeq:
		_, ok := am.(*linear.QSeq)
		if !ok {
			goto MISMATCH
		}
		return sequtils.Join(m, am, where)
	default:
		joinerRegistryLock.RLock()
		defer joinerRegistryLock.RUnlock()
		joinerFunc, ok := joinerRegistry[reflect.TypeOf(m)]
		if !ok {
			return fmt.Errorf("multi: sequence type %T not handled.", m)
		}
		if reflect.TypeOf(m) != reflect.TypeOf(am) {
			goto MISMATCH
		}
		return joinerFunc(m, am, where)
	}

MISMATCH:
	return fmt.Errorf("multi: sequence type mismatch: %T != %T.", m, am)
}
Exemple #2
0
func ExampleSeq_Join() {
	var s1, s2 *Seq

	s1 = NewSeq("a", []alphabet.Letter("agctgtgctga"), alphabet.DNA)
	s2 = NewSeq("b", []alphabet.Letter("CGTGCAGTCATGAGTGA"), alphabet.DNA)
	fmt.Printf("%-s %-s\n", s1, s2)
	if err := sequtils.Join(s1, s2, seq.Start); err == nil {
		fmt.Printf("%-s\n", s1)
	}

	s1 = NewSeq("a", []alphabet.Letter("agctgtgctga"), alphabet.DNA)
	s2 = NewSeq("b", []alphabet.Letter("CGTGCAGTCATGAGTGA"), alphabet.DNA)
	if err := sequtils.Join(s1, s2, seq.End); err == nil {
		fmt.Printf("%-s\n", s1)
	}
	// Output:
	// agctgtgctga CGTGCAGTCATGAGTGA
	// CGTGCAGTCATGAGTGAagctgtgctga
	// agctgtgctgaCGTGCAGTCATGAGTGA
}
func ExampleSeq_Join() {
	fmt.Printf("%-s\n\n%-s\n", n, n.Consensus(false))
	err := sequtils.Join(n, m, seq.End)
	if err == nil {
		fmt.Printf("\n%-s\n\n%-s\n", n, n.Consensus(false))
	}
	// Output:
	// ACGCTGACTTGGTGCACGT
	// ACGGTGACCTGGCGCGCAT
	// ACGtTGACGTGGCGCTCAT
	// acgCtg-------------
	//
	// acgctgacntggcgcncat
	//
	// ACGCTGACTTGGTGCACGTACGCTGACTTGGTGCACGT
	// ACGGTGACCTGGCGCGCATACGGTGACCTGGCGCGCAT
	// ACGtTGACGTGGCGCTCATACGATGACGTGGCGCTCAT
	// acgCtg-------------acgCtg-------------
	//
	// acgctgacntggcgcncatacgctgacntggcgcncat
}