Pep-Calc Microsoft Excel Add-In

Note

A less technical summary of Excel add-in usage can be found at http://www.pep-calc.com/excel/.

The VBA snippet below uses Pep-Calc API to add the custom calculation functions PTIDEPROP() and PTOIDPROP() to Microsoft Excel, and is available to download as a Microsoft Excel add-in (see Add-In Download).

Usage

PTIDEPROP() and PTOIDPROP() take the input values property, sequence, nTerm and cTerm. The property input can take any of the values listed in the table below. The remaining inputs describe the peptide/peptoid sequence and N- and C-terminal formulae, respectively.

Inputs should be formatted as described on the Peptide Calculator and Peptoid Calculator help pages.

Property Calculated Result Function Corresponding API Resource
'molecularWeight', 'formula' etc. Sequence molecular weight, molecular formula and any of the parameters listed on the Getting Started page PTIDEPROP(), PTOIDPROP() Basic Properties
'iso' Peptide isoelectric point PTIDEPROP() only Isoelectric Point
'extinctionOx', 'extinctionRed' Peptide molar extinction coefficient (oxidized or reduced) PTIDEPROP() only Extinction Coefficient

Add-In Download

The code below is included in the Microsoft Excel add-in Pep-Calc.xlam, which also includes the required JsonConverter.bas, Dictionary.cls and the URLEncode() function found here - see Visual Basic for Applications (VBA) for more information.

Add-ins can be installed from within Excel using File > Options > Add-Ins and browsing to the downloaded .xlam file. More detailed instructions for installing Excel add-ins can be found on the Office website.

Note

.xlam files downloaded from the internet may need to unblocked before use by right-clicking on the file and choosing Properties > General > Unblock.

'Peptide and peptoid calculation functions powered by Pep-Calc API
'http://www.pep-calc.com/

Private Function getJson(endpoint As String, sequence As String, nTerm As String, cTerm As String, masses As String)

  Dim Request As Object
  Dim seq, N_term, C_term, mz As String
  Dim Json As Dictionary

  seq = URLEncode(sequence)
  N_term = URLEncode(nTerm)
  C_term = URLEncode(cTerm)
  If masses <> "" Then mz = URLEncode(masses)

  Set Request = CreateObject("WinHttp.WinHttpRequest.5.1")
  Request.Open "GET", _
  "http://api.pep-calc.com" + endpoint + _
  "?seq=" + seq + "&N_term=" + N_term + "&C_term=" + C_term +"&mz=" + mz
  Request.Send
  Set Json = JsonConverter.ParseJson(Request.ResponseText)

  Set getJson = Json

End Function

Function ptideProp(property As String, sequence As String, nTerm As String, cTerm As String)

  Dim Json As Object

  If property = "iso" Then
    Set Json = getJson("/peptide/iso", sequence, nTerm, cTerm, "")
    ptideProp = Json("pI")
  ElseIf property = "extinctionOx" Then
    Set Json = getJson("/peptide/extinction", sequence, nTerm, cTerm, "")
    ptideProp = Json("oxidized")
  ElseIf property = "extinctionRed" Then
    Set Json = getJson("/peptide/extinction", sequence, nTerm, cTerm, "")
    ptideProp = Json("reduced")
  Else
    Set Json = getJson("/peptide", sequence, nTerm, cTerm, "")
    ptideProp = Json(property)
  End If

End Function

Function ptoidProp(property As String, sequence As String, nTerm As String, cTerm As String)

  Dim Json As Object

  Set Json = getJson("/peptoid", sequence, nTerm, cTerm, "")
  ptoidProp = Json(property)

End Function