PDA

View Full Version : Searching for a Consensus sequence



emem
02-13-2008, 11:18 AM
Hello,

I'm hoping that someone maybe able to point me in the right direction. I'm wishing to search a large spreadsheet (~3000 rows) for matchs to a specific text sequence. In col A there are peptide sequences, these are represented by letters, we are interested in peptides that have specific letters spaced apart
The consensus sequence is
[A,B,C,D] (x) [E,F,G] (x) X X [H,I] X X X [A,B,C,D]

where [] can be either of these letters
(x) may or mat not be present
X is any letter

the sequence will also be part of a text string within the cell e.g

FGTANFHPUHIEDCPOL

where the bit underlined would be a TRUE value for the search and excel would copy this whole section and paste it somewhere else(column or worksheet).
I know a wee bit about excel and VBA but this problem is giving me brain damage, I can't even think of a decent place to start.

So I was hoping that someone may have any ideas of the best way to go about this, I hope that I have explained it OK. I've attached a very small sample sheet which helps the explaination.

Many Thanks

Em

mikerickson
02-13-2008, 01:14 PM
Hello,

The consensus sequence is
[A,B,C,D] (x) [E,F,G] (x) X X [H,I] X X X [A,B,C,D]

where [] can be either of these letters
(x) may or mat not be present
X is any letter


The syntax of your example is very much like that used for the Like comparison.

Your loop would be


Dim oneCell as Range
For each oneCell in Range("A1:A1000")
If oneCell.Value Like "[A-D]?[E-F]???[HI]???[A-D]" Or _
oneCell.Value Like "[A-D][E-F]???[HI]???[A-D]" Or _
oneCell.Value Like "[A-D]?[E-F]??[HI]???[A-D]" Or _
oneCell.Value Like "[A-D][E-F]??[HI]???[A-D]" Then

MsgBox "Found in " & oneCell.Address

End If
Next oneCell