List of usage examples for org.apache.commons.lang RandomStringUtils randomNumeric
public static String randomNumeric(int count)
Creates a random string whose length is the number of characters specified.
Characters will be chosen from the set of numeric characters.
From source file:ubic.gemma.testing.PersistentDummyObjectHelper.java
/** * @param ee/*from www . ja v a 2s .c o m*/ */ public void addTestAnalyses(ExpressionExperiment ee) { /* * Add analyses */ ProbeCoexpressionAnalysis pca = ProbeCoexpressionAnalysis.Factory.newInstance(); pca.setName(RandomStringUtils.randomNumeric(RANDOM_STRING_LENGTH)); pca.setExperimentAnalyzed(ee); persisterHelper.persist(pca); /* * Diff */ DifferentialExpressionAnalysis expressionAnalysis = DifferentialExpressionAnalysis.Factory.newInstance(); Protocol protocol = Protocol.Factory.newInstance(); protocol.setName("Differential expression analysis settings"); protocol.setDescription("qvalue: " + true); expressionAnalysis.setProtocol(protocol); expressionAnalysis.setExperimentAnalyzed(ee); persisterHelper.persist(expressionAnalysis); }
From source file:ubic.gemma.testing.PersistentDummyObjectHelper.java
/** * @return//from w ww . j ava 2s . c o m */ public Gene getTestPeristentGene(Taxon t) { Gene gene = Gene.Factory.newInstance(); gene.setName(RandomStringUtils.randomNumeric(RANDOM_STRING_LENGTH) + "_test"); gene.setOfficialName(RandomStringUtils.randomNumeric(RANDOM_STRING_LENGTH) + "_test"); gene.setOfficialSymbol(RandomStringUtils.randomNumeric(RANDOM_STRING_LENGTH).toUpperCase()); if (t == null) { gene.setTaxon(this.getTestNonPersistentTaxon()); } else { gene.setTaxon(t); } GeneProduct gp = GeneProduct.Factory.newInstance(); gp.setGene(gene); gp.setName(RandomStringUtils.randomNumeric(5) + "_test"); gene.getProducts().add(gp); return (Gene) persisterHelper.persist(gene); }
From source file:ubic.gemma.testing.PersistentDummyObjectHelper.java
/** * Convenience method to provide an ArrayDesign that can be used to fill non-nullable associations in test objects. * The ArrayDesign is provided with some CompositeSequenece DesignElements if desired. If composite seequences are * created, they are each associated with a single generated Reporter. * // w w w . j a va2s .c o m * @param numCompositeSequences The number of CompositeSequences to populate the ArrayDesign with. * @param randomNames If true, probe names will be random strings; otherwise they will be 0_probe_at....N_probe_at * @param dosequence If true, biosequences and biosequence2GeneProduct associations are filled in (slower). * @return ArrayDesign */ public ArrayDesign getTestPersistentArrayDesign(int numCompositeSequences, boolean randomNames, boolean dosequence) { ArrayDesign ad = ArrayDesign.Factory.newInstance(); ad.setName("arrayDesign_" + RandomStringUtils.randomAlphabetic(RANDOM_STRING_LENGTH)); ad.setShortName("AD_" + RandomStringUtils.randomAlphabetic(5)); ad.setTechnologyType(TechnologyType.ONECOLOR); ad.setPrimaryTaxon(this.getTestPersistentTaxon()); for (int i = 0; i < numCompositeSequences; i++) { // Reporter reporter = Reporter.Factory.newInstance(); CompositeSequence compositeSequence = CompositeSequence.Factory.newInstance(); if (randomNames) { compositeSequence.setName(RandomStringUtils.randomNumeric(RANDOM_STRING_LENGTH) + "_testcs"); } else { compositeSequence.setName("probeset_" + i); } // compositeSequence.getComponentReporters().add( reporter ); compositeSequence.setArrayDesign(ad); ad.getCompositeSequences().add(compositeSequence); if (dosequence) { BioSequence bioSequence = getTestPersistentBioSequence(); compositeSequence.setBiologicalCharacteristic(bioSequence); bioSequence.setBioSequence2GeneProduct(this.getTestPersistentBioSequence2GeneProducts(bioSequence)); } } for (CompositeSequence cs : ad.getCompositeSequences()) { cs.setArrayDesign(ad); } assert (ad.getCompositeSequences().size() == numCompositeSequences); return (ArrayDesign) persisterHelper.persist(ad); }
From source file:ubic.gemma.testing.PersistentDummyObjectHelper.java
/** * @param ad//from w w w. jav a 2 s. c o m * @param bm * @return */ private BioAssay getTestNonPersistentBioAssay(ArrayDesign ad, BioMaterial bm) { BioAssay ba = ubic.gemma.model.expression.bioAssay.BioAssay.Factory.newInstance(); ba.setName(RandomStringUtils.randomNumeric(RANDOM_STRING_LENGTH) + "_testbioassay"); ba.setSampleUsed(bm); ba.setArrayDesignUsed(ad); ba.setIsOutlier(false); ba.setSequencePairedReads(false); DatabaseEntry de = DatabaseEntry.Factory.newInstance(); de.setExternalDatabase(this.geo); de.setAccession(ba.getName()); ba.setAccession(de); LocalFile file = LocalFile.Factory.newInstance(); try { file.setLocalURL(new URL("file:///tmp/" + ba.getName())); } catch (MalformedURLException e) { } ba.setRawDataFile(file); LocalFile fileb = LocalFile.Factory.newInstance(); try { fileb.setLocalURL(new URL("file:///tmp/raw" + ba.getName())); } catch (MalformedURLException e) { } ba.setRawDataFile(file); ba.getDerivedDataFiles().add(fileb); return ba; }
From source file:ubic.gemma.testing.PersistentDummyObjectHelper.java
/** * Slightly misleading, associations are persistent. * /*from w w w. jav a 2 s . co m*/ * @return */ private BioMaterial getTestNonPersistentBioMaterial() { BioMaterial bm = BioMaterial.Factory.newInstance(); bm.setName(RandomStringUtils.randomNumeric(RANDOM_STRING_LENGTH) + "_testbiomaterial"); if (geo == null) { geo = externalDatabaseService.find("GEO"); assert geo != null; } bm.setSourceTaxon(getTestNonPersistentTaxon()); bm.setExternalAccession(this.getTestPersistentDatabaseEntry(geo)); return bm; }
From source file:ubic.gemma.testing.PersistentDummyObjectHelper.java
/** * Slightly misleading, associations are persistent. * //from w w w . ja v a 2s .c om * @return */ private BioMaterial getTestNonPersistentBioMaterial(Taxon tax) { BioMaterial bm = BioMaterial.Factory.newInstance(); bm.setName(RandomStringUtils.randomNumeric(RANDOM_STRING_LENGTH) + "_testbiomaterial"); if (geo == null) { geo = externalDatabaseService.find("GEO"); assert geo != null; } bm.setSourceTaxon(tax); bm.setExternalAccession(this.getTestPersistentDatabaseEntry(geo)); return bm; }
From source file:ubic.gemma.testing.PersistentDummyObjectHelper.java
/** * @return/* ww w . j a v a2 s.c o m*/ */ public BioSequence getTestNonPersistentBioSequence() { BioSequence bs = BioSequence.Factory.newInstance(); bs.setName(RandomStringUtils.randomNumeric(RANDOM_STRING_LENGTH) + "_testbiosequence"); bs.setSequence(RandomStringUtils.random(40, "ATCG")); bs.setTaxon(getTestNonPersistentTaxon()); if (this.genbank == null) { genbank = ExternalDatabase.Factory.newInstance(); genbank.setName("Genbank"); } DatabaseEntry de = DatabaseEntry.Factory.newInstance(); de.setExternalDatabase(this.genbank); de.setAccession(RandomStringUtils.randomAlphanumeric(10)); bs.setSequenceDatabaseEntry(de); return bs; }
From source file:ubic.gemma.testing.PersistentDummyObjectHelper.java
/** * Convenience method to provide a Contact that can be used to fill non-nullable associations in test objects. * //from w w w . ja v a 2s . co m * @return */ public Contact getTestPersistentContact() { Contact c = Contact.Factory.newInstance(); c.setName(RandomStringUtils.randomNumeric(RANDOM_STRING_LENGTH) + "_testcontact"); c.setEmail(c.getName() + "@foo.org"); c = (Contact) persisterHelper.persist(c); return c; }
From source file:ubic.gemma.testing.PersistentDummyObjectHelper.java
/** * Convenience method to provide a DatabaseEntry that can be used to fill non-nullable associations in test objects. * The accession and ExternalDatabase name are set to random strings. * /* w w w.ja v a 2 s . co m*/ * @return */ public DatabaseEntry getTestPersistentDatabaseEntry(String accession, ExternalDatabase ed) { DatabaseEntry result = DatabaseEntry.Factory.newInstance(); if (accession == null) { result.setAccession(RandomStringUtils.randomNumeric(RANDOM_STRING_LENGTH) + "_testaccession"); } else { result.setAccession(accession); } if (ed == null) { ed = ExternalDatabase.Factory.newInstance(); ed.setName(RandomStringUtils.randomNumeric(RANDOM_STRING_LENGTH) + "_testdb"); ed = (ExternalDatabase) persisterHelper.persist(ed); } result.setExternalDatabase(ed); return result; }
From source file:ubic.gemma.testing.PersistentDummyObjectHelper.java
/** * Convenience method to provide an ExpressionExperiment that can be used to fill non-nullable associations in test * objects. This implementation does NOT fill in associations of the created object. * /*from w ww.j a v a 2 s . c o m*/ * @return */ public ExpressionExperiment getTestPersistentExpressionExperiment() { ExpressionExperiment ee = ExpressionExperiment.Factory.newInstance(); ee.setName(RandomStringUtils.randomNumeric(RANDOM_STRING_LENGTH) + "_testee"); ee = (ExpressionExperiment) persisterHelper.persist(ee); return ee; }