Script to find drug names from pub med publications
The following tables are used for input.
The first table contains the column title. We will highlight this column and loop through the rows to find matching drugs, chemicals or biological compounds.
The second table is a table of Preferred Terms and Synonyms that will be used to search the titles with.
Call this table titletable in Excel
Call this table agenttable in Excel
SYN
drug synonym
Option Explicit
Sub CheckAgentsInFieldAgainstList_12_17_08()
' Jad C
' You may copy any part of this code.
' This VBA script will match drugs,agents and chemicals from a 2
' column drug table like the table above from a column of titles
'Dim xCell As Range
Dim MyArray(), rCnt As Long, cCnt As Integer
With Sheet1.Range("titletable")
'set the bounds of your array
ReDim MyArray(1 To .Rows.Count, 1 To .Columns.Count)
'fill array with range
MyArray = Sheet1.Range("titletable")
End With
Dim MyArray2()
With Sheet2.Range("AgentsTable")
'set the bounds of your array
ReDim MyArray2(1 To .Rows.Count, 1 To .Columns.Count)
'fill array with range
MyArray2 = Sheet2.Range("AgentsTable")
End With
For Each xCell In Selection
Dim agents As String
agents = isAgentInTitle(MyArray2, xCell.Text)
If (agents <> "") Then
xCell.Offset(0, 6).Value = agents
Else
xCell.Offset(0, 6).Value = "NA"
End If
Next xCell
'
'
End Sub
' is the drug in the title?
' this function breaks the title apart and sends the list
' drugs as an array to Removedups and bubblesort if a list of drugs
' is foundFunction isAgentInTitle(arr(), str As String) As String
Dim bTrFal As String
Dim g As Integer
Dim h As Integer
Dim agentFoundList() As String
Dim numberAgentsFound As Integer
bTrFal = ""
numberAgentsFound = 0
For g = 1 To UBound(arr) ' How many items in array
Dim strSplit As Variant
strSplit = Split(str, " ")
For h = 0 To UBound(strSplit)
If UCase(strSplit(h)) = UCase(arr(g, 2)) Then
ReDim Preserve agentFoundList(numberAgentsFound)
agentFoundList(numberAgentsFound) = arr(g, 1)
numberAgentsFound = numberAgentsFound + 1
End If
Next
Next
If numberAgentsFound = 1 Then
isAgentInTitle = agentFoundList(0)
ElseIf numberAgentsFound > 1 Then
isAgentInTitle = BubbleSort(RemoveDups(agentFoundList()))
Else
isAgentInTitle = ""
End If
End Function
Function BubbleSort(MyArray() As String) As String' sort the array of Strings VBA
'
Dim First As Integer
Dim Last As Integer
Dim i As Integer
Dim j As Integer
Dim temp As String
Dim List As String
First = LBound(MyArray)
Last = UBound(MyArray)
For i = First To Last - 1
For j = i + 1 To Last
If MyArray(i) > MyArray(j) Then
temp = MyArray(j)
MyArray(j) = MyArray(i)
MyArray(i) = temp
End If
Next j
Next i
For i = 1 To UBound(MyArray)
If i = 1 Then
List = MyArray(i)
Else
List = List & "+" & MyArray(i)
End If
Next
BubbleSort = List
End Function
' Remove any duplicate - note this only works on arrays larger than 2
' that's my 0 through 1 in array speak. :)
Function RemoveDups(strings() As String) As String()
Dim old_i As Integer
Dim last_i As Integer
Dim result() As String
' Make the result array.
ReDim result(1 To UBound(strings))
' Copy the first item into the result array.
result(1) = strings(1)
' Copy the other items
last_i = 1
For old_i = 2 To UBound(strings)
If result(last_i) <> strings(old_i) Then
last_i = last_i + 1
result(last_i) = strings(old_i)
End If
Next old_i
' Remove unused entries from the result array.
ReDim Preserve result(1 To last_i)
' Return the result array.
RemoveDups = result
End Function
The following tables are used for input.
The first table contains the column title. We will highlight this column and loop through the rows to find matching drugs, chemicals or biological compounds.
The second table is a table of Preferred Terms and Synonyms that will be used to search the titles with.
Call this table titletable in Excel
pubmedid | tite | issn | year | journal | |
| 19065303 | In Memoriam: Gloria Gallo M.D. | 1744-2818 | 2008 | Amyloid : the international journal of experimental and clinical investigation : the official journal of the International Society of Amyloidosis | NA |
| 19065529 | [Analysis of the GNB3 gene 825C/T polymorphism in non-obese and obese Chinese.] | 1003-9406 | 2008 | Zhonghua yi xue yi chuan xue za zhi = Zhonghua yixue yichuanxue zazhi = Chinese journal of medical genetics | NA |
| 19065556 | Visible 405 nm SLD light photo-destroys methicillin-resistant Staphylococcus aureus (MRSA) in vitro. | 1096-9101 | 2008 | Lasers in surgery and medicine | NA |
| 19065636 | S6K1 is involved in polyploidization through its phosphorylation at Thr421/Ser424. | 1097-4652 | 2008 | Journal of cellular physiology | NA |
| 19065640 | The sandwich sign of nonlymphomatous origin. | 1097-0096 | 2008 | Journal of clinical ultrasound : JCU | NA |
| 19065677 | Competitive inhibition of leptin signaling results in amelioration of liver fibrosis through modulation of stellate cell function. | 1527-3350 | 2008 | Hepatology (Baltimore, Md.) | Liver (Food) |
| 19065794 | Therapeutic application of transmembrane T and natural killer cell receptor peptides. | 0065-2598 | 2008 | Advances in experimental medicine and biology | NA |
| 19065979 | Femtosecond laser photodisruption of porcine anterior chamber angle: an ex vivo study. | 1542-8877 | 2008 Nov-Dec | Ophthalmic surgery, lasers & imaging : the official journal of the International Society for Imaging in the Eye | NA |
| 19066073 | Bilirubin oxidation products, oxidative stress, and intracerebral hemorrhage. | 0065-1419 | 2008 | Acta neurochirurgica. Supplement | Bilirubin |
| 19066285 | Activation of P2X7 receptors causes isoform-specific translocation of protein kinase C in osteoclasts. | 0021-9533 | 2008 | Journal of cell science | Catechin |
| 19066312 | Fatty Acid Incubation of Myotubues from Humans with Type 2 Diabetes Leads to Enhanced Release of Beta Oxidation Products Due to Impaired Fatty Acid Oxidation: Effects of Tetradecylthioacetic Acid and Eicosapentaenoic Acid. | 1939-327X | 2008 | Diabetes | NA |
| 19066362 | Testimonies on the Veterinary Public Health Workforce Expansion Act of 2007 (H.R. 1232) Presented before the Subcommittee on Health of the United States House of Representatives Committee on Energy and Commerce, January 23, 2008. | 0748-321X | 2008 | Journal of veterinary medical education | NA |
| 19066370 | Effect of Selenium and Vitamin E on Risk of Prostate Cancer and Other Cancers: The Selenium and Vitamin E Cancer Prevention Trial (SELECT). | 1538-3598 | 2008 | JAMA : the journal of the American Medical Association | Chemotherapy+Dietary Selenium+Other+selenium |
| 19066382 | Dexamethasone and risk of nausea and vomiting and postoperative bleeding after tonsillectomy in children: a randomized trial. | 1538-3598 | 2008 | JAMA : the journal of the American Medical Association | Dexamethasone |
| 19066392 | Oncogenic Kras-induced leukemogeneis: hematopoietic stem cells as the initial target and lineage-specific progenitors as the potential targets for final leukemic transformation. | 1528-0020 | 2008 | Blood | Arsenic |
| 19066480 | New human data versus estimates of effects of inhaling fission product mixtures. | 1538-5159 | 2009 | Health physics | NA |
Call this table agenttable in Excel
SYN
drug synonym
| PT |
| drug |
Option Explicit
Sub CheckAgentsInFieldAgainstList_12_17_08()
' Jad C
' You may copy any part of this code.
' This VBA script will match drugs,agents and chemicals from a 2
' column drug table like the table above from a column of titles
'Dim xCell As Range
Dim MyArray(), rCnt As Long, cCnt As Integer
With Sheet1.Range("titletable")
'set the bounds of your array
ReDim MyArray(1 To .Rows.Count, 1 To .Columns.Count)
'fill array with range
MyArray = Sheet1.Range("titletable")
End With
Dim MyArray2()
With Sheet2.Range("AgentsTable")
'set the bounds of your array
ReDim MyArray2(1 To .Rows.Count, 1 To .Columns.Count)
'fill array with range
MyArray2 = Sheet2.Range("AgentsTable")
End With
For Each xCell In Selection
Dim agents As String
agents = isAgentInTitle(MyArray2, xCell.Text)
If (agents <> "") Then
xCell.Offset(0, 6).Value = agents
Else
xCell.Offset(0, 6).Value = "NA"
End If
Next xCell
'
'
End Sub
' is the drug in the title?
' this function breaks the title apart and sends the list
' drugs as an array to Removedups and bubblesort if a list of drugs
' is foundFunction isAgentInTitle(arr(), str As String) As String
Dim bTrFal As String
Dim g As Integer
Dim h As Integer
Dim agentFoundList() As String
Dim numberAgentsFound As Integer
bTrFal = ""
numberAgentsFound = 0
For g = 1 To UBound(arr) ' How many items in array
Dim strSplit As Variant
strSplit = Split(str, " ")
For h = 0 To UBound(strSplit)
If UCase(strSplit(h)) = UCase(arr(g, 2)) Then
ReDim Preserve agentFoundList(numberAgentsFound)
agentFoundList(numberAgentsFound) = arr(g, 1)
numberAgentsFound = numberAgentsFound + 1
End If
Next
Next
If numberAgentsFound = 1 Then
isAgentInTitle = agentFoundList(0)
ElseIf numberAgentsFound > 1 Then
isAgentInTitle = BubbleSort(RemoveDups(agentFoundList()))
Else
isAgentInTitle = ""
End If
End Function
Function BubbleSort(MyArray() As String) As String' sort the array of Strings VBA
'
Dim First As Integer
Dim Last As Integer
Dim i As Integer
Dim j As Integer
Dim temp As String
Dim List As String
First = LBound(MyArray)
Last = UBound(MyArray)
For i = First To Last - 1
For j = i + 1 To Last
If MyArray(i) > MyArray(j) Then
temp = MyArray(j)
MyArray(j) = MyArray(i)
MyArray(i) = temp
End If
Next j
Next i
For i = 1 To UBound(MyArray)
If i = 1 Then
List = MyArray(i)
Else
List = List & "+" & MyArray(i)
End If
Next
BubbleSort = List
End Function
' Remove any duplicate - note this only works on arrays larger than 2
' that's my 0 through 1 in array speak. :)
Function RemoveDups(strings() As String) As String()
Dim old_i As Integer
Dim last_i As Integer
Dim result() As String
' Make the result array.
ReDim result(1 To UBound(strings))
' Copy the first item into the result array.
result(1) = strings(1)
' Copy the other items
last_i = 1
For old_i = 2 To UBound(strings)
If result(last_i) <> strings(old_i) Then
last_i = last_i + 1
result(last_i) = strings(old_i)
End If
Next old_i
' Remove unused entries from the result array.
ReDim Preserve result(1 To last_i)
' Return the result array.
RemoveDups = result
End Function
Comments