Пример #1
0
func txSyncPopDesc(c *cmdapp.Command, l jdh.ListScanner, p *jdh.Taxon) {
	pId := p.Id
	if !p.IsValid {
		pId = p.Parent
	}
	for {
		desc := &jdh.Taxon{}
		if err := l.Scan(desc); err != nil {
			if err == io.EOF {
				break
			}
			fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
			os.Exit(1)
		}
		// check if the taxon is in the database
		if d := taxon(c, localDB, extDBFlag+":"+desc.Id); len(d.Id) != 0 {
			continue
		}
		// adds the new taxon
		tax := &jdh.Taxon{}
		*tax = *desc
		tax.Id = ""
		tax.Parent = pId
		tax.Extern = []string{extDBFlag + ":" + desc.Id}
		if _, err := localDB.Exec(jdh.Add, jdh.Taxonomy, tax); err != nil {
			fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
			os.Exit(1)
		}
	}
}
Пример #2
0
func spGrefNav(c *cmdapp.Command, l jdh.ListScanner, gzt geography.Gazetter) {
	for {
		desc := &jdh.Taxon{}
		if err := l.Scan(desc); err != nil {
			if err == io.EOF {
				break
			}
			fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
			os.Exit(1)
		}
		spGrefProc(c, desc, gzt)
	}
}
Пример #3
0
func raMkNav(c *cmdapp.Command, l jdh.ListScanner, spDB jdh.DB, prevRank, rank jdh.Rank, size float64) {
	for {
		desc := &jdh.Taxon{}
		if err := l.Scan(desc); err != nil {
			if err == io.EOF {
				break
			}
			fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
			os.Exit(1)
		}
		raMkFetch(c, spDB, desc, prevRank, rank, size)
	}
}
Пример #4
0
func spPopNav(c *cmdapp.Command, l jdh.ListScanner, prevRank, rank jdh.Rank) {
	for {
		desc := &jdh.Taxon{}
		if err := l.Scan(desc); err != nil {
			if err == io.EOF {
				break
			}
			fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
			os.Exit(1)
		}
		spPopFetch(c, desc, prevRank, rank)
	}
}
Пример #5
0
func txSyncRankNav(c *cmdapp.Command, l jdh.ListScanner, rank jdh.Rank) {
	for {
		desc := &jdh.Taxon{}
		if err := l.Scan(desc); err != nil {
			if err == io.EOF {
				break
			}
			fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
			os.Exit(1)
		}
		txSyncRankSet(c, desc, rank)
	}
}
Пример #6
0
func txLsProc(c *cmdapp.Command, l jdh.ListScanner) {
	for {
		tax := &jdh.Taxon{}
		if err := l.Scan(tax); err != nil {
			if err == io.EOF {
				break
			}
			fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
			os.Exit(1)
		}
		if machineFlag {
			fmt.Fprintf(os.Stdout, "%s\n", tax.Id)
			continue
		}
		if verboseFlag {
			fmt.Fprintf(os.Stdout, "%s\t%s\t%s %s\t\n", tax.Id, tax.Rank, tax.Name, tax.Authority)
			continue
		}
		fmt.Fprintf(os.Stdout, "%s %s\n", tax.Name, tax.Authority)
	}
}