<commit_before>/*
 * The Gemma project
 * 
 * Copyright (c) 2011 University of British Columbia
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */
package ubic.gemma.analysis.preprocess.svd;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
import java.util.Collection;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import ubic.gemma.expression.experiment.service.ExpressionExperimentService;
import ubic.gemma.loader.expression.geo.AbstractGeoServiceTest;
import ubic.gemma.loader.expression.geo.GeoDomainObjectGeneratorLocal;
import ubic.gemma.loader.expression.geo.service.GeoService;
import ubic.gemma.loader.util.AlreadyExistsInSystemException;
import ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVectorService;
import ubic.gemma.model.expression.experiment.ExpressionExperiment;

/**
 * @author paul
 * @version $Id$
 */
public class SVDServiceImplTest extends AbstractGeoServiceTest {

    @Autowired
    SVDService svdService;

    @Autowired
    protected GeoService geoService;

    @Autowired
    ExpressionExperimentService eeService;

    ExpressionExperiment ee;

    @Autowired
    ProcessedExpressionDataVectorService processedExpressionDataVectorService = null;

    @Test
    public void testsvd() throws Exception {
        ee = eeService.findByShortName( "GSE674" );

        assertNotNull( ee );

        ee = eeService.thaw( ee );
        SVDValueObject svd = svdService.svd( ee );

        assertNotNull( svd );

        assertNotNull( svd.getvMatrix() );
        assertEquals( 5, svd.getFactorCorrelations().size() );
    }

    @Before
    public void setUp() throws Exception {
        String path = getTestFileBasePath();
        geoService.setGeoDomainObjectGenerator( new GeoDomainObjectGeneratorLocal( path + GEO_TEST_DATA_ROOT
                + "shortTest" ) );
        // also used in the GeoDatasetServiceIntegrationTest.
        try {
            Collection<?> results = geoService.fetchAndLoad( "GDS472", false, true, false, false );
            ee = ( ExpressionExperiment ) results.iterator().next();
<commit_msg>the thaw pattern is to be avoided, but it introduces a new issue here.<commit_after>/*
 * The Gemma project
 * 
 * Copyright (c) 2011 University of British Columbia
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */
package ubic.gemma.analysis.preprocess.svd;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
import java.util.Collection;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import ubic.gemma.expression.experiment.service.ExpressionExperimentService;
import ubic.gemma.loader.expression.geo.AbstractGeoServiceTest;
import ubic.gemma.loader.expression.geo.GeoDomainObjectGeneratorLocal;
import ubic.gemma.loader.expression.geo.service.GeoService;
import ubic.gemma.loader.util.AlreadyExistsInSystemException;
import ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVectorService;
import ubic.gemma.model.expression.experiment.ExpressionExperiment;

/**
 * @author paul
 * @version $Id$
 */
public class SVDServiceImplTest extends AbstractGeoServiceTest {

    @Autowired
    SVDService svdService;

    @Autowired
    protected GeoService geoService;

    @Autowired
    ExpressionExperimentService eeService;

    ExpressionExperiment ee;

    @Autowired
    ProcessedExpressionDataVectorService processedExpressionDataVectorService = null;

    @Test
    public void testsvd() throws Exception {
        ee = eeService.findByShortName( "GSE674" );

        assertNotNull( ee );

        SVDValueObject svd = svdService.svd( ee );

        assertNotNull( svd );

        assertNotNull( svd.getvMatrix() );
        assertEquals( 5, svd.getFactorCorrelations().size() );
    }

    @Before
    public void setUp() throws Exception {
        String path = getTestFileBasePath();
        geoService.setGeoDomainObjectGenerator( new GeoDomainObjectGeneratorLocal( path + GEO_TEST_DATA_ROOT
                + "shortTest" ) );
        // also used in the GeoDatasetServiceIntegrationTest.
        try {
            Collection<?> results = geoService.fetchAndLoad( "GDS472", false, true, false, false );
            ee = ( ExpressionExperiment ) results.iterator().next();

{'fraction_non_alphanumeric': 0.0841930729550479, 'fraction_numerical': 0.00552689756816507, 'mean_word_length': 3.904245709123758, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '20983', 'n_tokens_mistral': 1506, 'n_tokens_neox': 1469, 'n_words': 416}