Example usage for org.jdom2 Document Document

List of usage examples for org.jdom2 Document Document

Introduction

In this page you can find the example usage for org.jdom2 Document Document.

Prototype

public Document() 

Source Link

Document

Creates a new empty document.

Usage

From source file:delfos.io.xml.casestudy.CaseStudyXML.java

License:Open Source License

private static void caseStudyToXMLFile_onlyAggregate(CaseStudy caseStudy, String descriptivePrefix, File file) {
    if (!caseStudy.isFinished()) {
        throw new UnsupportedOperationException("No se ha ejecutado el caso de uso todava");
    }/*from  w ww .jav  a  2s .  co  m*/

    Document doc = new Document();
    Element casoDeUso = new Element("Case");

    casoDeUso.setAttribute("seed", Long.toString(caseStudy.getSeedValue()));
    casoDeUso.setAttribute("numExec", Integer.toString(caseStudy.getNumExecutions()));

    casoDeUso.addContent(RecommenderSystemXML.getElement(caseStudy.getRecommenderSystem()));
    casoDeUso.addContent(ValidationTechniqueXML.getElement(caseStudy.getValidationTechnique()));

    casoDeUso.addContent(PredictionProtocolXML.getElement(caseStudy.getPredictionProtocol()));

    casoDeUso.addContent(RelevanceCriteriaXML.getElement(caseStudy.getRelevanceCriteria()));
    casoDeUso.addContent(DatasetLoaderXML.getElement(caseStudy.getDatasetLoader()));

    //casoDeUso.addContent(getResultsElement(caseStudy));
    casoDeUso.addContent(getAggregatedResultsElement(caseStudy));

    doc.addContent(casoDeUso);

    XMLOutputter outputter = new XMLOutputter(Constants.getXMLFormat());
    try (FileWriter fileWriter = new FileWriter(file)) {
        outputter.output(doc, fileWriter);
    } catch (IOException ex) {
        ERROR_CODES.CANNOT_WRITE_RESULTS_FILE.exit(ex);
    }
}

From source file:devicerestmodel.services.ResourceBase.java

private void addGetResourceXML(final String path, final DevicePropertyNode element) {

    final Resource.Builder resourceBuilder = Resource.builder();
    resourceBuilder.path(path);/*from w  w  w. j a va  2s .com*/

    final ResourceMethod.Builder methodBuilder = resourceBuilder.addMethod("GET");
    methodBuilder.produces(MediaType.APPLICATION_XML)
            .handledBy(new Inflector<ContainerRequestContext, Response>() {

                @Override
                public Response apply(ContainerRequestContext containerRequestContext) {
                    try {
                        if (containerRequestContext.getMethod().equals("GET")) {
                            System.out.println("Got a GET for " + path);
                            LoggerOut.println("Get a GET for " + path);
                            Document myDocument = new Document();
                            myDocument.setRootElement(element.getXml(containerRequestContext));
                            return Response.ok().type(MediaType.APPLICATION_XML)
                                    .entity(MdUtil.document2XmlString(myDocument)).build();
                        } else {
                            return Response.status(Response.Status.NOT_FOUND).build();
                        }
                    } catch (Exception ex) {
                        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
                    }

                }
            });

    final Resource resource = resourceBuilder.build();
    registerResources(resource);
}

From source file:edu.ucla.loni.server.ServerUtils.java

License:Open Source License

/**
 * Writes the access file for the root directory
 * Side Effect: Updates accessFileModified in the database
 *//*w w  w.  j av  a 2s .co  m*/
public static void writeAccessFile(Directory root) throws Exception {
    File accessFile = getAccessFile(root);
    if (!accessFile.exists()) {
        boolean success = accessFile.createNewFile();
        if (!success) {
            throw new Exception("Could not create access file");
        }
    }

    // <files>
    Element filesRoot = new Element("files");

    // For each pipe, add a <file> child to <files>
    Pipefile[] pipes = Database.selectPipefiles(root.dirId);

    if (pipes != null) {
        for (Pipefile p : pipes) {
            // Only add the pipefile if access is not empty
            if (!p.access.equals("")) {
                Element file = new Element("file");
                file.setAttribute("type", p.type);
                file.setAttribute("name", p.name);
                file.setAttribute("package", p.packageName);

                // Add agents
                String[] agents = p.access.split(",");
                for (String agent : agents) {
                    if (!agent.equals("")) {
                        file.addContent(agentElement(agent));
                    }
                }

                filesRoot.addContent(file);
            }
        }
    }

    // <groups>
    Element groupsRoot = new Element("groups");

    // For each group, add a <group> child to <groups>
    Group[] groups = Database.selectGroups(root.dirId);

    if (groups != null) {
        for (Group g : groups) {
            Element group = new Element("group");
            group.setAttribute("name", g.name);

            // Add agents
            String[] agents = g.users.split(",");
            for (String agent : agents) {
                if (!agent.equals("")) {
                    group.addContent(agentElement(agent));
                }
            }

            groupsRoot.addContent(group);
        }
    }

    // Root Element
    Element access = new Element("access");
    access.addContent(filesRoot);
    access.addContent(groupsRoot);

    // Document
    Document doc = new Document();
    doc.addContent(access);

    // Write document
    writeXML(accessFile, doc);

    // Update when the access file was written
    root.accessModified = new Timestamp(accessFile.lastModified());
    Database.updateDirectory(root);
}

From source file:es.uvigo.ei.sing.rubioseq.gui.view.models.configuration.ConfigProgramPathsChipSeq.java

License:Open Source License

public void exportToXML(File output) throws IOException {
    Document configurationFile = new Document();
    Comment comment = new Comment(COMMENT_CHIPSEQ);
    configurationFile.addContent(comment);

    Element configData = new Element(CONFIG_DATA);
    configurationFile.setRootElement(configData);

    Element bwaPath = new Element(BWA_PATH);
    bwaPath.addContent(this.getBwaPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(bwaPath);

    Element samtoolsPath = new Element(SAMTOOLS_PATH);
    samtoolsPath.addContent(this.getSamtoolsPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(samtoolsPath);

    Element picardPath = new Element(PICARD_PATH);
    picardPath.addContent(this.getPicardPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(picardPath);

    Element MACSPath = new Element(MACS_PATH);
    MACSPath.addContent(this.getMacsPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(MACSPath);

    Element PythonPath = new Element(PYTHON_PATH);
    PythonPath.addContent(this.getPythonPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(PythonPath);

    Element BEDToolsPath = new Element(BED_TOOLS_PATH);
    BEDToolsPath.addContent(this.getBedtoolsPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(BEDToolsPath);

    Element CCATPath = new Element(CCAT_PATH);
    CCATPath.addContent(this.getCcatPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(CCATPath);

    Element BedgraphtoWigPath = new Element(BGTW_PATH);
    BedgraphtoWigPath.addContent(this.getBedgraphtobigwigPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(BedgraphtoWigPath);

    Element IDRPath = new Element(IDR_PATH);
    IDRPath.addContent(this.getIdrPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(IDRPath);

    Element PeakAnnotatorPath = new Element(PEAKANNOTATOR_PATH);
    PeakAnnotatorPath.addContent(this.getPeakannotatorPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(PeakAnnotatorPath);

    Element fastqcPath = new Element(FASTQC_PATH);
    fastqcPath.addContent(this.getFastqcPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(fastqcPath);

    if (!this.getNthr().equals(nthr_DV)) {
        Element nthr = new Element(NTHR);
        nthr.addContent(String.valueOf(this.getNthr()));
        configurationFile.getRootElement().addContent(nthr);
    }//from w ww  .  ja v a 2  s  .  c o  m

    if (!this.getJavaRam().equals(javaRam_DV)) {
        Element javaRam = new Element(JAVA_RAM);
        javaRam.addContent(this.getJavaRam());
        configurationFile.getRootElement().addContent(javaRam);
    }

    Element queueSystem = new Element(QUEUE_SYSTEM);
    queueSystem.addContent(this.getQueueSystem().getDisplayName());
    configurationFile.getRootElement().addContent(queueSystem);

    if (!this.getQueueName().equals(queueName_DV)) {
        Element queueName = new Element(QUEUE_NAME);
        queueName.addContent(this.getQueueName());
        configurationFile.getRootElement().addContent(queueName);
    }

    if (!this.getMulticoreName().equals(multicoreName_DV)) {
        Element multicoreName = new Element(MULTICORE_NAME);
        multicoreName.addContent(this.getMulticoreName());
        configurationFile.getRootElement().addContent(multicoreName);
    }

    if (!this.getMulticoreNumber().equals(multicoreNumber_DV)) {
        Element multicoreNumber = new Element(MULTICORE_NUMBER);
        multicoreNumber.addContent(String.valueOf(this.getMulticoreNumber()));
        configurationFile.getRootElement().addContent(multicoreNumber);
    }

    XMLOutputter xmlOutput = new XMLOutputter();
    xmlOutput.setFormat(Format.getPrettyFormat());
    xmlOutput.output(configurationFile, new FileWriter(output));
    //      xmlOutput.output(configurationFile, new FileWriter(new File(output.getAbsolutePath()+".test")));
}

From source file:es.uvigo.ei.sing.rubioseq.gui.view.models.configuration.ConfigProgramPathsCNV.java

License:Open Source License

public void exportToXML(File output) throws IOException {
    Document configurationFile = new Document();
    Comment comment = new Comment(COMMENT_VARIANT_CALLER);
    configurationFile.addContent(comment);

    Element configData = new Element(CONFIG_DATA);
    configurationFile.setRootElement(configData);

    Element bwaPath = new Element(BWA_PATH);
    bwaPath.addContent(this.getBwaPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(bwaPath);

    Element samtoolsPath = new Element(SAMTOOLS_PATH);
    samtoolsPath.addContent(this.getSamtoolsPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(samtoolsPath);

    Element gatkpath = new Element(GATK_PATH);
    gatkpath.addContent(this.getGatkpath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(gatkpath);

    Element picardPath = new Element(PICARD_PATH);
    picardPath.addContent(this.getPicardPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(picardPath);

    Element BFASTPath = new Element(BFAST_PATH);
    BFASTPath.addContent(this.getBfastPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(BFASTPath);

    Element BEDToolsPath = new Element(BED_TOOLS_PATH);
    BEDToolsPath.addContent(this.getBedtoolsPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(BEDToolsPath);

    Element CONTRAPath = new Element(CONTRA_PATH);
    CONTRAPath.addContent(this.getContraPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(CONTRAPath);

    Element fastqcPath = new Element(FASTQC_PATH);
    fastqcPath.addContent(this.getFastqcPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(fastqcPath);

    if (!this.getNthr().equals(nthr_DV)) {
        Element nthr = new Element(NTHR);
        nthr.addContent(String.valueOf(this.getNthr()));
        configurationFile.getRootElement().addContent(nthr);
    }//  w  w  w.  j ava  2 s  .  c  om

    if (!this.getJavaRam().equals(javaRam_DV)) {
        Element javaRam = new Element(JAVA_RAM);
        javaRam.addContent(this.getJavaRam());
        configurationFile.getRootElement().addContent(javaRam);
    }

    Element queueSystem = new Element(QUEUE_SYSTEM);
    queueSystem.addContent(this.getQueueSystem().getDisplayName());
    configurationFile.getRootElement().addContent(queueSystem);

    if (!this.getQueueName().equals(queueName_DV)) {
        Element queueName = new Element(QUEUE_NAME);
        queueName.addContent(this.getQueueName());
        configurationFile.getRootElement().addContent(queueName);
    }

    if (!this.getMulticoreName().equals(multicoreName_DV)) {
        Element multicoreName = new Element(MULTICORE_NAME);
        multicoreName.addContent(this.getMulticoreName());
        configurationFile.getRootElement().addContent(multicoreName);
    }

    if (!this.getMulticoreNumber().equals(multicoreNumber_DV)) {
        Element multicoreNumber = new Element(MULTICORE_NUMBER);
        multicoreNumber.addContent(String.valueOf(this.getMulticoreNumber()));
        configurationFile.getRootElement().addContent(multicoreNumber);
    }

    XMLOutputter xmlOutput = new XMLOutputter();
    xmlOutput.setFormat(Format.getPrettyFormat());
    xmlOutput.output(configurationFile, new FileWriter(output));
}

From source file:es.uvigo.ei.sing.rubioseq.gui.view.models.configuration.ConfigProgramPathsMethylation.java

License:Open Source License

public void exportToXML(File output) throws IOException {
    Document configurationFile = new Document();
    Comment comment = new Comment(COMMENT_METHYLATION);
    configurationFile.addContent(comment);

    Element configData = new Element(CONFIG_DATA);
    configurationFile.setRootElement(configData);

    Element bismarkPath = new Element(BISMARK_PATH);
    bismarkPath.addContent(this.getBismarkPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(bismarkPath);

    Element bowtiePath = new Element(BOWTIE_PATH);
    bowtiePath.addContent(this.getBowtiePath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(bowtiePath);

    Element picardPath = new Element(PICARD_PATH);
    picardPath.addContent(this.getPicardPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(picardPath);

    Element BEDToolsPath = new Element(BED_TOOLS_PATH);
    BEDToolsPath.addContent(this.getBedtoolsPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(BEDToolsPath);

    Element fastxPath = new Element(FASTX_PATH);
    fastxPath.addContent(this.getFastxPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(fastxPath);

    Element filoPath = new Element(FILO_PATH);
    filoPath.addContent(this.getFiloPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(filoPath);

    Element fastqcPath = new Element(FASTQC_PATH);
    fastqcPath.addContent(this.getFastqcPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(fastqcPath);

    if (!this.getNthr().equals(nthr_DV)) {
        Element nthr = new Element(NTHR);
        nthr.addContent(String.valueOf(this.getNthr()));
        configurationFile.getRootElement().addContent(nthr);
    }/*w  ww  . java  2 s  .  co  m*/

    if (!this.getJavaRam().equals(javaRam_DV)) {
        Element javaRam = new Element(JAVA_RAM);
        javaRam.addContent(this.getJavaRam());
        configurationFile.getRootElement().addContent(javaRam);
    }

    Element queueSystem = new Element(QUEUE_SYSTEM);
    queueSystem.addContent(this.getQueueSystem().getDisplayName());
    configurationFile.getRootElement().addContent(queueSystem);

    if (!this.getQueueName().equals(queueName_DV)) {
        Element queueName = new Element(QUEUE_NAME);
        queueName.addContent(this.getQueueName());
        configurationFile.getRootElement().addContent(queueName);
    }

    if (!this.getMulticoreName().equals(multicoreName_DV)) {
        Element multicoreName = new Element(MULTICORE_NAME);
        multicoreName.addContent(this.getMulticoreName());
        configurationFile.getRootElement().addContent(multicoreName);
    }

    if (!this.getMulticoreNumber().equals(multicoreNumber_DV)) {
        Element multicoreNumber = new Element(MULTICORE_NUMBER);
        multicoreNumber.addContent(String.valueOf(this.getMulticoreNumber()));
        configurationFile.getRootElement().addContent(multicoreNumber);
    }

    XMLOutputter xmlOutput = new XMLOutputter();
    xmlOutput.setFormat(Format.getPrettyFormat());
    xmlOutput.output(configurationFile, new FileWriter(output));
}

From source file:es.uvigo.ei.sing.rubioseq.gui.view.models.configuration.ConfigProgramPathsSNV.java

License:Open Source License

public void exportToXML(File output) throws IOException {
    Document configurationFile = new Document();
    Comment comment = new Comment(COMMENT_VARIANT_CALLER);
    configurationFile.addContent(comment);

    Element configData = new Element(CONFIG_DATA);
    configurationFile.setRootElement(configData);

    Element bwaPath = new Element(BWA_PATH);
    bwaPath.addContent(this.getBwaPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(bwaPath);

    Element samtoolsPath = new Element(SAMTOOLS_PATH);
    samtoolsPath.addContent(this.getSamtoolsPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(samtoolsPath);

    Element gatkpath = new Element(GATK_PATH);
    gatkpath.addContent(this.getGatkpath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(gatkpath);

    Element picardPath = new Element(PICARD_PATH);
    picardPath.addContent(this.getPicardPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(picardPath);

    Element BFASTPath = new Element(BFAST_PATH);
    BFASTPath.addContent(this.getBfastPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(BFASTPath);

    Element fastqcPath = new Element(FASTQC_PATH);
    fastqcPath.addContent(this.getFastqcPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(fastqcPath);

    if (!this.getNthr().equals(nthr_DV)) {
        Element nthr = new Element(NTHR);
        nthr.addContent(String.valueOf(this.getNthr()));
        configurationFile.getRootElement().addContent(nthr);
    }//from   w w  w.jav a 2s . c  o  m

    if (!this.getJavaRam().equals(javaRam_DV)) {
        Element javaRam = new Element(JAVA_RAM);
        javaRam.addContent(this.getJavaRam());
        configurationFile.getRootElement().addContent(javaRam);
    }

    Element queueSystem = new Element(QUEUE_SYSTEM);
    queueSystem.addContent(this.getQueueSystem().getDisplayName());
    configurationFile.getRootElement().addContent(queueSystem);

    if (!this.getQueueName().equals(queueName_DV)) {
        Element queueName = new Element(QUEUE_NAME);
        queueName.addContent(this.getQueueName());
        configurationFile.getRootElement().addContent(queueName);
    }

    if (!this.getMulticoreName().equals(multicoreName_DV)) {
        Element multicoreName = new Element(MULTICORE_NAME);
        multicoreName.addContent(this.getMulticoreName());
        configurationFile.getRootElement().addContent(multicoreName);
    }

    if (!this.getMulticoreNumber().equals(multicoreNumber_DV)) {
        Element multicoreNumber = new Element(MULTICORE_NUMBER);
        multicoreNumber.addContent(String.valueOf(this.getMulticoreNumber()));
        configurationFile.getRootElement().addContent(multicoreNumber);
    }

    XMLOutputter xmlOutput = new XMLOutputter();
    xmlOutput.setFormat(Format.getPrettyFormat());
    xmlOutput.output(configurationFile, new FileWriter(output));
}

From source file:es.uvigo.ei.sing.rubioseq.gui.view.models.experiments.ChipSeqExperiment.java

License:Open Source License

public void generateXMLConfigurationFile(File output) throws IOException {
    Document configurationFile = new Document();
    Element configData = new Element(CONFIG_DATA);
    configurationFile.setRootElement(configData);
    configData.setAttribute(ExperimentUtils.BRANCH, ExperimentUtils.BRANCH_CHIPSEQ);

    Element genRef = new Element(GENREF);
    genRef.addContent(this.getGenRefPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(genRef);

    Element plattform = new Element(PLATTFORM);
    plattform.addContent(this.getPlattform().getDisplayName());
    configurationFile.getRootElement().addContent(plattform);

    if (!this.checkCasava.equals(checkCasava_DV)) {
        Element checkCasava = new Element(CHECKCASAVA);
        checkCasava.addContent(this.getCheckCasava().toString());
        configurationFile.getRootElement().addContent(checkCasava);
    }//w  w  w.  j  av a  2  s  . c  o  m

    Element dirOutBase = new Element(DIROUTBASE);
    dirOutBase.addContent(this.getDirOutBase().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(dirOutBase);

    Element projectId = new Element(PROJECTID);
    projectId.addContent(this.getProjectId());
    configurationFile.getRootElement().addContent(projectId);

    if (!this.getUserName().equals(userName_DV)) {
        Element userName = new Element(USERNAME);
        userName.addContent(this.getUserName());
        configurationFile.getRootElement().addContent(userName);
    }

    Element inDirPreProcess = new Element(INDIRPREPROCESS);
    inDirPreProcess.addContent(this.getDataInDirpreProcess().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(inDirPreProcess);

    for (CSExperiment experiment : this.getExperiments()) {
        Element chipSeqExperiment = new Element(EXPERIMENT);

        for (ChipSeqUnit csUnit : experiment.getChipSeqUnits()) {
            Element csUnitElement = new Element(CHIPSEQUNIT);

            Sample sampleTreatment = csUnit.getSampleTreatment();

            Element sampleTreatmentElement = new Element(SAMPLE_TREATMENT);

            Element sampleName = new Element(SAMPLE_NAME);
            sampleName.addContent(sampleTreatment.getSampleName());
            sampleTreatmentElement.addContent(sampleName);

            Element sampleFiles = new Element(SAMPLE_FILES);
            sampleFiles.addContent(sampleTreatment.getSampleFiles());
            sampleTreatmentElement.addContent(sampleFiles);

            Element sampleSuffix = new Element(SAMPLE_SUFFIX);
            sampleSuffix.addContent(sampleTreatment.getSampleSuffix());
            sampleTreatmentElement.addContent(sampleSuffix);

            Element sampleType = new Element(SAMPLE_TYPE);
            sampleType.addContent(sampleTreatment.getSampleType().getDisplayName());
            sampleTreatmentElement.addContent(sampleType);

            csUnitElement.addContent(sampleTreatmentElement);

            Sample sampleInput = csUnit.getSampleInput();
            if (sampleInput.checkSample()) {

                Element sampleInputElement = new Element(SAMPLE_INPUT);

                Element sampleInputName = new Element(SAMPLE_NAME);
                sampleInputName.addContent(sampleInput.getSampleName());
                sampleInputElement.addContent(sampleInputName);

                Element sampleInputFiles = new Element(SAMPLE_FILES);
                sampleInputFiles.addContent(sampleInput.getSampleFiles());
                sampleInputElement.addContent(sampleInputFiles);

                Element sampleInputSuffix = new Element(SAMPLE_SUFFIX);
                sampleInputSuffix.addContent(sampleInput.getSampleSuffix());
                sampleInputElement.addContent(sampleInputSuffix);

                Element sampleInputType = new Element(SAMPLE_TYPE);
                sampleInputType.addContent(sampleInput.getSampleType().getDisplayName());
                sampleInputElement.addContent(sampleInputType);

                csUnitElement.addContent(sampleInputElement);
            }

            chipSeqExperiment.addContent(csUnitElement);
        }

        Element replicatesFlag = new Element(REPLICATES_FLAG);
        replicatesFlag.addContent(experiment.isReplicatesFlag() ? "1" : "0");
        chipSeqExperiment.addContent(replicatesFlag);

        configurationFile.getRootElement().addContent(chipSeqExperiment);
    }

    Element chromSize = new Element(CHROMSIZE);
    chromSize.addContent(this.getChromSize().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(chromSize);

    if (!this.getPeakAnalysisType().equals(peakAnalysisType_DV)) {
        Element peakAnalysis = new Element(PEAKANALYSIS);
        peakAnalysis.addContent(this.getPeakAnalysisType().getDisplayName());
        configurationFile.getRootElement().addContent(peakAnalysis);
    }

    if (this.getCcatConfigFile() != ccatConfigFile_DV) {
        Element ccaConfigFile = new Element(CCAT_CONFIG_FILE);
        ccaConfigFile.addContent(this.getCcatConfigFile().getFile().getAbsolutePath());
        configurationFile.getRootElement().addContent(ccaConfigFile);
    }

    if (!this.getMacsExtraArgs().equals(macsExtraArgs_DV)) {
        Element macsExtraArgs = new Element(MACS_EXTRAARGS);
        macsExtraArgs.addContent(this.getMacsExtraArgs());
        configurationFile.getRootElement().addContent(macsExtraArgs);
    }

    if (!this.getFastqc().equals(fastqc_DV)) {
        Element fastqc = new Element(FASTQC);
        fastqc.addContent(this.getFastqc().toString());
        configurationFile.getRootElement().addContent(fastqc);
    }

    if (this.getAnnotFile() != annotFile_DV) {
        Element annotFile = new Element(ANNOTFILE);
        annotFile.addContent(this.getAnnotFile().getFile().getAbsolutePath());
        configurationFile.getRootElement().addContent(annotFile);
    }

    if (!this.getQueueSGEProject().equals(queueSGEProject_DV)) {
        Element queueProject = new Element(QUEUESGEPROJECT);
        queueProject.addContent(this.getQueueSGEProject().toString());
        configurationFile.getRootElement().addContent(queueProject);
    }

    XMLOutputter xmlOutput = new XMLOutputter();
    xmlOutput.setFormat(Format.getPrettyFormat());
    xmlOutput.output(configurationFile, new FileWriter(output));
}

From source file:es.uvigo.ei.sing.rubioseq.gui.view.models.experiments.CopyNumberVariationExperiment.java

License:Open Source License

public void generateXMLConfigurationFile(File output) throws IOException {
    Document configurationFile = new Document();
    Element configData = new Element(CONFIG_DATA);
    configurationFile.setRootElement(configData);
    configData.setAttribute(ExperimentUtils.BRANCH, ExperimentUtils.BRANCH_CNV);

    Element genRef = new Element(GENREF);
    genRef.addContent(this.getGenRefPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(genRef);

    Element dbSnpAnnot = new Element(DBSNPANNOT);
    dbSnpAnnot.addContent(this.getDbSnpAnnotPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(dbSnpAnnot);

    Element indelAnnot = new Element(INDELANNOT);
    indelAnnot.addContent(this.getIndelAnnotPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(indelAnnot);

    Element intervals = new Element(INTERVALS);
    intervals.addContent(this.getIntervalsPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(intervals);

    if (this.getKnownIndels().size() > 0) {
        for (KnownIndels kI : this.getKnownIndels()) {
            Element knownIndels = new Element(KNOWNINDELS);
            knownIndels.addContent(kI.getFile().getFile().getAbsolutePath());
            configurationFile.getRootElement().addContent(knownIndels);
        }/*from  w  ww  .j a va  2  s.c om*/
    }

    Element plattform = new Element(PLATTFORM);
    plattform.addContent(this.getPlattform().getDisplayName());
    configurationFile.getRootElement().addContent(plattform);

    if (!this.getCheckCasava().equals(checkCasava_DV)) {
        Element checkCasava = new Element(CHECKCASAVA);
        checkCasava.addContent(this.getCheckCasava().toString());
        configurationFile.getRootElement().addContent(checkCasava);
    }

    Element dirOutBase = new Element(DIROUTBASE);
    dirOutBase.addContent(this.getDirOutBase().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(dirOutBase);

    Element projectId = new Element(PROJECTID);
    projectId.addContent(this.getProjectId());
    configurationFile.getRootElement().addContent(projectId);

    if (!this.getUserName().equals(userName_DV)) {
        Element userName = new Element(USERNAME);
        userName.addContent(this.getUserName());
        configurationFile.getRootElement().addContent(userName);
    }

    Element dataInDirpreProcess = new Element(INDIRPREPROCESS);
    dataInDirpreProcess.addContent(this.getDataInDirpreProcess().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(dataInDirpreProcess);

    for (Sample s : this.getSamples()) {
        Element sample = new Element(SAMPLE);

        Element sampleName = new Element(SAMPLE_NAME);
        sampleName.addContent(s.getSampleName());
        sample.addContent(sampleName);

        Element sampleFiles = new Element(SAMPLE_FILES);
        sampleFiles.addContent(s.getSampleFiles());
        sample.addContent(sampleFiles);

        Element sampleSuffix = new Element(SAMPLE_SUFFIX);
        sampleSuffix.addContent(s.getSampleSuffix());
        sample.addContent(sampleSuffix);

        Element sampleType = new Element(SAMPLE_TYPE);
        sampleType.addContent(s.getSampleType().getDisplayName());
        sample.addContent(sampleType);

        configurationFile.getRootElement().addContent(sample);
    }

    if (!this.getFastqc().equals(fastqc_DV)) {
        Element fastqc = new Element(FASTQC);
        fastqc.addContent(this.getFastqc().toString());
        configurationFile.getRootElement().addContent(fastqc);
    }

    if (!this.getExtraContra().equals(extraContra_DV)) {
        Element extraContra = new Element(EXTRACONTRA);
        extraContra.addContent(this.getExtraContra().toString());
        configurationFile.getRootElement().addContent(extraContra);
    }

    if (this.getBaseline() != baseline_DV) {
        Element baseline = new Element(BASELINE);
        baseline.addContent(this.getBaseline().getFile().getAbsolutePath());
        configurationFile.getRootElement().addContent(baseline);
    }

    if (!this.getmDFlag().equals(mDFlag_DV)) {
        Element mDFlag = new Element(MDFLAG);
        mDFlag.addContent(this.getmDFlag().toString());
        configurationFile.getRootElement().addContent(mDFlag);
    }

    if (!this.getQueueSGEProject().equals(queueSGEProject_DV)) {
        Element queueSGEProject = new Element(QUEUESGEPROJECT);
        queueSGEProject.addContent(this.getQueueSGEProject().toString());
        configurationFile.getRootElement().addContent(queueSGEProject);
    }

    XMLOutputter xmlOutput = new XMLOutputter();
    xmlOutput.setFormat(Format.getPrettyFormat());
    xmlOutput.output(configurationFile, new FileWriter(output));
}

From source file:es.uvigo.ei.sing.rubioseq.gui.view.models.experiments.MethylationExperiment.java

License:Open Source License

public void generateXMLConfigurationFile(File output) throws IOException {
    Document configurationFile = new Document();
    Element configData = new Element(CONFIG_DATA);
    configurationFile.setRootElement(configData);
    configData.setAttribute(ExperimentUtils.BRANCH, ExperimentUtils.BRANCH_METHYLATION);

    Element referencePath = new Element(REFERENCEPATH);
    referencePath.addContent(this.getReferencePath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(referencePath);

    Element readsPath = new Element(READSPATH);
    readsPath.addContent(this.getReadsPath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(readsPath);

    Element projectCompletePath = new Element(PROJECT_COMPLETE_PATH);
    projectCompletePath.addContent(this.getProjectCompletePath().getFile().getAbsolutePath());
    configurationFile.getRootElement().addContent(projectCompletePath);

    Element plattform = new Element(PLATTFORM);
    plattform.addContent(this.getPlattform().getDisplayName());
    configurationFile.getRootElement().addContent(plattform);

    Element methylType = new Element(METHYLTYPE);
    methylType.addContent(this.getMethylType().toString());
    configurationFile.getRootElement().addContent(methylType);

    for (MethylationSample ms : this.getSamples()) {
        Element sample1 = new Element(SAMPLE1);
        sample1.addContent(ms.getSample1().getFile().getName());
        configurationFile.getRootElement().addContent(sample1);
    }//from   ww  w  .ja v a 2  s . co m

    for (MethylationSample ms : this.getSamples()) {
        if (ms.getSample2() != null) {
            Element sample2 = new Element(SAMPLE2);
            sample2.addContent(ms.getSample2().getFile().getName());
            configurationFile.getRootElement().addContent(sample2);
        }
    }

    if (!this.getSeedLength().equals(seedLength_DV)) {
        Element seedLength = new Element(SEED_LENGTH);
        seedLength.addContent(this.getSeedLength().toString());
        configurationFile.getRootElement().addContent(seedLength);
    }

    if (!this.getNumMis().equals(numMis_DV)) {
        Element numMiss = new Element(NUM_MIS);
        numMiss.addContent(this.getNumMis().toString());
        configurationFile.getRootElement().addContent(numMiss);
    }

    if (this.getIntervalsPath() != intervalsPath_DV) {
        Element intervalsPath = new Element(INTERVALS);
        intervalsPath.addContent(this.getIntervalsPath().getFile().getAbsolutePath());
        configurationFile.getRootElement().addContent(intervalsPath);
    }

    if (!this.getContextType().equals(contextType_DV)) {
        Element contextType = new Element(CONTEXT);
        contextType.addContent(this.getContextType().toString());
        configurationFile.getRootElement().addContent(contextType);
    }

    if (!this.getTrimTagLength().equals(trimTagLength_DV)) {
        Element trimTagLength = new Element(TRIMTAGLENGTH);
        trimTagLength.addContent(this.getTrimTagLength());
        configurationFile.getRootElement().addContent(trimTagLength);
    }

    if (!this.getMinQual().equals(minQual_DV)) {
        Element minQual = new Element(MINQUAL);
        minQual.addContent(this.getMinQual().toString());
        configurationFile.getRootElement().addContent(minQual);
    }

    if (!this.getFastqc().equals(fastqc_DV)) {
        Element fastqc = new Element(FASTQC);
        fastqc.addContent(this.getFastqc().toString());
        configurationFile.getRootElement().addContent(fastqc);
    }

    if (!this.getDepthFilter().equals(depthFilter_DV)) {
        Element depthFilter = new Element(DEPTHFILTER);
        depthFilter.addContent(this.getDepthFilter().toString());
        configurationFile.getRootElement().addContent(depthFilter);
    }

    if (!this.getQueueSGEProject().equals(queueSGEProject_DV)) {
        Element queueProject = new Element(QUEUESGEPROJECT);
        queueProject.addContent(this.getQueueSGEProject().toString());
        configurationFile.getRootElement().addContent(queueProject);
    }

    if (!this.getMultiExec().equals(multiExec_DV)) {
        Element multiExec = new Element(MULTIEXEC);
        multiExec.addContent(this.getMultiExec().toString());
        configurationFile.getRootElement().addContent(multiExec);
    }

    XMLOutputter xmlOutput = new XMLOutputter();
    xmlOutput.setFormat(Format.getPrettyFormat());
    xmlOutput.output(configurationFile, new FileWriter(output));
}