Esempio n. 1
0
func (m *MyWorker) New(input_file string) disq.Worker {
	sequencename := strings.TrimRight(input_file, ".fm")
	var filename = ""
	if _, err := os.Stat(input_file); os.IsNotExist(err) {
		if _, err := os.Stat(sequencename); os.IsNotExist(err) {
			log.Fatal("Exit!")
		} else {
			filename = input_file
			fmt.Printf("No such index: %s, build it now!\n", filename)
			m.idx = fmi.Build(sequencename)
		}
	} else {
		filename = input_file
		m.idx = fmi.Load(input_file)
		fmt.Println("Download the index file.")
	}

	/*   fmt.Println("Load index", input_file)
	     idx = fmi.Load(input_file)*/
	fmt.Println("\tSimpleNode.Configure", input_file)
	w := new(MyWorker)
	w.idx = m.idx

	// w := MyWorker{m.idx}
	return w
}
Esempio n. 2
0
func (I fmiworker) Analyze(message []byte) []byte {
	element := strings.Split(string(message), " ")
	if element[0] != filename {
		sequencename := strings.TrimRight(element[0], ".fm")
		if _, err := os.Stat(element[0]); os.IsNotExist(err) {
			if _, err := os.Stat(sequencename); os.IsNotExist(err) {
				return []byte(fmt.Sprintf("No such index: %s, need to build it first. But no such sequence: %s!", filename, sequencename))
				// log.Fatal("Exit!")
			} else {
				filename = element[0]
				fmt.Printf("No such index: %s, build it now!\n", filename)
				idx = fmi.Build(sequencename)
			}
		} else {
			filename = element[0]
			idx = fmi.Load(element[0])
			fmt.Println("Download the index file.")
		}
	}
	result := fmi.Search(idx, []byte(element[2]))
	return format_result(element[1], result)
}