summaryrefslogtreecommitdiff
path: root/test-pubmed-index
blob: 554cc04e742d3ebbf7dceea62258c225eaf54652 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash

seconds_start=$(date "+%s")
for i in {1..100}
do
  echo $(( ( 1 + RANDOM % 30000) * 1000 + ( RANDOM % 1000) ))
done |
sort -n |
uniq |
fetch-pubmed |
xtract -pattern PubmedArticle -element MedlineCitation/PMID ArticleTitle |
while read uid ttl
do
  if [ "$ttl" = "[Not Available]." ]
  then
    echo "$uid SKIP"
    continue
  fi
  if [ "$ttl" = "Health." ]
  then
    echo "$uid SKIP"
    continue
  fi
  if [ -z "$ttl" ]
  then
    echo "$uid TRIM -- $ttl"
    continue
  fi
  res=`phrase-search -exact "$ttl"`
  report="1"
  if [ -z "$res" ]
  then
    echo "$uid NONE -- $ttl"
    continue
  fi
  num=`echo "$res" | wc -l | tr -d '[:space:]'`
  echo "$res" |
  while read pmid
  do
    if [[ $uid =~ $pmid ]]
    then
      if [ "$num" -lt 2 ]
      then
        echo "$uid OKAY -- $ttl"
      else
        echo "$uid MULT ${num## } -- $ttl"
      fi
      report="0"
      break
    fi
  done
  if [ "$report" -lt 1 ]
  then
    echo "$uid FAIL $num -- $ttl"
  fi
done
seconds_end=$(date "+%s")
seconds=$((seconds_end - seconds_start))
echo "$seconds seconds"