NAL-i5K / tripal_eutils

ncbi loader via the eutils interface
GNU General Public License v3.0
4 stars 3 forks source link

will secondary records have all necessary associations? #187

Closed bradfordcondon closed 5 years ago

bradfordcondon commented 5 years ago

user inserts an assembly, creating linked records.

The linked project wont insert all of the extra stuff in it. however, will it LINK things to that project properly, if those linked records are in the db?

bradfordcondon commented 5 years ago

i think the answer is no.

/**
   * Creates a project and linked records.
   *
   * @param array $data
   *   Data from bioproject parser.
   *
   * @return object
   *   chado project record.
   *
   * @throws \Exception
   */
  public function create(array $data) {
    // Throw an exception if a required field is missing.
    $this->validateFields($data);

    // Create the base record.
    $description = is_array($data['description']) ? implode("\n",
      $data['description']) : $data['description'];

    $project = $this->createproject([
      'name' => $data['name'],
      'description' => $description,
    ]);

    $this->base_record_id = $project->project_id;
    $this->createAccessions($data['accessions']);
    $this->createProps($data['attributes']);

    $this->createXMLProp($data['full_ncbi_xml']);

    if ($this->create_linked_records) {

      $links = $data['linked_records'];
      $pubs = $links['pubs'];
      $biosamples = $links['biosample'];
      $assemblies = $links['assembly'];
      if (!empty($biosamples)) {
        $this->createLinkedRecords($biosamples, 'biosample');
      }
      if (!empty($assemblies)) {
        $this->createLinkedRecords($assemblies, 'assembly');
      }
      // Pubs are linked records but we always want to import them
      // since they wont cause a link-loop.
      if (!empty($pubs)) {
        $this->createPubs($pubs);
      }
    }

    return $project;
  }

instead of wrapping all the linking logic in $this->create_linked_records, we need only block creation. If the record exists in the db, or in the cache, then we still want to link.