Changeset 6522


Ignore:
Timestamp:
Dec 20, 2021, 7:34:53 AM (10 months ago)
Author:
Nicklas Nordborg
Message:

References #1355: Implement dialog for listing variants for a single raw bioassay

The popup dialog has been implemented. We have re-used to implementation from the table listing for HTML generation since the display is very similar.

Location:
extensions/net.sf.basedb.varsearch/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.varsearch/trunk/resources/varsearch.js

    r6418 r6522  
    2424    {
    2525      Events.addEventHandler(element, 'click', varsearch.showHitDetails);
     26    }
     27    else if (autoInit == 'varsearch-rba-hits')
     28    {
     29      Events.addEventHandler(element, 'click', varsearch.showRbaHits);
    2630    }
    2731    else if (autoInit == 'varsearch-hide-col')
     
    192196  }
    193197
     198  varsearch.showRbaHits = function(event)
     199  {
     200    var url = varsearch.getHome()+'rba-hits.jsp?ID='+App.getSessionId();
     201    url += '&rbaId='+Data.get(event.currentTarget, 'rba');
     202    url += '&idx='+encodeURIComponent(Data.get(event.currentTarget, 'idx'));
     203    Dialogs.openPopup(url, 'VarSearchRbaHits', 900, 600);
     204  }
     205
    194206  varsearch.reloadPage = function()
    195207  {
     
    235247  var wizard = {};
    236248  var internal = {};
    237   var debug = 0;
     249  var debug = 1;
    238250 
    239251  var numLiveAsyncRequests = 0;
  • extensions/net.sf.basedb.varsearch/trunk/src/net/sf/basedb/varsearch/LuceneColumnFactory.java

    r6408 r6522  
    194194    private final SubColumn[] columns;
    195195    private int maxHitsPerRba;
    196     private String home;
     196    private String home = ".";
    197197   
    198198    public LuceneColumnAction(LuceneIndex idx, LuceneFilterAction filter, SubColumn... columns)
     
    218218          sb.append("<div class=\"varsearch-grid\" style=\"grid-template-columns: 1fr 1fr 18px 18px;\">");
    219219          sb.append("<div class=\"gridcol-0 gridrow-0\">").append(numVariants == null ? "No" : "Yes").append("</div>");
    220           sb.append("<div class=\"gridcol-1 gridrow-0\" style=\"grid-column: span 3;\">").append(numVariants == null ? "" : numVariants).append("</div>");
     220          sb.append("<div class=\"gridcol-1 gridrow-0\" style=\"grid-column: span 2;\">").append(numVariants == null ? "" : numVariants).append("</div>");
     221          sb.append("<div class=\"varsearch-zoom gridrow-0\">");
     222          if (numVariants != null && numVariants > 0)
     223          {
     224            sb.append("<span class=\"link no-print auto-init\" data-auto-init=\"varsearch-rba-hits\" data-idx=\""+idx.getId()+"\" data-rba=\""+item.getId()+"\" title=\"List variants...\"><img src=\""+home+"/images/zoom.svg\"></span>");
     225          }
     226          sb.append("</div>");
    221227          sb.append("</div>");
    222228          return sb.toString();
     
    308314    }
    309315
    310     void setHome(String home)
     316    /**
     317      Set the path to the HOME directory (so that URLs to images are correct).
     318      The default path is '.'.
     319      @since 1.4
     320    */
     321    public void setHome(String home)
    311322    {
    312323      this.home = home;
    313324    }
    314325   
    315     void setMaxHitsPerRba(int maxHits)
     326    /**
     327      Set the max number of hits to display per raw bioassay.
     328      @since 1.4
     329    */
     330    public void setMaxHitsPerRba(int maxHits)
    316331    {
    317332      this.maxHitsPerRba = maxHits;
  • extensions/net.sf.basedb.varsearch/trunk/src/net/sf/basedb/varsearch/query/AutoPrefixer.java

    r6171 r6522  
    5353  }
    5454 
    55   String autoPrefix(String query)
     55  public String autoPrefix(String query)
    5656  {
    5757    Matcher m = rsid.matcher(query);
  • extensions/net.sf.basedb.varsearch/trunk/src/net/sf/basedb/varsearch/query/LuceneQueryFactory.java

    r6380 r6522  
    99import org.apache.lucene.document.IntPoint;
    1010import org.apache.lucene.index.Term;
     11import org.apache.lucene.queryparser.classic.ParseException;
    1112import org.apache.lucene.queryparser.classic.QueryParser;
    1213import org.apache.lucene.search.BooleanClause;
     
    127128    {
    128129      return queries;
     130    }
     131   
     132    /**
     133      Add a query to the filter.
     134      @since 1.4
     135    */
     136    public void addQuery(String query)
     137      throws ParseException
     138    {
     139      queries.add(parser.parse(query));
    129140    }
    130141   
  • extensions/net.sf.basedb.varsearch/trunk/src/net/sf/basedb/varsearch/servlet/HitServlet.java

    r6381 r6522  
    2020import net.sf.basedb.util.error.ThrowableUtil;
    2121import net.sf.basedb.varsearch.JsonUtil;
     22import net.sf.basedb.varsearch.LuceneColumnFactory;
    2223import net.sf.basedb.varsearch.VarSearch;
     24import net.sf.basedb.varsearch.LuceneColumnFactory.LuceneColumnAction;
     25import net.sf.basedb.varsearch.LuceneColumnFactory.SubColumn;
    2326import net.sf.basedb.varsearch.analyze.AminoAcidTranslator;
    2427import net.sf.basedb.varsearch.index.LuceneIndex;
     28import net.sf.basedb.varsearch.query.AutoPrefixer;
     29import net.sf.basedb.varsearch.query.LuceneQueryFactory.LuceneFilterAction;
    2530import net.sf.basedb.varsearch.service.VarSearchService;
    2631import net.sf.basedb.varsearch.util.NullSafeJSONObject;
     
    134139        json.put("raw", line.line());
    135140      }
     141      else if ("GetAllRbaHits".equals(cmd))
     142      {
     143        sc = VarSearch.getSessionControl(req);
     144        dc = sc.newDbControl();
     145       
     146        int rbaId = Values.getInt(req.getParameter("rbaId"));
     147        RawBioAssay rba = RawBioAssay.getById(dc, rbaId);
     148
     149        LuceneIndex idx = VarSearchService.getInstance().getIndexById(Values.getStringOrNull(req.getParameter("idx")));
     150       
     151        json.put("indexName", idx.getName());
     152        json.put("rbaName", rba.getName());
     153       
     154        String visibleColumns = Values.getString(sc.getUserClientSetting("net.sf.basedb.varsearch.visible-columns."+idx.getId()),
     155            "GENE,POS,REF_ALT,TYPE,HGVSC,HGVSP,LINKS");
     156        SubColumn[] columns = SubColumn.getByName(visibleColumns.split(","));
     157        StringBuilder gridTemplate = new StringBuilder();
     158        gridTemplate.append("1.6rem ");
     159        for (int colNo = 0; colNo < columns.length; colNo++)
     160        {
     161          gridTemplate.append(columns[colNo].getWidth()).append(" ");
     162        }
     163        gridTemplate.append("18px 18px");
     164
     165        StringBuilder sb = new StringBuilder();
     166        sb.append("<div id=\"varsearch-header."+idx.getId()+"\" class=\"varsearch-grid\" style=\"grid-template-columns: "+gridTemplate+";\">");
     167        int colNo = 0;
     168        boolean enableHideColumn = columns.length > 1;
     169        sb.append("<div class=\"varsearch-hitno\">#</div>");
     170        for (SubColumn col : columns)
     171        {
     172          sb.append("<div title=\"").append(col.getTooltip()).append("\"");
     173          sb.append(" class=\"gridcol-"+colNo+"\"");
     174          sb.append(" data-index-id=\""+idx.getId()+"\" data-col=\""+col.name()+"\" data-col-no=\""+colNo+"\"");
     175          if (enableHideColumn) sb.append(" draggable=\"true\"");
     176          sb.append(">");
     177          if (enableHideColumn)
     178          {
     179            sb.append("<span class=\"hide-col auto-init\" data-auto-init=\"varsearch-hide-col\" title=\"Hide this column\"></span>");
     180          }
     181          sb.append(col.getTitle()).append("</div>");
     182          colNo++;
     183        }
     184        sb.append("<div style=\"border-left-width: 0; padding: 1px; grid-column: span 2;\">");
     185        sb.append("<span class=\"varsearch-help link no-print auto-init\" data-auto-init=\"varsearch-options\" data-index-id=\""+idx.getId()+"\" title=\"Configuration options\"><img src=\"./images/gear.svg\"></span>");
     186        sb.append("</div>");
     187        sb.append("</div>");
     188        json.put("header", sb.toString());
     189       
     190        LuceneFilterAction filter = new LuceneFilterAction(null, idx);
     191        filter.addQuery(AutoPrefixer.INSTANCE.autoPrefix("0/1 OR 1/0 OR 1/1"));
     192       
     193        LuceneColumnAction action = new LuceneColumnAction(idx, filter, columns);
     194        action.setMaxHitsPerRba(LuceneColumnFactory.MAX_HITS_PER_TABLE);
     195        json.put("results", action.getValue(dc, rba));
     196      }
    136197    }
    137198    catch (Throwable t)
Note: See TracChangeset for help on using the changeset viewer.