1
Hello ! I have a problem in my condition in the while cycle . It does not recognize when it should stop and is in an infinite loop. The purpose of the function is to count what is between "a" "t" "g" and "t" "a" "g" or "t" "g" "a" or "t" "a" "a". If anyone can help would appreciate :) .
orfs<-function(x,p){
count<-0
cntorfs<-0
n<-length(x)
v<-n-2
for (i in 1:v){
if(x[i]=="a"&& x[i+1]=="t"&& x[i+2]=="g"){
k<-i+3;
w<-x[k]
y<-x[k+1]
z<-x[k+2]
while (w!="t"&&y!="a"&& z!="g" ||w!="t" &&y!="a"&&z!="a"||w!="t"&&y!="g"&& z!="a"){
count<-count+1
k<-k+1
w<-x[k]
y<-x[k+1]
z<-x[k+2]
}
}
if(count>p){
cntorfs<-cntorfs+1
}
if (count!=0){
count<-0
}
}
cat("orf:",cntorfs)
`insira o código aqui`}
Should this code detect an ORF in a genetic sequence? 'Cause if it is, I bet it has R functions that will do this job faster, without having to reinvent the wheel.
– Marcus Nunes
Yes it is to count Orfs. The exercise my teacher gave me told me to do a function that includes the Orfs present in a genetic code. This genetic code came from a FASTA file.
– Hotfinger
Does the exercise require a loop? It is possible to work with genetic sequence as a text string, using functions such as strsplit and length to isolate and check sequence size.
– Carlos Eduardo Lagosta
No , but in the meantime I have already built a code that theoretically meets the Orfs. I had to exchange my cycle "for" for a "while".
– Hotfinger
See the package Lncfinder.
– Rui Barradas