/**
   * Gets Interaction Detection element. It is possible that an interaction is missing important
   * attributes, such as Experimental System Name, XRef DB, and XRef ID. All of these attributes are
   * required by PSI. Rather than throwing an exception here, the data_mapper manually specifies
   * "Not Specified" for all missing attributes.
   *
   * @param interaction Interaction.
   * @return InteractionDetection Object.
   */
  private CvType getInteractionDetection(
      org.cytoscape.coreplugin.psi_mi.model.Interaction interaction) {
    CvType interactionDetection = new CvType();
    String idStr = null;

    try {
      idStr = (String) interaction.getAttribute(InteractionVocab.EXPERIMENTAL_SYSTEM_NAME);
    } catch (ClassCastException e) {
      idStr = null;
    }

    if (idStr == null) {
      idStr = "Not Specified";
    }

    String idRef = null;

    try {
      idRef = (String) interaction.getAttribute(InteractionVocab.EXPERIMENTAL_SYSTEM_XREF_ID);
    } catch (ClassCastException e) {
      idRef = null;
    }

    //  If there is no ID Ref, find a best match.
    if (idRef == null) {
      if (idStr.equals(EXP_AFFINITY_PRECIPITATION) || idStr.equals(EXP_AFFINITY_CHROMOTOGRAPHY)) {
        idStr = "affinity chromatography technologies";
        idRef = "MI:0004";
      } else if (idStr.equals(EXP_TWO_HYBRID)) {
        idStr = "classical two hybrid";
        idRef = "MI:0018";
      } else if (idStr.equals(EXP_PURIFIED_COMPLEX)) {
        idStr = "copurification";
        idRef = "MI:0025";
      } else {
        idRef = "Not Specified";
      }
    }

    NamesType names = createName(idStr, null);
    interactionDetection.setNames(names);

    String dbRef = null;

    try {
      dbRef = (String) interaction.getAttribute(InteractionVocab.EXPERIMENTAL_SYSTEM_XREF_DB);
    } catch (ClassCastException e) {
      dbRef = null;
    }

    if (dbRef == null) {
      dbRef = "PSI-MI";
    }

    XrefType xref = createXRef(dbRef, idRef);
    interactionDetection.setXref(xref);

    return interactionDetection;
  }
  /**
   * Gets Experiment Description.
   *
   * @param interaction Interaction object.
   * @return Castor InteractionElementTypeChoice object.
   */
  private InteractionElementType.ExperimentList getExperimentDescription(
      org.cytoscape.coreplugin.psi_mi.model.Interaction interaction, int index) {
    //  Create New Experiment List
    InteractionElementType.ExperimentList expList = new InteractionElementType.ExperimentList();

    //  Create New Experiment Description
    ExperimentType expType = new ExperimentType();

    //  Set Experimental ID
    expType.setId(index);

    //  Set Bibliographic Reference
    BibrefType bibRef = null;

    Object pmid = interaction.getAttribute(InteractionVocab.PUB_MED_ID);

    if ((pmid != null) && pmid instanceof String) {
      bibRef = createBibRef(PUB_MED_DB, (String) pmid);
      expType.setBibref(bibRef);
    }

    //  Set Interaction Detection
    CvType interactionDetection = getInteractionDetection(interaction);
    expType.setInteractionDetectionMethod(interactionDetection);

    //  Set Choice Element
    expList.getExperimentRefOrExperimentDescription().add(expType);

    return expList;
  }
  /**
   * Gets a complete list of NonRedundant Proteins.
   *
   * @return HashMap of NonRedundant Proteins.
   */
  private HashMap getNonRedundantInteractors() {
    HashMap interactorMap = new HashMap();

    for (int i = 0; i < interactions.size(); i++) {
      org.cytoscape.coreplugin.psi_mi.model.Interaction interaction =
          (org.cytoscape.coreplugin.psi_mi.model.Interaction) interactions.get(i);
      List interactors = interaction.getInteractors();

      for (int j = 0; j < interactors.size(); j++) {
        Interactor interactor = (Interactor) interactors.get(j);
        addToHashMap(interactor, interactorMap);
      }
    }

    return interactorMap;
  }
  /**
   * Gets the Interaction Participant List.
   *
   * @param interaction Interaction object.
   * @return Castor Participant List.
   */
  private InteractionElementType.ParticipantList getParticipantList(
      org.cytoscape.coreplugin.psi_mi.model.Interaction interaction) {
    InteractionElementType.ParticipantList participantList =
        new InteractionElementType.ParticipantList();

    List interactors = interaction.getInteractors();

    for (int i = 0; i < interactors.size(); i++) {
      Interactor interactor = (Interactor) interactors.get(i);
      String name = interactor.getName();
      ParticipantType participant1 = createParticipant(name);
      participantList.getParticipant().add(participant1);
    }

    return participantList;
  }