Skip to content

Commit ef87824

Browse files
committed
finished ipi r3 parser
1 parent f32b9d2 commit ef87824

File tree

1 file changed

+218
-12
lines changed

1 file changed

+218
-12
lines changed

ipi/ipi.php

Lines changed: 218 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,224 @@ public function Run(){
135135
}
136136
}
137137

138+
private function gene_xrefs(){
139+
while($aLine = $this->getReadFile()->Read(4096)){
140+
$tLine = explode("\t", $aLine);
141+
if(!$this->startsWith($tLine[0], "#")){
142+
$chromosome = null;
143+
$cosmid = array();
144+
$start_coord = null;
145+
$gene_symbol = null;
146+
$end_coord = null;
147+
$strand = array();
148+
$gene_location = array();
149+
$ensembl_id = array();
150+
$gene_id = null;
151+
$ipi_ids = array();
152+
$uniprotkb_ids = array();
153+
$uniprot_tre = array();
154+
$ensembl_peptide_id = array();
155+
$refseq_ids = array();
156+
$tair_ids = array();
157+
$hinv_ids = array();
158+
$unigene_ids = array();
159+
$ccds_ids = array();
160+
$refseq_gis = array();
161+
$vega_genes = array();
162+
$vega_peptides = array();
163+
164+
165+
if(count(isset($tLine[0]))){
166+
@$chr_arr = readIdentifiers($tLine[0]);
167+
if($chr_arr[0] != "Un"){
168+
$chromosome = $chr_arr[0];
169+
}
170+
}
171+
172+
if(count(isset($tLine[1]))){
173+
@$cosmid = readIdentifiers($tLine[1]);
174+
}
175+
176+
if(count(isset($tLine[2]))){
177+
@$start_coord_t = readIdentifiers($tLine[2]);
178+
if(count($start_coord_t) == 1){
179+
$start_coord = $start_coord_t[0];
180+
}
181+
}
182+
183+
if(count(isset($tLine[3]))){
184+
@$end_coord_t = readIdentifiers($tLine[3]);
185+
if(count($end_coord_t) == 1){
186+
$end_coord = $end_coord_t[0];
187+
}
188+
}
189+
if(count(isset($tLine[4]))){
190+
@$strand = readIdentifiers($tLine[4]);
191+
}
192+
193+
if(count(isset($tLine[5]))){
194+
@$gene_location = readIdentifiers($tLine[5]);
195+
}
196+
197+
if(count(isset($tLine[6]))){
198+
@$ensembl_id = readIdentifiers($tLine[6]);
199+
}
200+
if(count(isset($tLine[8]))){
201+
@$gene_id_t = readIdentifiers($tLine[8]);
202+
if (count($gene_id_t) == 2){
203+
$gene_id = $gene_id_t[0];
204+
$gene_symbol = $gene_id_t[1];
205+
}
206+
}
207+
if(count(isset($tLine[9]))){
208+
@$ipi_ids = readIdentifiers($tLine[9]);
209+
}
210+
if(count(isset($tLine[10]))){
211+
@$uniprotkb_ids = readIdentifiers($tLine[10]);
212+
}
213+
if(count(isset($tLine[11]))){
214+
@$uniprot_tre = readIdentifiers($tLine[11]);
215+
}
216+
if(count(isset($tLine[12]))){
217+
@$ensembl_peptide_id = readIdentifiers($tLine[12]);
218+
}
219+
if(count(isset($tLine[13]))){
220+
@$refseq_ids = readIdentifiers($tLine[13]);
221+
}
222+
if(count(isset($tLine[14]))){
223+
@$tair_ids = readIdentifiers($tLine[14]);
224+
}
225+
if(count(isset($tLine[15]))){
226+
@$hinv_ids = readIdentifiers($tLine[15]);
227+
}
228+
if(count(isset($tLine[16]))){
229+
@$unigene_ids = readIdentifiers($tLine[16]);
230+
}
231+
if(count(isset($tLine[17]))){
232+
@$ccds_ids = readIdentifiers($tLine[17]);
233+
}
234+
if(count(isset($tLine[18]))){
235+
@$refseq_gis = readIdentifiers($tLine[18]);
236+
}
237+
if(count(isset($tLine[19]))){
238+
@$vega_genes = readIdentifiers($tLine[19]);
239+
}
240+
if(count(isset($tLine[20]))){
241+
@$refseq_ids = readIdentifiers($tLine[20]);
242+
}
243+
//lets make some RDF
244+
if(count($gene_id)){
245+
$res = "gene:".$gene_id;
246+
parent::AddRDF(
247+
parent::triplifyString($res, $this->getVoc()."gene-symbol", $gene_symbol).
248+
parent::triplifyString($res, $this->getVoc()."chromosome", $chromosome).
249+
parent::triplifyString($res, $this->getVoc()."start-coordinate", $start_coord).
250+
parent::triplifyString($res, $this->getVoc()."end-coordinate", $end_coord)
251+
);
252+
}
253+
if(count($strand)){
254+
parent::AddRDF(
255+
parent::triplifyString($res, $this->getVoc()."strand", $strand[0])
256+
);
257+
}
258+
if(count($ensembl_id)){
259+
foreach($ensembl_id as $x){
260+
parent::AddRDF(
261+
parent::triplify($res, $this->getVoc()."x-ensembl", "ensembl:".$x)
262+
);
263+
}
264+
}
265+
if(count($gene_location)){
266+
foreach($gene_location as $x){
267+
parent::AddRDF(
268+
parent::triplifyString($res, $this->getVoc()."gene-location", $x)
269+
);
270+
}
271+
}
272+
if(count($ipi_ids)){
273+
foreach($ipi_ids as $x){
274+
parent::AddRDF(
275+
parent::triplify($res, $this->getVoc()."x-ipi", "ipi:".$x)
276+
);
277+
}
278+
}
279+
if(count($uniprotkb_ids)){
280+
foreach($uniprotkb_ids as $x){
281+
parent::AddRDF(
282+
parent::triplify($res, $this->getVoc()."x-uniprot", "uniprot:".$x)
283+
);
284+
}
285+
}
286+
if(count($uniprotkb_tre)){
287+
foreach($uniprotkb_tre as $x){
288+
parent::AddRDF(
289+
parent::triplify($res, $this->getVoc()."x-uniprot", "uniprot:".$x)
290+
);
291+
}
292+
}
293+
if(count($ensembl_peptide_id)){
294+
foreach($ensembl_peptide_id as $x){
295+
parent::AddRDF(
296+
parent::triplify($res, $this->getVoc()."x-ensembl", "ensembl:".$x)
297+
);
298+
}
299+
}
300+
if(count($refseq_ids)){
301+
foreach($refseq_ids as $x){
302+
parent::AddRDF(
303+
parent::triplify($res, $this->getVoc()."x-refseq", "refseq:".$x)
304+
);
305+
}
306+
}
307+
if(count($tair_ids)){
308+
foreach($tair_ids as $x){
309+
parent::AddRDF(
310+
parent::triplify($res, $this->getVoc()."x-tair", "tair:".$x)
311+
);
312+
}
313+
}
314+
if(count($hinv_ids)){
315+
foreach($hinv_ids as $x){
316+
parent::AddRDF(
317+
parent::triplify($res, $this->getVoc()."x-hinv", "hinv:".$x)
318+
);
319+
}
320+
}
321+
if(count($unigene_ids)){
322+
foreach($unigene_ids as $x){
323+
parent::AddRDF(
324+
parent::triplify($res, $this->getVoc()."x-unigene", "unigene:".$x)
325+
);
326+
}
327+
}
328+
if(count($refseq_gis)){
329+
foreach($refseq_gis as $x){
330+
if(count($x) != 0 && $x != "\n" && $x != ""){
331+
parent::AddRDF(
332+
parent::triplify($res, $this->getVoc()."x-refseq", "refseq:".$x)
333+
);
334+
}
335+
}
336+
}
337+
$this->WriteRDFBufferToWriteFile();
338+
}
339+
}
340+
}
341+
342+
private function gi2ipi(){
343+
while($aLine = $this->getReadFile()->Read(4096)){
344+
preg_match("/(\d+)\t(\w+)/", $aLine, $matches);
345+
if(count($matches)){
346+
$ipi_res = $this->getVoc().$matches[2];
347+
$gi_res = "gi:".$matches[1];
348+
parent::AddRDF(
349+
parent::triplify($ipi_res, $this->getVoc()."x-gi", $gi_res)
350+
);
351+
$this->WriteRDFBufferToWriteFile();
352+
}
353+
}
354+
}
355+
138356
private function species_xrefs(){
139357
while($aLine = $this->getReadFile()->Read(4096)){
140358
$tLine = explode("\t", $aLine);
@@ -382,22 +600,10 @@ private function species_xrefs(){
382600
}
383601
}
384602
}
385-
386-
387-
388-
389603
$this->WriteRDFBufferToWriteFile();
390-
391604
}//while
392605
}
393606

394-
private function gene_xrefs(){
395-
echo "c";
396-
}
397-
398-
private function gi2ipi(){
399-
echo "b";
400-
}
401607

402608
private function getPackageMap(){
403609
return self::$packageMap;

0 commit comments

Comments
 (0)