public String getAlias() { return sampleStep.getInput().getAlias(); }
private Matcher getSampleAliasMatcher(DetailedLibrary library) throws MisoNamingException { Matcher m = samplePattern.matcher(library.getSample().getAlias()); if (!m.matches()) { throw new MisoNamingException("Cannot generate alias due to non-standard alias on parent Sample"); } return m; }
@Override protected void populate(Element xml, Sample sample) { xml.setAttribute("alias", sample.getAlias()); xml.setAttribute("center_name", centreName); Element sampleTitle = xml.getOwnerDocument().createElementNS(null, "TITLE"); sampleTitle.setTextContent(sample.getAlias()); xml.appendChild(sampleTitle); Element sampleName = xml.getOwnerDocument().createElementNS(null, "SAMPLE_NAME"); Element sampleScientificName = xml.getOwnerDocument().createElementNS(null, "SCIENTIFIC_NAME"); sampleScientificName.setTextContent(sample.getScientificName()); sampleName.appendChild(sampleScientificName); // 2/11/2011 Antony Colles moved IF !=null statement, to help produce valid submission XML. Element sampleTaxonIdentifier = xml.getOwnerDocument().createElementNS(null, "TAXON_ID"); if (!isStringEmptyOrNull(sample.getTaxonIdentifier())) { sampleTaxonIdentifier.setTextContent(sample.getTaxonIdentifier()); } else { sampleTaxonIdentifier.setTextContent("000001"); } sampleName.appendChild(sampleTaxonIdentifier); xml.appendChild(sampleName); Element sampleDescription = xml.getOwnerDocument().createElementNS(null, "DESCRIPTION"); sampleDescription.setTextContent(sample.getDescription()); xml.appendChild(sampleDescription); }
/** * Checks whether sample's alias conforms to the naming scheme. Validation is skipped for DetailedSamples * {@code if (sample.hasNonStandardAlias())} * * @param sample */ private void validateAlias(Sample sample) { if (!isDetailedSample(sample) || !((DetailedSample) sample).hasNonStandardAlias()) { uk.ac.bbsrc.tgac.miso.core.service.naming.validation.ValidationResult aliasValidation = namingScheme.validateSampleAlias(sample .getAlias()); if (!aliasValidation.isValid()) { throw new IllegalArgumentException("Invalid sample alias: '" + sample.getAlias() + "' - " + aliasValidation.getMessage()); } } }
/** * Checks whether the configured naming scheme allows duplicate alias. If not, checks whether an alias is used by multiple samples. * This method should be called <b>after</b> saving a new Sample. DetailedSamples marked as having non-standard alias are also * considered valid * * @param alias the alias to validate * @throws ConstraintViolationException if duplicate alias are <b>not</b> allowed, <b>and</b> the Sample does not have nonStandardAlias * <b>and</b> the alias is used by multiple Samples * @throws IOException */ private void validateAliasUniqueness(Sample sample) throws IOException { if (isDetailedSample(sample) && ((DetailedSample) sample).hasNonStandardAlias()) { return; } if (!namingScheme.duplicateSampleAliasAllowed() && sampleStore.listByAlias(sample.getAlias()).size() > 1) { throw new ConstraintViolationException(String.format("A sample with this alias '%s' already exists in the database", sample.getAlias()), null, "alias"); } }
@Override public String generate(Library library) throws MisoNamingException, IOException { if (library.getSample() != null) { Pattern samplePattern = Pattern.compile("([A-z0-9]+)_S([A-z0-9]+)_(.*)"); Matcher m = samplePattern.matcher(library.getSample().getAlias()); if (m.matches()) { Collection<Library> siblings = libraryStore.listBySampleId(library.getSample().getId()); Set<String> siblingAliases = siblings.stream() .map(Library::getAlias) .collect(Collectors.toSet()); String alias = null; long siblingNumber = siblings.stream() .filter(sibling -> sibling.getId() != library.getId()) .count(); do { siblingNumber++; alias = m.group(1) + "_" + "L" + m.group(2) + "-" + siblingNumber + "_" + m.group(3); } while (siblingAliases.contains(alias)); return alias; } else { throw new MisoNamingException( "Cannot generate Library alias for: " + library.toString() + " from supplied sample alias: " + library.getSample().getAlias()); } } else { throw new NullPointerException("This alias generation scheme requires the Library to have a parent Sample set."); } }
sampleDescriptor.setAttribute("refname", experiment.getLibrary().getSample().getAlias()); sampleDescriptor.setAttribute("refcenter", centreName); if (!isStringEmptyOrNull(experiment.getLibrary().getSample().getAccession())) {
private static ArraySampleDto asArraySampleDto(String position, @Nonnull Sample sample) { ArraySampleDto dto = new ArraySampleDto(); dto.setCoordinates(position); dto.setId(sample.getId()); dto.setAlias(sample.getAlias()); dto.setName(sample.getName()); dto.setIdentificationBarcode(sample.getIdentificationBarcode()); return dto; }
@Override public void update(Sample sample) throws IOException { Sample managed = get(sample.getId()); managed.setChangeDetails(authorizationManager.getCurrentUser()); boolean validateAliasUniqueness = !managed.getAlias().equals(sample.getAlias()); authorizationManager.throwIfNotWritable(managed); maybeRemoveFromBox(sample); boxService.throwIfBoxPositionIsFilled(sample); validateChange(sample, managed); applyChanges(managed, sample); loadChildEntities(managed); if (isDetailedSample(managed)) { DetailedSample detailedUpdated = (DetailedSample) managed; if (detailedUpdated.getParent() != null) { detailedUpdated.setParent((DetailedSample) get(detailedUpdated.getParent().getId())); validateHierarchy(detailedUpdated); } } save(managed, validateAliasUniqueness); boxService.updateBoxableLocation(sample); }
dto.setQcPassed(from.getQcPassed()); dto.setAlias(from.getAlias()); dto.setProjectId(from.getProject().getId()); dto.setScientificName(from.getScientificName());
if (isStringEmptyOrNull(sample.getAlias()) && namingScheme.hasSampleAliasGenerator()) { sample.setAlias(generateTemporaryName());
dto.setName(from.getName()); dto.setParentSampleId(from.getSample().getId()); dto.setParentSampleAlias(from.getSample().getAlias()); dto.setParentSampleProjectId(from.getSample().getProject().getId()); if (from.getSample() instanceof DetailedSample) {
if (sam != null) { v.setSampleAccession(sam.getAccession()); v.setSampleAlias(sam.getAlias()); v.setSampleDescription(sam.getDescription()); v.setSampleId(sam.getId());
target.setAlias(source.getAlias()); target.setDescription(source.getDescription()); target.setDiscarded(source.isDiscarded());