473,320 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Basic programming question on find() function

I am familiar with the notation
>>>dna = ....
>>>Ecori = "ATGATG"....
>>>find(dna, Ecori)
>>>find(dna,Ecori, 2)

My question is how to i find the second undefined base 'n'
ie.
>>>seq = 'ATGATGnATGnATG'
>>>find(seq, 'n')
6
>>>find(seq, 'n', 2)
6 Does not work - Should say 10
Mar 22 '10 #1

✓ answered by bvdet

Your argument '2' is the starting index position, not the second occurrence. Example:
Expand|Select|Wrap|Line Numbers
  1. >>> import string
  2. >>> string.find('ATGATGnATGnATG', 'n', 2)
  3. 6
  4. >>> string.find('ATGATGnATGnATG', 'n', 7)
  5. 10
  6. >>> 
The string module has been deprecated for a while now. You should use str object methods instead.
Expand|Select|Wrap|Line Numbers
  1. >>> 'ATGATGnATGnATG'.find('n', 2)
  2. 6
  3. >>> 'ATGATGnATGnATG'.find('n', 7)
  4. 10
  5. >>> 

2 1879
bvdet
2,851 Expert Mod 2GB
Your argument '2' is the starting index position, not the second occurrence. Example:
Expand|Select|Wrap|Line Numbers
  1. >>> import string
  2. >>> string.find('ATGATGnATGnATG', 'n', 2)
  3. 6
  4. >>> string.find('ATGATGnATGnATG', 'n', 7)
  5. 10
  6. >>> 
The string module has been deprecated for a while now. You should use str object methods instead.
Expand|Select|Wrap|Line Numbers
  1. >>> 'ATGATGnATGnATG'.find('n', 2)
  2. 6
  3. >>> 'ATGATGnATGnATG'.find('n', 7)
  4. 10
  5. >>> 
Mar 22 '10 #2
Thanks so much - your really helpful :)
Mar 22 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: AK | last post by:
I don't want any part of the previous discussion on Visual Basic versus Visual Basic.Net. My query is about using Visual Basic for Applications; and whether it is better to use Visual Basic 6 or...
1
by: Rookie | last post by:
I have done a lot of programming some time ago using Fortran and various varieties of the Basic programming languages, Hewlett Packard Technical Basic, QBasic, Quick Basic. With each of these...
2
by: Mark R Rivet | last post by:
I've installed JDK1.1.5 on my windows 2000 professional system and when I give it the command ( in a command prompt window) to compile, it does, but when I try to run the program I get this...
3
by: rgb | last post by:
I've got Visual Studio 6.0 and I'm working on a Visual Basic applicaiton. There a couple parts that really require C. I've done C programming on a mainframe but nothing on a PC. So I'm trying to...
4
by: Mark Linehan | last post by:
Greetings and salutations. I began programming God knows how many years ago in basic on the Commodore 64. I dabbled in a little assembly as well. I moved on to the PC eventually and stuck with...
13
by: usenet | last post by:
How and where can one find out about the basics of VB/Access2003 syntax? I am a died in the wool C/C++/Java Linux/Unix programmer and I am finding it difficult to understand the program format...
97
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in...
6
by: Simon Walsh | last post by:
I'm an Electronics student in college and I'm currently working on a project. I was given a circuit diagram for my project, from which I had to design a printed circuit board to be sent off and...
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
14
by: MartinRinehart | last post by:
Working on parser for my language, I see that all classes (Token, Production, Statement, ...) have one thing in common. They all maintain start and stop positions in the source text. So it seems...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.