The contig ID must be twenty characters or fewer. The names of the headers created following SPAdes assembly
        are usually far too long. This renames them as the sample name
767551
def headerthreads(self):
        
        # Create and start threads
        for i in range(self.cpus):
            # Send the threads to the appropriate destination function
            threads = Thread(target=self.headers, args=())
            # Set the daemon to true - something to do with thread management
            threads.setDaemon(True)
            # Start the threading
            threads.start()
        for sample in self.runmetadata.samples:
            # Create an attribute to store the path/file name of the fasta file with fixed headers
            sample.general.fixedheaders = sample.general.bestassemblyfile.replace('.fasta', '.ffn')
            self.headerqueue.put(sample)
        self.headerqueue.join()
246755
def _create_gnu_long_header(cls, name, type, encoding, errors):
        
        name = name.encode(encoding, errors) + NUL

        info = {}
        info["name"] = "././@LongLink"
        info["type"] = type
        info["size"] = len(name)
        info["magic"] = GNU_MAGIC

        # create extended header + name blocks.
        return cls._create_header(info, USTAR_FORMAT, encoding, errors) + \
                cls._create_payload(name)
156202
static List<HpackHeader> createHeaders(int numHeaders, int nameLength, int valueLength,
                                           boolean limitToAscii) {
        List<HpackHeader> hpackHeaders = new ArrayList<HpackHeader>(numHeaders);
        for (int i = 0; i < numHeaders; ++i) {
            byte[] name = randomBytes(new byte[nameLength], limitToAscii);
            byte[] value = randomBytes(new byte[valueLength], limitToAscii);
            hpackHeaders.add(new HpackHeader(name, value));
        }
        return hpackHeaders;
    }
1110043
function(name) {
    var idx, length, regexp,
      header = this.headers[Utils.headerize(name)],
      result = [];

    if (header) {
      length = header.length;
      for (idx = 0; idx < length; idx++) {
        result.push(header[idx]);
      }
      return result;
    } else {
      length = this.extraHeaders.length;
      regexp = new RegExp('^\\s*'+ name +'\\s*:','i');
      for (idx=0; idx<length; idx++) {
        header = this.extraHeaders[idx];
        if (regexp.test(header)) {
          result.push(header.substring(header.indexOf(':')+1).trim());
        }
      }
      return result;
    }
  }
888206
def format_sourcefile_name(self, fileName, runSet):
        '''
        
        '''
        if fileName.startswith(runSet.common_prefix):
            fileName = fileName[len(runSet.common_prefix):]
        return fileName.ljust(runSet.max_length_of_filename + 4)
325934
def create_temp_space():
    
    # Truncating uuid to just take final 12 characters since space name
    # is used to name services and there is a 50 character limit on instance
    # names.  
    # MAINT: hacky with possible collisions
    unique_name = str(uuid.uuid4()).split('-')[-1]
    admin = predix.admin.cf.spaces.Space()
    res = admin.create_space(unique_name)

    space = predix.admin.cf.spaces.Space(
            guid=res['metadata']['guid'],
            name=res['entity']['name'])
    space.target()

    return space
559856
def _remove_small_contigs(self, infile, outfile, keep=None):
        ''''''
        removed = set()
        all_names = set()
        if keep is None:
            keep = set()

        file_reader = pyfastaq.sequences.file_reader(infile)
        fout = pyfastaq.utils.open_file_write(outfile)

        for seq in file_reader:
            all_names.add(seq.id)
            if len(seq) >= self.min_contig_length or seq.id in keep:
                print(seq, file=fout)
            else:
                removed.add(seq.id)

        pyfastaq.utils.close(fout)
        return all_names, removed
605440
private void resizeHeaders()
  {
    CharBuffer []newKeys = new CharBuffer[_headerSize * 2];
    CharBuffer []newValues = new CharBuffer[_headerSize * 2];

    for (int i = 0; i < _headerSize; i++) {
      newKeys[i] = _headerKeys[i];
      newValues[i] = _headerValues[i];
    }

    for (int i = _headerSize; i < newKeys.length; i++) {
      newKeys[i] = new CharBuffer();
      newValues[i] = new CharBuffer();
    }

    _headerKeys = newKeys;
    _headerValues = newValues;
  }
47947
function constructSafeFilename(prefix = '', trimmable = '', suffix = '') {
  if (!trimmable) {
    throw new DetoxRuntimeError({
      message: 'no trimmable filename was given to constructSafeFilename(prefix, trimmable, suffix)',
      debugInfo: 'the arguments were: ' + JSON.stringify({
        prefix,
        trimmable,
        suffix,
      }, null, 2),
    });
  }

  const nonTrimmableLength = prefix.length + suffix.length;

  if (nonTrimmableLength >= MAX_FILE_LENGTH) {
    throw new DetoxRuntimeError({
      message: `cannot trim filename to match filesystem limits because prefix and/or suffix are exceed ${MAX_FILE_LENGTH} chars limit`,
      debugInfo: JSON.stringify({
        prefix,
        prefixLength: prefix.length,
        trimmable,
        trimmableLength: trimmable.length,
        suffix,
        suffixLength: suffix.length,
        nonTrimmableLength,
      }, null, 2),
    });
  }

  const trimmed = trimmable.slice(-MAX_FILE_LENGTH + nonTrimmableLength);
  const unsafe = prefix + trimmed + suffix;
  const sanitized = sanitize(unsafe, sanitizeOptions);

  return sanitized;
}
616574
private void createDirectory() {
        int numTables = 9;
        // Create the TrueType header
        writeByte((byte)0);
        writeByte((byte)1);
        writeByte((byte)0);
        writeByte((byte)0);
        realSize += 4;

        writeUShort(numTables);
        realSize += 2;

        // Create searchRange, entrySelector and rangeShift
        int maxPow = maxPow2(numTables);
        int searchRange = maxPow * 16;
        writeUShort(searchRange);
        realSize += 2;

        writeUShort(maxPow);
        realSize += 2;

        writeUShort((numTables * 16) - searchRange);
        realSize += 2;

        // Create space for the table entries
        writeString("cvt ");
        cvtDirOffset = currentPos;
        currentPos += 12;
        realSize += 16;

        if (hasFpgm()) {
            writeString("fpgm");
            fpgmDirOffset = currentPos;
            currentPos += 12;
            realSize += 16;
        }

        writeString("glyf");
        glyfDirOffset = currentPos;
        currentPos += 12;
        realSize += 16;

        writeString("head");
        headDirOffset = currentPos;
        currentPos += 12;
        realSize += 16;

        writeString("hhea");
        hheaDirOffset = currentPos;
        currentPos += 12;
        realSize += 16;

        writeString("hmtx");
        hmtxDirOffset = currentPos;
        currentPos += 12;
        realSize += 16;

        writeString("loca");
        locaDirOffset = currentPos;
        currentPos += 12;
        realSize += 16;

        writeString("maxp");
        maxpDirOffset = currentPos;
        currentPos += 12;
        realSize += 16;

        writeString("prep");
        prepDirOffset = currentPos;
        currentPos += 12;
        realSize += 16;
    }
1328916
def _makeUniqueFilename(taken_names, name):
    
    if name in taken_names:
        # try to form up new name
        basename, ext = os.path.splitext(name)
        num = 1
        name = "%s-%d%s" % (basename, num, ext)
        while name in taken_names:
            num += 1
            name = "%s-%d%s" % (basename, num, ext)
    # finally, enter name into set
    taken_names.add(name)
    return name
1296921
def _create_mbap_header(slave_id, pdu):
    
    # 65535 = (2**16)-1 aka maximum number that fits in 2 bytes.
    transaction_id = randint(0, 65535)
    length = len(pdu) + 1

    return struct.pack('>HHHB', transaction_id, 0, length, slave_id)
1252125
private boolean initNameSetsLengths()
    {
        if (m_maxNameLength_ > 0) {
            return true;
        }

        String extra = "0123456789ABCDEF<>-";
        // set hex digits, used in various names, and <>-, used in extended
        // names
        for (int i = extra.length() - 1; i >= 0; i --) {
            add(m_nameSet_, extra.charAt(i));
        }

        // set sets and lengths from algorithmic names
        m_maxNameLength_ = addAlgorithmName(0);
        // set sets and lengths from extended names
        m_maxNameLength_ = addExtendedName(m_maxNameLength_);
        // set sets and lengths from group names, set global maximum values
        addGroupName(m_maxNameLength_);
        return true;
    }
1020774
function (pluginName, targetName, targetData) {
        if (arguments.length < 2) {
          throw (new Error('expected at least 2 arguments'));
        }

        if (arguments.length === 2) {
          targetData = targetName;
          targetName = lib.getNameUID(prefix, data.id);
        }

        gtx.configFor(pluginName, targetName, targetData);

        lib.pushUnique(data.plugins, pluginName);
        lib.pushHash(plugins, pluginName, data);

        lib.pushUnique(tasks, pluginName + ':' + targetName);
      }
537162
def nice_pkg_name(name):
    
    logger.debug("%s", name)

    root, ext = os.path.splitext(name)
    logger.debug("root :'%s', ext: '%s'", root, ext)

    if ext in ugly_ext:
        logger.debug("remove ext %s to get %s", ext, root)
        return root

    logger.debug("no change %s", name)
    return name
811326
function generateHash( module, testName ) {
	var hex,
		i = 0,
		hash = 0,
		str = module + "\x1C" + testName,
		len = str.length;

	for ( ; i < len; i++ ) {
		hash  = ( ( hash << 5 ) - hash ) + str.charCodeAt( i );
		hash |= 0;
	}

	// Convert the possibly negative integer hash code into an 8 character hex string, which isn't
	// strictly necessary but increases user understanding that the id is a SHA-like hash
	hex = ( 0x100000000 + hash ).toString( 16 );
	if ( hex.length < 8 ) {
		hex = "0000000" + hex;
	}

	return hex.slice( -8 );
}
984805
function padding (packageName, maxLength)
{
    const length = packageName.length;

    return (length < maxLength)
        ? " ".repeat(maxLength - length)
        : "";
}