Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added genus and species to drop-down with common name #2537

Merged
merged 7 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Features

- Add option to suppress calculation of non-canonical splice site [2509](https://github.com/GMOD/Apollo/issues/2509).
- Added the ability to sync the gene and transcript name with the click of a button [2519](https://github.com/GMOD/Apollo/issues/2519).
- Added organism and species to menus [2537](https://github.com/GMOD/Apollo/pull/2537).

Bug Fixes

Expand Down
36 changes: 31 additions & 5 deletions src/gwt/org/bbop/apollo/gwt/client/MainPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.OptionElement;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.http.client.*;
import com.google.gwt.json.client.*;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
Expand All @@ -24,6 +27,7 @@
import org.bbop.apollo.gwt.client.rest.*;
import org.bbop.apollo.gwt.shared.FeatureStringEnum;
import org.bbop.apollo.gwt.shared.GlobalPermissionEnum;
import org.bbop.apollo.gwt.shared.OrganismComparator;
import org.bbop.apollo.gwt.shared.PermissionEnum;
import org.gwtbootstrap3.client.ui.*;
import org.gwtbootstrap3.client.ui.Anchor;
Expand All @@ -34,9 +38,7 @@
import org.gwtbootstrap3.extras.bootbox.client.Bootbox;
import org.gwtbootstrap3.extras.bootbox.client.callback.ConfirmCallback;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.*;

/**
* Created by ndunn on 12/18/14.
Expand Down Expand Up @@ -657,6 +659,16 @@ public static void updateGenomicViewer(boolean forceReload, boolean forceUrl) {
}
}

private String capitalize(String input){
return input.substring(0,1).toUpperCase(Locale.ROOT) + input.substring(1).toLowerCase(Locale.ROOT);
}

private String createSpace(int length){
StringBuffer buffer = new StringBuffer();
for(int i = 0 ; i < length ; i++) { buffer.append("&nbsp;");}
return buffer.toString();
}

public void setAppState(AppStateInfo appStateInfo) {
trackPanel.clear();

Expand All @@ -673,6 +685,8 @@ public void setAppState(AppStateInfo appStateInfo) {
organismInfoList = appStateInfo.getOrganismList();
}

Collections.sort(organismInfoList, new OrganismComparator() );

commonDataDirectory = appStateInfo.getCommonDataDirectory();
currentSequence = appStateInfo.getCurrentSequence();
currentOrganism = appStateInfo.getCurrentOrganism();
Expand All @@ -681,8 +695,20 @@ public void setAppState(AppStateInfo appStateInfo) {

organismListBox.clear();
for (OrganismInfo organismInfo : organismInfoList) {
organismListBox.addItem(organismInfo.getName(), organismInfo.getId());
if (currentOrganism.getId().equals(organismInfo.getId())) {
// Element listElement = organismListBox.getElement();
String display = organismInfo.getName();
if(organismInfo.getGenus()!=null && organismInfo.getSpecies()!=null) {
// display = "<i>"+capitalize(organismInfo.getGenus()) + " " + organismInfo.getSpecies()+ "</i> (" + display + ")";
display = capitalize(organismInfo.getGenus()) + " " + organismInfo.getSpecies()+ " (" + display + ")";
}

// allows an html option
// OptionElement optionElement = Document.get().createOptionElement();
// optionElement.setInnerSafeHtml(SafeHtmlUtils.fromTrustedString(display));
// optionElement.setValue(organismInfo.getId());
organismListBox.addItem(display, organismInfo.getId());
// listElement.appendChild(optionElement);
if (currentOrganism.getId().equals(organismInfo.getId())) {
organismListBox.setSelectedIndex(organismListBox.getItemCount() - 1);

// fixes #2319
Expand Down
44 changes: 29 additions & 15 deletions src/gwt/org/bbop/apollo/gwt/client/OrganismPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.bbop.apollo.gwt.client.rest.OrganismRestService;
import org.bbop.apollo.gwt.client.rest.RestService;
import org.bbop.apollo.gwt.shared.FeatureStringEnum;
import org.bbop.apollo.gwt.shared.OrganismComparator;
import org.bbop.apollo.gwt.shared.track.SequenceTypeEnum;
import org.gwtbootstrap3.client.ui.*;
import org.gwtbootstrap3.client.ui.Button;
Expand All @@ -38,6 +39,7 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;

/**
* Created by ndunn on 12/17/14.
Expand Down Expand Up @@ -181,10 +183,14 @@ public void callback(boolean result) {
TextColumn<OrganismInfo> organismNameColumn = new TextColumn<OrganismInfo>() {
@Override
public String getValue(OrganismInfo organism) {
String display = organism.getName();
if (organism.getObsolete()) {
return "(obs) " + organism.getName();
display = "(obs) " + display;
}
return organism.getName();
if(organism.getGenus()!=null && organism.getSpecies()!=null){
display = organism.getGenus() + " " + organism.getSpecies() + " ("+display +")";
}
return display ;
}
};
Column<OrganismInfo, Number> annotationsNameColumn = new Column<OrganismInfo, Number>(new NumberCell()) {
Expand Down Expand Up @@ -262,12 +268,12 @@ public void onDoubleClick(DoubleClickEvent event) {

ColumnSortEvent.ListHandler<OrganismInfo> sortHandler = new ColumnSortEvent.ListHandler<OrganismInfo>(organismInfoList);
dataGrid.addColumnSortHandler(sortHandler);
sortHandler.setComparator(organismNameColumn, new Comparator<OrganismInfo>() {
@Override
public int compare(OrganismInfo o1, OrganismInfo o2) {
return o1.getName().compareTo(o2.getName());
}
});
sortHandler.setComparator(organismNameColumn, new OrganismComparator());
// @Override
// public int compare(OrganismInfo o1, OrganismInfo o2) {
// return o1.getName().compareTo(o2.getName());
// }
// });
sortHandler.setComparator(annotationsNameColumn, new Comparator<OrganismInfo>() {
@Override
public int compare(OrganismInfo o1, OrganismInfo o2) {
Expand Down Expand Up @@ -298,10 +304,21 @@ static void filterList() {
return ;
}
for (OrganismInfo organismInfo : organismInfoList) {
if (organismInfo.getName().toLowerCase().contains(text.toLowerCase())) {
filteredOrganismInfoList.add(organismInfo);
String searchText = text.toLowerCase(Locale.ROOT);
if(organismInfo.getGenus()!=null && organismInfo.getSpecies()!=null){
if (organismInfo.getGenus().toLowerCase().contains(searchText)
|| organismInfo.getSpecies().toLowerCase(Locale.ROOT).contains(searchText)
|| organismInfo.getName().toLowerCase(Locale.ROOT).contains(searchText)
) {
filteredOrganismInfoList.add(organismInfo);
}
}
else{
if (organismInfo.getName().toLowerCase().contains(searchText)) {
filteredOrganismInfoList.add(organismInfo);
}
}
}
}
}

public void loadOrganismInfo() {
Expand All @@ -313,11 +330,8 @@ public void loadOrganismInfo(OrganismInfo organismInfo) {
setNoSelection();
return;
}

setTextEnabled(organismInfo.isEditable());

GWT.log("loadOrganismInfo setValue " + organismInfo.getPublicMode());
Boolean isEditable = organismInfo.isEditable() || MainPanel.getInstance().isCurrentUserAdmin();
boolean isEditable = organismInfo.isEditable() || MainPanel.getInstance().isCurrentUserAdmin();

organismName.setText(organismInfo.getName());
organismName.setEnabled(isEditable);
Expand Down
2 changes: 1 addition & 1 deletion src/gwt/org/bbop/apollo/gwt/client/OrganismPanel.ui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
</gwt:FormPanel>
<b:Row addStyleNames="{style.searchRow}">
<b:Column size="MD_4">
<b:TextBox placeholder="Search" ui:field="nameSearchBox"/>
<b:TextBox placeholder="Search common name" ui:field="nameSearchBox"/>
</b:Column>
<b:Column size="MD_4">
<b:ButtonGroup dataToggle="BUTTONS">
Expand Down
26 changes: 26 additions & 0 deletions src/gwt/org/bbop/apollo/gwt/shared/OrganismComparator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.bbop.apollo.gwt.shared;

import org.bbop.apollo.gwt.client.dto.OrganismInfo;

import java.util.Comparator;

public class OrganismComparator implements Comparator<OrganismInfo> {
@Override
public int compare(OrganismInfo o1, OrganismInfo o2) {
if(o1.getGenus()==null && o2.getGenus()!=null) return 1 ;
if(o1.getGenus()!=null && o2.getGenus()==null) return -1 ;
if(o1.getGenus()!=null && o2.getGenus()!=null){
if(!o1.getGenus().equalsIgnoreCase(o2.getGenus())) return o1.getGenus().compareToIgnoreCase(o2.getGenus());
if(o1.getGenus().equalsIgnoreCase(o2.getGenus())) {
if(o1.getSpecies()==null && o2.getSpecies()!=null) return 1 ;
if(o1.getSpecies()!=null && o2.getSpecies()==null) return -1 ;
if(o1.getSpecies()==null && o2.getSpecies()==null) return o1.getName().compareToIgnoreCase(o2.getName());
if(!o1.getSpecies().equalsIgnoreCase(o2.getSpecies())) {
return o1.getSpecies().compareToIgnoreCase(o2.getSpecies());
}
}
}
return o1.getName().compareToIgnoreCase(o2.getName());
}

}