Created
August 10, 2013 23:55
-
-
Save samuell/6202714 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/samuell/blow" | |
"github.com/trustmaster/goflow" | |
// "log" | |
"runtime" | |
) | |
const ( | |
NUMTHREADS = 1 | |
BUFSIZE = 512 | |
) | |
// --------------------------------------------------------- | |
// BaseComplementer network | |
// --------------------------------------------------------- | |
type BaseComplementerApp struct { | |
flow.Graph | |
} | |
func NewBaseCompelenterApp() *BaseComplementerApp { | |
// Make all processes started from here synchronous | |
flow.DefaultComponentMode = flow.ComponentModeSync | |
network := new(BaseComplementerApp) | |
network.InitGraphState() | |
// Add components | |
fr := new(blow.FileReader) | |
bc1 := blow.NewBaseComplementer("bc1") | |
bc2 := blow.NewBaseComplementer("bc2") | |
bc3 := blow.NewBaseComplementer("bc3") | |
bc4 := blow.NewBaseComplementer("bc4") | |
pr := new(blow.Printer) | |
fr.Component.Mode = flow.ComponentModeSync | |
bc1.Component.Mode = flow.ComponentModeSync | |
bc2.Component.Mode = flow.ComponentModeSync | |
bc3.Component.Mode = flow.ComponentModeSync | |
bc4.Component.Mode = flow.ComponentModeSync | |
pr.Component.Mode = flow.ComponentModeSync | |
network.Add(fr, "filereader") | |
network.Add(bc1, "bc1") | |
network.Add(bc2, "bc2") | |
network.Add(bc3, "bc3") | |
network.Add(bc4, "bc4") | |
network.Add(pr, "printer") | |
// Connect components | |
network.MapInPort("In", "filereader", "FileName") | |
network.Connect("filereader", "Line", "bc1", "Sequence", make(chan []byte, BUFSIZE)) | |
network.Connect("bc1", "BaseComplementedSequence", "bc2", "Sequence", make(chan []byte, BUFSIZE)) | |
network.Connect("bc2", "BaseComplementedSequence", "bc3", "Sequence", make(chan []byte, BUFSIZE)) | |
network.Connect("bc3", "BaseComplementedSequence", "bc4", "Sequence", make(chan []byte, BUFSIZE)) | |
network.Connect("bc4", "BaseComplementedSequence", "printer", "Line", make(chan []byte, BUFSIZE)) | |
return network | |
} | |
// --------------------------------------------------------- | |
// Main method | |
// --------------------------------------------------------- | |
var finish chan bool | |
// Use this handler to let main() know when the network terminates | |
func (a *BaseComplementerApp) Finish() { | |
finish <- true | |
} | |
func main() { | |
// Set the number of Operating System-threads to use | |
runtime.GOMAXPROCS(NUMTHREADS) | |
// Termination signal channel | |
finish = make(chan bool) | |
// Create network | |
net := NewBaseCompelenterApp() | |
// Create the "In" channel | |
in := make(chan string) | |
net.SetInPort("In", in) | |
// Run net | |
flow.RunNet(net) | |
// Give the Filename to read | |
in <- "Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa" | |
close(in) | |
<-finish | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment