Exemple #1
0
func _main(c *cli.Context) {

	if c.String("input") == "" {
		fmt.Fprintf(os.Stderr, "Input required, exiting\n")
		cli.ShowAppHelp(c)
		os.Exit(1)
	}

	gff_ain, err := autoio.OpenReadScannerSimple(c.String("input"))
	_ = gff_ain
	if err != nil {
		fmt.Fprintf(os.Stderr, "%v", err)
		os.Exit(1)
	}
	defer gff_ain.Close()

	ref_ain := simplestream.SimpleStream{}
	ref_fp := os.Stdin
	if c.String("ref-input") != "-" {
		var e error
		ref_fp, e = os.Open(c.String("ref-input"))
		if e != nil {
			fmt.Fprintf(os.Stderr, "%v", err)
			os.Exit(1)
		}
		defer ref_fp.Close()
	}
	ref_ain.Init(ref_fp)

	var ref_start int64
	ref_start = 0
	ss := c.Int("ref-start")
	if ss > 0 {
		ref_start = int64(ss)
	}

	var seq_start int64
	seq_start = 0
	_ = seq_start
	ss = c.Int("seq-start")
	if ss > 0 {
		seq_start = int64(ss)
	}

	aout := os.Stdout
	if c.String("output") != "-" {
		aout, err = os.Open(c.String("output"))
		if err != nil {
			fmt.Fprintf(os.Stderr, "%v", err)
			os.Exit(1)
		}
		defer aout.Close()
	}

	if c.Bool("pprof") {
		gProfileFlag = true
		gProfileFile = c.String("pprof-file")
	}

	if c.Bool("mprof") {
		gMemProfileFlag = true
		gMemProfileFile = c.String("mprof-file")
	}

	gVerboseFlag = c.Bool("Verbose")

	if c.Int("max-procs") > 0 {
		runtime.GOMAXPROCS(c.Int("max-procs"))
	}

	allele := c.Int("allele")

	if gProfileFlag {
		prof_f, err := os.Create(gProfileFile)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Could not open profile file %s: %v\n", gProfileFile, err)
			os.Exit(2)
		}

		pprof.StartCPUProfile(prof_f)
		defer pprof.StopCPUProfile()
	}

	e := convert(&gff_ain, &ref_ain, aout, ref_start, allele)
	if e != nil && e != io.EOF {
		panic(e)
	}

	aout.Sync()

}
Exemple #2
0
func _main(c *cli.Context) {
	var err error

	if c.String("input") == "" {
		fmt.Fprintf(os.Stderr, "Input required, exiting\n")
		cli.ShowAppHelp(c)
		os.Exit(1)
	}

	pasta_ain := simplestream.SimpleStream{}
	pasta_fp := os.Stdin
	if len(c.String("input")) > 0 && c.String("input") != "-" {
		var e error
		pasta_fp, e = os.Open(c.String("input"))
		if e != nil {
			fmt.Fprintf(os.Stderr, "%v", e)
			os.Exit(1)
		}
		defer pasta_fp.Close()
	}
	pasta_ain.Init(pasta_fp)

	aout := os.Stdout
	if c.String("output") != "-" {
		aout, err = os.Open(c.String("output"))
		if err != nil {
			fmt.Fprintf(os.Stderr, "%v", err)
			os.Exit(1)
		}
		defer aout.Close()
	}

	/*
	  aout := os.Stdout
	  if err!=nil {
	    fmt.Fprintf(os.Stderr, "%v", err)
	    os.Exit(1)
	  }
	*/

	if c.Bool("pprof") {
		gProfileFlag = true
		gProfileFile = c.String("pprof-file")
	}

	if c.Bool("mprof") {
		gMemProfileFlag = true
		gMemProfileFile = c.String("mprof-file")
	}

	gVerboseFlag = c.Bool("Verbose")

	if c.Int("max-procs") > 0 {
		runtime.GOMAXPROCS(c.Int("max-procs"))
	}

	if gProfileFlag {
		prof_f, err := os.Create(gProfileFile)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Could not open profile file %s: %v\n", gProfileFile, err)
			os.Exit(2)
		}

		pprof.StartCPUProfile(prof_f)
		defer pprof.StopCPUProfile()
	}

	convert(&pasta_ain, aout)

}