<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 Dbxref = dbxref.Dbxref;

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 Dataset = module.exports.Dataset = React.createClass({
    render: function() {
        var context = this.props.context;
        var itemClass = globals.itemClass(context, 'view-item');
        var pubmed_url = "http://www.ncbi.nlm.nih.gov/pubmed/?term=";
        var pubmed_links = context.references.map(function(id) {
        	return <li><a href={pubmed_url + id.slice(5)}>{id}</a></li>;
        });
        var experiments = {};
        context.files.forEach(function (file) {
            var experiment = file.replicate && file.replicate.experiment;
            if (experiment) {
                experiments[experiment['@id']] = experiment;
            }
        });
        experiments = _.values(experiments);
        return (
            <div className={itemClass}>
                <header className="row">
                    <div className="span12">
                        <h2>Dataset {context.accession}</h2>
                    </div>
                </header>
                <div className="panel data-display">
                    <dl className="key-value">
                        <dt>Accession</dt>
                        <dd>{context.accession}</dd>

                        {context.description ? <dt>Description</dt> : null}
                        {context.description ? <dd>{context.description}</dd> : null}

                        {context.dataset_type ? <dt>Dataset type</dt> : null}
                        {context.dataset_type ? <dd className="sentence-case">{context.dataset_type}</dd> : null}
                        
                        {context.lab ? <dt>Lab</dt> : null}
                        {context.lab ? <dd>{context.lab.title}</dd> : null}
                        
                        {context.aliases.length ? <dt>Aliases</dt> : null}
                        {context.aliases.length ? <dd>
                            <DbxrefList values={context.aliases} />
                         </dd> : null}
                        
                        {context.references.length ? <dt>References</dt> : null}
                        {context.references.length ? <dd>
                        	<ul className="horizontal-list">
                        		{pubmed_links}
                        	</ul>
                        </dd> : null}
                        
                        <dt>External resources</dt>
						<dd>
							{context.geo_dbxrefs.length ?
								<DbxrefList values={context.geo_dbxrefs} prefix="GEO" />
							: <em>None submitted</em> }
						</dd>
                    </dl>
                </div>

				{context.documents.length ?
                    <div>
                        <h3>Dataset documents</h3>
                        {context.documents.map(Panel)}
                    </div>
                : null}

                {experiments.length ?
                    <div>
                        <h3>Related experiments for dataset {context.accession}</h3><commit_msg>Updated page to use dbxref.<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 Dbxref = dbxref.Dbxref;

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 Dataset = module.exports.Dataset = React.createClass({
    render: function() {
        var context = this.props.context;
        var itemClass = globals.itemClass(context, 'view-item');
        var pubmed_url = "http://www.ncbi.nlm.nih.gov/pubmed/?term=";
        var pubmed_links = context.references.map(function(id) {
        	return <li><a href={pubmed_url + id.slice(5)}>{id}</a></li>;
        });
        var experiments = {};
        context.files.forEach(function (file) {
            var experiment = file.replicate && file.replicate.experiment;
            if (experiment) {
                experiments[experiment['@id']] = experiment;
            }
        });
        experiments = _.values(experiments);
        return (
            <div className={itemClass}>
                <header className="row">
                    <div className="span12">
                        <h2>Dataset {context.accession}</h2>
                    </div>
                </header>
                <div className="panel data-display">
                    <dl className="key-value">
                        <dt>Accession</dt>
                        <dd>{context.accession}</dd>

                        {context.description ? <dt>Description</dt> : null}
                        {context.description ? <dd>{context.description}</dd> : null}

                        {context.dataset_type ? <dt>Dataset type</dt> : null}
                        {context.dataset_type ? <dd className="sentence-case">{context.dataset_type}</dd> : null}
                        
                        {context.lab ? <dt>Lab</dt> : null}
                        {context.lab ? <dd>{context.lab.title}</dd> : null}
                        
                        {context.aliases.length ? <dt>Aliases</dt> : null}
                        {context.aliases.length ? <dd>
                            <DbxrefList values={context.aliases} />
                         </dd> : null}
                        
                        {context.references.length ? <dt>References</dt> : null}
                        {context.references.length ? <dd>
                        	<ul className="horizontal-list">
                        		{pubmed_links}
                        	</ul>
                        </dd> : null}
                        
                        <dt>External resources</dt>
						<dd>
							{context.dbxrefs.length ?
								<DbxrefList values={context.dbxrefs}/>
							: <em>None submitted</em> }
						</dd>
                    </dl>
                </div>

				{context.documents.length ?
                    <div>
                        <h3>Dataset documents</h3>
                        {context.documents.map(Panel)}
                    </div>
                : null}

                {experiments.length ?
                    <div>
                        <h3>Related experiments for dataset {context.accession}</h3>
{'fraction_non_alphanumeric': 0.13037166085946575, 'fraction_numerical': 0.002613240418118467, 'mean_word_length': 1.3479890933878664, 'pattern_counts': {'":': 0, '<': 115, '<?xml version=': 0, '>': 115, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2876417', 'n_tokens_mistral': 1953, 'n_tokens_neox': 1778, 'n_words': 334}