<commit_before>'use strict';
var React = require('react');
var queryString = require('query-string');
var url = require('url');
var _ = require('underscore');
var globals = require('./globals');
var browse = module.exports;
var audit = require('./audit');
var Panel = require('react-bootstrap').Panel;
var Button = require('react-bootstrap').Button;
var DropdownButton = require('react-bootstrap').DropdownButton;
var MenuItem = require('react-bootstrap').MenuItem;
var store = require('../store');
var AuditIndicators = audit.AuditIndicators;
var AuditDetail = audit.AuditDetail;
var AuditMixin = audit.AuditMixin;

// Should really be singular...
var types = {
    annotation: {title: 'Annotation file set'},
    antibody_lot: {title: 'Antibodies'},
    biosample: {title: 'Biosamples'},
    experiment: {title: 'Experiments'},
    target: {title: 'Targets'},
    dataset: {title: 'Datasets'},
    image: {title: 'Images'},
    matched_set: {title: 'Matched set series'},
    organism_development_series: {title: 'Organism development series'},
    publication: {title: 'Publications'},
    page: {title: 'Web page'},
    pipeline: {title: 'Pipeline'},
    project: {title: 'Project file set'},
    publication_data: {title: 'Publication file set'},
    reference: {title: 'Reference file set'},
    reference_epigenome: {title: 'Reference epigenome series'},
    replication_timing_series: {title: 'Replication timing series'},
    software: {title: 'Software'},
    treatment_concentration_series: {title: 'Treatment concentration series'},
    treatment_time_series: {title: 'Treatment time series'},
    ucsc_browser_composite: {title: 'UCSC browser composite file set'}
};

var datasetTypes = {
    'Annotation': types['annotation'].title,
    'Dataset': types['dataset'].title,
    'MatchedSet': types['matched_set'].title,
    'OrganismDevelopmentSeries': types['organism_development_series'].title,
    'Project': types['project'].title,
    'PublicationData': types['publication_data'].title,
    'Reference': types['reference'].title,
    'ReferenceEpigenome': types['reference_epigenome'].title,
    'ReplicationTimingSeries': types['replication_timing_series'].title,
    'TreatmentConcentrationSeries': types['treatment_concentration_series'].title,
    'TreatmentTimeSeries': types['treatment_time_series'].title,
    'UcscBrowserComposite': types['ucsc_browser_composite'].title
};

var Listing = module.exports.Listing = function (props) {
    // XXX not all panels have the same markup
    var context;
    if (props['@id']) {
        context = props;
        props = {context: context, passExperiments: passExperiments,  key: context['@id']};
    }
    var ListingView = globals.listing_views.lookup(props.context);
    return <ListingView {...props} />;
};

var Item = module.exports.Item = React.createClass({
    render: function() {
        return (
            <div>Browse should not be used for this data type</div>
        );
    }
});
globals.listing_views.register(Item, 'Item');

var ExperimentSet = module.exports.ExperimentSet = React.createClass({
    getInitialState: function() {
    	return {
            open: false
        };
    },

    handleToggle: function (e) {
        e.preventDefault();
        this.setState({
  		  open: !this.state.open
  	  });
    },

    sortByKey: function(array) {
        return array.sort(function(a, b) {
            var keyA = a.key.toLowerCase();
            var keyB = b.key.toLowerCase();
            return ((keyA < keyB) ? -1 : ((keyA > keyB) ? 1 : 0));
        });
    },

    render: function() {
        var result = this.props.context;
        var passExperiments = this.props.passExperiments;
        var experimentArray = result.experiments_in_set;
        var childExperiments = experimentArray.map(function (experiment) {
            if(passExperiments.has(experiment)){
                return (
                    <ExperimentSublist passed={true} result={experiment} key={'a' + experiment.uuid} />
                );
            }else{
                return (
                    <ExperimentSublist passed={false} result={experiment} key={'b' + experiment.uuid} />
                );
            }
        });
        var passed = "expset-entry";
        if(passExperiments.size === experimentArray.length){
            passed += " expset-entry-passed";
        }
        var exptHits = "(" + passExperiments.size + " of " + experimentArray.length +" experiments)";
        this.sortByKey(childExperiments);<commit_msg>FF-265 #comment Fixed a small bug in the expset entry in browse that was using all pass experiments instead of the intersection of pass experiments and experiments in set.<commit_after>'use strict';
var React = require('react');
var queryString = require('query-string');
var url = require('url');
var _ = require('underscore');
var globals = require('./globals');
var browse = module.exports;
var audit = require('./audit');
var Panel = require('react-bootstrap').Panel;
var Button = require('react-bootstrap').Button;
var DropdownButton = require('react-bootstrap').DropdownButton;
var MenuItem = require('react-bootstrap').MenuItem;
var store = require('../store');
var AuditIndicators = audit.AuditIndicators;
var AuditDetail = audit.AuditDetail;
var AuditMixin = audit.AuditMixin;

// Should really be singular...
var types = {
    annotation: {title: 'Annotation file set'},
    antibody_lot: {title: 'Antibodies'},
    biosample: {title: 'Biosamples'},
    experiment: {title: 'Experiments'},
    target: {title: 'Targets'},
    dataset: {title: 'Datasets'},
    image: {title: 'Images'},
    matched_set: {title: 'Matched set series'},
    organism_development_series: {title: 'Organism development series'},
    publication: {title: 'Publications'},
    page: {title: 'Web page'},
    pipeline: {title: 'Pipeline'},
    project: {title: 'Project file set'},
    publication_data: {title: 'Publication file set'},
    reference: {title: 'Reference file set'},
    reference_epigenome: {title: 'Reference epigenome series'},
    replication_timing_series: {title: 'Replication timing series'},
    software: {title: 'Software'},
    treatment_concentration_series: {title: 'Treatment concentration series'},
    treatment_time_series: {title: 'Treatment time series'},
    ucsc_browser_composite: {title: 'UCSC browser composite file set'}
};

var datasetTypes = {
    'Annotation': types['annotation'].title,
    'Dataset': types['dataset'].title,
    'MatchedSet': types['matched_set'].title,
    'OrganismDevelopmentSeries': types['organism_development_series'].title,
    'Project': types['project'].title,
    'PublicationData': types['publication_data'].title,
    'Reference': types['reference'].title,
    'ReferenceEpigenome': types['reference_epigenome'].title,
    'ReplicationTimingSeries': types['replication_timing_series'].title,
    'TreatmentConcentrationSeries': types['treatment_concentration_series'].title,
    'TreatmentTimeSeries': types['treatment_time_series'].title,
    'UcscBrowserComposite': types['ucsc_browser_composite'].title
};

var Listing = module.exports.Listing = function (props) {
    // XXX not all panels have the same markup
    var context;
    if (props['@id']) {
        context = props;
        props = {context: context, passExperiments: passExperiments,  key: context['@id']};
    }
    var ListingView = globals.listing_views.lookup(props.context);
    return <ListingView {...props} />;
};

var Item = module.exports.Item = React.createClass({
    render: function() {
        return (
            <div>Browse should not be used for this data type</div>
        );
    }
});
globals.listing_views.register(Item, 'Item');

var ExperimentSet = module.exports.ExperimentSet = React.createClass({
    getInitialState: function() {
    	return {
            open: false
        };
    },

    handleToggle: function (e) {
        e.preventDefault();
        this.setState({
  		  open: !this.state.open
  	  });
    },

    sortByKey: function(array) {
        return array.sort(function(a, b) {
            var keyA = a.key.toLowerCase();
            var keyB = b.key.toLowerCase();
            return ((keyA < keyB) ? -1 : ((keyA > keyB) ? 1 : 0));
        });
    },

    render: function() {
        var result = this.props.context;
        var passExperiments = this.props.passExperiments;
        passExperiments.add(5);
        var experimentArray = result.experiments_in_set;
        var intersection = new Set(experimentArray.filter(x => passExperiments.has(x)));
        var childExperiments = experimentArray.map(function (experiment) {
            if(passExperiments.has(experiment)){
                return (
                    <ExperimentSublist passed={true} result={experiment} key={'a' + experiment.uuid} />
                );
            }else{
                return (
                    <ExperimentSublist passed={false} result={experiment} key={'b' + experiment.uuid} />
                );
            }
        });
        var passed = "expset-entry";
        if(intersection.size > 0 && intersection.size === experimentArray.length){
            passed += " expset-entry-passed";
        }
        var exptHits = "(" + intersection.size + " of " + experimentArray.length +" experiments)";
        this.sortByKey(childExperiments);
{'fraction_non_alphanumeric': 0.1402661515346641, 'fraction_numerical': 0.0011805108392358874, 'mean_word_length': 3.3043879907621245, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '397971', 'n_tokens_mistral': 2709, 'n_tokens_neox': 2644, 'n_words': 623}