Exemple #1
0
func readInput(r io.Reader) ([]string, []spectrum.Mass, error) {
	var n int
	_, err := fmt.Fscanf(r, "%d\n", &n)
	if err != nil {
		return nil, nil, err
	}

	prots := []string{}
	for len(prots) < n {
		var s string
		_, err := fmt.Fscanf(r, "%s\n", &s)
		if err != nil {
			return nil, nil, err
		}
		prots = append(prots, s)
	}

	masses := []spectrum.Mass{}
	for {
		var s string
		_, err := fmt.Fscanf(r, "%s\n", &s)
		if err == io.EOF {
			break
		} else if err != nil {
			return nil, nil, err
		}
		m, err := spectrum.ParseMass(s)
		if err != nil {
			return nil, nil, err
		}
		masses = append(masses, m)
	}

	return prots, masses, nil
}
Exemple #2
0
func main() {
	masses := []spectrum.Mass{}

	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		m, err := spectrum.ParseMass(scanner.Text())
		if err != nil {
			log.Fatal(err)
		}
		masses = append(masses, m)
	}
	if err := scanner.Err(); err != nil {
		log.Fatal(err)
	}

	spec, err := spectrum.New(masses[1:])
	if err != nil {
		log.Fatal(err)
	}
	p, ok := spec.Protein()
	if ok {
		fmt.Println(p)
	} else {
		log.Fatal("Protein not found")
	}
}
Exemple #3
0
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	spec := []spectrum.Mass{}

	for scanner.Scan() {
		t := scanner.Text()
		w, err := spectrum.ParseMass(t)
		if err != nil {
			log.Fatal(err)
		}

		spec = append(spec, w)
	}

	fmt.Println(ProteinFromSpectrum(spec))
}