本文整理汇总了Golang中github.com/biogo/biogo/seq/linear.NewSeq函数的典型用法代码示例。如果您正苦于以下问题:Golang NewSeq函数的具体用法?Golang NewSeq怎么用?Golang NewSeq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewSeq函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
var err error
m, err = NewMulti("example multi",
[]seq.Sequence{
linear.NewSeq("example DNA 1", []alphabet.Letter("ACGCTGACTTGGTGCACGT"), alphabet.DNA),
linear.NewSeq("example DNA 2", []alphabet.Letter("ACGGTGACCTGGCGCGCAT"), alphabet.DNA),
linear.NewSeq("example DNA 3", []alphabet.Letter("ACGATGACGTGGCGCTCAT"), alphabet.DNA),
},
seq.DefaultConsensus)
if err != nil {
panic(err)
}
}
开发者ID:gordon,项目名称:biogo,代码行数:14,代码来源:multi_example_test.go
示例2: TestReadFasta
func (s *S) TestReadFasta(c *check.C) {
var (
obtainN []string
obtainS [][]alphabet.Letter
)
for _, fa := range fas {
r := NewReader(bytes.NewBufferString(fa), linear.NewSeq("", nil, alphabet.Protein))
for {
if s, err := r.Read(); err != nil {
if err == io.EOF {
break
} else {
c.Fatalf("Failed to read %q: %s", fa, err)
}
} else {
t := s.(*linear.Seq)
header := t.Name()
if desc := t.Description(); len(desc) > 0 {
header += " " + desc
}
obtainN = append(obtainN, header)
obtainS = append(obtainS, t.Slice().(alphabet.Letters))
}
}
c.Check(obtainN, check.DeepEquals, expectN)
obtainN = nil
for i := range obtainS {
c.Check(len(obtainS[i]), check.Equals, len(expectS[i]))
c.Check(obtainS[i], check.DeepEquals, expectS[i])
}
obtainS = nil
}
}
开发者ID:gordon,项目名称:biogo,代码行数:34,代码来源:fasta_test.go
示例3: TestReadFromFunc
func (s *S) TestReadFromFunc(c *check.C) {
var (
obtainNfa []string
obtainSfa [][]alphabet.Letter
)
sc := seqio.NewScannerFromFunc(
fasta.NewReader(
bytes.NewBufferString(testaln0),
linear.NewSeq("", nil, alphabet.Protein),
).Read,
)
for sc.Next() {
t := sc.Seq().(*linear.Seq)
header := t.Name()
if desc := t.Description(); len(desc) > 0 {
header += " " + desc
}
obtainNfa = append(obtainNfa, header)
obtainSfa = append(obtainSfa, t.Slice().(alphabet.Letters))
}
c.Check(sc.Error(), check.Equals, nil)
c.Check(obtainNfa, check.DeepEquals, expectNfa)
for i := range obtainSfa {
c.Check(len(obtainSfa[i]), check.Equals, len(expectSfa[i]))
c.Check(obtainSfa[i], check.DeepEquals, expectSfa[i])
}
}
开发者ID:gordon,项目名称:biogo,代码行数:28,代码来源:seqio_test.go
示例4: TestReadFasta
func (s *S) TestReadFasta(c *check.C) {
r := fasta.NewReader(strings.NewReader(fa), linear.NewSeq("", nil, alphabet.Protein))
m, _ := multi.NewMulti("", nil, seq.DefaultConsensus)
a, err := NewReader(r, m).Read()
c.Check(err, check.Equals, nil)
c.Check(a.Rows(), check.Equals, 11)
}
开发者ID:gordon,项目名称:biogo,代码行数:7,代码来源:alignio_test.go
示例5: main
func main() {
flag.Parse()
if *exclude == "" {
flag.Usage()
os.Exit(1)
}
nameSet := make(map[string]struct{})
f, err := os.Open(*exclude)
if err != nil {
log.Fatalf("failed to open exclude file %q: %v", *exclude, err)
}
ls := bufio.NewScanner(f)
for ls.Scan() {
nameSet[ls.Text()] = struct{}{}
}
err = ls.Err()
if err != nil {
log.Fatalf("failed to read exclude file: %v", err)
}
sc := seqio.NewScanner(fasta.NewReader(os.Stdin, linear.NewSeq("", nil, alphabet.DNA)))
for sc.Next() {
s := sc.Seq().(*linear.Seq)
if _, ok := nameSet[s.ID]; ok {
continue
}
fmt.Printf("%60a\n", s)
}
if err := sc.Error(); err != nil {
log.Fatalf("error during gff read: %v", err)
}
}
开发者ID:kortschak,项目名称:loopy,代码行数:33,代码来源:keelhaul.go
示例6: ExampleSet_AppendEach
func ExampleSet_AppendEach() {
ss := [][]alphabet.Letter{
[]alphabet.Letter("ACGCTGACTTGGTGCACGT"),
[]alphabet.Letter("ACGACTGGGACGT"),
[]alphabet.Letter("ACGCTGACTGGCCGT"),
[]alphabet.Letter("GCCTTTGCACGT"),
}
set = make(Set, 4)
for i := range set {
set[i] = linear.NewSeq(fmt.Sprintf("example DNA %d", i), ss[i], alphabet.DNA)
}
as := [][]alphabet.QLetter{
alphabet.QLetter{L: 'A'}.Repeat(2),
alphabet.QLetter{L: 'C'}.Repeat(2),
alphabet.QLetter{L: 'G'}.Repeat(2),
alphabet.QLetter{L: 'T'}.Repeat(2),
}
set.AppendEach(as)
for _, s := range set {
fmt.Printf("%-s\n", s)
}
// Output:
// ACGCTGACTTGGTGCACGTAA
// ACGACTGGGACGTCC
// ACGCTGACTGGCCGTGG
// GCCTTTGCACGTTT
}
开发者ID:gordon,项目名称:biogo,代码行数:29,代码来源:set_example_test.go
示例7: main
func main() {
flag.Parse()
if *in == "" {
flag.Usage()
os.Exit(1)
}
f, err := os.Open(*in)
if err != nil {
log.Fatalf("failed to open %q: %v", *in, err)
}
events := make(map[string][]*gff.Feature)
fsc := featio.NewScanner(gff.NewReader(f))
for fsc.Next() {
f := fsc.Feat().(*gff.Feature)
fields := strings.Fields(f.FeatAttributes.Get("Read"))
if len(fields) != 3 {
log.Fatalf("bad record: %+v", f)
}
events[fields[0]] = append(events[fields[0]], f)
}
if err := fsc.Error(); err != nil {
log.Fatalf("error during gff read: %v", err)
}
f.Close()
for _, ref := range flag.Args() {
f, err = os.Open(ref)
if err != nil {
log.Fatalf("failed to open reference %q: %v", ref, err)
}
ssc := seqio.NewScanner(fasta.NewReader(f, linear.NewSeq("", nil, alphabet.DNA)))
for ssc.Next() {
seq := ssc.Seq().(*linear.Seq)
for _, f := range events[seq.Name()] {
fields := strings.Fields(f.FeatAttributes.Get("Read"))
if len(fields) != 3 {
log.Fatalf("bad record: %+v", f)
}
start, err := strconv.Atoi(fields[1])
if err != nil {
log.Fatalf("failed to get start coordinate: %v", err)
}
end, err := strconv.Atoi(fields[2])
if err != nil {
log.Fatalf("failed to get end coordinate: %v", err)
}
tmp := *seq
tmp.ID += fmt.Sprintf("//%d_%d", start, end)
tmp.Seq = tmp.Seq[start:end]
fmt.Printf("%60a\n", &tmp)
}
}
if err := ssc.Error(); err != nil {
log.Fatalf("error during fasta read: %v", err)
}
f.Close()
}
}
开发者ID:kortschak,项目名称:loopy,代码行数:59,代码来源:catch_global.go
示例8: SetUpSuite
func (s *S) SetUpSuite(c *check.C) {
MaxKmerLen = 14
s.Seq = linear.NewSeq("", nil, alphabet.DNA)
s.Seq.Seq = make(alphabet.Letters, testLen)
for i := range s.Seq.Seq {
s.Seq.Seq[i] = [...]alphabet.Letter{'A', 'C', 'G', 'T', 'a', 'c', 'g', 't'}[rand.Int()%8]
}
}
开发者ID:gordon,项目名称:biogo,代码行数:8,代码来源:kmerindex_test.go
示例9: ExampleNewMulti
func ExampleNewMulti() {
m, err := NewMulti("example multi",
[]seq.Sequence{
linear.NewSeq("example DNA 1", []alphabet.Letter("ACGCTGACTTGGTGCACGT"), alphabet.DNA),
linear.NewSeq("example DNA 2", []alphabet.Letter("ACGGTGACCTGGCGCGCAT"), alphabet.DNA),
linear.NewSeq("example DNA 3", []alphabet.Letter("ACGATGACGTGGCGCTCAT"), alphabet.DNA),
},
seq.DefaultConsensus)
if err != nil {
return
}
fmt.Printf("%- s\n\n%-s\n", m, m.Consensus(false))
// Output:
// ACGCTGACTTGGTGCACGT
// ACGGTGACCTGGCGCGCAT
// ACGATGACGTGGCGCTCAT
//
// acgntgacntggcgcncat
}
开发者ID:gordon,项目名称:biogo,代码行数:21,代码来源:multi_example_test.go
示例10: getFasta
func getFasta(fn string) (seq.Sequence, error) {
fasta_file, err := os.Open(fn)
if err != nil {
fmt.Println("Erro ao ler o arquivo", err)
}
defer fasta_file.Close()
var s []alphabet.Letter
t := linear.NewSeq("", s, alphabet.Protein)
reader := fasta.NewReader(fasta_file, t)
seq, _ := reader.Read()
return seq, nil
}
开发者ID:jgcarvalho,项目名称:ASAnative_amber,代码行数:12,代码来源:ASAamb.go
示例11: writeFlankSeqs
// writeFlankSeqs writes fasta files containing the sequence of unmapped flanks
// identified in the primary hits provided. cutoff specifies the minimum sequence
// length to consider. left and right specify the filenames for the left and right
// flank fasta sequence files.
func writeFlankSeqs(reads string, hits hitSet, cutoff int, left, right string) error {
f, err := os.Open(reads)
if err != nil {
return err
}
defer f.Close()
lf, err := os.Create(left)
if err != nil {
return err
}
rf, err := os.Create(right)
if err != nil {
return err
}
r := fasta.NewReader(f, linear.NewSeq("", nil, alphabet.DNA))
sc := seqio.NewScanner(r)
for sc.Next() {
seq := sc.Seq().(*linear.Seq)
h, ok := hits[seq.Name()]
if !ok {
continue
}
all := seq.Seq
if h.qStart >= cutoff {
seq.Seq = all[:h.qStart]
_, err := fmt.Fprintf(lf, "%60a\n", seq)
if err != nil {
return err
}
}
if h.qLen-h.qEnd >= cutoff {
seq.Seq = all[h.qEnd:]
_, err := fmt.Fprintf(rf, "%60a\n", seq)
if err != nil {
return err
}
}
}
err = sc.Error()
if err != nil {
return err
}
err = lf.Close()
if err != nil {
return err
}
return rf.Close()
}
开发者ID:kortschak,项目名称:loopy,代码行数:55,代码来源:loopy.go
示例12: readFasta
func readFasta(fn string) (name string, seq string, err error) {
fFasta, err := os.Open(fn)
defer fFasta.Close()
if err != nil {
return "", "", err
}
t := linear.NewSeq("", nil, alphabet.Protein)
reader := fasta.NewReader(fFasta, t)
s, err := reader.Read()
if err != nil {
return "", "", err
}
sl := s.(*linear.Seq)
return sl.Name(), sl.String(), nil
}
开发者ID:jgcarvalho,项目名称:gPHydro,代码行数:15,代码来源:gPHydro.go
示例13: readContigs
func readContigs(file string) (map[string]int, error) {
f, err := os.Open(file)
if err != nil {
return nil, err
}
lengths := make(map[string]int)
sc := seqio.NewScanner(fasta.NewReader(f, linear.NewSeq("", nil, alphabet.DNA)))
for sc.Next() {
s := sc.Seq()
lengths[s.Name()] = s.Len()
}
if err != nil {
log.Fatalf("error during fasta read: %v", err)
}
return lengths, nil
}
开发者ID:kortschak,项目名称:loopy,代码行数:16,代码来源:rinse.go
示例14: Clone
func (r Row) Clone() seq.Sequence {
b := make([]alphabet.Letter, r.Len())
for i, c := range r.Align.Seq {
b[i] = c[r.Row]
}
switch {
case r.Row < 0:
panic("under")
case r.Row >= r.Align.Rows():
panic("bang over Rows()")
case r.Row >= len(r.Align.SubAnnotations):
panic(fmt.Sprintf("bang over len(SubAnns): %d %d", r.Row, len(r.Align.SubAnnotations)))
}
return linear.NewSeq(r.Name(), b, r.Alphabet())
}
开发者ID:gordon,项目名称:biogo,代码行数:16,代码来源:alignment.go
示例15: readContigs
func readContigs(file string) (map[string]*linear.Seq, error) {
f, err := os.Open(file)
if err != nil {
return nil, err
}
seqs := make(map[string]*linear.Seq)
sc := seqio.NewScanner(fasta.NewReader(f, linear.NewSeq("", nil, alphabet.DNAgapped)))
for sc.Next() {
s := sc.Seq().(*linear.Seq)
seqs[s.ID] = s
}
if err != nil {
return nil, err
}
return seqs, nil
}
开发者ID:kortschak,项目名称:loopy,代码行数:16,代码来源:reefer.go
示例16: main
func main() {
flag.Parse()
if *in == "" {
flag.Usage()
os.Exit(1)
}
f, err := os.Open(*in)
if err != nil {
log.Fatalf("failed to open %q: %v", *in, err)
}
defer f.Close()
names := make(map[string][]string)
sc := seqio.NewScanner(fasta.NewReader(f, linear.NewSeq("", nil, alphabet.DNAgapped)))
for sc.Next() {
seq := sc.Seq().(*linear.Seq)
idx := strings.LastIndex(seq.ID, "/")
names[seq.ID[:idx]] = append(names[seq.ID[:idx]], seq.ID[idx+1:])
}
if err := sc.Error(); err != nil {
log.Fatalf("error during fasta read: %v", err)
}
f.Close()
base := filepath.Base(*in)
unique, err := os.Create(base + ".unique.text")
if err != nil {
log.Fatalf("failed to create %q: %v", base+".unique.text", err)
}
defer unique.Close()
nonUnique, err := os.Create(base + ".non-unique.text")
if err != nil {
log.Fatalf("failed to create %q: %v", base+".non-unique.text", err)
}
defer nonUnique.Close()
for name, coords := range names {
switch len(coords) {
case 0:
case 1:
fmt.Fprintln(unique, name)
default:
fmt.Fprintf(nonUnique, "%s\t%v\n", name, coords)
}
}
}
开发者ID:kortschak,项目名称:loopy,代码行数:47,代码来源:dedup_ccs.go
示例17: main
func main() {
flag.Parse()
if *in == "" {
flag.Usage()
os.Exit(1)
}
inFile, err := os.Open(*in)
if err != nil {
log.Fatalf("failed to open input:%v", err)
}
defer inFile.Close()
*in = filepath.Base(*in)
sc := seqio.NewScanner(fasta.NewReader(inFile, linear.NewSeq("", nil, alphabet.DNA)))
var i, size int
out, err := os.Create(fmt.Sprintf("%s-%d.fa", *in, i))
for sc.Next() {
if sc.Seq().Len() < *cut {
continue
}
if size != 0 && size+sc.Seq().Len() > *bundle {
err = out.Close()
if err != nil {
log.Fatalf("failed to close file bundle %d: %v", i, err)
}
i++
size = 0
out, err = os.Create(fmt.Sprintf("%s-%d.fa", *in, i))
if err != nil {
log.Fatalf("failed to open file bundle %d: %v", i, err)
}
}
size += sc.Seq().Len()
fmt.Fprintf(out, "%60a\n", sc.Seq())
}
if sc.Error() != nil {
log.Fatal(sc.Error())
}
err = out.Close()
if err != nil {
log.Fatalf("failed to close file bundle %d: %v", i, err)
}
}
开发者ID:kortschak,项目名称:loopy,代码行数:45,代码来源:bundle.go
示例18: metaSeq
func (r *Reader) metaSeq(moltype, id []byte) (seq.Sequence, error) {
var line, body []byte
var err error
for {
line, err = r.r.ReadBytes('\n')
if err != nil {
if err == io.EOF {
return nil, err
}
return nil, &csv.ParseError{Line: r.line, Err: err}
}
r.line++
line = bytes.TrimSpace(line)
if len(line) == 0 {
continue
}
if len(line) < 2 || !bytes.HasPrefix(line, []byte("##")) {
return nil, &csv.ParseError{Line: r.line, Err: ErrBadSequence}
}
line = bytes.TrimSpace(line[2:])
if unsafeString(line) == "end-"+unsafeString(moltype) {
break
} else {
line = bytes.Join(bytes.Fields(line), nil)
body = append(body, line...)
}
}
var alpha alphabet.Alphabet
switch feat.ParseMoltype(unsafeString(moltype)) {
case feat.DNA:
alpha = alphabet.DNA
case feat.RNA:
alpha = alphabet.RNA
case feat.Protein:
alpha = alphabet.Protein
default:
return nil, ErrBadMoltype
}
s := linear.NewSeq(string(id), alphabet.BytesToLetters(body), alpha)
return s, err
}
开发者ID:gordon,项目名称:biogo,代码行数:44,代码来源:gff.go
示例19: TestWriteFasta
func (s *S) TestWriteFasta(c *check.C) {
fa := fas[0]
b := &bytes.Buffer{}
w := NewWriter(b, 60)
seq := linear.NewSeq("", nil, alphabet.Protein)
var n int
for i := range expectN {
seq.ID = expectN[i]
seq.Seq = expectS[i]
_n, err := w.Write(seq)
if err != nil {
c.Fatalf("Failed to write to buffer: %s", err)
}
n += _n
}
c.Check(n, check.Equals, b.Len())
c.Check(string(b.Bytes()), check.Equals, fa)
}
开发者ID:gordon,项目名称:biogo,代码行数:21,代码来源:fasta_test.go
示例20: mangle
func mangle() {
seen := make(map[string]bool)
hash := sha1.New()
sc := seqio.NewScanner(fasta.NewReader(os.Stdin, linear.NewSeq("", nil, alphabet.DNA)))
for sc.Next() {
s := sc.Seq().(*linear.Seq)
if s.Desc == "" {
s.Desc = s.ID
} else {
s.Desc = fmt.Sprintf("%s %s", s.ID, s.Desc)
}
hash.Write([]byte(s.Desc))
s.ID = fmt.Sprintf("%040x", hash.Sum(nil))
if seen[s.ID] {
log.Fatalf("duplicate sha1: %s", s.ID)
}
seen[s.ID] = true
hash.Reset()
fmt.Printf("%60a\n", s)
}
}
开发者ID:kortschak,项目名称:loopy,代码行数:21,代码来源:mangle.go
注:本文中的github.com/biogo/biogo/seq/linear.NewSeq函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论