Skip to content

Commit

Permalink
Merge branch 'hotfix-1.30.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
arteymix committed Oct 10, 2023
2 parents 570a7c6 + f9118db commit 9ef364e
Show file tree
Hide file tree
Showing 138 changed files with 1,895 additions and 1,663 deletions.
2 changes: 1 addition & 1 deletion .idea/runConfigurations/Gemma_Web.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gemma-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>gemma</artifactId>
<groupId>gemma</groupId>
<version>1.30.2</version>
<version>1.30.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gemma-cli</artifactId>
Expand Down
21 changes: 19 additions & 2 deletions gemma-cli/src/main/java/ubic/gemma/core/apps/GemmaCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.security.core.context.SecurityContextHolder;
import ubic.gemma.core.logging.LoggingConfigurer;
import ubic.gemma.core.logging.log4j.Log4jConfigurer;
import ubic.gemma.core.util.AbstractCLI;
import ubic.gemma.core.util.CLI;
import ubic.gemma.core.logging.log4j.Log4jConfigurer;
import ubic.gemma.core.logging.LoggingConfigurer;
import ubic.gemma.persistence.util.Settings;
import ubic.gemma.persistence.util.SpringContextUtil;
import ubic.gemma.persistence.util.SpringProfiles;
Expand Down Expand Up @@ -151,6 +151,8 @@ public static void main( String[] args ) {
profiles.add( SpringProfiles.TEST );
}

lintConfiguration();

ApplicationContext ctx = SpringContextUtil.getApplicationContext( profiles.toArray( new String[0] ) );

/*
Expand Down Expand Up @@ -216,6 +218,21 @@ static String getOptStringForLogging( Object[] argsToPass ) {
return matcher.replaceAll( "$1 XXXXXX" );
}

private static void lintConfiguration() {
// check some common settings that might affect initialization time
if ( Settings.getBoolean( "load.ontologies" ) ) {
log.warn( "Auto-loading of ontologies is enabled, this is not recommended for the CLI. Disable it by setting load.ontologies=false in Gemma.properties." );
}

if ( Settings.getBoolean( "load.homologene" ) ) {
log.warn( "Homologene is enabled, this is not recommended for the CLI. Disable it by setting load.homologene=false in Gemma.properties." );
}

if ( Settings.getString( "gemma.hibernate.hbm2ddl.auto" ).equals( "validate" ) ) {
log.warn( "Hibernate is configured to validate the database schema, this is not recommended for the CLI. Disable it by setting gemma.hibernate.hbm2ddl.auto= in Gemma.properties." );
}
}

private static void printHelp( Options options, @Nullable SortedMap<CommandGroup, SortedMap<String, CLI>> commands ) {
System.err.println( "============ Gemma CLI tools ============" );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,10 @@
*/
package ubic.gemma.core.apps;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.lang3.StringUtils;

import ubic.gemma.core.analysis.report.ArrayDesignReportService;
import ubic.gemma.core.analysis.service.ArrayDesignAnnotationService;
import ubic.gemma.core.apps.GemmaCLI.CommandGroup;
Expand All @@ -49,6 +44,10 @@
import ubic.gemma.persistence.service.genome.sequenceAnalysis.AnnotationAssociationService;
import ubic.gemma.persistence.service.genome.taxon.TaxonService;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
* Create (or update) an array design based on the current set of transcripts for a taxon.
* This is used to create a 'platform' for linking non-array based data to the system, or data for which we have only
Expand Down Expand Up @@ -242,12 +241,19 @@ protected void doWork() throws Exception {
}
bioSequence.setSequenceDatabaseEntry( de );
} else {
bioSequence.setSequenceDatabaseEntry( accessions.iterator().next() );
existing = bioSequenceService.findByAccession( accessions.iterator().next() );

// FIXME It is possible that this sequence will have been aligned to the genome, which is a bit
// confusing. So it will map to a gene. Worse case: it maps to more than one gene ...

existing = bioSequenceService.findByAccession( accessions.iterator().next() );
if ( existing == null ) {
// create a copy, each biosequence must own their database entry
DatabaseEntry databaseEntry = accessions.iterator().next();
DatabaseEntry clone = DatabaseEntry.Factory.newInstance();
clone.setAccession( databaseEntry.getAccession() );
clone.setAccessionVersion( databaseEntry.getAccessionVersion() );
clone.setUri( databaseEntry.getUri() );
clone.setExternalDatabase( databaseEntry.getExternalDatabase() );
bioSequence.setSequenceDatabaseEntry( clone );
}
}

if ( existing == null ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected void doWork() throws Exception {
assert files.size() == 1;
LocalFile gene2Gofile = files.iterator().next();
AbstractCLI.log.info( "Removing all old GO associations" );
gene2GOAssociationService.removeAllInBatch();
gene2GOAssociationService.removeAll();

AbstractCLI.log.info( "Done, loading new ones" );
gene2GOAssLoader.load( gene2Gofile );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import ubic.gemma.core.util.test.BaseCliTest;
import ubic.gemma.core.util.test.category.SlowTest;
import ubic.gemma.model.common.description.DatabaseType;
Expand Down Expand Up @@ -65,7 +64,7 @@ public void test() throws Exception {
ExternalDatabase gene2go = ExternalDatabase.Factory.newInstance( "go", DatabaseType.OTHER );
when( externalDatabaseService.findByNameWithAuditTrail( "go" ) ).thenReturn( gene2go );
ncbiGene2GOAssociationLoaderCLI.executeCommand( new String[] {} );
verify( gene2GOAssociationService ).removeAllInBatch();
verify( gene2GOAssociationService ).removeAll();
verify( externalDatabaseService ).findByNameWithAuditTrail( "go" );
verify( externalDatabaseService ).updateReleaseLastUpdated( same( gene2go ), isNull(), any() );
}
Expand Down
2 changes: 1 addition & 1 deletion gemma-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>gemma</artifactId>
<groupId>gemma</groupId>
<version>1.30.2</version>
<version>1.30.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gemma-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package ubic.gemma.core.analysis.preprocess;

import org.apache.commons.lang3.exception.ExceptionUtils;
import ubic.gemma.model.expression.experiment.ExpressionExperiment;

/**
Expand All @@ -33,6 +34,6 @@ public PreprocessingException( ExpressionExperiment ee, String message ) {
}

public PreprocessingException( ExpressionExperiment ee, Throwable cause ) {
super( String.format( "Failed to pre-process %s", ee.getShortName() ), cause );
super( String.format( "Failed to pre-process %s: %s", ee.getShortName(), ExceptionUtils.getRootCauseMessage( cause ) ), cause );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix;
import ubic.gemma.core.datastructure.matrix.ExpressionDataMatrix;
import ubic.gemma.model.analysis.expression.ExpressionExperimentSet;
import ubic.gemma.model.common.auditAndSecurity.curation.CurationDetails;
import ubic.gemma.model.common.description.Characteristic;
import ubic.gemma.model.common.description.DatabaseEntry;
import ubic.gemma.model.common.measurement.Measurement;
Expand Down Expand Up @@ -65,6 +64,8 @@ public class SplitExperimentServiceImpl implements SplitExperimentService {

private static final Log log = LogFactory.getLog( SplitExperimentServiceImpl.class );

private static final int MAX_SPLIT_NAME_LENGTH = 255;

@Autowired
private PreprocessorService preprocessor;

Expand Down Expand Up @@ -156,17 +157,7 @@ public ExpressionExperimentSet split( ExpressionExperiment toSplit, Experimental
split.setShortName( sourceShortName + "." + splitNumber );

// copy everything but samples over
String factorValueString = splitValue.getValue();
if ( StringUtils.isBlank( factorValueString ) ) {
factorValueString = splitValue.getDescriptiveString();
}
split.setName( String.format( "Split part %d of: %s [%s = %s]",
splitNumber,
toSplit.getName(),
splitValue.getExperimentalFactor().getCategory() != null ?
splitValue.getExperimentalFactor().getCategory().getValue() :
splitValue.getExperimentalFactor().getName(),
factorValueString ) );
split.setName( generateNameForSplit( toSplit, splitNumber, splitValue ) );
split.setDescription( "This experiment was created by Gemma splitting another: \n" + toSplit + toSplit.getDescription() );

split.setCharacteristics( this.cloneCharacteristics( toSplit.getCharacteristics() ) );
Expand Down Expand Up @@ -350,6 +341,31 @@ public ExpressionExperimentSet split( ExpressionExperiment toSplit, Experimental
return g;
}

static String generateNameForSplit( ExpressionExperiment toSplit, int splitNumber, FactorValue splitValue ) {
String template = "Split part %d of: %s [%s = %s]";
String originalName = StringUtils.strip( toSplit.getName() );
String factorValueString = splitValue.getDescriptiveString();
String newFullName = String.format( template, splitNumber, originalName,
StringUtils.strip( splitValue.getExperimentalFactor().getCategory() != null ?
splitValue.getExperimentalFactor().getCategory().getValue() :
splitValue.getExperimentalFactor().getName() ),
factorValueString );
if ( newFullName.length() <= MAX_SPLIT_NAME_LENGTH )
return newFullName;
// truncate the original name
int lengthOfEverythingElse = newFullName.length() - String.format( "%s", originalName ).length();
// we want at least 100 characters of the original name
if ( lengthOfEverythingElse > MAX_SPLIT_NAME_LENGTH - 100 ) {
throw new IllegalArgumentException( "It's not possible to truncate the name of the split such that it won't exceed 255 characters." );
}
return String.format( template, splitNumber, StringUtils.abbreviate( originalName, "…", 255 - lengthOfEverythingElse )
.replace( "\\s+…$", "…" ),
StringUtils.strip( splitValue.getExperimentalFactor().getCategory() != null ?
splitValue.getExperimentalFactor().getCategory().getValue() :
splitValue.getExperimentalFactor().getName() ),
factorValueString );
}

private void enforceOtherParts( Collection<ExpressionExperiment> result ) {
// Enforce relation to other parts of the split.
for ( ExpressionExperiment split : result ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class WhatsNew {
private Map<Taxon, Long> eeCountPerTaxon;
private Map<Taxon, Collection<Long>> newEEIdsPerTaxon;
private Map<Taxon, Collection<Long>> updatedEEIdsPerTaxon;
private int newBioMaterialCount = 0;
private long newBioMaterialCount = 0L;
private Date date;

public WhatsNew( Date date ) {
Expand Down Expand Up @@ -195,11 +195,11 @@ public void setUpdatedEEIdsPerTaxon( Map<Taxon, Collection<Long>> map ) {
/**
* @return get a count of the number of biomaterials in the new expression experiments
*/
public int getNewBioMaterialCount() {
public long getNewBioMaterialCount() {
return this.newBioMaterialCount;
}

public void setNewBioMaterialCount( int count ) {
public void setNewBioMaterialCount( long count ) {
this.newBioMaterialCount = count;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,43 +20,39 @@

import org.springframework.security.access.annotation.Secured;

import java.util.Date;
import javax.annotation.Nullable;

/**
* Creates reports that can be shown on the web pages or in social media feeds.
* <p>
* Reports are always generated from an anonymous user's perspective.
*
* @author paul
*/
public interface WhatsNewService {

/**
* save the report from last week.
* Generate the report from yesterday.
* @return new or updated objects from within a day ago.
*/
@Secured({ "GROUP_AGENT" })
void generateWeeklyReport();
WhatsNew getDailyReport();

/**
* save the report from the date specified.
*
* @param date the date of the report
*/
void saveReport( Date date );

/**
* @param date the date of the report
* @return representing the updated or new objects.
* Generate the report from last week.
* @return new or updated objects from within one week ago.
*/
WhatsNew getReport( Date date );
WhatsNew getWeeklyReport();

/**
* @return new or updated objects from within one week ago.
* Generate and save the report from last week. It can later be retrieved with {@link #getLatestWeeklyReport()}.
*/
WhatsNew getWeeklyReport();
@Secured({ "GROUP_AGENT" })
WhatsNew generateWeeklyReport();

/**
* Retrieve the latest WhatsNew report.
*
* @return WhatsNew the latest WhatsNew report cache, or null if it hasn't been computed
* Retrieve the latest weekly report if available.
* @return the latest weekly report, or null if unavailable
*/
@Nullable
WhatsNew getLatestWeeklyReport();
}
Loading

0 comments on commit 9ef364e

Please sign in to comment.