Camelia, the Perl 6 bug

IRC log for #bioruby, 2012-10-22

| Channels | #bioruby index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
13:20 shevy hey
13:20 shevy just came back from university
13:20 shevy lintsu, this is bogus:
13:20 shevy seqHash = {name, dna, protein}
13:21 shevy this is also bogus:
13:21 shevy seqHash << f.definition, s, s.translate
13:21 shevy remember how to define a hash in ruby
13:21 shevy there are two (actually at least three) ways to do so:
13:21 shevy (1) most common way:
13:21 shevy hash = {}
13:21 shevy (2) also often seen but not so common and a tiny bit slower:
13:21 shevy hash = Hash.new
13:21 shevy there may be other ways, such as via eval(), or .send
13:22 shevy remember, a hash is nothing more than key: value pair
13:22 shevy so when you use this, lintsu:
13:22 shevy seqHash = {name, dna, protein}
13:22 shevy what is the key, what is the value?
13:22 shevy what I see is, you have three different keys
13:22 shevy (1) name (2) dna (3) protein
13:22 shevy but no value
13:22 shevy one way to initialize all this would be like doing this here:
13:23 shevy seqHash[name] = nil
13:23 shevy seqHash[dna] = nil
13:23 shevy seqHash[protein] = nil
13:24 shevy lintsu also, hash has no << method
13:24 shevy array has
13:24 shevy you could add an array to your hash though
13:24 shevy seqHash[name_of_entry_goes_here] = [ f.definition, s, s.translate ]
13:24 shevy lintsu, you really should use irb, it makes it easy to look at datastructure of ruby any time :)
13:34 Xeago joined #bioruby
14:24 ngoto joined #bioruby
17:02 lintsu shevy: thanks for your explanation :)
17:04 shevy hehe
17:04 shevy I wanna see how far you manage to go
17:04 shevy from 0 ruby knowledge to a working application :)
17:05 shevy back when I started with ruby, shoes did not exist, I only wrote commandline things for some years
17:05 lintsu :P
17:05 shevy hi ngoto! :)
17:05 shevy lintsu, ngoto is kinda the big boss
17:05 lintsu ah ok :)
17:05 shevy ngoto, lintsu is the guy testing the bioruby tutorial :)
17:05 shevy he is in the japanese time zone though, so often when we are awake, he is sleeping hehe
17:05 lintsu shevy: I think my next step should be planning what I want my application to do
17:06 shevy well
17:06 shevy you could always do this:
17:06 shevy - make it as modular as possible
17:06 shevy combine things into it
17:06 shevy like, have one widget that solves one useful thing
17:06 shevy then add another widget
17:06 shevy etc...
17:06 shevy I used to do a little bioruby things with ruby-gnome
17:07 shevy tried to make a browser that pulled in useful data
17:07 shevy and a little app that always outputs the opposing nucleotide base to A,T,C,G input so you could copy paste
17:07 shevy the browsers changed things though, I think using the browser is often simpler than using a traditional GUI
17:10 lintsu yeah, in kind of it is easier
17:10 lintsu but then you need to have server to set it up
17:11 lintsu or a lot ways it would be easier :D i'm native speaker with html and css
17:13 lintsu shevy: can you suggest some function here https://gist.github.com/94b72f539d9ea1dfd547 that would be easy / useful to put in method?
17:14 shevy well, the thing is, you kind of put your logic all within shoes
17:14 shevy for instance, look at all flow do/end
17:15 shevy flow is a method which shoes defines
17:15 shevy def flow
17:15 shevy end
17:15 shevy something more complicated than that :)
17:15 shevy I can tell you what I did with ruby-gnome
17:15 lintsu yeah please
17:15 shevy I tried to write one method for every button that can be pressed
17:15 shevy so for instance, just a rough line to give an idea
17:15 shevy flow do
17:15 shevy run_delete_actions if @user_pressed_delete_button
17:15 shevy end
17:16 shevy and before that code, I would define it
17:16 shevy def run_delete_actions
17:16 shevy # put all the logic for this here
17:16 shevy end
17:16 shevy if you need to pass arguments to such a method, it could be like:
17:16 shevy def run_delete_actions(input)
17:16 shevy # lala do something with argument: input here
17:16 shevy end
17:16 shevy right now, you put all logic inside flow do/end
17:16 shevy this makes it harder to regroup things
17:16 shevy especially if your app becomes larger
17:17 shevy right now it is small, so it is ok
17:17 shevy hehe
17:17 shevy button "Save as text file" do
17:17 shevy save_text
17:17 shevy end
17:17 shevy see?
17:17 lintsu yeah
17:17 shevy lemme write the example
17:18 shevy http://pastie.org/5099152
17:18 lintsu in high school I attended java and c++ courses with my bf but I always dropped out when we started using classes :D
17:19 shevy hehe
17:19 shevy I dropped because of memory management and pointer usage :(
17:20 shevy But C is too important, I need to learn it until I master it ...
17:20 shevy otherwise, functions and methods are very similar in ruby and C/C++/Java
17:20 shevy and ruby uses similar things as C++ does
17:20 shevy in C++ you do things like:
17:20 shevy cout << "Hello World!" << endl;
17:20 shevy in ruby
17:20 shevy puts "Hello World!"
17:20 shevy but you can use << too for strings
17:21 lintsu yeah I like ruby so far so much better language to learn to code
17:21 shevy puts '' << "Hello World!"
17:21 shevy this works in ruby for instance
17:21 shevy yeah, scripting languages are cool
17:21 shevy but I think, in the long run one always has to combine it with either C or C++ or Java or C# or D or Go :)
17:57 shevy joined #bioruby
17:59 lintsu shevy: yay my methods are working!
18:02 shevy wheee!
18:02 shevy you entered the first level of ruby :)
18:02 shevy once you are good with methods,
18:02 shevy you will be able to arrange them into your own custom classes
18:02 shevy then you could have your whole shoes code work in a standalone class
18:02 shevy class LintsuWidget
18:02 shevy end
18:02 shevy foo = LintsuWidget.new
18:03 shevy foo.set_background_colour 'green'
18:03 shevy # or the ruby way also works like this:
18:03 shevy foo.background_colour = 'green'
18:03 shevy I myself like to use set_ and get_
18:03 shevy but most other guys use the second way
18:03 lintsu :)
18:03 lintsu I just found this http://www.libgosu.org/
18:03 shevy I like it because it reads nicer in my own code, I dont like to call methods via = assignment
18:04 shevy ah gosu
18:04 shevy is good too
18:04 shevy #gamebox uses it
18:04 shevy but dont worry too much about the underlying widget really
18:04 shevy most widgets are very similar
18:04 lintsu yeah
18:04 shevy 60% at least
18:04 shevy a button will always be a button :)
18:04 lintsu I should focus on the code and not gui :D

| Channels | #bioruby index | Today | | Search | Google Search | Plain-Text | summary