use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.
the class AclAuthorizationTest method setup.
@Before
public void setup() {
arrayDesign = ArrayDesign.Factory.newInstance();
arrayDesign.setName(arrayDesignName);
arrayDesign.setShortName(arrayDesignName);
arrayDesign.setDescription("A test ArrayDesign from " + this.getClass().getName());
arrayDesign.setPrimaryTaxon(this.getTaxon("mouse"));
CompositeSequence cs1 = CompositeSequence.Factory.newInstance();
cs1.setName(compositeSequenceName1);
CompositeSequence cs2 = CompositeSequence.Factory.newInstance();
cs2.setName(compositeSequenceName2);
Collection<CompositeSequence> col = new HashSet<>();
col.add(cs1);
col.add(cs2);
cs1.setArrayDesign(arrayDesign);
cs2.setArrayDesign(arrayDesign);
arrayDesign.setCompositeSequences(col);
// persister helper
arrayDesign = (ArrayDesign) persisterHelper.persist(arrayDesign);
try {
userManager.loadUserByUsername(aDifferentUsername);
} catch (UsernameNotFoundException e) {
userManager.createUser(new UserDetailsImpl("foo", aDifferentUsername, true, null, RandomStringUtils.randomAlphabetic(10) + "@gmail.com", "key", new Date()));
}
}
use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.
the class CompositeSequenceGeneMapperServiceTest method testGetCompositeSequencesByGeneId.
/**
* Tests finding the composite sequences for a given gene id.
*/
@Test
public void testGetCompositeSequencesByGeneId() {
Collection<Gene> genes = geneService.findByOfficialSymbol(geneOfficialSymbol);
if (genes == null || genes.isEmpty())
return;
Gene g = genes.iterator().next();
Collection<CompositeSequence> compositeSequences = geneService.getCompositeSequencesById(g.getId());
assertNotNull(compositeSequences);
assertEquals(compositeSequences.size(), 1);
assertEquals((compositeSequences.iterator().next()).getName(), csName);
}
use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.
the class ExpressionDataDoubleMatrixTest method testConstructExpressionDataDoubleMatrixWithGeoValues.
/**
* This is a self-contained test. That is, it does not depend on the setup in onSetUpInTransaction}. It tests
* creating an {@link ExpressionDataDoubleMatrix} using real values from the Gene Expression Omnibus (GEO). That is,
* we have obtained information from GSE994. The probe sets used are 218120_s_at and 121_at, and the samples used
* are GSM15697 and GSM15744. Specifically, we the Gemma objects that correspond to the GEO objects are:
* DesignElement 1 = 218120_s_at, DesignElement 2 = 121_at
* BioAssay 1 = "Current Smoker 73", BioAssay 2 = "Former Smoker 34"
* BioMaterial 1 = "GSM15697", BioMaterial 2 = "GSM15744"
* BioAssayDimension = "GSM15697, GSM15744" (the names of all the biomaterials).
*/
@Test
public void testConstructExpressionDataDoubleMatrixWithGeoValues() {
ByteArrayConverter bac = new ByteArrayConverter();
ee = ExpressionExperiment.Factory.newInstance();
QuantitationType qt = QuantitationType.Factory.newInstance();
qt.setName("VALUE");
qt.setIsBackgroundSubtracted(false);
qt.setIsNormalized(false);
qt.setIsBackground(false);
qt.setIsRatio(false);
qt.setIsPreferred(true);
qt.setIsMaskedPreferred(false);
qt.setRepresentation(PrimitiveType.DOUBLE);
BioAssayDimension bioAssayDimension = BioAssayDimension.Factory.newInstance();
bioAssayDimension.setName("GSM15697, GSM15744");
List<BioAssay> assays = new ArrayList<>();
BioAssay assay1 = BioAssay.Factory.newInstance();
assay1.setName("Current Smoker 73");
BioMaterial sample1 = BioMaterial.Factory.newInstance();
sample1.setName("GSM15697");
assay1.setSampleUsed(sample1);
assays.add(assay1);
BioAssay assay2 = BioAssay.Factory.newInstance();
assay2.setName("Former Smoker 34");
BioMaterial sample2 = BioMaterial.Factory.newInstance();
sample2.setName("GSM15744");
assay2.setSampleUsed(sample2);
assays.add(assay2);
bioAssayDimension.setBioAssays(assays);
RawExpressionDataVector vector1 = RawExpressionDataVector.Factory.newInstance();
double[] ddata1 = { 74.9, 101.7 };
byte[] bdata1 = bac.doubleArrayToBytes(ddata1);
vector1.setData(bdata1);
vector1.setQuantitationType(qt);
vector1.setBioAssayDimension(bioAssayDimension);
RawExpressionDataVector vector2 = RawExpressionDataVector.Factory.newInstance();
double[] ddata2 = { 404.6, 318.7 };
byte[] bdata2 = bac.doubleArrayToBytes(ddata2);
vector2.setData(bdata2);
vector2.setQuantitationType(qt);
vector2.setBioAssayDimension(bioAssayDimension);
ArrayDesign ad = ArrayDesign.Factory.newInstance();
ad.setName("test ar");
CompositeSequence de1 = CompositeSequence.Factory.newInstance();
de1.setName("218120_s_at");
vector1.setDesignElement(de1);
BioSequence bs1 = BioSequence.Factory.newInstance();
bs1.setName("test1");
de1.setBiologicalCharacteristic(bs1);
de1.setArrayDesign(ad);
CompositeSequence de2 = CompositeSequence.Factory.newInstance();
de2.setName("121_at");
BioSequence bs2 = BioSequence.Factory.newInstance();
bs2.setName("test2");
de2.setBiologicalCharacteristic(bs2);
de2.setArrayDesign(ad);
vector2.setDesignElement(de2);
Collection<RawExpressionDataVector> eeVectors = new LinkedHashSet<>();
eeVectors.add(vector1);
eeVectors.add(vector2);
ee.setRawExpressionDataVectors(eeVectors);
ExpressionDataDoubleMatrix expressionDataMatrix = new ExpressionDataDoubleMatrix(eeVectors);
assertNotNull(expressionDataMatrix);
assertEquals(expressionDataMatrix.rows(), 2);
assertEquals(expressionDataMatrix.columns(), 2);
}
use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.
the class DataUpdaterTest method testAddData.
@Test
public void testAddData() throws Exception {
/*
* Load a regular data set that has no data. Platform is (basically) irrelevant.
*/
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath()));
ExpressionExperiment ee;
try {
// RNA-seq data.
Collection<?> results = geoService.fetchAndLoad("GSE37646", false, true, false);
ee = (ExpressionExperiment) results.iterator().next();
} catch (AlreadyExistsInSystemException e) {
// log.warn( "Test skipped because GSE37646 was not removed from the system prior to test" );
ee = (ExpressionExperiment) ((List<?>) e.getData()).get(0);
}
ee = experimentService.thawLite(ee);
List<BioAssay> bioAssays = new ArrayList<>(ee.getBioAssays());
assertEquals(31, bioAssays.size());
List<BioMaterial> bms = new ArrayList<>();
for (BioAssay ba : bioAssays) {
bms.add(ba.getSampleUsed());
}
targetArrayDesign = this.getTestPersistentArrayDesign(100, true);
DoubleMatrix<CompositeSequence, BioMaterial> rawMatrix = new DenseDoubleMatrix<>(targetArrayDesign.getCompositeSequences().size(), bms.size());
/*
* make up some fake data on another platform, and match it to those samples
*/
for (int i = 0; i < rawMatrix.rows(); i++) {
for (int j = 0; j < rawMatrix.columns(); j++) {
rawMatrix.set(i, j, (i + 1) * (j + 1) * Math.random() / 100.0);
}
}
List<CompositeSequence> probes = new ArrayList<>(targetArrayDesign.getCompositeSequences());
rawMatrix.setRowNames(probes);
rawMatrix.setColumnNames(bms);
QuantitationType qt = this.makeQt(true);
ExpressionDataDoubleMatrix data = new ExpressionDataDoubleMatrix(ee, qt, rawMatrix);
assertNotNull(data.getBestBioAssayDimension());
assertEquals(rawMatrix.columns(), data.getBestBioAssayDimension().getBioAssays().size());
assertEquals(probes.size(), data.getMatrix().rows());
/*
* Replace it.
*/
ee = dataUpdater.replaceData(ee, targetArrayDesign, data);
for (BioAssay ba : ee.getBioAssays()) {
assertEquals(targetArrayDesign, ba.getArrayDesignUsed());
}
ee = experimentService.thaw(ee);
for (BioAssay ba : ee.getBioAssays()) {
assertEquals(targetArrayDesign, ba.getArrayDesignUsed());
}
assertEquals(100, ee.getRawExpressionDataVectors().size());
for (RawExpressionDataVector v : ee.getRawExpressionDataVectors()) {
assertTrue(v.getQuantitationType().getIsPreferred());
}
assertEquals(100, ee.getProcessedExpressionDataVectors().size());
Collection<DoubleVectorValueObject> processedDataArrays = dataVectorService.getProcessedDataArrays(ee);
for (DoubleVectorValueObject v : processedDataArrays) {
assertEquals(31, v.getBioAssays().size());
}
/*
* Test adding data (non-preferred)
*/
qt = this.makeQt(false);
ExpressionDataDoubleMatrix moreData = new ExpressionDataDoubleMatrix(ee, qt, rawMatrix);
ee = dataUpdater.addData(ee, targetArrayDesign, moreData);
ee = experimentService.thaw(ee);
try {
// add preferred data twice.
dataUpdater.addData(ee, targetArrayDesign, data);
fail("Should have gotten an exception");
} catch (IllegalArgumentException e) {
// okay.
}
dataUpdater.deleteData(ee, qt);
}
use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.
the class AffyProbeReaderTest method testReadInputStream.
/*
* Class under test for Map read(InputStream)
*/
public final void testReadInputStream() throws Exception {
is = AffyProbeReaderTest.class.getResourceAsStream("/data/loader/affymetrix-probes-test.txt");
apr.setSequenceField(5);
apr.parse(is);
// 10
String expectedValue = "GCCCCCGTGAGGATGTCACTCAGAT";
CompositeSequence cs = this.getProbeMatchingName("1004_at");
TestCase.assertNotNull("CompositeSequence was null", cs);
boolean foundIt = false;
for (Reporter element : apr.get(cs)) {
if (element.getName().equals("1004_at#2:557:275")) {
String actualValue = element.getImmobilizedCharacteristic().getSequence();
TestCase.assertEquals(expectedValue, actualValue);
foundIt = true;
break;
}
}
TestCase.assertTrue("Didn't find the probe ", foundIt);
}
Aggregations