@@ -370,11 +370,17 @@ function genes()
370
370
}
371
371
}
372
372
373
- function parseList ($ str )
373
+ function parseList ($ str, $ delim = ' ; ' )
374
374
{
375
375
$ list = '' ;
376
- if ($ str [0 ] == '" ' ) $ list = explode ('"," ' , substr ($ str ,1 ,-1 ));
377
- else $ list = array ($ str );
376
+ if ($ str [0 ] == '" ' ) {
377
+ $ list = explode ('"," ' , substr ($ str ,1 ,-1 ));
378
+ } else {
379
+ if (strstr ($ str ,$ delim )) {
380
+ $ list = explode ($ delim , $ str );
381
+ }
382
+ }
383
+ if (!is_array ($ list )) $ list = array ($ str );
378
384
return $ list ;
379
385
}
380
386
@@ -454,7 +460,7 @@ function drugs()
454
460
if (trim ($ a [2 ])) {
455
461
// generic names
456
462
// Entacapona [INN-Spanish],Entacapone [Usan:Inn],Entacaponum [INN-Latin],entacapone
457
- $ list = $ this ->parseList (trim ($ a [2 ]));
463
+ $ list = $ this ->parseList (trim ($ a [2 ]), " , " );
458
464
foreach ($ list AS $ c ) {
459
465
parent ::addRDF (
460
466
parent ::triplifyString ($ id , parent ::getVoc ()."generic_name " , str_replace ('" ' ,'' ,$ c ))
@@ -467,7 +473,7 @@ function drugs()
467
473
if (trim ($ a [3 ])) {
468
474
// trade names
469
475
//Disorat,OptiPranolol,Trimepranol
470
- $ list = $ this ->parseList (trim ($ a [3 ]));
476
+ $ list = $ this ->parseList (trim ($ a [3 ]), " , " );
471
477
foreach ($ list as $ c ) {
472
478
parent ::addRDF (
473
479
parent ::triplifyString ($ id , parent ::getVoc ()."trade_name " , str_replace (array ("' " , "\"" ), array ("\\\' " , "" ) ,$ c ))
@@ -480,7 +486,7 @@ function drugs()
480
486
if (trim ($ a [4 ])) {
481
487
// Brand Mixtures
482
488
// Benzyl benzoate 99+ %,"Dermadex Crm (Benzoic Acid + Benzyl Benzoate + Lindane + Salicylic Acid + Zinc Oxide + Zinc Undecylenate)",
483
- $ list = $ this ->parseList (trim ($ a [4 ]));
489
+ $ list = $ this ->parseList (trim ($ a [4 ]), " , " );
484
490
foreach ($ list as $ c ) {
485
491
parent ::addRDF (
486
492
parent ::triplifyString ($ id , parent ::getVoc ()."brand_mixture " , str_replace (array ("' " , "\"" ),array ("\\\' " ,"" ), $ c ))
@@ -500,7 +506,7 @@ function drugs()
500
506
if (trim ($ a [6 ])) {
501
507
// Cross References
502
508
// drugBank:DB00789,keggDrug:D01707,pubChemCompound:55466,pubChemSubstance:192903,url:http://en.wikipedia.org/wiki/Gadopentetate_dimeglumine
503
- $ list = $ this ->parseList (trim ($ a [6 ]));
509
+ $ list = $ this ->parseList (trim ($ a [6 ]), " , " );
504
510
foreach ($ list as $ c ) {
505
511
$ this ->getRegistry ()->parseQName ($ c ,$ ns ,$ id1 );
506
512
if ($ ns == "chebi " ) $ id1 = substr ($ id1 , 6 );
@@ -544,7 +550,10 @@ function drugs()
544
550
// External Vocabulary
545
551
// ATC:H01AC(Somatropin and somatropin agonists),ATC:V04CD(Tests for pituitary function)
546
552
// ATC:D07AB(Corticosteroids, moderately potent (group II)) => this is why you don't use brackets and commas as separators.
547
- $ list = $ this ->parseList (trim ($ a [10 ]));
553
+ $ list = $ this ->parseList (trim ($ a [10 ]),", " );
554
+ if (strstr ($ a [10 ],"potent " )) { $ c = array (implode (", " ,$ list ));$ list = $ c ;}
555
+ else if (strstr ($ a [10 ],"weak " )) { $ c = array (implode (", " ,$ list ));$ list = $ c ;}
556
+
548
557
foreach ($ list as $ c ) {
549
558
preg_match ("/([^\(]+)?\((.*)\)/ " , $ c , $ m );
550
559
if (isset ($ m [1 ])) {
@@ -566,7 +575,7 @@ function drugs()
566
575
}
567
576
if (trim ($ a [22 ])) {
568
577
// ATC identifiers
569
- $ list = $ this ->parseList (trim ($ a [22 ]));
578
+ $ list = $ this ->parseList (trim ($ a [22 ]), " , " );
570
579
foreach ($ list as $ c ) {
571
580
parent ::addRDF (
572
581
parent ::triplify ($ id , parent ::getVoc ()."x-atc " , "atc: " .$ c )
@@ -868,17 +877,15 @@ function clinical_ann_metadata()
868
877
// [5] => Genotype-Phenotypes IDs
869
878
// [6] => Text
870
879
if ($ a [5 ]) {
871
- $ gps = explode ('"," ' ,$ a [5 ]);
872
- $ gps_texts = explode ('"," ' ,$ a [6 ]);
880
+ $ gps = explode ('; ' ,$ a [5 ]);
881
+ $ gps_texts = explode ('; ' ,$ a [6 ]);
873
882
foreach ($ gps AS $ i => $ gp ) {
874
- $ gp = str_replace ('" ' ,'' ,trim ($ gp ));
875
- $ gp_text = str_replace ('" ' ,'' ,trim ($ gps_texts [$ i ]));
876
- $ b = explode (": " ,$ gp_text ,2 );
883
+ $ gp_text = str_replace ('\\' ,'' ,$ gps_texts [$ i ]);
877
884
878
885
parent ::addRDF (
879
886
parent ::describeIndividual (parent ::getNamespace ().$ gp , $ gp_text , parent ::getVoc ()."Genotype-Phenotype-Association " ).
880
887
parent ::triplify ($ id , parent ::getVoc ()."genotype_phenotype " , parent ::getNamespace ().$ gp ).
881
- parent ::triplifyString (parent ::getNamespace ().$ gp , parent ::getVoc ()."genotype " , trim ($ b [ 0 ] )).
888
+ parent ::triplifyString (parent ::getNamespace ().$ gp , parent ::getVoc ()."genotype " , trim ($ gp )).
882
889
parent ::describeClass (parent ::getVoc ()."Genotype-Phenotype-Association " , "PharmGKB Genotype Phenotype Association " ).
883
890
parent ::describeProperty (parent ::getVoc ()."genotype_phenotype " , "Relationship between a PharmGKB entity and a Genotype Phenotype " ).
884
891
parent ::describeProperty (parent ::getVoc ()."genotype " , "Relationship between a PharmGKB Genotype Phenotype and a genotype " )
@@ -889,11 +896,14 @@ function clinical_ann_metadata()
889
896
// [7] => Variant Annotations IDs
890
897
// [8] => Variant Annotations
891
898
if ($ a [7 ]) {
892
- $ b = explode ('"," ' ,$ a [7 ]);
893
- $ b_texts = explode ('"," ' ,$ a [8 ]);
899
+ $ b = explode ('; ' ,$ a [7 ]);
900
+ $ b_texts = explode ('; ' ,$ a [8 ]);
901
+ if (count ($ b ) != count ($ b_texts )) {
902
+ trigger_error ("Error in parsing variant annotations " );
903
+ exit ();
904
+ }
894
905
foreach ($ b AS $ i => $ variant ) {
895
- $ variant = str_replace ('" ' ,'' ,trim ($ variant ));
896
- $ variant_text = str_replace ('" ' ,'' ,trim ($ b_texts [$ i ]));
906
+ $ variant_text = trim ($ b_texts [$ i ]);
897
907
parent ::addRDF (
898
908
parent ::describeIndividual (parent ::getNamespace ().$ variant , $ variant_text , parent ::getVoc ()."Variant-Annotation " ).
899
909
parent ::triplify ($ id , parent ::getVoc ()."variant " , parent ::getNamespace ().$ variant )
@@ -903,7 +913,7 @@ function clinical_ann_metadata()
903
913
904
914
// [9] => PMIDs
905
915
if ($ a [9 ]) {
906
- $ b = $ this -> parseList ( $ a [9 ]);
916
+ $ b = explode ( ' ; ' , $ a [9 ]);
907
917
foreach ($ b AS $ i => $ pmid ) {
908
918
parent ::addRDF (
909
919
parent ::triplify ($ id , parent ::getVoc ()."article " , "pubmed: " .$ pmid )
@@ -921,8 +931,7 @@ function clinical_ann_metadata()
921
931
922
932
// [11] => Related Chemicals
923
933
if ($ a [11 ]) {
924
- //print_r($a);exit;
925
- $ b = $ this ->parseList ($ a [11 ]);
934
+ $ b = explode ('; ' , $ a [11 ]);
926
935
foreach ($ b AS $ drug_label ) {
927
936
preg_match ('/\(PA(.*)\)/ ' ,$ drug_label ,$ m );
928
937
@@ -940,7 +949,7 @@ function clinical_ann_metadata()
940
949
}
941
950
// [12] => Related Diseases
942
951
if ($ a [12 ]) {
943
- $ b = $ this -> parseList ( $ a [12 ]);
952
+ $ b = explode ( ' ; ' , $ a [12 ]);
944
953
foreach ($ b AS $ disease_label ) {
945
954
preg_match ('/\(PA(.*)\)/ ' ,$ disease_label ,$ m );
946
955
if (isset ($ m [1 ])) {
0 commit comments