close

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, quot;Aquot;).End(xlUp).Row
Application.ScreenUpdating = False
For i = 4 To iLastRow
For j = 1 To Len(Cells(i, quot;Aquot;).Value)
Select Case Mid$(Cells(i, quot;Aquot;).Value, j, 1)
Case quot;Aquot;: MW = MW 71.03711
Case quot;Cquot;: MW = MW 103.00919
Case quot;Dquot;: MW = MW 115.02694
Case quot;Equot;: MW = MW 129.04259
Case quot;Fquot;: MW = MW 147.06841
Case quot;Gquot;: MW = MW 57.02146
Case quot;Hquot;: MW = MW 137.05891
Case quot;Iquot;: MW = MW 113.08406
Case quot;Kquot;: MW = MW 128.09496
Case quot;Lquot;: MW = MW 113.08406
Case quot;Mquot;: MW = MW 131.04049
Case quot;Nquot;: MW = MW 114.04293
Case quot;Pquot;: MW = MW 97.05276
Case quot;Qquot;: MW = MW 128.05858
Case quot;Rquot;: MW = MW 156.10111
Case quot;Squot;: MW = MW 87.03203
Case quot;Tquot;: MW = MW 101.04768
Case quot;Vquot;: MW = MW 99.06841
Case quot;Wquot;: MW = MW 186.07931
Case quot;Yquot;: MW = MW 163.06333
y = y 1.00782
Case Else: Z = Z 1.00782
End Select
Next jIf MW gt; 18 Then
Cells(i, quot;Bquot;).Value = MW 17.00274 1.00782 1.00782
End If
MW = 0

Next i
Application.ScreenUpdating = True

End Sub
paulinoluciano wrote:
gt; Dear,
gt; I have used the VBA code bellow in order to compute the molecular mass
gt; (biochemistry) of a amino acid sequence. Since I have a sequence of
gt; letters (Like LASFSDFGASASRTIY) on A4, it will display its molecular
gt; mass on B4 when I run the macro. Now, I would like to use similar
gt; script in order to get the subsequence displaying an specific molecular
gt; mass or the nearest molecular mass.
gt; Example:
gt; If I have the sequence LASFSDFGASASRTIY I will get as molecular mass
gt; the number 1692,82329.
gt; I would like to put at cell A2 the molecular mass I would like to find
gt; inside LASFSDFGASASRTIY. If I put 654,27347
gt; in cell A2 I would receive as response the subsequence SDFGASA.
gt; However, sometimes I will need to use a range with limits from 600 to
gt; 700. Therefore, at cells C4:C I would like to receive all possibilities
gt; in such a range.
gt; Do you have some suggestion?
gt; Best regards,
gt; Luciano
gt;
gt; VBA code:
gt; Sub MM()
gt; '
gt; ' Protweight Macro
gt; ' Macro recorded 20/10/2005 by Luciano Paulino da Silva
gt; '
gt;
gt; iLastRow = Cells(Rows.Count, quot;Aquot;).End(xlUp).Row
gt; Application.ScreenUpdating = False
gt; For i = 4 To iLastRow
gt; For j = 1 To Len(Cells(i, quot;Aquot;).Value)
gt; Select Case Mid$(Cells(i, quot;Aquot;).Value, j, 1)
gt; Case quot;Aquot;: MW = MW 71.03711
gt; Case quot;Cquot;: MW = MW 103.00919
gt; Case quot;Dquot;: MW = MW 115.02694
gt; Case quot;Equot;: MW = MW 129.04259
gt; Case quot;Fquot;: MW = MW 147.06841
gt; Case quot;Gquot;: MW = MW 57.02146
gt; Case quot;Hquot;: MW = MW 137.05891
gt; Case quot;Iquot;: MW = MW 113.08406
gt; Case quot;Kquot;: MW = MW 128.09496
gt; Case quot;Lquot;: MW = MW 113.08406
gt; Case quot;Mquot;: MW = MW 131.04049
gt; Case quot;Nquot;: MW = MW 114.04293
gt; Case quot;Pquot;: MW = MW 97.05276
gt; Case quot;Qquot;: MW = MW 128.05858
gt; Case quot;Rquot;: MW = MW 156.10111
gt; Case quot;Squot;: MW = MW 87.03203
gt; Case quot;Tquot;: MW = MW 101.04768
gt; Case quot;Vquot;: MW = MW 99.06841
gt; Case quot;Wquot;: MW = MW 186.07931
gt; Case quot;Yquot;: MW = MW 163.06333
gt; y = y 1.00782
gt; Case Else: Z = Z 1.00782
gt; End Select
gt; Next j
gt;
gt;
gt; If MW gt; 18 Then
gt; Cells(i, quot;Bquot;).Value = MW 17.00274 1.00782 1.00782
gt; End If
gt; MW = 0
gt;
gt; Next i
gt; Application.ScreenUpdating = True
gt;
gt; End Sub

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()