Multiple sequence alignment - javascript

I know it may seem kind of strange but I was wondering if anybody has ever seen some javascript code for the multiple sequence alignment problem. If not (as I suppose) also some easily portable code (i.e. I need no kitchen sink) will do. Keep in mind that I won't be aligning more than 4-5 sequences less than 100-200 symbols long.
Note: I know javascript is not really the best choice for this kind of things. Trust me, there's a good reason why I have to do it in javascript.

http://biostar.stackexchange.com/

The closest thing I found is just a pairwise sequence alignment algorithm. I turned it into something that would do MSA but it's definitely too slow to be usable for anything longer than a hundred symbols.

Related

AI bot for a simple game

There is a relatively simple game with such rules:
There is a safe which needs to be unlocked.
Code to the safe is a 4 digits number without repetitions(1234, 4867, 1092, etc., code like 1231 isn't possible in this game).
The game gives 5 attempts to guess the right code.
Let's say I start a new game and on the first try I test code like 0123.
The game responds with 2-1. 2 means that code 0123 has 2 right numbers which I need to use in the final unlock code. 1 means that one of those 2 numbers is at the correct position already.
After this I have 4 more exact same steps where I try different codes based on the previous tested numbers and responses from the game.
The goal is to get final code, let's say 9135(based on the prev 0123 try) and response from the game needs to be 4-4(4 right numbers, 4 in place). The earlier it happens - better.
I know that this can be solved using combinatorics just by excluding some combinations but I don't know how to choose the most weighted combination for the next try and hope AI can do it better.
I'm a frontend developer and an absolute beginner in AI. I don't really understand how complex code will be to solve this problem and what effort it requires. I will really appreciate if you can explain to me and share some links/code examples(lang doesn't matter but would be good if it is JS or Python) of similar solved tasks, so I can solve my problem based on this.
Feel free to tell me if my explanation wasn't clear, I will try more simple words then:)
Thanks!
Your game sounds similar to Mastermind, only with numbers instead of colored pegs.
Googling "Mastermind AI" leads to e.g. this implementation using a genetic algorithm to solve Mastermind, which you could probably look at for inspiration.
While #AKX is correct that this is a variant of Mastermind, a genetic algorithm might not be the first place to look, as this is probably more complex that simpler approaches.
Donald Knuth is famous (among many other things) for working out a solution to the game. There is a good overview of this approach on the Puzzling Stack Exchange site, and if you look at the other answers on that question, there is also a discussion of how to code the solution.
In your case, the simple approach is to write a function that iterates from 0000 to 9999. These are all potential answers. But, when you iterate through the numbers you want to remove (1) all numbers with duplicate digits and (2) all numbers that are inconsistent with the guesses so far. Any other numbers can be put in an array or list storing potential answers. From these remaining numbers, you can just guess any number and then continue the process.
A more complicated approach would be to make the next guess using an algorithm similar to ID3 to try to find the guess that maximizes the information gain you get from the response. But, given how much information you get from each guess, this is unlikely to be needed.

How to learn Matplotlib without searching Google --

I am not really new to Matplotlib. I have made quite some figures with it, though I don't use it everyday (or every week, or even every month). So I tend to forget some basic things, for example, how to add a legend, how to add a color bar, how to customize a colormap, how to change the font of a specific part of the figure, how to make some transparency effect, etc. Of course, each time when I have a question, I can always google it and Google will most likely take me to stackoverflow or some other similar sites, or some blog articles, and I can almost always get a solution. This gives me an impression that the ``official'' documentation is not as useful as it should be.
But I must be wrong, namely, the official documentation must be very useful, otherwise how do those people who answer the questions know the solutions? Maybe they are ``insiders'' (developers of Matplotlib)?
So my question is, in case you are not a developer (but you are welcome to answer this question if you are), and suppose you have answered many Matplotlib-related questions here, how do you learn those techniques by yourself without asking Google? Where and how do you look for if the answer does not come to your mind immediately (not Google, because it is you who is answering that question, and before that maybe the answer does not exist in Google yet)?
Note that I am not complaining about the documentation. I think I just haven't found an efficient way to make use of it.
Or maybe finding the solution to a specific request is inevitably not straightforward due to the intrinsic complexity of Matplotlib? By intrinsic complexity, I mean in Matplotlib similar things can usually be done in many different ways, thus if one happens to choose one specific (and uncommon for whatever reasons) way in the beginning, and later comes across a problem, the solution to this problem may not have been listed explicitly in the manual, and maybe only those gurus who know how Matplotlib really works under the hood can come up with a solution.
I'm quite confused why it's under javascipt ... and think it's not so good to ask on SO, Quora instead.
BTW, learn by doing works for me many times.
(I really hope I have enough reputation to add a comment instead of answer it since it has not an explicit answer)

Creating mixed-height justified headlines?

I have a design that has a lot of three-line mixed-height headlines. Probably the easiest way to explain the look is with an example:
(For the purpose of this, ignore the fact that the last line has two words.)
Everything's fully-justified, but the font-size and kerning change depending on the length of the word.
Is there any way of doing this with either JavaScript or CSS?
I went through a boatload of libraries for this project, including:
FitText.js
Couldn't get it to work so that different lines are different sizes (I.e., justified, but not mixed-height).
BigText.js
Couldn't get it to work at all.
Stretch
I forget the issue with this, but it didn't work for my purposes.
Winner: SlabText
This is what I ended up using, and it works fantastic.
You can take a look at Adjusting Kerning in CSS for the CSS part and have you take a look at http://kerningjs.com/ ?

Finding a polygonal approximation of a Closed Path

I'd like to be able to find the best fitting polygonal approximation of a closed path (could be any path as they're being pulled out of images) but am having issues with how to approach coding an algorithm to find it.
I can think of a naive approach: every x amount of pixels along the path, choose the best fit line for those pixels, then brute force for different starting offsets and lengths and find the one that minimizes the least-square error with the minimum amount of lines.
There's got to be something more elegant. Anyone know of anything? Also, (cringe) but this is going to be implemented in javascript unless I get really desperate, so nice libraries that do things for you are pretty much ruled out, (opencv has a polygonal fitter for instance).
D3.js1 has some adaptive resampling code that you might be able to use. There's also an illustrated description of the algorithm used (Visvalingam’s algorithm).
The Ramer–Douglas–Peucker algorithm seems appropriate here, and is simple to implement.
Note that the acceptable error is an input to this algorithm, so if you have a target number of lines you can binary-search using the error parameter to hit the target.

Javascript 3d-like carousel for complex content

I have been spending about 7 hours today, trying to:
a) Create my own carousel using intensive javascript and CSS3 features (see this pastebin)
b) Setup and integrate the Roundabout plugin from FredHQ
c) Setup and integrate the Cloud Carousel plugin from Professor Cloud
Both third party solutions were tried because i failed in accomplishing what i wanted by myself. Unfortunately, both solutions do not work the way i would require them to. Both are amazing for displaying images, but i need to show more complex content, a heavily styled DIV with multiple encapsulated DIVs inside, PNGs with transparency, and so forth.
FredHQ's version did not work as it did not scale the content inside my DIVs. Not even the text was scaled, until i removed the font-size parameter, but that is something i need for a proper layout. Cloud's version works with images only.
I have hit a wall and i cannot seem to find any other solution. It seems the word "carousel" is used for slideshows and sliders, so i find hundreds of such solutions, but not one that works like i need it to.
What i need is decreasing opacity on further objects, while the center one is at full opacity. Also further objects should be scaled down by certain scale factors. It does not have to be 3D (not desired, even), but due to the scaling it would look 3d-like.
It does not have to be jQuery, although its probably a good idea if it is.
Does anybody know or can anyone point me to a proper solution?
Have you looked at monete(git), http://www.jacklmoore.com/monte? 184 line. Not sure you'll find something easier to dig into and make it work your way. Hundreds of solutions? So I'll take it you looked at the cycle plugin as well. That's probably one of the most mature and robust ones out there. You're asking for a lot in your question and these kind of question just wear people out after a while. That's all.
You probably won't find anything that fits your needs EXACTLY and you'll have to roll it yourself or hire someone. If you get something going and come back for specific help, you'll fair much better.

Categories