fetchObject()) { // Get the score for this feature $score = chado_query($score_sql, array(':feature_id' => $line->feature_id))->fetchField(); print $line->landmark_uname . "\t"; print $source . "\t"; print $line->type . "\t"; print ($line->fmin + 1). "\t"; print $line->fmax . "\t"; if ($score) { print $score . "\t"; } else { print "." . "\t"; } if ($line->strand) { print $line->strand . "\t"; } else { print '.' . "\t"; } if ($line->phase) { print $line->phase . "\t"; } else { print '.' . "\t"; } print "ID=" . $line->uniquename . ";Name=" . $line->name . ";"; // Look for a parent of this feature $args = array(':feature_id' => $line->feature_id); $parents = chado_query($parent_sql, $args); $attr = ''; while ($parent = $parents->fetchObject()) { $attr .= $parent->uniquename . ","; } if ($attr) { print "Parent=" . substr($attr, 0, -1) . ";"; } // Add in any aliases $args = array(':feature_id' => $line->feature_id); $aliases = chado_query($alias_sql, $args); $attr = ''; while ($alias = $aliases->fetchObject()) { $attr .= $alias->name . ","; } if ($attr) { print "Alias=" . substr($attr, 0, -1) . ";"; } $props = chado_query($props_sql, array(':feature_id' => $line->feature_id)); $prop_name = ''; while ($prop = $props->fetchobject()) { // If this is the first time we've encountered this property then // add the name=value key pair. if ($prop_name != $prop->name) { if ($prop_name) { // End the previous property print ";"; } // TODO: urlencode the properties print $prop->name . "=" . $prop->value; $prop_name = $prop->name; } // If we've seen this property before then just add the value. else { print "," . $prop->value; } } // End the last property if ($prop_name) { print ";"; } // Add in any DBXref records $args = array( ':feature_id' => $line->feature_id, ':dbxref_id' => $line->dbxref_id, ); $dbxrefs = chado_query($dbxref_sql, $args); $xrefs = ''; while ($dbxref = $dbxrefs->fetchObject()) { if ($dbxref->dbname = 'GFF_source') { continue; } $xrefs .= $dbxref->dbname . ":" . $dbxref->accession . ","; } if ($xrefs) { print "Dbxref=" . substr($xrefs, 0, -1) . ";"; } // Add in any CVTerm records $args = array(':feature_id' => $line->feature_id); $cvterms = chado_query($cvterm_sql, $args); $xrefs = ''; while ($cvterm = $cvterms->fetchObject()) { $xrefs .= $cvterm->db_name . ":" . $cvterm->accession . ","; } if ($xrefs) { print "Ontology_term=" . substr($xrefs, 0, -1) . ";"; } print "\n"; // Look for children of this feature and recursively add them. $children_sql = " SELECT FR.subject_id FROM {feature_relationship} FR INNER JOIN {cvterm} CVT on CVT.cvterm_id = FR.type_id WHERE CVT.name = 'part_of' AND FR.object_id = :feature_id "; $children = chado_query($children_sql, array(':feature_id' => $line->feature_id)); while ($child = $children->fetchObject()) { $child_filters = array( 'feature_id' => $child->subject_id, ); tripal_chado_gff3_exporter($source, $child_filters); } } }