Skip to content

Commit

Permalink
remove unused ReadRaw functions
Browse files Browse the repository at this point in the history
  • Loading branch information
teharrison committed Apr 27, 2018
1 parent 156cc09 commit b5b08d2
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 273 deletions.
21 changes: 0 additions & 21 deletions shock-server/node/file/format/fasta/fasta.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,6 @@ func (self *Reader) Read() (sequence *seq.Seq, err error) {
return
}

// Read a single sequence and return it or an error.
func (self *Reader) ReadRaw(p []byte) (n int, err error) {
if self.r == nil {
self.r = bufio.NewReader(self.f)
}
p[n] = byte('>')
n = 1
for {
read, er := self.r.ReadBytes('>')
if len(read) > 1 {
copy(p[n:n+len(read)-1], read[0:len(read)-1])
n += len(read) - 1
break
} else if er != nil {
err = er
break
}
}
return
}

// Read a single sequence and return read offset for indexing.
func (self *Reader) GetReadOffset() (n int, err error) {
if self.r == nil {
Expand Down
43 changes: 1 addition & 42 deletions shock-server/node/file/format/fastq/fastq.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

var (
Regex = regexp.MustCompile(`^[\n\r]*@[\S\t ]+[\n\r]+[A-Za-z\-]+[\n\r]+\+[\S\t ]*[\n\r]+\S*[\n\r]+`)
Regex = regexp.MustCompile(`^[\n\r]*@\S+[\S\t ]+[\n\r]+[A-Za-z\-]+[\n\r]+\+[\S\t ]*[\n\r]+\S*[\n\r]+`)
)

// Fastq sequence format reader type.
Expand Down Expand Up @@ -97,47 +97,6 @@ READ:
return
}

func (self *Reader) ReadRaw(p []byte) (n int, err error) {
if self.r == nil {
self.r = bufio.NewReader(self.f)
}
curr := 0
id, err := self.r.ReadBytes('\n')
if err != nil {
return 0, err
} else if !bytes.HasPrefix(id, []byte{'@'}) {
return 0, errors.New("Invalid format: id line does not start with @")
}
copy(p[curr:len(id)+curr], id)
curr += len(id)

seq, err := self.r.ReadBytes('\n')
if err != nil {
return 0, err
}
copy(p[curr:len(seq)+curr], seq)
curr += len(seq)

plus, err := self.r.ReadBytes('\n')
if err != nil {
return 0, err
} else if !bytes.HasPrefix(plus, []byte{'+'}) {
return 0, errors.New("Invalid format: plus line does not start with +")
}
copy(p[curr:len(plus)+curr], plus)
curr += len(plus)

qual, err := self.r.ReadBytes('\n')
if err != nil {
return 0, err
} else if len(seq) != len(qual) {
return 0, errors.New("Invalid format: length of sequence and quality lines do not match")
}
copy(p[curr:len(qual)+curr], qual)
n = curr + len(qual)
return
}

// Read a single sequence and return read offset for indexing.
func (self *Reader) GetReadOffset() (n int, err error) {
if self.r == nil {
Expand Down
10 changes: 0 additions & 10 deletions shock-server/node/file/format/multi/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@ func (r *Reader) Read() (*seq.Seq, error) {
return r.r.Read()
}

func (r *Reader) ReadRaw(p []byte) (n int, err error) {
if r.r == nil {
err := r.DetermineFormat()
if err != nil {
return 0, err
}
}
return r.r.ReadRaw(p)
}

func (r *Reader) GetReadOffset() (n int, err error) {
if r.r == nil {
err := r.DetermineFormat()
Expand Down
19 changes: 0 additions & 19 deletions shock-server/node/file/format/sam/sam.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,6 @@ func (self *Reader) Read() (sequence *seq.Seq, err error) {
return
}

// Read a single sequence and return it or an error. (used for making record index)
func (self *Reader) ReadRaw(p []byte) (n int, err error) {
for {
read, er := self.r.ReadBytes('\n')
n += len(read)
if len(read) > 1 {
if read[0] == '@' {
continue
}
copy(p[0:len(read)], read[0:len(read)])
break
} else if er != nil {
err = er
break
}
}
return
}

// Read a single sequence and return read offset for indexing.
func (self *Reader) GetReadOffset() (n int, err error) {
for {
Expand Down
179 changes: 0 additions & 179 deletions shock-server/node/file/format/sam/sam_test.go

This file was deleted.

2 changes: 0 additions & 2 deletions shock-server/node/file/format/seq/seq.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ type ReadFormater interface {

type Reader interface {
Read() (*Seq, error)
ReadRaw(p []byte) (int, error)
GetReadOffset() (int, error)
SeekChunk(int64) (int64, error)
}

type ReadRewinder interface {
Read() (*Seq, error)
ReadRaw(p []byte) (int, error)
GetReadOffset() (int, error)
SeekChunk(int64) (int64, error)
Rewind() error
Expand Down

0 comments on commit b5b08d2

Please sign in to comment.