<commit_before>/** @jsx React.DOM */
'use strict';
var React = require('react');
var _ = require('underscore');
var globals = require('./globals');
var dbxref = require('./dbxref');

var DbxrefList = dbxref.DbxrefList;

var Panel = function (props) {
    // XXX not all panels have the same markup
    var context;
    if (props['@id']) {
        context = props;
        props = {context: context};
    }
    return globals.panel_views.lookup(props.context)(props);
};



var Experiment = module.exports.Experiment = React.createClass({
    render: function() {
        var context = this.props.context;
        var itemClass = globals.itemClass(context, 'view-item');
        var replicates = _.sortBy(context.replicates, function(item) {
            return item.biological_replicate_number;
        });
        var documents = {};
        replicates.forEach(function (replicate) {
            if (!replicate.library) return;
            replicate.library.documents.forEach(function (doc) {
                documents[doc['@id']] = Panel({context: doc});
            });
        })
        // Adding experiment specific documents
        context.documents.forEach(function (document) {
            documents[document['@id']] = Panel({context: document})
        });
        var antibodies = {};
        replicates.forEach(function (replicate) {
            if (replicate.antibody) {
                antibodies[replicate.antibody['@id']] = replicate.antibody;
            }
        });
        var antibody_accessions = []
        for (var key in antibodies) {
            antibody_accessions.push(antibodies[key].accession);
        }
        // XXX This makes no sense.
        //var control = context.possible_controls[0];
        return (
            <div className={itemClass}>
                <header className="row">
                    <div className="span12">
                        <ul className="breadcrumb">
                            <li>Experiment <span className="divider">/</span></li>
                            <li className="active">{context.assay_term_name}</li>
                        </ul>
                        <h2>Experiment summary for {context.accession}</h2>
                    </div>
                </header>
                <div className="panel data-display">
                    <dl className="key-value">
                        <dt>Accession</dt>
                        <dd>{context.accession}</dd>

                        <dt hidden={!context.description}>Description</dt>
                        <dd hidden={!context.description}>{context.description}</dd>

                        <dt hidden={!context.biosample_term_name}>Biosample</dt>
                        <dd hidden={!context.biosample_term_name}>{context.biosample_term_name}</dd>

                        <dt hidden={!context.biosample_type}>Biosample type</dt>
                        <dd hidden={!context.biosample_type}>{context.biosample_type}</dd>

                        {context.target ? <dt>Target</dt> : null}
                        {context.target ? <dd><a href={context.target['@id']}>{context.target.label}</a></dd> : null}

                        {antibody_accessions.length ? <dt>Antibody</dt> : null}
                        {antibody_accessions.length ? <dd>{antibody_accessions.join(', ')}</dd> : null}

                        <dt hidden={!context.possible_controls.length}>Controls</dt>
                        <dd hidden={!context.possible_controls.length}>
                            <ul>
                                    {context.possible_controls.map(function (control) {
                                        return (
                                            <li key={control['@id']}>
                                                <a href={control['@id']}>
                                                    {control.accession}
                                                </a>
                                            </li>
                                        );
                                    })}
                                </ul>
                        </dd>

                        <dt hidden={!context.encode2_dbxrefs.length}>ENCODE2 ID</dt>
                        <dd hidden={!context.encode2_dbxrefs.length} className="no-cap">
                            <DbxrefList values={context.encode2_dbxrefs} prefix="ENCODE2" />
                        </dd>

                        <dt>Lab</dt>
                        <dd>{context.lab.title}</dd>

                        <dt hidden={!context.aliases.length}>Aliases</dt>
                        <dd className="no-cap" hidden={!context.aliases.length}>{context.aliases.join(", ")}</dd>

                        <dt>Project</dt>
                        <dd>{context.award.rfa}</dd>

                    </dl>
                </div>

                <BiosamplesUsed replicates={replicates} />
                <AssayDetails replicates={replicates} />

                <div hidden={!Object.keys(documents).length}>
                    <h3>Protocols</h3>
                    {documents}
                </div>

                {replicates.map(function (replicate, index) {
                    return (
                        <Replicate replicate={replicate} key={index} />
                    );
                })}

                <FilesLinked context={context} />
            </div>
        );
    }
});

globals.content_views.register(Experiment, 'experiment');

var BiosamplesUsed = module.exports.BiosamplesUsed = function (props) {
    var replicates = props.replicates;
    if (!replicates.length) return (<div hidden={true}></div>);
    var biosamples = {};
    replicates.forEach(function(replicate) {
        var biosample = replicate.library.biosample;
        if (biosample) {<commit_msg>Handle replicates without libraries.<commit_after>/** @jsx React.DOM */
'use strict';
var React = require('react');
var _ = require('underscore');
var globals = require('./globals');
var dbxref = require('./dbxref');

var DbxrefList = dbxref.DbxrefList;

var Panel = function (props) {
    // XXX not all panels have the same markup
    var context;
    if (props['@id']) {
        context = props;
        props = {context: context};
    }
    return globals.panel_views.lookup(props.context)(props);
};



var Experiment = module.exports.Experiment = React.createClass({
    render: function() {
        var context = this.props.context;
        var itemClass = globals.itemClass(context, 'view-item');
        var replicates = _.sortBy(context.replicates, function(item) {
            return item.biological_replicate_number;
        });
        var documents = {};
        replicates.forEach(function (replicate) {
            if (!replicate.library) return;
            replicate.library.documents.forEach(function (doc) {
                documents[doc['@id']] = Panel({context: doc});
            });
        })
        // Adding experiment specific documents
        context.documents.forEach(function (document) {
            documents[document['@id']] = Panel({context: document})
        });
        var antibodies = {};
        replicates.forEach(function (replicate) {
            if (replicate.antibody) {
                antibodies[replicate.antibody['@id']] = replicate.antibody;
            }
        });
        var antibody_accessions = []
        for (var key in antibodies) {
            antibody_accessions.push(antibodies[key].accession);
        }
        // XXX This makes no sense.
        //var control = context.possible_controls[0];
        return (
            <div className={itemClass}>
                <header className="row">
                    <div className="span12">
                        <ul className="breadcrumb">
                            <li>Experiment <span className="divider">/</span></li>
                            <li className="active">{context.assay_term_name}</li>
                        </ul>
                        <h2>Experiment summary for {context.accession}</h2>
                    </div>
                </header>
                <div className="panel data-display">
                    <dl className="key-value">
                        <dt>Accession</dt>
                        <dd>{context.accession}</dd>

                        <dt hidden={!context.description}>Description</dt>
                        <dd hidden={!context.description}>{context.description}</dd>

                        <dt hidden={!context.biosample_term_name}>Biosample</dt>
                        <dd hidden={!context.biosample_term_name}>{context.biosample_term_name}</dd>

                        <dt hidden={!context.biosample_type}>Biosample type</dt>
                        <dd hidden={!context.biosample_type}>{context.biosample_type}</dd>

                        {context.target ? <dt>Target</dt> : null}
                        {context.target ? <dd><a href={context.target['@id']}>{context.target.label}</a></dd> : null}

                        {antibody_accessions.length ? <dt>Antibody</dt> : null}
                        {antibody_accessions.length ? <dd>{antibody_accessions.join(', ')}</dd> : null}

                        <dt hidden={!context.possible_controls.length}>Controls</dt>
                        <dd hidden={!context.possible_controls.length}>
                            <ul>
                                    {context.possible_controls.map(function (control) {
                                        return (
                                            <li key={control['@id']}>
                                                <a href={control['@id']}>
                                                    {control.accession}
                                                </a>
                                            </li>
                                        );
                                    })}
                                </ul>
                        </dd>

                        <dt hidden={!context.encode2_dbxrefs.length}>ENCODE2 ID</dt>
                        <dd hidden={!context.encode2_dbxrefs.length} className="no-cap">
                            <DbxrefList values={context.encode2_dbxrefs} prefix="ENCODE2" />
                        </dd>

                        <dt>Lab</dt>
                        <dd>{context.lab.title}</dd>

                        <dt hidden={!context.aliases.length}>Aliases</dt>
                        <dd className="no-cap" hidden={!context.aliases.length}>{context.aliases.join(", ")}</dd>

                        <dt>Project</dt>
                        <dd>{context.award.rfa}</dd>

                    </dl>
                </div>

                <BiosamplesUsed replicates={replicates} />
                <AssayDetails replicates={replicates} />

                <div hidden={!Object.keys(documents).length}>
                    <h3>Protocols</h3>
                    {documents}
                </div>

                {replicates.map(function (replicate, index) {
                    return (
                        <Replicate replicate={replicate} key={index} />
                    );
                })}

                <FilesLinked context={context} />
            </div>
        );
    }
});

globals.content_views.register(Experiment, 'experiment');

var BiosamplesUsed = module.exports.BiosamplesUsed = function (props) {
    var replicates = props.replicates;
    if (!replicates.length) return (<div hidden={true}></div>);
    var biosamples = {};
    replicates.forEach(function(replicate) {
        var biosample = replicate.library && replicate.library.biosample;
        if (biosample) {
{'fraction_non_alphanumeric': 0.12797670035977385, 'fraction_numerical': 0.002055850608189138, 'mean_word_length': 1.409203466776723, 'pattern_counts': {'":': 0, '<': 169, '<?xml version=': 0, '>': 169, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1876745', 'n_tokens_mistral': 3073, 'n_tokens_neox': 2837, 'n_words': 488}