ontology

package
v0.0.0-...-2b433ae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2024 License: BSD-2-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GroupTag = "ontology-group"
)

Variables

View Source
var LoadCmd = &cobra.Command{
	Use:   "load",
	Short: "load obojson formatted ontologies to arangodb",
	Args:  cobra.NoArgs,
	PreRunE: func(cmd *cobra.Command, args []string) error {
		return setOboReaders(cmd)
	},
	RunE: func(cmd *cobra.Command, args []string) error {
		dsa, err := araobo.NewDataSource(ConnectParams(), CollectParams())
		if err != nil {
			return errors.Errorf("error in connecting to arangodb %s", err)
		}
		logger := registry.GetLogger()
		for name, rdr := range registry.GetAllReaders(registry.OboReadersKey) {
			logger.Debugf("going to load %s,", name)
			grph, err := graph.BuildGraph(rdr)
			if err != nil {
				return errors.Errorf(
					"error in building graph from %s %s",
					name,
					err,
				)
			}
			if !dsa.ExistsOboGraph(grph) {
				logger.Debugf(
					"obograph %s does not exist, have to be loaded",
					name,
				)
				if err := saveNewGraph(dsa, grph, logger); err != nil {
					return errors.Errorf(
						"error in saving new obograph %s %s",
						name,
						err,
					)
				}

				continue
			}
			logger.Debugf("obograph %s exist, have to be updated", name)
			if err := saveExistentGraph(dsa, grph, logger); err != nil {
				return errors.Errorf(
					"error in saving existing obograph %s %s",
					name,
					err,
				)
			}
		}
		logger.Infof(
			"uploaded %d obojson files",
			len(registry.GetAllReaders(registry.OboReadersKey)),
		)
		return nil
	},
}

LoadCmd obojson formmated ontologies to arangodb

View Source
var OntologyCmd = &cobra.Command{
	Use:   "ontology",
	Short: "subcommand for ontology management",
}

OntologyCmd is the subcommand for managing ontology

View Source
var RefreshCmd = &cobra.Command{
	Use:   "refresh",
	Short: "updates ontologies in S3 storage",
	Args:  cobra.NoArgs,
	RunE: func(cmd *cobra.Command, args []string) error {
		dir, err := git.CloneRepo(
			viper.GetString("repository"),
			viper.GetString("branch"),
		)
		if err != nil {
			return err
		}
		files, err := obojsonFiles(dir)
		if err != nil {
			return err
		}
		logger := registry.GetLogger()
		for _, e := range files {
			_, err := registry.GetS3Client().FPutObject(
				viper.GetString("s3-bucket"),
				fmt.Sprintf("%s/%s", viper.GetString("s3-bucket-path"), filepath.Base(e)),
				e, minio.PutObjectOptions{
					UserMetadata: map[string]string{
						GroupTag: viper.GetString("group"),
					},
				},
			)
			if err != nil {
				return err
			}
			logger.Debugf("uploaded %s file", filepath.Base(e))
		}
		logger.Infof("refreshed %d obo files", len(files))
		return nil
	},
}

RefreshCmd updates obojson formatted ontologies in S3(minio) storage

Functions

func CollectParams

func CollectParams() *araobo.CollectionParams

func ConnectParams

func ConnectParams() *araobo.ConnectParams

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL