<commit_before>define( ['dojo/_base/array',
         'JBrowse/Util',
         './Util'
        ],
        function( array, Util, BAMUtil ) {


var SEQRET_DECODER = ['=', 'A', 'C', 'x', 'G', 'x', 'x', 'x', 'T', 'x', 'x', 'x', 'x', 'x', 'x', 'N'];
var CIGAR_DECODER  = ['M', 'I', 'D', 'N', 'S', 'H', 'P', '=', 'X', '?', '?', '?', '?', '?', '?', '?'];

var readInt   = BAMUtil.readInt;
var readShort = BAMUtil.readShort;
var readFloat = BAMUtil.readFloat;

var Feature = Util.fastDeclare(

/**
 * @lends JBrowse.Store.BAM.Feature
 */
{

    /**
     * Feature object used for the JBrowse BAM backend.
     * @param args.store the BAM store this feature comes from
     * @param args.record optional BAM record (a plain object) containing the data for this feature
     * @constructs
     */
    constructor: function( args ) {
        this.file = args.file;
        this.store = args.store;

        var data = args.data
            || args.bytes && this._fromBytes( args.bytes.byteArray, args.bytes.start, args.bytes.end )
            || args.record && dojo.clone(args.record);

        // figure out start and end
        data.start = data.start || data.pos;
        data.end = data.end || ( data.length_on_ref ? data.pos + data.length_on_ref : data.seq ? data.pos + data.seq.length : undefined );

        // trying to determine orientation from 'XS' optional field,
        // or from the seq_reverse_complemented flag
        data.strand = ('XS' in data )                ? ( data.XS == '-' ? -1 : 1 ) :
                       data.seq_reverse_complemented ? -1                          :
                                                       1;

        data.score = data.mapping_quality || data.MQ || data.mq;
        data.type = data.type || 'match';
        data.source = args.store.source;

        if( data.qual && data.qual.join )
            data.qual = data.qual.join(' ');

        if( data.readName ) {
            data.name = data.readName;
            delete data.readName;
        }
        delete data.pos;

        this._refID = data._refID;
        delete data._refID;

        this.data = data;
        this._subCounter = 0;
        this._uniqueID = args.parent ? args.parent._uniqueID + '-' + ++args.parent._subCounter
                                     : data.name+'/'+data.MD+'/'+data.cigar+'/'+data.start;

        if( this.store.createSubfeatures ) {
            var subs = this.data.subfeatures = [];
	    var cigar = data.CIGAR || data.cigar;
	    if( cigar )
	        sub.push.apply( subs, this._cigarToSubfeats( cigar ) );<commit_msg>fix my enbugging of BAM subfeatures enbuggin<commit_after>define( ['dojo/_base/array',
         'JBrowse/Util',
         './Util'
        ],
        function( array, Util, BAMUtil ) {


var SEQRET_DECODER = ['=', 'A', 'C', 'x', 'G', 'x', 'x', 'x', 'T', 'x', 'x', 'x', 'x', 'x', 'x', 'N'];
var CIGAR_DECODER  = ['M', 'I', 'D', 'N', 'S', 'H', 'P', '=', 'X', '?', '?', '?', '?', '?', '?', '?'];

var readInt   = BAMUtil.readInt;
var readShort = BAMUtil.readShort;
var readFloat = BAMUtil.readFloat;

var Feature = Util.fastDeclare(

/**
 * @lends JBrowse.Store.BAM.Feature
 */
{

    /**
     * Feature object used for the JBrowse BAM backend.
     * @param args.store the BAM store this feature comes from
     * @param args.record optional BAM record (a plain object) containing the data for this feature
     * @constructs
     */
    constructor: function( args ) {
        this.file = args.file;
        this.store = args.store;

        var data = args.data
            || args.bytes && this._fromBytes( args.bytes.byteArray, args.bytes.start, args.bytes.end )
            || args.record && dojo.clone(args.record);

        // figure out start and end
        data.start = data.start || data.pos;
        data.end = data.end || ( data.length_on_ref ? data.pos + data.length_on_ref : data.seq ? data.pos + data.seq.length : undefined );

        // trying to determine orientation from 'XS' optional field,
        // or from the seq_reverse_complemented flag
        data.strand = ('XS' in data )                ? ( data.XS == '-' ? -1 : 1 ) :
                       data.seq_reverse_complemented ? -1                          :
                                                       1;

        data.score = data.mapping_quality || data.MQ || data.mq;
        data.type = data.type || 'match';
        data.source = args.store.source;

        if( data.qual && data.qual.join )
            data.qual = data.qual.join(' ');

        if( data.readName ) {
            data.name = data.readName;
            delete data.readName;
        }
        delete data.pos;

        this._refID = data._refID;
        delete data._refID;

        this.data = data;
        this._subCounter = 0;
        this._uniqueID = args.parent ? args.parent._uniqueID + '-' + ++args.parent._subCounter
                                     : data.name+'/'+data.MD+'/'+data.cigar+'/'+data.start;

        if( this.store.createSubfeatures ) {
            var subs = this.data.subfeatures = [];
	    var cigar = data.CIGAR || data.cigar;
	    if( cigar )
	        subs.push.apply( subs, this._cigarToSubfeats( cigar ) );
{'fraction_non_alphanumeric': 0.15730337078651685, 'fraction_numerical': 0.0019372336303758234, 'mean_word_length': 1.8540630182421227, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7547722', 'n_tokens_mistral': 1693, 'n_tokens_neox': 1627, 'n_words': 382}