use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.Document in project webin-cli by enasequence.
the class ReadsXmlWriter method createRunXml.
String createRunXml(ReadsManifest manifest, String submissionTitle, String submissionAlias, String centerName, Path inputDir, Path uploadDir) {
try {
String title = submissionTitle;
Element runSetE = new Element("RUN_SET");
Element runE = new Element("RUN");
runSetE.addContent(runE);
Document doc = new Document(runSetE);
runE.setAttribute("alias", submissionAlias);
if (null != centerName && !centerName.isEmpty()) {
runE.setAttribute("center_name", centerName);
}
runE.addContent(new Element("TITLE").setText(title));
Element experimentRefE = new Element("EXPERIMENT_REF");
runE.addContent(experimentRefE);
experimentRefE.setAttribute("refname", submissionAlias);
Element dataBlockE = new Element("DATA_BLOCK");
runE.addContent(dataBlockE);
Element filesE = new Element("FILES");
dataBlockE.addContent(filesE);
manifest.files(FileType.BAM).stream().map(file -> file.getFile().toPath()).forEach(file -> filesE.addContent(createFileElement(inputDir, uploadDir, file, "bam", null)));
manifest.files(FileType.CRAM).stream().map(file -> file.getFile().toPath()).forEach(file -> filesE.addContent(createFileElement(inputDir, uploadDir, file, "cram", null)));
manifest.files(FileType.FASTQ).stream().forEach(file -> filesE.addContent(createFileElement(inputDir, uploadDir, file.getFile().toPath(), "fastq", file.getAttributes())));
Element runAttributesE = new Element("RUN_ATTRIBUTES");
if (manifest.getSubmissionTool() != null && !manifest.getSubmissionTool().isEmpty()) {
Element submissionToolRunAttributeTagE = new Element("TAG").setText("SUBMISSION_TOOL");
Element submissionToolRunAttributeValueE = new Element("VALUE").setText(manifest.getSubmissionTool());
Element submissionToolRunAttributeE = new Element("RUN_ATTRIBUTE");
submissionToolRunAttributeE.addContent(submissionToolRunAttributeTagE);
submissionToolRunAttributeE.addContent(submissionToolRunAttributeValueE);
runAttributesE.addContent(submissionToolRunAttributeE);
}
if (manifest.getSubmissionToolVersion() != null && !manifest.getSubmissionToolVersion().isEmpty()) {
Element submissionToolVersionRunAttributeTagE = new Element("TAG").setText("SUBMISSION_TOOL_VERSION");
Element submissionToolVersionRunAttributeValueE = new Element("VALUE").setText(manifest.getSubmissionToolVersion());
Element submissionToolVersionRunAttributeE = new Element("RUN_ATTRIBUTE");
submissionToolVersionRunAttributeE.addContent(submissionToolVersionRunAttributeTagE);
submissionToolVersionRunAttributeE.addContent(submissionToolVersionRunAttributeValueE);
runAttributesE.addContent(submissionToolVersionRunAttributeE);
}
if (runAttributesE.getContentSize() > 0) {
runE.addContent(runAttributesE);
}
XMLOutputter xmlOutput = new XMLOutputter();
xmlOutput.setFormat(Format.getPrettyFormat());
StringWriter stringWriter = new StringWriter();
xmlOutput.output(doc, stringWriter);
return stringWriter.toString();
} catch (IOException ex) {
throw WebinCliException.systemError(ex);
}
}
use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.Document in project webin-cli by enasequence.
the class ReadsXmlWriter method createExperimentXml.
private String createExperimentXml(ReadsManifest manifest, ReadsValidationResponse response, String submissionTitle, String submissionAlias, String centerName) {
String instrument = manifest.getInstrument();
String description = StringUtils.isBlank(manifest.getDescription()) ? "unspecified" : manifest.getDescription();
String libraryStrategy = manifest.getLibraryStrategy();
String librarySource = manifest.getLibrarySource();
String librarySelection = manifest.getLibrarySelection();
String libraryName = manifest.getLibraryName();
String platform = manifest.getPlatform();
Integer insertSize = manifest.getInsertSize();
try {
String title = submissionTitle;
Element experimentSetE = new Element("EXPERIMENT_SET");
Element experimentE = new Element("EXPERIMENT");
experimentSetE.addContent(experimentE);
Document doc = new Document(experimentSetE);
experimentE.setAttribute("alias", submissionAlias);
if (null != centerName && !centerName.isEmpty()) {
experimentE.setAttribute("center_name", centerName);
}
experimentE.addContent(new Element("TITLE").setText(title));
Element studyRefE = new Element("STUDY_REF");
experimentE.addContent(studyRefE);
if (manifest.getStudy() != null) {
studyRefE.setAttribute("accession", manifest.getStudy().getBioProjectId());
}
Element designE = new Element("DESIGN");
experimentE.addContent(designE);
Element designDescriptionE = new Element("DESIGN_DESCRIPTION");
designDescriptionE.setText(description);
designE.addContent(designDescriptionE);
Element sampleDescriptorE = new Element("SAMPLE_DESCRIPTOR");
if (manifest.getStudy() != null) {
sampleDescriptorE.setAttribute("accession", manifest.getSample().getBioSampleId());
}
designE.addContent(sampleDescriptorE);
Element libraryDescriptorE = new Element("LIBRARY_DESCRIPTOR");
designE.addContent(libraryDescriptorE);
if (null != libraryName) {
Element libraryNameE = new Element("LIBRARY_NAME");
libraryNameE.setText(libraryName);
libraryDescriptorE.addContent(libraryNameE);
}
Element libraryStrategyE = new Element("LIBRARY_STRATEGY");
libraryStrategyE.setText(libraryStrategy);
libraryDescriptorE.addContent(libraryStrategyE);
Element librarySourceE = new Element("LIBRARY_SOURCE");
librarySourceE.setText(librarySource);
libraryDescriptorE.addContent(librarySourceE);
Element librarySelectionE = new Element("LIBRARY_SELECTION");
librarySelectionE.setText(librarySelection);
libraryDescriptorE.addContent(librarySelectionE);
Element libraryLayoutE = new Element("LIBRARY_LAYOUT");
if (!response.isPaired()) {
libraryLayoutE.addContent(new Element("SINGLE"));
} else {
Element pairedE = new Element("PAIRED");
libraryLayoutE.addContent(pairedE);
if (null != insertSize) {
pairedE.setAttribute("NOMINAL_LENGTH", String.valueOf(insertSize));
}
}
libraryDescriptorE.addContent(libraryLayoutE);
Element platformE = new Element("PLATFORM");
experimentE.addContent(platformE);
Element platformRefE = new Element(platform);
platformE.addContent(platformRefE);
Element instrumentModelE = new Element("INSTRUMENT_MODEL");
instrumentModelE.setText(instrument);
platformRefE.addContent(instrumentModelE);
Element expAttributesE = new Element("EXPERIMENT_ATTRIBUTES");
if (manifest.getSubmissionTool() != null && !manifest.getSubmissionTool().isEmpty()) {
Element submissionToolExpAttributeTagE = new Element("TAG").setText("SUBMISSION_TOOL");
Element submissionToolExpAttributeValueE = new Element("VALUE").setText(manifest.getSubmissionTool());
Element submissionToolExpAttributeE = new Element("EXPERIMENT_ATTRIBUTE");
submissionToolExpAttributeE.addContent(submissionToolExpAttributeTagE);
submissionToolExpAttributeE.addContent(submissionToolExpAttributeValueE);
expAttributesE.addContent(submissionToolExpAttributeE);
}
if (manifest.getSubmissionToolVersion() != null && !manifest.getSubmissionToolVersion().isEmpty()) {
Element submissionToolVersionExpAttributeTagE = new Element("TAG").setText("SUBMISSION_TOOL_VERSION");
Element submissionToolVersionExpAttributeValueE = new Element("VALUE").setText(manifest.getSubmissionToolVersion());
Element submissionToolVersionExpAttributeE = new Element("EXPERIMENT_ATTRIBUTE");
submissionToolVersionExpAttributeE.addContent(submissionToolVersionExpAttributeTagE);
submissionToolVersionExpAttributeE.addContent(submissionToolVersionExpAttributeValueE);
expAttributesE.addContent(submissionToolVersionExpAttributeE);
}
if (expAttributesE.getContentSize() > 0) {
experimentE.addContent(expAttributesE);
}
XMLOutputter xmlOutput = new XMLOutputter();
xmlOutput.setFormat(Format.getPrettyFormat());
StringWriter stringWriter = new StringWriter();
xmlOutput.output(doc, stringWriter);
return stringWriter.toString();
} catch (IOException ex) {
throw WebinCliException.systemError(ex);
}
}
use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.Document in project n2o-framework by i-novus-llc.
the class SelectiveUtil method readByPath.
@SuppressWarnings("unchecked")
public static <N> N readByPath(String uri, NamespaceReaderFactory readerFactory) {
try (InputStream inputStream = FileSystemUtil.getContentAsStream(uri)) {
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(inputStream);
Element root = doc.getRootElement();
return (N) readerFactory.produce(root).read(root);
} catch (JDOMException | IOException e) {
throw new RuntimeException(e);
}
}
use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.Document in project n2o-framework by i-novus-llc.
the class SelectiveUtil method read.
@SuppressWarnings("unchecked")
public static <N> N read(String source, ElementReaderFactory readerFactory) {
try (Reader stringReader = new StringReader(source)) {
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(stringReader);
Element root = doc.getRootElement();
return (N) readerFactory.produce(root).read(root);
} catch (JDOMException | IOException e) {
throw new RuntimeException(e);
}
}
use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.Document in project plexus-containers by codehaus-plexus.
the class ComponentsXmlMergerTest method testMergeRoleComponents.
public void testMergeRoleComponents() throws Exception {
SAXBuilder saxBuilder = new SAXBuilder();
String source1 = "<component-set>\n" + " <components>\n" + " <component>\n" + " <role>org.codehaus.plexus.metadata.component.DockerComposeConfigHandler</role>\n" + " <implementation>org.codehaus.plexus.metadata.component.DominantComponent</implementation>\n" + " </component>\n" + " <component>\n" + " <role>org.codehaus.plexus.metadata.component.PropertyConfigHandler</role>\n" + " <implementation>org.codehaus.plexus.metadata.component.DominantComponent</implementation>\n" + " </component>\n" + " </components>\n" + "</component-set>";
Document doc1 = saxBuilder.build(new StringReader(source1));
String source2 = "<component-set>\n" + " <components>\n" + " <component>\n" + " <role>org.codehaus.plexus.metadata.component.ExternalConfigHandler</role>\n" + " <implementation>org.codehaus.plexus.metadata.component.DominantComponent</implementation>\n" + " </component>\n" + " </components>\n" + "</component-set>";
Document doc2 = saxBuilder.build(new StringReader(source2));
PlexusXmlMerger merger = new PlexusXmlMerger();
Document mergedDoc = merger.merge(doc1, doc2);
List<Element> components = mergedDoc.detachRootElement().getChild("components").getChildren();
assertEquals(3, components.size());
}
Aggregations