organism = new DefaultOrganism( -1 ); organism.setScientificName( "In vitro" ); organism.setCommonName( "In vitro" ); return organism; case -2: organism = new DefaultOrganism( -2 ); organism.setScientificName( "Chemical synthesis" ); organism.setCommonName( "Chemical synthesis" ); return organism; case -3: organism = new DefaultOrganism( -3 ); organism.setScientificName( "Unknown" ); organism.setCommonName( "Unknown" ); return organism; case -4: organism = new DefaultOrganism( -4 ); organism.setScientificName( "In vivo" ); organism.setCommonName( "In vivo" ); return organism; case -5: organism = new DefaultOrganism( -5 ); organism.setScientificName( "In Silico" ); organism.setCommonName( "In Silico" ); return organism; default:
/*** * This method will copy properties of organism source in organism target and will override all the other properties of Target organism. * @param source * @param target */ public static void copyAndOverrideOrganismProperties(Organism source, Organism target){ if (source != null && target != null){ target.setCommonName(source.getCommonName()); target.setScientificName(source.getScientificName()); target.setCellType(source.getCellType()); target.setTissue(source.getTissue()); target.setCompartment(source.getCompartment()); target.setTaxId(source.getTaxId()); // copy collections target.getAliases().clear(); target.getAliases().addAll(source.getAliases()); } } }
public static psidev.psi.mi.jami.model.Organism createOrganismFromEntry(UniProtEntry entity){ if(entity.getNcbiTaxonomyIds() == null || entity.getNcbiTaxonomyIds().isEmpty()){ return OrganismUtils.createUnknownOrganism(); } else if(entity.getNcbiTaxonomyIds().size() > 1){ throw new IllegalArgumentException( "Uniprot entry ["+entity.getPrimaryUniProtAccession().getValue()+"] " +"has multiple organisms."); } else { String id = entity.getNcbiTaxonomyIds().get(0).getValue(); try{ psidev.psi.mi.jami.model.Organism o = new DefaultOrganism( Integer.parseInt( id ) ); if(entity.getOrganism().hasCommonName()) o.setCommonName(entity.getOrganism().getCommonName().getValue()); if(entity.getOrganism().getScientificName() != null) o.setScientificName(entity.getOrganism().getScientificName().getValue()); if(entity.getOrganism().hasSynonym()) o.getAliases().add(AliasUtils.createAlias(Alias.SYNONYM, Alias.SYNONYM_MI, entity.getOrganism().getSynonym().getValue())); return o; }catch(NumberFormatException n){ throw new IllegalArgumentException("Uniprot entry ["+entity.getPrimaryUniProtAccession().getValue()+"] " + "has a TaxonomyID which could not be cast to an integer: ("+id+").",n); } } } }