Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
archivesBaseName = 'sequencetools'
group = 'uk.ac.ebi.ena.sequence'

version = '2.28.2'
version = '2.28.3'

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,22 @@
import uk.ac.ebi.ena.webin.cli.validator.api.Validator;
import uk.ac.ebi.ena.webin.cli.validator.manifest.*;
import uk.ac.ebi.ena.webin.cli.validator.reference.Attribute;
import uk.ac.ebi.ena.webin.cli.validator.reference.Sample;

public class SubmissionValidator implements Validator<Manifest, ValidationResponse> {

private SubmissionOptions options;
private static final int ERROR_MAX_LENGTH = 2000;
private static final Integer COVID_19_OUTBREAK_TAX_ID = 2697049;
private final TaxonomyClient taxonomyClient;

public SubmissionValidator() {}
public SubmissionValidator() {
this.taxonomyClient = new TaxonomyClient();
}

public SubmissionValidator(SubmissionOptions options) {
this.options = options;
this.taxonomyClient = new TaxonomyClient();
}

public void validate() throws ValidationEngineException {
Expand Down Expand Up @@ -181,6 +186,29 @@ SubmissionOptions mapManifestToSubmissionOptions(Manifest manifest)
msg, ValidationEngineException.ReportErrorType.VALIDATION_ERROR);
}

if (options.assemblyType.equals(AssemblyType.METAGENOME_ASSEMBLEDGENOME)) {
final Sample sample = manifest.getSample();
boolean isSampleOrganismMetagenome = false;

if (sample.getOrganism() != null) {
isSampleOrganismMetagenome = taxonomyClient.isOrganismMetagenome(sample.getOrganism());
} else if (sample.getTaxId() != null) {
isSampleOrganismMetagenome =
taxonomyClient.isMetagenomic(
taxonomyClient.getTaxonByTaxid(sample.getTaxId().longValue()));
}

if (isSampleOrganismMetagenome) {
final String msg =
"Assembly type: MAG (METAGENOME-ASSEMBLED GENOME) cannot reference a sample having a metagenome taxonomy";

reporter.writeToFile(manifest.getReportFile(), Severity.ERROR, msg);

throw new ValidationEngineException(
msg, ValidationEngineException.ReportErrorType.VALIDATION_ERROR);
}
}

options.context = Optional.of(Context.genome);
options.submissionFiles =
Optional.of(setGenomeOptions((GenomeManifest) manifest, assemblyInfo));
Expand Down