Created
August 6, 2013 12:42
-
-
Save samuell/6164115 to your computer and use it in GitHub Desktop.
Problematic code ...
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" | |
"runtime" | |
) | |
const ( | |
NUMTHREADS = 4 | |
) | |
// --------------------------------------------------------- | |
// BaseComplementer network | |
// --------------------------------------------------------- | |
type BaseComplementerApp struct { | |
flow.Graph | |
} | |
func NewBaseCompelenterApp() *BaseComplementerApp { | |
network := new(BaseComplementerApp) | |
network.InitGraphState() | |
// Add components | |
network.Add(new(blow.FileReader), "filereader") | |
network.Add(new(blow.BaseComplementer), "basecompl1") | |
network.Add(new(blow.BaseComplementer), "basecompl2") | |
network.Add(new(blow.BaseComplementer), "basecompl3") | |
network.Add(new(blow.BaseComplementer), "basecompl4") | |
network.Add(new(blow.Printer), "printer") | |
// Connect components | |
network.MapInPort("In", "filereader", "FileName") | |
network.Connect("filereader", "Line", "basecompl1", "Sequence", make(chan []byte)) | |
network.Connect("basecompl1", "BaseComplementedSequence", "basecompl2", "Sequence", make(chan []byte)) | |
network.Connect("basecompl2", "BaseComplementedSequence", "basecompl3", "Sequence", make(chan []byte)) | |
network.Connect("basecompl3", "BaseComplementedSequence", "basecompl4", "Sequence", make(chan []byte)) | |
network.Connect("basecompl4", "BaseComplementedSequence", "printer", "Line", make(chan []byte)) | |
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