Skip to content
Eamonn Maguire edited this page Sep 27, 2013 · 15 revisions

The first step to using the ISAcreator API is to either include the ISAcreator jar in your class path or to import ISAcreator as a dependency.

<dependency>
    <groupId>org.isatools</groupId>
    <artifactId>ISAcreator</artifactId>
    <version>1.7.2</version>
</dependency>

You should also include the ISA tools repository, which can be done through insertion of this fragment of XML.

<repositories>
    <repository>
            <id>oerc</id>
            <url>http://frog.oerc.ox.ac.uk:8080/nexus-2.1.2/content/repositories/releases/</url>
     </repository>
</repositories>

###Creating ISA-Tab programmatically from ISAcreator

This code has been taken from one of our tests which you can see here.

public void createISATabProgrammatically() {

    	String baseDir = System.getProperty("basedir");

        if ( baseDir == null )
        {
            try{
                baseDir = new File( "." ).getCanonicalPath();
            }catch(IOException e){
                e.printStackTrace();
            }
        }

        ISAcreator isaCreator = new ISAcreator(Mode.NORMAL_MODE, null, baseDir + ISAcreator.CONFIG_DIR);

        Investigation investigation = new Investigation("gis-investigation", "GIS investigation test");

        investigation.addContact(new InvestigationContact("maguire", "eamonn", "J", "[email protected]", "", "", "", "Oxford University", ""));
        investigation.addPublication(new InvestigationPublication("64654", "doi", "E. Maguire", "", ""));
        investigation.addPublication(new InvestigationPublication("634654", "doi", "P Rocca-Serra", "Stupid paper", ""));
        investigation.setFileReference("ProgramData/i_investigation.txt");

        Study study = new Study("gis-1");
        Assay studySample = new Assay("s_samples.txt", ConfigurationManager.selectTROForUserSelection(MappingObject.STUDY_SAMPLE));
        study.setStudySamples(studySample);

        studySample.getTableReferenceObject().addRowData(studySample.getTableReferenceObject().getHeaders().toArray(
                new String[]{"Source Name", "Characteristics[organism]", "Protocol REF", "Sample Name"}),
                new String[]{"source1", "homo sapiens", "sampling", "sample1"});

        investigation.addStudy(study);

        Assay testAssay = new Assay("assay_1.txt", "transcription profiling", "DNA microarray", "");

        study.addAssay(testAssay);

        ISAFileOutput fileOutput = new OutputISAFiles();
        fileOutput.saveISAFiles(true, investigation);
    }

###Searching for publications from ISAcreator

Publication searching is provided by CiteXplore from the EBI. To call the publication searcher from ISAcreator, the following code will get you there.

 public List<CiteExploreResult> searchForPublicationByTitle(SearchOption searchOption, String query) {
        CiteExploreClient publicationSearcher = new CiteExploreClient();

        try {
            return publicationSearcher.searchForPublication(searchOption, query);
        } catch (QueryException_Exception qex) {
            System.out.printf("Caught QueryException_Exception: %s\n", qex.getFaultInfo().getMessage());
        } catch (NoPublicationFoundException e) {
            System.out.println("No publication found");
        }

        return new ArrayList<CiteExploreResult>();
    }

Searching for Ontologies from from ISAcreator

Get all ontologies from BioPortal

public List<Ontology> getAllOntologies() {
        BioPortalClient client = new BioPortalClient();

        return client.getAllOntologies(true);
    }

###Using the NCBO Annotator from ISAcreator

The following fragment of code will take a Set of Strings and find the ontology equivalents in BioPortal. The returned Map is a map from the free text term to it's equivalents.

public  Map<String, Map<String, AnnotatorResult>> searchForMatches(Set<String> freeText) {
        AnnotatorSearchClient sc = new AnnotatorSearchClient();

        Map<String, Map<String, AnnotatorResult>> result = sc.searchForTerms(freeText, "", true);

        int termsWithMatches = 0;
        for (String key : result.keySet()) {
            if(result.get(key).size() > 0) {
                termsWithMatches++;
            }
        }

        System.out.println(termsWithMatches+ "/" + freeText.size() + " terms have matches.");

        return result;
    }
Clone this wiki locally