Bioinformatics/Subsequence: Difference between revisions

Line 316:
=={{header|Ring}}==
<lang ring>
/*-----------------------------------
load "consolecolors.ring"
# Project : DNA subsequences
# Date : 2021/03/23
# Author : Gal Zsolt (~ CalmoSoft ~)
# Email : <calmosoft@gmail.com>
-----------------------------------*/
 
load "stdlibcore.ring"
row = 0
load "guilib.ring"
 
base = ["A","C","G","T"]
dnaList = []
dnaSeq = []
ColLine = list(21)
base = ["A","C","G","T"]
long = 20
plus = 0
see "DNA sequence:" + nl + nl
see " 12345678901234567890" + nl
see " " + long + ": "
 
C_Spacing = 2
for nr = 1 to 200
row = row + 1
rnd = random(3)+1
baseStr = base[rnd]
see baseStr
plusLine()
add(dnaList,baseStr)
next
see nl+ " 12345678901234567890" + nl
 
C_ButtonDnaStyle = ' background-color: Red; border-radius: 8px;'
strDna = list2str(dnaList)
strDna = substr(strDna,nl,"")
 
Button = newlist(10,20)
while true
LayoutButtonRow = list(10)
strBase = ""
for n = 1 to 4
rnd = random(3)+1
strBase = strBase + base[rnd]
next
ind = substr(strDna,strBase)
if ind > 0
exit
ok
end
 
app = new qApp
see nl + "subsequence to search: " + strBase + nl
{
win = new qWidget() {
setWindowTitle('DNA subsequences')
setWinIcon(self,AppFile("white.jpg"))
setStyleSheet('background-color:White')
setgeometry(560,180,300,300)
//reSize(400,400)
winheight = 10
fontSize = 8 # + (winheight / 100)
 
LayoutButtonMain = new QVBoxLayout()
seqok = 0
LayoutButtonMain.setSpacing(C_Spacing)
see "start positions of subsequence : "
LayoutButtonMain.setContentsmargins(0,0,0,0)
for Col = 1 to 21
ColLine[Col] = new qLabel(win) {
setmaximumheight(20)
setAlignment(Qt_AlignHCenter | Qt_AlignVCenter)
setStyleSheet("background-color:darkgray")
setText(string(Col-1))
}
next
LayoutTitleRow = new QHBoxLayout() { setSpacing(C_Spacing) setContentsMargins(0,0,0,0) }
 
for nCol = 1 to 19621
LayoutTitleRow.AddWidget(ColLine[Col])
flag = 1
for m = 0 to 3 next
if dnaList[n+m] != strBase[m+1]
flag =LayoutButtonMain.AddLayout(LayoutTitleRow) 0
exit
ok RowLine = list(10)
next
if flag = 1
add(dnaSeq,n)
seqok = 1
see "" + n + " "
ok
next
 
for Row = 1 to 10
if seqok = 0
Letter = "" + Row*20
see "sequence not found" + nl
if Row*20 < 100
ok
Letter = " " + Row*20
ok
RowLine[Row] = new qLabel(win) { //setFont(new qFont("Verdana",fontSize,40,0))
setAlignment(Qt_AlignHCenter | Qt_AlignVCenter)
setStyleSheet("background-color:darkgray")
setText(Letter)
}
next
for Row = 1 to 10
LayoutButtonRow[Row] = new QHBoxLayout()
{
setSpacing(C_Spacing)
setContentsmargins(0,0,0,0)
}
 
LayoutButtonRow[Row].AddWidget(RowLine[Row])
row = 0
showDna(dnaList)
for Col = 1 to 20
Button[Row][Col] = new QPushButton(win) {
setmaximumwidth(20)
}
LayoutButtonRow[Row].AddWidget(Button[Row][Col])
next
LayoutButtonMain.AddLayout(LayoutButtonRow[Row])
next
 
LayoutDataRow = new QHBoxLayout() { setSpacing(C_Spacing) setContentsMargins(0,0,0,0) }
//LayoutDataRow.AddWidget(PlayScoreBlack)
setLayout(LayoutButtonMain)
pStart()
show()
}
exec()
}
 
//-----------------------------------------
 
func pStart()
for nr = 1 to 200
rnd = random(3)+1
baseStr = base[rnd]
row = ceil(nr/20)
col = nr%20
if col = 0
col = 20
ok
Button[row][col].settext(baseStr)
add(dnaList,baseStr)
next
startDna()
 
//-----------------------------------------
 
func startDna()
 
strDna = list2str(dnaList)
strDna = substr(strDna,nl,"")
 
while true
strBase = ""
for n = 1 to 4
rnd = random(3)+1
strBase = strBase + base[rnd]
next
ind = substr(strDna,strBase)
if ind > 0
exit
ok
end
 
seqok = 0
 
for n = 1 to 196
flag = 1
for m = 0 to 3
if dnaList[n+m] != strBase[m+1]
flag = 0
exit
ok
next
/*if flag = 1
add(dnaSeq,n)
seqok = 1
//see "" + n + " "
ok*/
next
showDna(dnaList)
 
//-----------------------------------------
 
func showDna(dnaList)
 
long = 20
strDna = list2str(dnaList)
see nl + "found subsequences:" + nl + nl
strDna = substr(strDna,nl,"")
see " 12345678901234567890" + nl
 
see " " + long + ": "
while true
for nr = 1 to len(dnaList)
if plus strBase = 0""
for rown = row1 +to 14
ok rnd = random(3)+1
if plus strBase = 1strBase + base[rnd]
nr = nr + 3next
rowind = row + 1substr(strDna,strBase)
if plusLine()ind > 0
exit
ok
end
 
for n = 1 to 196
flag = 1
for m = 0 to 3
if dnaList[n+m] != strBase[m+1]
flag = 0
exit
ok
next
if flag = 1
add(dnaSeq,n)
seqok = 1
see "" + n + " "
ok
next
 
for nr = 1 to len(dnaList)
ind = find(dnaSeq,nr)
if ind > 0
for n = nr to nr + 3
cc_print(CC_BG_DARK_REDrow |= CC_FG_WHITE,dnaList[ceil(n]/20)
ifcol n != nrn%20
if rowcol = row + 10
ok col = 20
plusLine()ok
Button[row][col].setStyleSheet(C_ButtonDnaStyle)
Button[row][col].settext(dnaList[n])
next
plus = 1
if (row%20) = 0
row = row + 1
nr = nr + 1
ok
else
plus = 0
see dnaList[nr]
ok
next plusLine()
next
see nl+ " 12345678901234567890" + nl
 
//-----------------------------------------
func plusLine()
if (row%20) = 0 and long < 200
long = long + 20
see nl
if long < 100
see " " + long + ": "
else
see "" + long + ": "
ok
ok
</lang>
[https://youtu.be/mwzp3qsgvZk Bioinformatics/Subsequence - video]
{{out}}
<pre>
DNA sequence:
 
12345678901234567890
20: CAGTAAATAAGGAGAACAGG
40: GATCTATCTGCGCAGTTGTT
60: CAAATCAAGAGGAAAAAGTT
80: AAATCCAACACGGTAGGATG
100: CATTGAAAGGTTGCGTAAGA
120: AAAAAGGAGGGAAATGATCG
140: AAACAAAGTACGTCAATTAG
160: ATGCCAAAGACCGATAAAAG
180: GTATTAGTATTAGAGCAGCG
200: AATGAGGAAGACTTCGAGAA
12345678901234567890
 
subsequence to search: AAGA
start positions of subsequence : 47 97 147 188
found subsequences:
 
12345678901234567890
20: CAGTAAATAAGGAGAACAGG
40: GATCTATCTGCGCAGTTGTT
60: CAAATC<span style="color: #CC0000;">AAGA</span>GGAAAAAGTT
80: AAATCCAACACGGTAGGATG
100: CATTGAAAGGTTGCGTAAGA
120: AAAAGGAGGGAAATGATCG
140: AAACAAAGTACGTCAATTAG
160: ATGCCAAAGACCGATAAAAG
180: GTATTAGTATTAGAGCAGCG
200: AATGAGGAAGACTTCGAGAA
12345678901234567890
</pre>
 
=={{header|Wren}}==
2,468

edits