Skip to content

Commit

Permalink
Merge pull request #273 from ISA-tools/development
Browse files Browse the repository at this point in the history
Merging 1.7.7 in to master.
  • Loading branch information
eamonnmag committed Apr 4, 2014
2 parents ca51657 + e59c0f5 commit 00c6411
Show file tree
Hide file tree
Showing 39 changed files with 575 additions and 2,079 deletions.
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.isatools</groupId>
<artifactId>ISAcreator</artifactId>
<packaging>bundle</packaging>
<version>1.7.5</version>
<version>1.7.7</version>
<name>ISAcreator</name>
<url>http://www.isa-tools.org</url>

Expand Down Expand Up @@ -305,6 +305,12 @@
<version>beta-20080629</version>
</dependency>

<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<version>2.0-RC3</version>
</dependency>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
Expand Down Expand Up @@ -555,7 +561,7 @@
<profile>
<id>build</id>
<properties>
<isacreator.version>${pom.version}</isacreator.version>
<isacreator.version>${project.version}</isacreator.version>
<isacreator.alwaysShowInvestigation>false</isacreator.alwaysShowInvestigation>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ public void run() {
updateArchiveOutputStatusLabel("<html>increase memory!</html>");
// force an immediate garbage collect to remove redundant objects immediately!
System.gc();
} catch (Exception e) {
e.printStackTrace();
updateArchiveOutputStatusLabel("<html>" + e.getMessage() + "</html>");
log.error(e.getMessage());
}
}

Expand All @@ -217,7 +221,8 @@ public void setupProgressBar() {

private JLayeredPane getAssayByRef(String assayRef) {
for (ISASection isaSection : ApplicationManager.getIsaSectionToDataEntryForm().keySet()) {
if (isaSection.getFieldValues().get(Assay.ASSAY_REFERENCE).equals(assayRef)) {
System.out.println(isaSection);
if (isaSection.getFieldValues().get(Assay.ASSAY_REFERENCE) != null && isaSection.getFieldValues().get(Assay.ASSAY_REFERENCE).equals(assayRef)) {
return ApplicationManager.getUserInterfaceForISASection(isaSection);
}
}
Expand Down Expand Up @@ -261,7 +266,9 @@ public void zipDir(String sourceDir, File dirToZip, ZipOutputStream zos, byte[]
}
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
updateArchiveOutputStatusLabel("<html>" + e.getMessage() + "</html>");
}
}

Expand Down Expand Up @@ -327,6 +334,7 @@ public boolean zipDirectoryContents(String archiveName, String directory,
for (String containingFile : filesToZip.get(parentISAFile)) {
File f = new File(containingFile);

log.info("Going to try and zip " + f.getAbsolutePath());
// this will test if the file being mentioned is in a relative location to the directory, just in case!
f = testIfRelativeOrAbsolutePath(f, isaFiles[0].getParentFile());

Expand Down Expand Up @@ -360,7 +368,7 @@ public boolean zipDirectoryContents(String archiveName, String directory,
statistics.setEndTime(System.currentTimeMillis());

if (missingFiles.size() > 0 || missingData.size() > 0) {
log.info("Archive creation failed, there are " + missingFiles.size() + " missing files referenced in the submission.");
log.error("Archive creation failed, there are " + missingFiles.size() + " missing files referenced in the submission.");

updateArchiveOutputStatusLabel("<html><strong>Archive output failed<strong>, there are <i>files</i> or <i>data</i> missing.</html>");

Expand All @@ -370,7 +378,7 @@ public boolean zipDirectoryContents(String archiveName, String directory,
firePropertyChange("archiveOutputFailed", false, true);
return false;
} else {
log.error("Archive output successful!");
log.info("Archive output successful!");
firePropertyChange("archiveOutputCompleted", false, true);
return true;
}
Expand All @@ -380,6 +388,11 @@ public boolean zipDirectoryContents(String archiveName, String directory,
e.printStackTrace();
return false;
} catch (IOException e) {
log.error("IO Exception - " + e.getMessage());
e.printStackTrace();
return false;
} catch (Exception e) {
log.error("Unexpected Exception - " + e.getMessage());
e.printStackTrace();
return false;
} finally {
Expand All @@ -395,7 +408,8 @@ public boolean zipDirectoryContents(String archiveName, String directory,

private File testIfRelativeOrAbsolutePath(File file, File isaDirectory) {
if (!file.exists()) {
return new File(isaDirectory.getAbsolutePath() + File.separator + file.getName());

return new File(isaDirectory.getAbsolutePath() + File.separator + file.getPath());
}

return file;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,15 @@ public void setDispatchTarget(String dispatchTarget) {
}

public String getDispatchTarget() {
return dispatchTarget == null ? measurementType.equals("[Sample]") ? "" : DispatchTargets.GENERIC.toString() : dispatchTarget;
return dispatchTarget == null ? isSampleOrInvestigation() ? "" : DispatchTargets.GENERIC.toString() : dispatchTarget;
}

public String getAssayType() {
return assayType == null ? measurementType.equals("[Sample]") ? "" : AssayTypes.GENERIC.toString() : assayType;
return assayType == null ? isSampleOrInvestigation() ? "" : AssayTypes.GENERIC.toString() : assayType;
}

private boolean isSampleOrInvestigation() {
return measurementType.equals("[Sample]") || measurementType.equals("[investigation]");
}

public void setAssayType(String assayType) {
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/org/isatools/isacreator/gui/AboutPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,4 @@ public void paint(Graphics graphics) {
g2d.drawString(ISAcreatorProperties.getProperty("version"), 130, 120);
}

public static void main(String[] args) {
ISAcreatorGUIProperties.setProperties();
JFrame container = new JFrame();
container.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
container.setLayout(new BorderLayout());
container.add(new AboutPanel());
container.pack();
container.setVisible(true);
}
}
2 changes: 0 additions & 2 deletions src/main/java/org/isatools/isacreator/gui/ISAcreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ public class ISAcreator extends AnimatableJFrame implements WindowFocusListener

private static Logger log = Logger.getLogger(ISAcreator.class);

public static final String CONFIG_DIR = "/Configurations/isaconfig-default_v2013-02-13/";

public static String DEFAULT_ISATAB_SAVE_DIRECTORY = "isatab files";
public static String DEFAULT_CONFIGURATIONS_DIRECTORY = "Configurations";
public static String DEFAULT_USER_PROFILE_DIRECTORY = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ The ISA Team and the ISA software suite have been funded by the EU Carcinogenomi
public class ISAtabFilesImporterFromGUI extends ISAtabImporter {

private DataEntryEnvironment dataEntryEnvironment;
private ISAcreator isacreator;

/**
* ImportISAFiles provides a facility for you to import ISATAB files
Expand All @@ -66,7 +65,6 @@ public class ISAtabFilesImporterFromGUI extends ISAtabImporter {
* @param isacreator - a reference to the Main entry point of the Application
*/
public ISAtabFilesImporterFromGUI(ISAcreator isacreator){
this.isacreator = isacreator;
this.dataEntryEnvironment = new DataEntryEnvironment();
isacreator.setCurDataEntryPanel(dataEntryEnvironment);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The ISA Team and the ISA software suite have been funded by the EU Carcinogenomi

import org.apache.commons.collections15.OrderedMap;
import org.apache.commons.collections15.map.ListOrderedMap;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.isatools.errorreporter.model.ErrorLevel;
import org.isatools.errorreporter.model.ErrorMessage;
Expand Down Expand Up @@ -162,6 +163,9 @@ private Pair<Set<String>, Investigation> processInvestigationSection(OrderedMap<
Map<String, String> record = getRecord(investigationSection, 0);

investigation.addToFields(record);
if (StringUtils.trimToNull(investigation.getInvestigationId()) == null) {
investigation.setDefaultInvestigationId();
}

Map<Integer, Map<String, String>> ontologyFields = IOUtils.getOntologyTerms(sectionFields);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public class ISAcreatorApplication {

private static final Logger log = Logger.getLogger(ISAcreatorApplication.class);

private static Framework m_framework = null;

/**
* Enables the bundle to run as a stand-alone application. When this
* static {@code main()} method is invoked, the application creates
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/isatools/isacreator/model/Investigation.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ public Investigation(String investigationId, String investigationTitle, String i
String submissionDate, String publicReleaseDate) {

super();
setInvestigationId(investigationId);

if (investigationId.equals(""))
setDefaultInvestigationId();
else
setInvestigationId(investigationId);
setInvestigationTitle(investigationTitle.equals("") ? "Investigation" : investigationTitle);
setInvestigationDescription(investigationDescription);
setSubmissionDate(submissionDate);
Expand All @@ -120,6 +124,10 @@ private void initialise() {
publications = new ArrayList<Publication>();
}

public void setDefaultInvestigationId(){
setInvestigationId( String.valueOf(System.currentTimeMillis()) );
}

@Override
public void setReferenceObjectForSection() {
setReferenceObject(ApplicationManager.getInvestigationDataEntryReferenceObject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class AnnotatorSearchClient {
public static final String BASE_QUERY_URL = "http://data.bioontology.org/annotator";

public Map<String, Map<String, AnnotatorResult>> searchForTerms(Set<String> terms) {
return searchForTerms(terms, AcceptedOntologies.getAllowedOntologyAcronyms(new HashSet<Ontology>()), true);
return searchForTerms(terms, "", true);
}

public Map<String, Map<String, AnnotatorResult>> searchForTerms(Set<String> terms, String ontologiesToSearchOn, boolean wholeWordOnly) {
Expand All @@ -44,6 +44,7 @@ public Map<String, Map<String, AnnotatorResult>> searchForTerms(Set<String> term

method.addParameter("ontologies", ontologiesToSearchOn);
method.addParameter("text", flattenedTerms);
method.addParameter("include", "prefLabel");
method.addParameter("apikey", "fd88ee35-6995-475d-b15a-85f1b9dd7a42");

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,76 +74,55 @@ public class WSOntologyTreeCreator implements OntologyTreeCreator, TreeSelection
private Map<String, RecommendedOntology> ontologies;

private Container browser;
private static OntologyService bioportalClient;
private static BioPortal4Client bioportalClient;

private JTree tree;

public WSOntologyTreeCreator(Container browser, JTree tree) {
this.browser = browser;
this.tree = tree;
observers = new ArrayList<TreeObserver>();

bioportalClient = new BioPortal4Client();
}

public DefaultMutableTreeNode createTree(Map<String, RecommendedOntology> ontologies) throws FileNotFoundException {
this.ontologies = ontologies;

rootNode = new DefaultMutableTreeNode(ontologies.size() + " recommended ontologies");
treeModel = new DefaultTreeModel(rootNode);
treeModel.addTreeModelListener(this);

tree.setModel(treeModel);
tree.addTreeExpansionListener(this);
tree.addTreeSelectionListener(this);


initiateOntologyVisualization();
return rootNode;
}

private void initiateOntologyVisualization() {


// instead of visualising just one ontology, we need to visualise all that have been selected to browse on, if they have branches
// specified...or maybe should allow to browse the whole ontology as well.

try {
browser.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
for (String ontology : ontologies.keySet()) {
System.out.println("Adding " + ontology + " to tree");

RecommendedOntology recommendedOntology = ontologies.get(ontology);

System.out.println("initialising ontology visualisation for " + recommendedOntology.getOntology().getOntologyDisplayLabel());

System.out.println("Ontology version is: " + recommendedOntology.getOntology().getOntologyVersion());
// if ontology has no branch specified, query the whole ontology.
Map<String, OntologyTerm> rootTerms;

String nodeLabel = recommendedOntology.getOntology().getOntologyDisplayLabel();

OntologyService service = getCorrectOntologyService(recommendedOntology.getOntology());


if (recommendedOntology.getBranchToSearchUnder() != null) {

nodeLabel += " under " + recommendedOntology.getBranchToSearchUnder().getBranchName();

String branchIdentifier = recommendedOntology.getBranchToSearchUnder().getBranchIdentifier();

if (StringProcessing.isURL(branchIdentifier)) {
branchIdentifier = OntologyUtils.getModifiedBranchIdentifier(branchIdentifier, "#");
}

System.out.println("Going to search for " + branchIdentifier + " in " + recommendedOntology.getOntology().getOntologyDisplayLabel());

rootTerms = service.getTermChildren(branchIdentifier, getCorrectQueryString(service, recommendedOntology.getOntology()));
rootTerms = bioportalClient.getTermChildren(branchIdentifier, recommendedOntology.getOntology().getOntologyAbbreviation());

} else {
rootTerms = service.getOntologyRoots(
getCorrectQueryString(service, recommendedOntology.getOntology()));

rootTerms = bioportalClient.getOntologyRoots(recommendedOntology.getOntology().getOntologyAbbreviation());
}

DefaultMutableTreeNode ontologyNode = new DefaultMutableTreeNode(nodeLabel);
Expand Down Expand Up @@ -177,14 +156,6 @@ private void initiateOntologyVisualization() {
}
}

private OntologyService getCorrectOntologyService(Ontology ontology) {
return bioportalClient;
}

private String getCorrectQueryString(OntologyService service, Ontology ontology) {
return ontology.getOntologyVersion();
}

public void updateTree() {
DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot();
TreePath path = new TreePath(root.getPath());
Expand All @@ -203,10 +174,7 @@ private void preloadNextOntologyLevel(String termAccession, DefaultMutableTreeNo
browser.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

Ontology ontology = extractOntologyFromNode(parentTerm);

OntologyService service = getCorrectOntologyService(ontology);

Map<String, OntologyTerm> termChildren = service.getTermChildren(termAccession, getCorrectQueryString(service, ontology));
Map<String, OntologyTerm> termChildren = bioportalClient.getTermChildren(termAccession, ontology.getOntologyAbbreviation());

// add the level of non visible nodes
for (String accession : termChildren.keySet()) {
Expand Down Expand Up @@ -277,9 +245,8 @@ public void expandTreeToReachTerm(OntologyTerm term) {

Ontology ontology = new Ontology("", term.getOntologyVersionId(), term.getOntologySourceInformation().getSourceName(), term.getOntologySourceInformation().getSourceDescription());

OntologyService service = getCorrectOntologyService(ontology);

Map<String, OntologyTerm> nodeParentsFromRoot = service.getAllTermParents(term.getOntologyTermAccession(), term.getOntologySourceInformation().getSourceVersion());
Map<String, OntologyTerm> nodeParentsFromRoot = bioportalClient.getAllTermParents(term.getOntologyTermAccession(), term.getOntologySourceInformation().getSourceVersion());
TreePath lastPath = null;

for (OntologyTerm node : nodeParentsFromRoot.values()) {
Expand Down Expand Up @@ -327,16 +294,15 @@ public void valueChanged(TreeSelectionEvent treeSelectionEvent) {

// load children only for leaf nodes and those that have not been marked as processed
if (node.isLeaf() && node.getAllowsChildren()) {
OntologyService service = getCorrectOntologyService(ontologyTerm.getOntology());
// load children. if no children, set allowsChildren to false
Map<String, OntologyTerm> termChildren = service.getTermChildren(ontologyTerm.getBranch().getBranchIdentifier(),
getCorrectQueryString(service, ontologyTerm.getOntology()));
Map<String, OntologyTerm> termChildren = bioportalClient.getTermChildren(ontologyTerm.getBranch().getBranchIdentifier(),
ontologyTerm.getOntology().getOntologyAbbreviation());

if (termChildren.size() > 0) {
node.setAllowsChildren(true);
}
}
// olsDialog.loadMetaData(nodeInfo.getTermId(), OLSDialog.OLS_DIALOG_BROWSE_ONTOLOGY);

} else {
rootNode.removeAllChildren();
treeModel.reload();
Expand Down
Loading

0 comments on commit 00c6411

Please sign in to comment.