P
paulinoluciano
Dear,
I have used the VBA code bellow in order to compute the molecular mass
(biochemistry) of a amino acid sequence. Since I have a sequence of
letters (Like LASFSDFGASASRTIY) on A4, it will display its molecular
mass on B4 when I run the macro. Now, I would like to use similar
script in order to get the subsequence displaying an specific molecular
mass or the nearest molecular mass.
Example:
If I have the sequence LASFSDFGASASRTIY I will get as molecular mass
the number 1692,82329.
I would like to put at cell A2 the molecular mass I would like to find
inside LASFSDFGASASRTIY. If I put 654,27347
in cell A2 I would receive as response the subsequence SDFGASA.
However, sometimes I will need to use a range with limits from 600 to
700. Therefore, at cells C4:C I would like to receive all possibilities
in such a range.
Do you have some suggestion?
Best regards,
Luciano
VBA code:
Sub MM()
'
' Protweight Macro
' Macro recorded 20/10/2005 by Luciano Paulino da Silva
'
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Application.ScreenUpdating = False
For i = 4 To iLastRow
For j = 1 To Len(Cells(i, "A").Value)
Select Case Mid$(Cells(i, "A").Value, j, 1)
Case "A": MW = MW + 71.03711
Case "C": MW = MW + 103.00919
Case "D": MW = MW + 115.02694
Case "E": MW = MW + 129.04259
Case "F": MW = MW + 147.06841
Case "G": MW = MW + 57.02146
Case "H": MW = MW + 137.05891
Case "I": MW = MW + 113.08406
Case "K": MW = MW + 128.09496
Case "L": MW = MW + 113.08406
Case "M": MW = MW + 131.04049
Case "N": MW = MW + 114.04293
Case "P": MW = MW + 97.05276
Case "Q": MW = MW + 128.05858
Case "R": MW = MW + 156.10111
Case "S": MW = MW + 87.03203
Case "T": MW = MW + 101.04768
Case "V": MW = MW + 99.06841
Case "W": MW = MW + 186.07931
Case "Y": MW = MW + 163.06333
y = y + 1.00782
Case Else: Z = Z + 1.00782
End Select
Next j
If MW > 18 Then
Cells(i, "B").Value = MW + 17.00274 + 1.00782 + 1.00782
End If
MW = 0
Next i
Application.ScreenUpdating = True
End Sub
I have used the VBA code bellow in order to compute the molecular mass
(biochemistry) of a amino acid sequence. Since I have a sequence of
letters (Like LASFSDFGASASRTIY) on A4, it will display its molecular
mass on B4 when I run the macro. Now, I would like to use similar
script in order to get the subsequence displaying an specific molecular
mass or the nearest molecular mass.
Example:
If I have the sequence LASFSDFGASASRTIY I will get as molecular mass
the number 1692,82329.
I would like to put at cell A2 the molecular mass I would like to find
inside LASFSDFGASASRTIY. If I put 654,27347
in cell A2 I would receive as response the subsequence SDFGASA.
However, sometimes I will need to use a range with limits from 600 to
700. Therefore, at cells C4:C I would like to receive all possibilities
in such a range.
Do you have some suggestion?
Best regards,
Luciano
VBA code:
Sub MM()
'
' Protweight Macro
' Macro recorded 20/10/2005 by Luciano Paulino da Silva
'
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Application.ScreenUpdating = False
For i = 4 To iLastRow
For j = 1 To Len(Cells(i, "A").Value)
Select Case Mid$(Cells(i, "A").Value, j, 1)
Case "A": MW = MW + 71.03711
Case "C": MW = MW + 103.00919
Case "D": MW = MW + 115.02694
Case "E": MW = MW + 129.04259
Case "F": MW = MW + 147.06841
Case "G": MW = MW + 57.02146
Case "H": MW = MW + 137.05891
Case "I": MW = MW + 113.08406
Case "K": MW = MW + 128.09496
Case "L": MW = MW + 113.08406
Case "M": MW = MW + 131.04049
Case "N": MW = MW + 114.04293
Case "P": MW = MW + 97.05276
Case "Q": MW = MW + 128.05858
Case "R": MW = MW + 156.10111
Case "S": MW = MW + 87.03203
Case "T": MW = MW + 101.04768
Case "V": MW = MW + 99.06841
Case "W": MW = MW + 186.07931
Case "Y": MW = MW + 163.06333
y = y + 1.00782
Case Else: Z = Z + 1.00782
End Select
Next j
If MW > 18 Then
Cells(i, "B").Value = MW + 17.00274 + 1.00782 + 1.00782
End If
MW = 0
Next i
Application.ScreenUpdating = True
End Sub