/    Sign up×
Community /Pin to ProfileBookmark

Please help

Hi when i put the code CTGATGACATAGACA in , Why does my alert box say start codon not found insted of postion 3.
This is the code i am working to

function findStartCodon(someBases, startingPlace) {

var startCodonAt = -1;
var aCodon = ”;
var codonFound = false;

while ((codonFound == false) && ((startingPlace + 3) <= someBases.length)) {

aCodon = someBases.substring(startingPlace, startingPlace + 3);

if (aCodon == ‘ATG’) {

startCodonAt = startingPlace;
codonFound = true;
} else {

startingPlace = startingPlace + 3;
}
}

return (startCodonAt);
}

function testFindStartCodon() {

var startCodonAt = -1;

var someGeneticInfo = this.document.testForm.sequenceString.value;

startCodonAt = findStartCodon(someGeneticInfo);

if (startCodonAt != -1) {

window.alert(“The beginning of the start codon is at position ” + startCodonAt + “.”);
}else {

window.alert (“The start codon was not found in this sequence.”);
}
}

Would be gratefull of any help
Daz

to post a comment
JavaScript

11 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceMay 26.2006 — Perhaps this:

startCodonAt = findStartCodon(someGeneticInfo);

should be this:

startCodonAt = findStartCodon(someGeneticInfo, 0);
Copy linkTweet thisAlerts:
@ZappauthorMay 26.2006 — Have tried that but dosent seem to work
Copy linkTweet thisAlerts:
@phpnoviceMay 27.2006 — Get an Interactive JavaScript Debugger and step through your code to see just where it fails.
Copy linkTweet thisAlerts:
@ZappauthorMay 27.2006 — Sorry that did work

But i am strugling with the reverse this is what i have done so far

function findStopCodon(someBases, startingPlace) {

var stopCodonAt = -1;
var aCodon = '';
var codonFound = false;

while((codonFound == false) && ((startingPlace + 3) <=somebases.length));
aCodon = someBases.substing(startingPlace, startingPlace +3);
if (aCodon == 'TGA, TAG, TAA'){

stopCodonAt = startingPlace;
codonFound = true;
} else {
startingPlace = startingPlace + 3;
}
}
return (stopCodonAt);
}

function testFindStopCodon() {

var stopCodonBeginsAt = -1;

var someGeneticInfo = this.document.testForm.sequenceString.value;

stopCodonBeginsAt = findStopCodon(someGeneticInfo, 0);

if (stopCodonBeginsAt != -1) {

window.alert ("The beginning of the stop codon is at position " + stopCodonBeginsAt + ".");
} else {

window.alert ("The stop codon was not found in this sequence.");
}
}

Any ideas???
Copy linkTweet thisAlerts:
@phpnoviceMay 27.2006 — But i am strugling with the reverse...[/QUOTE]
What do you mean?
Copy linkTweet thisAlerts:
@ZappauthorMay 27.2006 — I am now trying to find the stop point but unlike the first one the are 3 possible stop points.

When i run the code in my first post it just says invalid return

not sure where im going wrong but guessing its a logic problem???

Hope this makes sense

Daz
Copy linkTweet thisAlerts:
@phpnoviceMay 27.2006 — The second code post you made is missing an opening brace at the end of the [B]while[/B] statement line.
Copy linkTweet thisAlerts:
@netbuddyMay 27.2006 — if (aCodon == 'TGA, TAG, TAA'){

?

Are you looking for a string match of 'TGA, TAG, TAA' or ar you looking for 'TGA' or 'TAG' or 'TAA' ?
Copy linkTweet thisAlerts:
@ZappauthorMay 28.2006 — Are you looking for a string match of 'TGA, TAG, TAA' or ar you looking for 'TGA' or 'TAG' or 'TAA' ?

I am looking for 'TGA' or 'TAG' or 'TAA'

Cheers
Copy linkTweet thisAlerts:
@netbuddyMay 28.2006 — this...

if (aCodon == 'TGA, TAG, TAA'){

should be...

if (aCodon == 'TGA' || aCodon == 'TAG' || aCodon == 'TAA'){
Copy linkTweet thisAlerts:
@PuppazMay 29.2006 — Zapp, you do realise, that asking for help on this forum, for your final TMA of all things, is pretty much as plagaristic as you can get.
×

Success!

Help @Zapp spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...