473,761 Members | 5,163 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Matching strings with a dictionary built from a flat file

19 New Member
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:

>Musmusculusl et-7g
UGAGGUAGUAGUUUG UACAGU
>Musmusculusl et-7i
UGAGGUAGUAGUUUG UGCUGU

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 '>Musmusculusle t-7g' and the value 'UGAGGUAGUAGUUU GUACAGU' 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
0 1114

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

Similar topics

2
2348
by: Christopher Boomer | last post by:
Until now I have been using XSLT to translate from a known foreign XML format to a local XML format for import to Postgres. Now I need to be able to let others define the relationship from new foreign documents using a gui. My thought was to generate a flat dictionary representation of the foreign and local formats with the absolute Xpath expression as dictionary key. The user is presented with a list of elements&attributes in the...
17
14066
by: Andrew McLean | last post by:
I have a problem that is suspect isn't unusual and I'm looking to see if there is any code available to help. I've Googled without success. Basically, I have two databases containing lists of postal addresses and need to look for matching addresses in the two databases. More precisely, for each address in database A I want to find a single matching address in database B. I'm 90% of the way there, in the sense that I have a simplistic...
12
2243
by: Antoon Pardon | last post by:
Well at least I find them missing. For the moment I frequently come across the following cases. 1) Two files, each with key-value pairs for the same dictionary. However it is an error if the second file contains a key that was not in the first file. In treating the second file I miss a 'set' method. dct.set(key, value) would be equivallent to dct = value,
12
2710
by: David W. Thorell | last post by:
I am trying to write a basic spell check function, one which has as its parameters two strings arrays, one is an article from a file source which needs to be checked for valid words, in this case the word needs to be at least 2 characters long with no intervening punctuation, numbers or other non-letters. This word then needs to be lower case and then compared to the dictionary input array. the end result being the printing out of all the...
2
1543
by: Berimor | last post by:
Hey guys, has anybody scripted online translators? I got the task to build one but it should traslate big pieces of text at once - up to 5000 words!!! Traslation is simple - just words replacing. How to create dictionary correct - DB based or file with plain text? I'm searching the way to gain as much speed as possible. I realise - (not sure) that most convinient would be to read all dictionary into the hash (native => alien) and then...
2
3398
by: Ole Nielsby | last post by:
First, bear with my xpost. This goes to comp.lang.c++ comp.lang.functional with follow-up to comp.lang.c++ - I want to discuss an aspect of using C++ to implement a functional language, and I'd like the attention of fp as well as C++ gurus if available. The language I'm implementing - PILS - is dynamically
9
4319
by: Chris | last post by:
Is anyone aware of any prior work done with searching or matching a pattern over nested Python lists? I have this problem where I have a list like: , 9, 9], 10] and I'd like to search for the pattern so that is returns: , 9, 9], 10] , 9, 9]
2
1245
by: Joe Strout | last post by:
Catching up on what's new in Python since I last used it a decade ago, I've just been reading up on template strings. These are pretty cool! However, just as a template string has some advantages over % substitution for building a string, it seems like it would have advantages over manually constructing a regex for string matching. So... is there any way to use a template string for matching? I expected something like: templ =...
0
173
by: Joe Strout | last post by:
On Oct 9, 2008, at 7:05 AM, skip@pobox.com wrote: Right. Well, what do y'all think? It wouldn't be too hard to write this for myself, but it seems like the sort of thing Python ought to have built in. Right on the Template class, so it doesn't add anything new to the global namespace; it just makes this class more useful.
0
9336
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9948
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6603
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.