Jump to content

Bioinformatics/Subsequence: Difference between revisions

m
→‎{{header|REXX}}: moved some code to subroutines.
m (→‎{{header|REXX}}: added commas to the numbers in the output, enhanced title with the length that was used for data field width.)
m (→‎{{header|REXX}}: moved some code to subroutines.)
Line 65:
if rndDNA=='' | rndDNA=="," then rndDNA= copies(., rndLen) /*what we're looking for*/
if datatype(seed, 'W') then call random ,,seed /*used to generate repeatable random #s*/
call genRnd /*gen data field of random proteins. */
call show /*show " " end" " " */
say " index │"center(' DNA sequence of ' commas(totLen) " proteins", oWidth + 10)
say "───────┼"center('' , oWidth + 10, '─')
idx= 1 /*assign the index number of 1st line. */
$=; $$= /*gen data field of random proteins. */
do j=1 for totLen; c= substr( basePr, random(1, lenB), 1)
$$= $$ || c /*append a random protein.*/
if Bevery\==0 then if j//Bevery==0 then $= $' ' /*maybe add a blank. */
if length( space($ || c, 0) )<oWidth then do; $= $ || c; iterate /*width OK*/
end
say strip( right(idx, 7)'│' $, 'T'); $= /*display line──► terminal*/
idx= idx + oWidth /*bump the index number. */
end /*j*/
if $\=='' then say right(idx, 7)"│" strip($, 'T') /*display residual protein data.*/
say
say ' base DNA proteins used: ' basePr
say 'random DNA proteins used: ' dna?
call findRnd
@=; p=0 /*@: list of all found random proteins*/
do until p==0; p= pos(dna?, $$, p+1) /*find all overlapped positions in data*/
if p>0 then @= @ commas(p) /*Found one? Append it to the "Found"s*/
end /*p*/
say
if @=='' then do; say "the random DNA proteins weren't found."; exit 4; end
say 'the random DNA proteins were found in positions:' strip(@)
Line 92 ⟶ 75:
/*──────────────────────────────────────────────────────────────────────────────────────*/
commas: parse arg ?; do jc=length(?)-3 to 1 by -3; ?=insert(',', ?, jc); end; return ?
/*──────────────────────────────────────────────────────────────────────────────────────*/
findRnd: @=; p=0 p=0 /*@: list of allthe found randomtarget proteins*/
do until p==0; p= pos(dna?, $$, p+1); /*find all overlapped positions inif data*/p>0 then @= @ commas(p)
if p>0 then @= @ commas(p) /*Found one? Append it to the "Found"s*/
end /*p*/; return
/*──────────────────────────────────────────────────────────────────────────────────────*/
genRnd: dna?=; use= basePr; upper use basePr rndDNA; lenB= length(basePr)
Line 100 ⟶ 88:
dna?= dna? || x /*build a random protein seq.*/
end /*k*/
return</lang>
/*──────────────────────────────────────────────────────────────────────────────────────*/
show: say " index │"center(' DNA sequence of ' commas(totLen) " proteins", oWidth + 10)
say "───────┼"center('' , oWidth + 10, '─')
$=; $$=; idx= 1 /*gen data field of random proteins. */
do j=1 for totLen; c= substr( basePr, random(1, lenB), 1)
$$= $$ || c /*append a random protein. */
if Bevery\==0 then if j//Bevery==0 then $= $' ' /*maybepossibly add a blank. */
if length( space($ || c, 0) )<oWidth then do; $= $ || c; iterate; /*width OK*/end
say strip( right(idx, 7)'│' $, 'T'); $= /*display line──►line ──► terminal.*/
idx= 1 idx= idx + oWidth /*assignbump the index number. of 1st line. */
end /*j*/
if $\=='' then say right(idx, 7)"│" strip($, 'T') /*displayshow residual protein data.*/
say; return</lang>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
Cookies help us deliver our services. By using our services, you agree to our use of cookies.