public ProteinDao getProteinDao() { return new ProteinDaoImpl( getCurrentSession(), intactSession ); }
public List<ProteinImpl> getUniprotProteins( Integer firstResult, Integer maxResults ) { Criteria crit = criteriaForUniprotProteins() .addOrder( Order.asc( "xref.primaryId" ) ); if ( firstResult != null && firstResult >= 0 ) { crit.setFirstResult( firstResult ); } if ( maxResults != null && maxResults > 0 ) { crit.setMaxResults( maxResults ); } return crit.list(); }
public List<ProteinImpl> getByUniprotId( String uniprotId ) { return getSession().createCriteria( getEntityClass() ) .createAlias( "xrefs", "xref" ) .createAlias( "xref.cvXrefQualifier", "qual" ) .createAlias( "xref.cvDatabase", "database" ) .createCriteria( "qual.xrefs", "qualXref" ) .createCriteria( "database.xrefs", "dbXref" ) .add( Restrictions.eq( "qualXref.primaryId", CvXrefQualifier.IDENTITY_MI_REF ) ) .add( Restrictions.eq( "dbXref.primaryId", CvDatabase.UNIPROT_MI_REF ) ) .add( Restrictions.eq( "xref.primaryId", uniprotId ) ).list(); }
public List<String> getUniprotUrlTemplateByProteinAc( String proteinAc ) { if ( proteinAc == null ) { throw new NullPointerException( "proteinAc" ); } Criteria crit = getSession().createCriteria( ProteinImpl.class ) .add( Restrictions.idEq( proteinAc ) ) .createAlias( "xrefs", "xref" ) .createAlias( "xref.cvXrefQualifier", "cvQual" ) .createAlias( "xref.cvDatabase", "cvDb" ) .createAlias( "cvDb.annotations", "annot" ) .createAlias( "annot.cvTopic", "cvTopic" ) .add( Restrictions.eq( "cvQual.shortLabel", CvXrefQualifier.IDENTITY ) ) .add( Restrictions.eq( "cvTopic.shortLabel", CvTopic.SEARCH_URL ) ) .setProjection( Projections.property( "annot.annotationText" ) ); return crit.list(); }
public List<String> getPartnersUniprotIdsByProteinAc( String proteinAc ) { return partnersByProteinAcCriteria( proteinAc ) .createAlias( "prot.xrefs", "xref" ) .createAlias( "xref.cvXrefQualifier", "qual" ) .createAlias( "xref.cvDatabase", "database" ) .createCriteria( "qual.xrefs", "qualXref" ) .createCriteria( "database.xrefs", "dbXref" ) .add( Restrictions.eq( "qualXref.primaryId", CvXrefQualifier.IDENTITY_MI_REF ) ) .add( Restrictions.eq( "dbXref.primaryId", CvDatabase.UNIPROT_MI_REF ) ) .setProjection( Projections.distinct( Property.forName( "xref.primaryId" ) ) ).list(); }
public List<ProteinImpl> getSpliceVariants( Protein protein ) { if ( protein == null ) { throw new NullPointerException( "The master protein must not be null." ); } String ac = protein.getAc(); if ( ac == null ) { // This protein doesn't have an AC, it cannot have splice variants. return new ArrayList<ProteinImpl>( 1 ); } return getSession().createCriteria( ProteinImpl.class ) .createAlias( "xrefs", "xref" ) .createAlias( "xref.cvXrefQualifier", "qual" ) .createAlias( "xref.cvDatabase", "database" ) .createCriteria( "qual.xrefs", "qualXref" ) .createCriteria( "database.xrefs", "dbXref" ) .add( Restrictions.eq( "qualXref.primaryId", CvXrefQualifier.ISOFORM_PARENT_MI_REF ) ) .add( Restrictions.eq( "dbXref.primaryId", CvDatabase.INTACT_MI_REF ) ) .add( Restrictions.eq( "xref.primaryId", ac ) ).list(); }
public Integer countPartnersByProteinAc( String proteinAc ) { return ( Integer ) partnersByProteinAcCriteria( proteinAc ) .setProjection( Projections.countDistinct( "prot.ac" ) ).uniqueResult(); }
public String getUniprotAcByProteinAc( String proteinAc ) { Criteria crit = getSession().createCriteria( ProteinImpl.class ) .add( Restrictions.idEq( proteinAc ) ) .createAlias( "xrefs", "xref" ) .createAlias( "xref.cvXrefQualifier", "qual" ) .add( Restrictions.eq( "qual.shortLabel", CvXrefQualifier.IDENTITY ) ) .setProjection( Projections.property( "xref.primaryId" ) ); return ( String ) crit.uniqueResult(); }
public List<ProteinImpl> getUniprotProteinsInvolvedInInteractions( Integer firstResult, Integer maxResults ) { Criteria crit = criteriaForUniprotProteins() .add( Restrictions.isNotEmpty( "activeInstances" ) ) .addOrder( Order.asc( "xref.primaryId" ) ); if ( firstResult != null && firstResult >= 0 ) { crit.setFirstResult( firstResult ); } if ( maxResults != null && maxResults > 0 ) { crit.setMaxResults( maxResults ); } return crit.list(); }
public Map<String, List<String>> getPartnersWithInteractionAcsByProteinAc( String proteinAc ) { Criteria crit = partnersByProteinAcCriteria( proteinAc ) .setProjection( Projections.projectionList() .add( Projections.distinct( Projections.property( "prot.ac" ) ) ) .add( Projections.property( "int.ac" ) ) ) .addOrder( Order.asc( "prot.ac" ) ); Map<String, List<String>> results = new HashMap<String, List<String>>(); for ( Object[] res : ( List<Object[]> ) crit.list() ) { String partnerProtAc = ( String ) res[0]; String interactionAc = ( String ) res[1]; if ( results.containsKey( partnerProtAc ) ) { results.get( partnerProtAc ).add( interactionAc ); } else { List<String> interactionAcList = new ArrayList<String>(); interactionAcList.add( interactionAc ); results.put( partnerProtAc, interactionAcList ); } } return results; }
public String getIdentityXrefByProteinAc( String proteinAc ) { Criteria crit = getSession().createCriteria( ProteinImpl.class ) .add( Restrictions.idEq( proteinAc ) ) .createAlias( "xrefs", "xref" ) .createAlias( "xref.cvXrefQualifier", "qual" ) .add( Restrictions.eq( "qual.shortLabel", CvXrefQualifier.IDENTITY ) ) .setProjection( Projections.property( "xref.ac" ) ); return ( String ) crit.uniqueResult(); }
public Integer countUniprotProteinsInvolvedInInteractions() { return ( Integer ) criteriaForUniprotProteins() .add( Restrictions.isNotEmpty( "activeInstances" ) ) .setProjection( Projections.rowCount() ).uniqueResult(); }
CvXrefQualifier isoformParent = ( CvXrefQualifier ) getSession().createCriteria( CvXrefQualifier.class ) .createAlias( "xrefs", "xref" ) .createAlias( "xref.cvXrefQualifier", "qual" ) return ( ProteinImpl ) getSession().createCriteria( ProteinImpl.class ) .add( Restrictions.eq( "ac", masterAc ) ).uniqueResult();
public Integer countUniprotProteins() { return ( Integer ) criteriaForUniprotProteins() .setProjection( Projections.rowCount() ).uniqueResult(); }
private Criteria partnersByProteinAcCriteria( String proteinAc ) { if ( proteinAc == null ) { throw new NullPointerException( "proteinAc" ); } return getSession().createCriteria( InteractorImpl.class ) .add( Restrictions.idEq( proteinAc ) ) .createAlias( "activeInstances", "comp" ) .createAlias( "comp.interaction", "int" ) .createAlias( "int.components", "intcomp" ) .createAlias( "intcomp.interactor", "prot" ) .add( Restrictions.disjunction() .add( Restrictions.ne( "prot.ac", proteinAc ) ) .add( Restrictions.eq( "comp.stoichiometry", 2f ) ) ); }
public Map<String, Integer> getPartnersCountingInteractionsByProteinAc( String proteinAc ) { if ( proteinAc == null ) { throw new NullPointerException( "proteinAc" ); } Criteria crit = getSession().createCriteria( ProteinImpl.class ) .add( Restrictions.idEq( proteinAc ) ) .createAlias( "activeInstances", "comp" ) .createAlias( "comp.interaction", "int" ) .createAlias( "int.components", "intcomp" ) .createAlias( "intcomp.interactor", "prot" ) .add( Restrictions.disjunction() .add( Restrictions.ne( "prot.ac", proteinAc ) ) .add( Restrictions.eq( "comp.stoichiometry", 2f ) ) ) .setProjection( Projections.projectionList() .add( Projections.countDistinct( "int.ac" ) ) .add( Projections.groupProperty( "prot.ac" ) ) ); List<Object[]> queryResults = crit.list(); Map<String, Integer> results = new HashMap<String, Integer>( queryResults.size() ); for ( Object[] res : queryResults ) { results.put( ( String ) res[1], ( Integer ) res[0] ); } return results; }
/** * Builds a Hibernate Criteria allowing to select a UniProt protein. * * @return a non null Hibernate criteria. */ private Criteria criteriaForUniprotProteins() { return getSession().createCriteria( ProteinImpl.class ) .createAlias( "xrefs", "xref" ) .createAlias( "xref.cvDatabase", "cvDatabase" ) .createAlias( "xref.cvXrefQualifier", "cvXrefQualifier" ) .add( Restrictions.eq( "cvDatabase.shortLabel", CvDatabase.UNIPROT ) ) .add( Restrictions.eq( "cvXrefQualifier.shortLabel", CvXrefQualifier.IDENTITY ) ) .add( Restrictions.not( Restrictions.like( "xref.primaryId", "A%" ) ) ) .add( Restrictions.not( Restrictions.like( "xref.primaryId", "B%" ) ) ) .add( Restrictions.not( Restrictions.like( "xref.primaryId", "C%" ) ) ); } }