@@ -34,7 +34,7 @@ class irefindexParser extends Bio2RDFizer
34
34
function __construct ($ argv ) { //
35
35
parent ::__construct ($ argv ,"irefindex " );
36
36
parent ::addParameter ('files ' ,true ,'all|10090|10116|4932|559292|562|6239|7227|9606|other ' ,'all ' ,'all or comma-separated list of files to process ' );
37
- parent ::addParameter ('version ' ,false ,null , ' 10182011 '/* '03022013'*/ ,'dated version of files to download ' );
37
+ parent ::addParameter ('version ' ,false ,' 03022013| 10182011 ', '03022013 ' ,'dated version of files to download ' );
38
38
parent ::addParameter ('download_url ' ,false ,null ,'ftp://ftp.no.embnet.org/irefindex/data/current/psi_mitab/MITAB2.6/ ' );
39
39
parent ::initialize ();
40
40
}
@@ -51,23 +51,25 @@ function Run()
51
51
$ ldir = parent ::getParameterValue ('indir ' );
52
52
$ odir = parent ::getParameterValue ('outdir ' );
53
53
$ rdir = parent ::getParameterValue ('download_url ' );
54
+
54
55
55
56
foreach ($ files AS $ file ) {
56
57
$ download = parent ::getParameterValue ('download ' );
57
58
$ base_file = ucfirst ($ file ).".mitab. " .parent ::getParameterValue ("version " ).".txt " ;
58
59
$ zip_file = $ base_file .".zip " ;
59
60
$ lfile = $ ldir .$ zip_file ;
60
61
62
+ $ gz = (strstr (parent ::getParameterValue ('output_format ' ),".gz " ) === FALSE )?false :true ;
61
63
$ ofile = "irefindex- " .$ file .". " .parent ::getParameterValue ('output_format ' );
62
- $ gz = (strstr (parent ::getParameterValue ('output_format ' ),".gz " ) === FALSE )?false :true ;
63
- $ download_files [] = $ ofile ;
64
64
65
65
if (!file_exists ($ lfile )) {
66
66
trigger_error ($ lfile ." not found. Will attempt to download. " , E_USER_NOTICE );
67
67
$ download = true ;
68
68
}
69
69
70
+ $ rfile = "ftp://ftp.no.embnet.org/irefindex/data/current/psi_mitab/MITAB2.6/ $ zip_file " ;
70
71
if ($ download == true ) {
72
+ echo "downloading $ rfile " .PHP_EOL ;
71
73
if (FALSE === Utils::Download ("ftp://ftp.no.embnet.org " ,array ("/irefindex/data/current/psi_mitab/MITAB2.6/ " .$ zip_file ),$ ldir )) {
72
74
trigger_error ("Error in Download " );
73
75
return FALSE ;
@@ -98,21 +100,52 @@ function Run()
98
100
parent ::getWriteFile ()->close ();
99
101
$ zin ->close ();
100
102
echo "Done! " .PHP_EOL ;
103
+
104
+ $ graph_uri = parent ::getGraphURI ();
105
+ if (parent ::getParameterValue ('dataset_graph ' ) == true ) parent ::setGraphURI (parent ::getDatasetURI ());
106
+
107
+ // dataset description
108
+ $ source_file = (new DataResource ($ this ))
109
+ ->setURI ($ rfile )
110
+ ->setTitle ("iRefIndex ( $ zip_file " )
111
+ ->setRetrievedDate ( date ("Y-m-d\TG:i:s\Z " , filemtime ($ lfile )))
112
+ ->setFormat ("text/tab-separated-value " )
113
+ ->setFormat ("application/zip " )
114
+ ->setPublisher ("http://irefindex.uio.no " )
115
+ ->setHomepage ("http://irefindex.uio.no " )
116
+ ->setRights ("use " )
117
+ ->setRights ("by-attribution " )
118
+ ->setRights ("no-commercial " )
119
+ ->setLicense ("http://irefindex.uio.no/wiki/README_MITAB2.6_for_iRefIndex#License " )
120
+ ->setDataset ("http://identifiers.org/irefindex/ " );
121
+
122
+ $ prefix = parent ::getPrefix ();
123
+ $ bVersion = parent ::getParameterValue ('bio2rdf_release ' );
124
+ $ date = date ("Y-m-d\TG:i:s\Z " );
125
+ $ output_file = (new DataResource ($ this ))
126
+ ->setURI ("http://download.bio2df.org/release/ $ bVersion/ $ prefix/ $ ofile " )
127
+ ->setTitle ("Bio2RDF v $ bVersion RDF version of $ prefix (generated at $ date) " )
128
+ ->setSource ($ source_file ->getURI ())
129
+ ->setCreator ("https://github.com/bio2rdf/bio2rdf-scripts/blob/master/irefindex/irefindex.php " )
130
+ ->setCreateDate ($ date )
131
+ ->setHomepage ("http://download.bio2rdf.org/release/ $ bVersion/ $ prefix/ $ prefix.html " )
132
+ ->setPublisher ("http://bio2rdf.org " )
133
+ ->setRights ("use-share-modify " )
134
+ ->setRights ("by-attribution " )
135
+ ->setRights ("restricted-by-source-license " )
136
+ ->setLicense ("http://creativecommons.org/licenses/by/3.0/ " )
137
+ ->setDataset (parent ::getDatasetURI ());
138
+
139
+ if ($ gz ) $ output_file ->setFormat ("application/gzip " );
140
+ if (strstr (parent ::getParameterValue ('output_format ' ),"nt " )) $ output_file ->setFormat ("application/n-triples " );
141
+ else $ output_file ->setFormat ("application/n-quads " );
142
+
143
+ $ dataset_description .= $ source_file ->toRDF ().$ output_file ->toRDF ();
144
+ parent ::setGraphURI ($ graph_uri );
101
145
}
102
146
103
- // generate the release file
104
- $ desc = parent ::getBio2RDFDatasetDescription (
105
- parent ::getPrefix (),
106
- "https://github.com/bio2rdf/bio2rdf-scripts/blob/master/irefindex/irefindex.php " ,
107
- $ download_files ,
108
- "http://irefindex.uio.no " ,
109
- array ("use " ,"attribution " ,"no-commercial " ),
110
- "http://irefindex.uio.no/wiki/README_MITAB2.6_for_iRefIndex#License " ,
111
- parent ::getParameterValue ('download_url ' ),
112
- parent ::getDatasetVersion ()
113
- );
114
- parent ::setWriteFile ($ odir .parent ::getBio2RDFReleaseFile (parent ::getPrefix ()));
115
- parent ::getWriteFile ()->write ($ desc );
147
+ parent ::setWriteFile ($ odir .parent ::getBio2RDFReleaseFile ());
148
+ parent ::getWriteFile ()->write ($ dataset_description );
116
149
parent ::getWriteFile ()->close ();
117
150
118
151
return TRUE ;
@@ -153,13 +186,14 @@ function Parse()
153
186
154
187
// generate the label
155
188
// interaction type[52] by method[6]
189
+ unset($ method );
156
190
if ($ a [6 ] != '- ' ) {
157
191
$ qname = $ this ->ParseString ($ a [6 ],$ ns ,$ id ,$ method );
158
192
if ($ qname ) parent ::addRDF (parent ::triplify ($ iid ,parent ::getVoc ()."method " ,$ qname ));
159
193
}
160
194
161
195
$ method_label = '' ;
162
- if ($ method != ' NA ' && $ method != ' -1 ' ) $ method_label = " identified by $ method " ;
196
+ if (isset ( $ method) ) $ method_label = " identified by $ method " ;
163
197
parent ::addRDF (
164
198
parent ::describeIndividual ($ iid ,$ label .$ method_label ,parent ::getVoc ().$ type )
165
199
);
0 commit comments