Question: Best Dynamic Reverse Complement In Html/Javascript
2
gravatar for Casbon
8.9 years ago by
Casbon3.2k
Casbon3.2k wrote:

We should be ashamed of ourselves. All the web resources for reverse complementing a piece of DNA are straight from the 90s, requiring a round trip to the server and opening a new window. We can do better. (I'm not linking to any examples on purpose).

Please post a piece of HTML that computes the reverse complement for DNA entered into a textarea that dynamically displays the result using client side javascript. This should not require a form submit and therefore work without a server. Bonus points for handling degenerate characters correctly and preserving FASTA header lines.

codegolf • 4.1k views
ADD COMMENTlink modified 12 months ago by zx87548.3k • written 8.9 years ago by Casbon3.2k
9

Personally, I think we should be ashamed with ourselves if we have to use a web-browser to reverse complement a sequence.

ADD REPLYlink written 8.9 years ago by Gww2.7k
1

check this out: http://www.ualberta.ca/~stothard/javascript/rev_comp.html

ADD REPLYlink written 8.9 years ago by Gerd10
1

+1 This is a real javascript implementation. It opens a window, which may look like a CGI behavior. That website is really good. The developer has put a lot of efforts.

ADD REPLYlink written 8.8 years ago by lh331k

OK, so its client side but its not dynamic, right?

ADD REPLYlink written 8.9 years ago by Casbon3.2k

You mean copy and paste of sequence in the Textarea form should automatically generate reserve complement? Or if I keep on typing sequences in the Textarea should keep on generating reserve strand?

ADD REPLYlink written 8.9 years ago by Thaman3.2k

Personally I do not like another window with results popping out at the other corner of the screen but this is probably a matter of taste.

ADD REPLYlink written 6.3 years ago by audrius.meskauskas100
1

If you need to reverse complement a sequence as part of an application/pipeline, or if the sequence is large, I agree with GWW - you shouldn't consider a web solution (too slow, consumes network bandwidth). For once-off small tasks, I see nothing wrong with a web tool for convenience. @Casbon, if people are going to use the tool for small sequences, I don't think there is an urgent need for a completely client-side solution - savings are minimal. Out of interest, why are you asking the community to write this? Do you intend to make it available on a server?

ADD REPLYlink written 8.9 years ago by Bio_X2Y3.7k

When we look for troubles in alignments etc., having a web page like this would be convenient.

ADD REPLYlink written 8.8 years ago by lh331k

Writing a code reverse complement may look trivial, but if you do not want your tool to be substandard, please consider the features that a current user normally expacts: the correct handling of nucleotide ambiquity codes, preserving upper/lowercase, handling spaces/numbers/newlines/FASTA header as expected and the like.

ADD REPLYlink modified 6.3 years ago • written 6.3 years ago by audrius.meskauskas100
3
gravatar for lh3
8.8 years ago by
lh331k
United States
lh331k wrote:

As an exercise. BTW, my favorite javascript program is this one.

ADD COMMENTlink written 8.8 years ago by lh331k
1

This is a link to the Editor for Phylogenetic Trees. It is not doing anything relevant to the question.

ADD REPLYlink written 6.3 years ago by audrius.meskauskas100
1
gravatar for Pierre Lindenbaum
8.8 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum123k wrote:

I've not time to answer for a reverse-complement sequence but I played with Mozilla XUL+javascript to translate a DNA sequence to protein: see my post here.

The code for your challenge would be nearly identical, and even shorter.

alt text

ADD COMMENTlink modified 6 weeks ago by RamRS24k • written 8.8 years ago by Pierre Lindenbaum123k

All I get there is "Sorry, the page you were looking for in this blog does not exist. "

ADD REPLYlink written 6.3 years ago by audrius.meskauskas100

look closer: the URL in my post was cut by the biostars HTML renderer.

ADD REPLYlink written 6.3 years ago by Pierre Lindenbaum123k

Note: The URL problem has now been fixed.

ADD REPLYlink written 6 weeks ago by RamRS24k
1
gravatar for Alex Reynolds
5.5 years ago by
Alex Reynolds29k
Seattle, WA USA
Alex Reynolds29k wrote:

Since we're playing code golf, paste the following in your browser's address field or web/JS console, replacing the variable s with your sequence of interest:

javascript:s='ACGTT';o=s.split();for(i=0;i<s.length;i++)o[i]=s.charAt(i).replace(/[ACGTacgt]/g,function(c){return {'A':'T','C':'G','G':'C','T':'A','a':'t','c':'g','g':'c','t':'a'}[c];});alert(o.reverse().join(''));

If you want to handle a degenerate nucleotide case, just add its base to the regex in the replace call and its associated complement base in the callback function map function(c){...}.

$ echo "javascript:s='ACGTT'..." | wc -c
 215

Probably not too practical, but then code golf isn't about usability.

ADD COMMENTlink modified 6 weeks ago by RamRS24k • written 5.5 years ago by Alex Reynolds29k
0
gravatar for Audriusa
7.7 years ago by
Audriusa10
Switzerland
Audriusa10 wrote:

In our site (reverse-complement.com) we have JavaScript based tools to compute reverse complement that preserves FASTA header and upper-lowercase regions (these can be used to mark various sequences of interest). We also have JavaScript based protein translator and the tool to convert between plain sequence and formatted GenBank representation, both ways. It is easy to share such services with anybody who is interested in as in comparison to server side solutions it scales very well.

ADD COMMENTlink written 7.7 years ago by Audriusa10
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1237 users visited in the last hour