Bioinformatics/Global alignment: Difference between revisions

m
syntax highlighting fixup automation
(→‎{{header|Perl}}: added Pascal by prepending to perl)
m (syntax highlighting fixup automation)
Line 58:
{{trans|Nim}}
 
<langsyntaxhighlight lang=11l>-V ACGT = [‘A’, ‘C’, ‘G’, ‘T’]
 
F permutations(slist)
Line 137:
L(test) TestSequences
V scs = shortestCommonSuperstring(test)
printCounts(scs)</langsyntaxhighlight>
 
{{out}}
Line 185:
=={{header|Go}}==
{{trans|Julia}}
<langsyntaxhighlight lang=go>package main
 
import (
Line 355:
printCounts(scs)
}
}</langsyntaxhighlight>
 
{{out}}
Line 403:
{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''
<syntaxhighlight lang=jq>
<lang jq>
### Generic helper functions
 
Line 415:
range(0;length) as $i
| [.[$i]] + (del(.[$i])|permutations)
end ;</langsyntaxhighlight><syntaxhighlight lang =jq>
# Give a synoptic view of the input string,
# highlighting the occurrence of ACGTU letters
Line 475:
else . end)
| .shortestsuper;
</syntaxhighlight>
</lang>
'''The specific tasks'''
<syntaxhighlight lang=jq>
<lang jq>
def examples:
[
Line 509:
| "Task \($i+1):", ($examples[$i]|t), "";
 
tasks</langsyntaxhighlight>
{{out}}
<pre>
Line 558:
 
=={{header|Julia}}==
<langsyntaxhighlight lang=julia>using Combinatorics
 
""" Given a DNA sequence, report the sequence, length and base counts"""
Line 639:
printcounts(scs)
end
</langsyntaxhighlight>{{out}}
<pre>
Nucleotide counts for TAAGAA:
Line 684:
=={{header|Nim}}==
{{trans|Wren}}
<langsyntaxhighlight lang=Nim>import algorithm, sequtils, strformat, strutils, tables
 
const ACGT = ['A', 'C', 'G', 'T'] # Four DNA bases.
Line 765:
for test in TestSequences:
let scs = test.shortestCommonSuperstring
scs.printCounts()</langsyntaxhighlight>
 
{{out}}
Line 812:
Here nearly no runtime.But see [[N-queens_problem]] that using permutation is not the way for > 17<BR>
Of course this is more a traveling salesman problem.
<langsyntaxhighlight lang=pascal>
program BaseInDNA;
{$IFDEF FPC}
Line 1,103:
find;
END.
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,127:
 
=={{header|Perl}}==
<langsyntaxhighlight lang=perl>#!/usr/bin/perl
 
use strict; # https://rosettacode.org/wiki/Bioinformatics/global_alignment
Line 1,210:
use Data::Dump 'dd'; dd \%ch;
}
}</langsyntaxhighlight>
{{out}}
<pre>
Line 1,227:
 
=={{header|Phix}}==
<!--<langsyntaxhighlight lang=Phix>(phixonline)-->
<span style="color: #008080;">procedure</span> <span style="color: #000000;">printcounts</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">ss</span><span style="color: #0000FF;">)</span>
<span style="color: #000080;font-style:italic;">-- Given DNA sequence(s), report the sequence, length and base counts</span>
Line 1,312:
<span style="color: #0000FF;">}</span>
<span style="color: #7060A8;">papply</span><span style="color: #0000FF;">(</span><span style="color: #000000;">tests</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">shortest_common_superstring</span><span style="color: #0000FF;">)</span>
<!--</langsyntaxhighlight>-->
{{out}}
(Shows three length-6 results for the first test)
Line 1,343:
{{trans|Go}}
 
<langsyntaxhighlight lang=python>import os
 
from collections import Counter
Line 1,459:
#
# .. if you don't want all possible shortest superstrings.
</syntaxhighlight>
</lang>
 
{{out}}
Line 1,527:
{{trans|Go}}
{{trans|Julia}}
<syntaxhighlight lang=raku perl6line># 20210209 Raku programming solution
 
sub printCounts(\seq) {
Line 1,583:
>,
)
</syntaxhighlight>
</lang>
 
{{out}}
Line 1,607:
{{libheader|Wren-str}}
{{libheader|Wren-math}}
<langsyntaxhighlight lang=ecmascript>import "/fmt" for Fmt
import "/seq" for Lst
import "/str" for Str
Line 1,725:
var scs = shortestCommonSuperstring.call(test)
printCounts.call(scs)
}</langsyntaxhighlight>
 
{{out}}
10,333

edits