/** * Creates an instance of Polymer type based on type. * * @param owner The Institution which owns this instance * @param source The biological source of the Protein observation * @param shortLabel The memorable label to identify this instance * @param type The interactor type. This alone decides which type to create - should be not null. * * @return an instance of <code>Polymer</code> based on <code>type</code> or null if a Polymer cannot be * instantiated (for exampple, no MI found in given type) */ public static Polymer factory( Institution owner, BioSource source, String shortLabel, CvInteractorType type ) { Polymer polymer = null; if ( CvObjectUtils.isProteinType( type ) ) { polymer = new ProteinImpl( owner, source, shortLabel, type ); } else if ( CvObjectUtils.isPeptideType( type ) ) { polymer = new ProteinImpl( owner, source, shortLabel, type ); } else if ( CvObjectUtils.isNucleicAcidType( type ) ) { polymer = new NucleicAcidImpl( owner, source, shortLabel, type ); } else { throw new IllegalArgumentException( "The given MI is neither a Protein, a Peptide or a NUcleicAcid MI: " + type ); } return polymer; }
/** * Creates an instance of Polymer type based on type. * * @param owner The Institution which owns this instance * @param source The biological source of the Protein observation * @param shortLabel The memorable label to identify this instance * @param type The interactor type. This alone decides which type to create - should be not null. * * @return an instance of <code>Polymer</code> based on <code>type</code> or null if a Polymer cannot be * instantiated (for exampple, no MI found in given type) */ public static Polymer factory( Institution owner, BioSource source, String shortLabel, CvInteractorType type ) { Polymer polymer = null; if ( CvObjectUtils.isProteinType( type ) ) { polymer = new ProteinImpl( owner, source, shortLabel, type ); } else if ( CvObjectUtils.isPeptideType( type ) ) { polymer = new ProteinImpl( owner, source, shortLabel, type ); } else if ( CvObjectUtils.isNucleicAcidType( type ) ) { polymer = new NucleicAcidImpl( owner, source, shortLabel, type ); } else { throw new IllegalArgumentException( "The given MI is neither a Protein, a Peptide or a NUcleicAcid MI: " + type ); } return polymer; }
public Protein createProtein(String uniprotId, String shortLabel, BioSource bioSource) { CvInteractorType intType = createCvObject(CvInteractorType.class, CvInteractorType.PROTEIN_MI_REF, CvInteractorType.PROTEIN); Protein protein = new ProteinImpl(getInstitution(), bioSource, shortLabel, intType); InteractorXref idXref = createIdentityXrefUniprot(protein, uniprotId); protein.addXref(idXref); InteractorAlias alias = createAliasGeneName(protein, shortLabel.toUpperCase()); protein.addAlias(alias); String sequence = randomPeptideSequence(); String crc64 = Crc64.getCrc64(sequence); protein.setSequence(sequence); protein.setCrc64(crc64); return protein; }
polymer = new ProteinImpl( owner, source, shortLabel, type ); } else if ( CvInteractorType.isNucleicAcidMI( mi ) ) { polymer = new NucleicAcidImpl( owner, source, shortLabel, type );
private Protein createProtein(String uniprotId, String shortLabel, String geneName, BioSource bioSource, CvInteractorType intType) { Protein protein = new ProteinImpl(getInstitution(), bioSource, shortLabel, intType); InteractorXref idXref = createIdentityXrefUniprot(protein, uniprotId); protein.addXref(idXref); InteractorAlias alias = createAliasGeneName(protein, geneName); protein.addAlias(alias); String sequence = randomPeptideSequence(); String crc64 = Crc64.getCrc64(sequence); protein.setSequence(sequence); protein.setCrc64(crc64); return protein; }
private Protein createProtein(String uniprotId, String shortLabel, String geneName, BioSource bioSource, CvInteractorType intType) { Protein protein = new ProteinImpl(getInstitution(), bioSource, shortLabel, intType); InteractorXref idXref = createIdentityXrefUniprot(protein, uniprotId); protein.addXref(idXref); InteractorAlias alias = createAliasGeneName(protein, geneName); protein.addAlias(alias); String sequence = randomPeptideSequence(); String crc64 = Crc64.getCrc64(sequence); protein.setSequence(sequence); protein.setCrc64(crc64); return protein; }
interactor = new ProteinImpl( getInstitution(), organism, shortLabel, interactorType ); } else if ( CvInteractorType.PEPTIDE_MI_REF.equals(typeId)) { // found in dip interactor = new ProteinImpl( getInstitution(), organism, shortLabel, interactorType ); } else if ( CvInteractorType.SMALL_MOLECULE_MI_REF.equals(typeId)) { interactor = new SmallMoleculeImpl( shortLabel, getInstitution(), interactorType ); interactor = new ProteinImpl( getInstitution(), organism, shortLabel, interactorType ); } else if (interactorTypeLabel.equals( "peptide" ) ) { // found in dip interactor = new ProteinImpl( getInstitution(), organism, shortLabel, interactorType ); } else if ( interactorTypeLabel.equals( CvInteractorType.SMALL_MOLECULE ) ) { interactor = new SmallMoleculeImpl( shortLabel, getInstitution(), interactorType );
protein = new ProteinImpl( IntactContext.getCurrentInstance().getInstitution(), bioSource, shortlabel, proteinType ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getProteinDao().persist( (ProteinImpl)protein );
protein = new ProteinImpl( IntactContext.getCurrentInstance().getInstitution(), bioSource, shortlabel, proteinType ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getProteinDao().persist( (ProteinImpl)protein );
protein = new ProteinImpl( IntactContext.getCurrentInstance().getInstitution(), bioSource, shortlabel, proteinType ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getProteinDao().persist( (ProteinImpl)protein );
/** * Rigourous Test :-) */ public void testIsValidArgument() { Institution institution = new Institution("EBI"); BioSource bioSource = new BioSource(institution, "human", "9606"); CvInteractorType cvInteractorType = new CvInteractorType(institution,"protein"); Protein protein = new ProteinImpl(institution, bioSource, "lsm7", cvInteractorType); // This should return true. assertTrue(MethodArgumentValidator.isValidArgument(protein,Protein.class) ); // This should return true as Protein is a sub class of Interactor assertTrue(MethodArgumentValidator.isValidArgument(protein,Interactor.class) ); //This should send an IllegalArgumentException try{ MethodArgumentValidator.isValidArgument(protein,BioSource.class); fail("This should have sent and IllegalArgumentException as protein is not a BioSource"); }catch(IllegalArgumentException e){ assertTrue(true); } //This should send an NullPointerException try{ assertTrue(MethodArgumentValidator.isValidArgument(null,Interactor.class) ); fail("This should have sent and NullPointerException as protein is null"); }catch( NullPointerException e){ assertTrue(true); } }