function tripal_pub_add_publications
2.x tripal_pub.pub_importers.inc | tripal_pub_add_publications($pubs, $do_contact, $update = FALSE) |
3.x tripal_chado.pub_importers.inc | tripal_pub_add_publications($pubs, $do_contact, $update = FALSE) |
1.x tripal_pub.api.inc | tripal_pub_add_publications($pubs, $do_contact, $update = FALSE) |
3 calls to tripal_pub_add_publications()
- tripal_pub_import_by_dbxref in tripal_pub/
api/ tripal_pub.api.inc - tripal_pub_import_publications in tripal_pub/
api/ tripal_pub.api.inc - tripal_pub_update_publications in tripal_pub/
api/ tripal_pub.api.inc
File
- tripal_pub/
api/ tripal_pub.api.inc, line 359 - The Tripal Pub API
Code
function tripal_pub_add_publications($pubs, $do_contact, $update = FALSE) {
$report = array();
$report['error'] = 0;
$report['inserted'] = array();
$report['skipped'] = array();
$total_pubs = count($pubs);
// iterate through the publications and add each one
$i = 1;
foreach ($pubs as $pub) {
$memory = number_format(memory_get_usage()) . " bytes";
print "Processing $i of $total_pubs. Memory usage: $memory.\r";
// add the publication to Chado
$action = '';
// make sure the publication has a citation before trying to add. The citation
// becomes the uniquename for the pub. If it doesn't exist then the importer
// couldn't create one because the pub type is not handled, so skip it
if (!$pub['Citation']) {
$action = 'skipped';
}
else {
$pub_id = tripal_pub_add_publication($pub, $action, $do_contact, $update);
}
if ($pub_id) {
// add the publication cross reference (e.g. to PubMed)
if ($pub['Publication Dbxref']) {
$pub_dbxref = tripal_pub_add_pub_dbxref($pub_id, $pub['Publication Dbxref']);
}
$pub['pub_id'] = $pub_id;
}
switch ($action) {
case 'error':
$report['error']++;
break;
case 'inserted':
$report['inserted'][] = $pub;
break;
case 'updated':
$report['updated'][] = $pub;
break;
case 'skipped':
$report['skipped'][] = $pub;
break;
}
$i++;
}
print "\n";
return $report;
}