Skip to content

Commit db71105

Browse files
fixed dbsnp query bug
1 parent 5088383 commit db71105

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

dbsnp/dbsnp.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function getSNPs($clinical_flag = false)
151151
$clinical = array("pathogenic","probable-pathogenic","drug-response","other");
152152
if($clinical_flag == true) {
153153
$term = implode("[Clinical Significance] or ",$all);
154-
$term = '"'.substr($term,0)."\"[Clinical Significance]";
154+
$term = '"'.substr($term,0)."[Clinical Significance]";
155155
} else {
156156
$term = "snp";
157157
}
@@ -160,16 +160,15 @@ function getSNPs($clinical_flag = false)
160160
echo "Downloading snp list ";
161161
$xmlfile = $this->getParameterValue('indir').'snp.list.xml';
162162
$retmax = 10000000;
163-
// $retmax = 10;
164163
$start = 0;
165164
$mylist = array();
166165
do {
167166
echo count($mylist).PHP_EOL;
168167
$url = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=snp&retmax=$retmax&term=".urlencode($term)."&retstart=$start";
169-
170168
$c = file_get_contents($url);
171169
preg_match_all("/<Id>([^\<]+)<\/Id>/",$c,$m);
172-
if(!isset($m[1])) break;
170+
if(!isset($m[1]) or count($m[1]) == 0) break;
171+
173172
$mylist = array_merge($mylist,$m[1]);
174173
$start += $retmax;
175174
} while(true);

0 commit comments

Comments
 (0)