Beispiel #1
0
// numJobs returns an appoximate number of Bower values from the list of files
// provided. Note that a PDB file is counted as a single value even if there
// are multiple chains in it. On the other hand, FASTA files are counted for
// each individual sequence in the file.
//
// If there is a problem reading a file, it is ignored. (Presumably the error
// will be properly dealt with later.)
func numJobs(fpaths []string) int {
	count := 0
	for _, fpath := range fpaths {
		switch {
		case IsFasta(fpath):
			func() {
				r, fp, err := fastaOpen(fpath)
				if err != nil {
					return
				}
				defer fp.Close()

				n, _ := fasta.QuickSequenceCount(r)
				count += n
			}()
		case IsPDB(fpath):
			count += 1
		default:
			count += 1 // Errors result in a single call to JobDone.
		}
	}
	return count
}
Beispiel #2
0
func main() {
	rfasta := util.OpenFasta(util.Arg(0))
	count, err := fasta.QuickSequenceCount(rfasta)
	util.Assert(err)
	fmt.Println(count)
}