protected Key keyForBioSource(BioSource bioSource) { StringBuilder sb = new StringBuilder(256); sb.append("BioSource:").append(bioSource.getTaxId()); if (bioSource.getCvCellType() != null) { sb.append("|").append(bioSource.getCvCellType().getIdentifier()); } if (bioSource.getCvTissue() != null) { sb.append("|").append(bioSource.getCvTissue().getIdentifier()); } return new Key(sb.toString()); }
protected Key keyForBioSource(BioSource bioSource) { StringBuilder sb = new StringBuilder(256); sb.append("BioSource:").append(bioSource.getTaxId()); if (bioSource.getCvCellType() != null) { sb.append("|").append(bioSource.getCvCellType().getIdentifier()); } if (bioSource.getCvTissue() != null) { sb.append("|").append(bioSource.getCvTissue().getIdentifier()); } return new Key(sb.toString()); }
private static void displayFoundMessage( BioSource bioSource ) { StringBuffer sb = new StringBuffer( 128 ); sb.append( "Found BioSource by taxid " ).append( bioSource.getTaxId() ); sb.append( ". Shortlabel is " ).append( bioSource.getShortLabel() ); if ( null != bioSource.getCvCellType() ) { sb.append( ", Celltype shortlabel: " ).append( bioSource.getCvCellType().getShortLabel() ); } else { sb.append( ", No CellType" ); } if ( null != bioSource.getCvTissue() ) { sb.append( ", Tissue shortlabel: " ).append( bioSource.getCvTissue().getShortLabel() ); } else { sb.append( ", No Tissue" ); } System.out.println( sb.toString() ); }
private static void displayFoundMessage( BioSource bioSource ) { StringBuffer sb = new StringBuffer( 128 ); sb.append( "Found BioSource by taxid " ).append( bioSource.getTaxId() ); sb.append( ". Shortlabel is " ).append( bioSource.getShortLabel() ); if ( null != bioSource.getCvCellType() ) { sb.append( ", Celltype shortlabel: " ).append( bioSource.getCvCellType().getShortLabel() ); } else { sb.append( ", No CellType" ); } if ( null != bioSource.getCvTissue() ) { sb.append( ", Tissue shortlabel: " ).append( bioSource.getCvTissue().getShortLabel() ); } else { sb.append( ", No Tissue" ); } System.out.println( sb.toString() ); }
public BioSource getByTaxonIdUnique( String taxonId ) { if ( taxonId == null ) { throw new NullPointerException( "taxonId must not be null." ); } Collection<BioSource> biosources = getByTaxonId( taxonId ); // Get the biosource with null values for cell type and tisse // (there is only one of them exists). for ( BioSource biosrc : biosources ) { if ( ( biosrc.getCvCellType() == null ) && ( biosrc.getCvTissue() == null ) ) { return biosrc; } } // None found. return null; }
private static void displayFoundMessage( BioSource bioSource ) { StringBuffer sb = new StringBuffer( 128 ); sb.append( "Found BioSource by taxid " ).append( bioSource.getTaxId() ); sb.append( ". Shortlabel is " ).append( bioSource.getShortLabel() ); if ( null != bioSource.getCvCellType() ) { sb.append( ", Celltype shortlabel: " ).append( bioSource.getCvCellType().getShortLabel() ); } else { sb.append( ", No CellType" ); } if ( null != bioSource.getCvTissue() ) { sb.append( ", Tissue shortlabel: " ).append( bioSource.getCvTissue().getShortLabel() ); } else { sb.append( ", No Tissue" ); } System.out.println( sb.toString() ); }
public BioSource getByTaxonIdUnique( String taxonId ) { if ( taxonId == null ) { throw new NullPointerException( "taxonId must not be null." ); } Collection<BioSource> biosources = getByTaxonId( taxonId ); // Get the biosource with null values for cell type and tisse // (there is only one of them exists). for ( BioSource biosrc : biosources ) { if ( ( biosrc.getCvCellType() == null ) && ( biosrc.getCvTissue() == null ) ) { return biosrc; } } // None found. return null; }
public BioSource getByTaxonIdUnique( String taxonId ) { if ( taxonId == null ) { throw new NullPointerException( "taxonId must not be null." ); } Collection<BioSource> biosources = getByTaxonId( taxonId ); // Get the biosource with null values for cell type and tisse // (there is only one of them exists). for ( BioSource biosrc : biosources ) { if ( ( biosrc.getCvCellType() == null ) && ( biosrc.getCvTissue() == null ) ) { return biosrc; } } // None found. return null; }
/** * Finds a biosource based on its properties. * * @param bioSource the object we are searching an AC for. * @return an AC or null if it couldn't be found. */ protected String findAcForBioSource( BioSource bioSource ) { Query query = getEntityManager().createQuery( "select bio.ac, cellType, tissue " + "from BioSource bio " + "left join bio.cvCellType as cellType " + "left join bio.cvTissue as tissue " + "where bio.taxId = :taxId" ); query.setParameter( "taxId", bioSource.getTaxId() ); final List<Object[]> biosources = query.getResultList(); for ( Object[] bs : biosources ) { String ac = ( String ) bs[0]; CvCellType cellType = ( CvCellType ) bs[1]; CvTissue tissue = ( CvTissue ) bs[2]; if ( same( tissue, bioSource.getCvTissue() ) && same( cellType, bioSource.getCvCellType() ) ) { return ac; } } return null; }
/** * Finds a biosource based on its properties. * * @param bioSource the object we are searching an AC for. * @return an AC or null if it couldn't be found. */ protected String findAcForBioSource( BioSource bioSource ) { Query query = getEntityManager().createQuery( "select bio.ac, cellType, tissue " + "from BioSource bio " + "left join bio.cvCellType as cellType " + "left join bio.cvTissue as tissue " + "where bio.taxId = :taxId" ); query.setParameter( "taxId", bioSource.getTaxId() ); final List<Object[]> biosources = query.getResultList(); for ( Object[] bs : biosources ) { String ac = ( String ) bs[0]; CvCellType cellType = ( CvCellType ) bs[1]; CvTissue tissue = ( CvTissue ) bs[2]; if ( same( tissue, bioSource.getCvTissue() ) && same( cellType, bioSource.getCvCellType() ) ) { return ac; } } return null; }
protected void traverseBioSource(BioSource bioSource, IntactVisitor ... visitors) { if (bioSource == null) return; for (IntactVisitor visitor : visitors) { visitor.visitBioSource(bioSource); } // check if this element has been traversed already, to avoid cyclic recursion if (recursionChecker.isAlreadyTraversed(bioSource)) { return; } traverse(bioSource.getCvCellType(), visitors); traverse(bioSource.getCvTissue(), visitors); }
protected void traverseBioSource(BioSource bioSource, IntactVisitor ... visitors) { if (bioSource == null) return; for (IntactVisitor visitor : visitors) { visitor.visitBioSource(bioSource); } // check if this element has been traversed already, to avoid cyclic recursion if (recursionChecker.isAlreadyTraversed(bioSource)) { return; } traverse(bioSource.getCvCellType(), visitors); traverse(bioSource.getCvTissue(), visitors); }
/** * Select a BioSource that has neither CvCellType nor CvTissue. * * @param bioSources the Collection of BioSource that potentially contains some having CvCellType or CvTissue. * * @return the unique BioSource that has neither CvCellType nor CvTissue * * @throws BioSourceServiceException if several of such BioSource are found in the database. */ private BioSource getOriginalBioSource( Collection<BioSource> bioSources ) throws BioSourceServiceException { BioSource original = null; for ( BioSource bioSource : bioSources ) { if ( bioSource.getCvTissue() == null && bioSource.getCvCellType() == null ) { if ( original == null ) { // first one is found original = bioSource; } else { // multiple bioSource found String msg = "More than one BioSource with this taxId " + original.getTaxId() + "and CvTissue/CvCellType were found: " + original.getAc() + " and " + "" + bioSource.getAc(); log.error( msg ); throw new BioSourceServiceException( msg ); } } } return original; }
private void synchronizeBioSource( BioSource bioSource, boolean synchronizeAnnotatedAttributes ) { bioSource.setCvCellType( synchronize( bioSource.getCvCellType() ) ); bioSource.setCvTissue( synchronize( bioSource.getCvTissue() ) ); if (synchronizeAnnotatedAttributes){ synchronizeAnnotatedObjectCommons( bioSource ); } }
private void synchronizeBioSource( BioSource bioSource, boolean synchronizeAnnotatedAttributes ) { bioSource.setCvCellType( synchronize( bioSource.getCvCellType() ) ); bioSource.setCvTissue( synchronize( bioSource.getCvTissue() ) ); if (synchronizeAnnotatedAttributes){ synchronizeAnnotatedObjectCommons( bioSource ); } }
protected UniquenessStringBuilder createUniquenessString(BioSource bioSource) { if (keyExists(bioSource)) { UniquenessStringBuilder builder = getKey(bioSource); if (builder != null){ return builder; } else{ identityToCrc.remove(System.identityHashCode(bioSource)); } } UniquenessStringBuilder sb = new UniquenessStringBuilder(); putKey(bioSource, sb); if (bioSource == null) return sb; // tax id sb.append(bioSource.getTaxId()); // tissue sb.append(createUniquenessString(bioSource.getCvTissue())); // cell type sb.append(createUniquenessString(bioSource.getCvCellType())); return sb; }
protected UniquenessStringBuilder createUniquenessString(BioSource bioSource) { if (keyExists(bioSource)) { UniquenessStringBuilder builder = getKey(bioSource); if (builder != null){ return builder; } else{ identityToCrc.remove(System.identityHashCode(bioSource)); } } UniquenessStringBuilder sb = new UniquenessStringBuilder(); putKey(bioSource, sb); if (bioSource == null) return sb; // tax id sb.append(bioSource.getTaxId()); // tissue sb.append(createUniquenessString(bioSource.getCvTissue())); // cell type sb.append(createUniquenessString(bioSource.getCvCellType())); return sb; }
public BioSource cloneBioSource(BioSource bioSource) throws IntactClonerException { if (bioSource == null) return null; BioSource clone = new BioSource(); clonerManager.addClone(bioSource, clone); clone.setTaxId(bioSource.getTaxId()); clone.setCvCellType(clone(bioSource.getCvCellType())); clone.setCvTissue(clone(bioSource.getCvTissue())); return clone; }
public BioSource cloneBioSource(BioSource bioSource) throws IntactClonerException { if (bioSource == null) return null; BioSource clone = new BioSource(); clonerManager.addClone(bioSource, clone); clone.setTaxId(bioSource.getTaxId()); clone.setCvCellType(clone(bioSource.getCvCellType())); clone.setCvTissue(clone(bioSource.getCvTissue())); return clone; }
public Organism intactToPsi(BioSource intactObject) { intactStartConversation(intactObject); Organism organism = new Organism(); // populates names // Set id, annotations, xrefs and aliases PsiConverterUtils.populateNames(intactObject, organism, aliasConverter); // taxId if (intactObject.getTaxId() != null){ organism.setNcbiTaxId(Integer.valueOf(intactObject.getTaxId())); } else { log.error("BioSource without taxId : " + intactObject.getShortLabel()); } // cell type final CvCellType intactCellType = intactObject.getCvCellType(); if (intactCellType != null) { CellType psiCellType = cellTypeConverter.intactToPsi(intactCellType); organism.setCellType(psiCellType); } // tissue final CvTissue intactTissue = intactObject.getCvTissue(); if (intactTissue != null) { Tissue psiTissue = tissueConverter.intactToPsi(intactTissue); organism.setTissue(psiTissue); } intactEndConversion(intactObject); return organism; }