By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,898 Members | 1,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

Matching strings with a dictionary built from a flat file

P: 19
Hello again,

I am still working on my same project and have run into another little problem. I have created a flat file with data from a server, each line looks like this:

BLAT Search Results
ACTIONS QUERY SCORE START END QSIZE IDENTITY CHRO STRAND START END SPAN
---------------------------------------------------------------------------------------------------
browser details Musmusculuslet-7g 21 1 21 21 100.0% 22 + 46884872 46884892 21
browser details Musmusculuslet-7i 21 1 21 21 100.0% 5 + 50605174 50605194 21

My original input looked like this:

>Musmusculuslet-7g
UGAGGUAGUAGUUUGUACAGU
>Musmusculuslet-7i
UGAGGUAGUAGUUUGUGCUGU

As you can see, the original RNA codes were deleted in the reply. Also, my replies are sorted differently and have multiple matches in some cases, so I want to create a library that has all of my matches, and then feed in the above file and add the RNA codes whenever it finds the matching Musmusculus statements. I have the following code, but it just matches an exact string:

Expand|Select|Wrap|Line Numbers
  1. DictionaryMaker ( filename ):
  2.     dict = {}
  3.     for i in dict.keys(practice):
  4.     if  i == string:
  5.         print 'Yes there is a match!'
  6.         string = string + ' ' + practice[i]
  7.  
  8.  
  9.  
I also need to read in the data I have for the dictionary somehow to build my dictionary from my flat file. The key should be '>Musmusculuslet-7g' and the value 'UGAGGUAGUAGUUUGUACAGU' from above. Is there an easy way to read this in from a file containing all of these sequences?

Any help would be appreciated!

Mark
Aug 2 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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