Take only the first whitespace-delimited word as the name of the sequence.
    Essentially removes any extra text from the sequence's description.
433979
def first_name_capture(records):
    
    logging.info('Applying _first_name_capture generator: '
                 'making sure ID only contains the first whitespace-delimited '
                 'word.')
    whitespace = re.compile(r'\s+')
    for record in records:
        if whitespace.search(record.description):
            yield SeqRecord(record.seq, id=record.id,
                            description="")
        else:
            yield record
414382
public static String remove_first_word(EvaluationContext ctx, Object text) {
        String _text = StringUtils.stripStart(Conversions.toString(text, ctx), null);
        String firstWord = first_word(ctx, _text);

        if (StringUtils.isNotEmpty(firstWord)) {
            return StringUtils.stripStart(_text.substring(firstWord.length()), null);
        } else {
            return "";
        }
    }
22615
def _get_sequence_with_spacing(self, # pylint: disable=no-self-use
                                   new_grammar,
                                   expressions: List[Expression],
                                   name: str = '') -> Sequence:
        
        expressions = [subexpression
                       for expression in expressions
                       for subexpression in (expression, new_grammar['ws'])]
        return Sequence(*expressions, name=name)
1270543
private static String trimSpaceAtStart(final String temp, final String termName) {
        if (termName != null && termName.charAt(termName.length() - 1) == ' ') {
            if (temp.charAt(0) == ' ') {
                return temp.substring(1);
            }
        }
        return temp;
    }
1001650
def _strip(text):
        """"""
        text = text.strip()
        text = text.replace('  ', ' ')  # remove duplicate spaces
        text = text.lower()
        for joiner in TextTitle.JOINERS:
            text = text.replace(joiner, 'and')
        for article in TextTitle.ARTICLES:
            if text.startswith(article + ' '):
                text = text[len(article) + 1:]
                break
        return text
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
980595
def _trim_after_first_match(self, pattern, candidate):
        """"""
        trailing_chars_match = pattern.search(candidate)
        if trailing_chars_match:
            candidate = candidate[:trailing_chars_match.start()]
        return candidate
1124446
def sanitize_word(s):
    
    s = re.sub('[^\w-]+', '_', s)
    s = re.sub('__+', '_', s)
    return s.strip('_')
1172850
def remove_read_more_sep(self, raw_content):
        
        if self._read_more_exp is None:
            return raw_content

        sp = self._read_more_exp.split(raw_content, maxsplit=1)
        if len(sp) == 2 and sp[0]:
            result = '\n\n'.join((sp[0].rstrip(), sp[1].lstrip()))
        else:
            result = raw_content
        return result
796430
def fix_whitespace(tokens, start, result):
    """"""
    for e in result:
        for child in e.iter():
            child.text = child.text.replace(' , ', ', ')
            for hyphen in HYPHENS:
                child.text = child.text.replace(' %s ' % hyphen, '%s' % hyphen)
            child.text = re.sub(r'- (.) -', r'-\1-', child.text)
    return result
1286572
def clean_text_by_word(text, language="english", deacc=False, additional_stopwords=None):
    
    init_textcleanner(language, additional_stopwords)
    text_without_acronyms = replace_with_separator(text, "", [AB_ACRONYM_LETTERS])
    original_words = list(tokenize(text_without_acronyms, lowercase=True, deacc=deacc))
    filtered_words = filter_words(original_words)
    if HAS_PATTERN:
        tags = tag(" ".join(original_words))  # tag needs the context of the words in the text
    else:
        tags = None
    units = merge_syntactic_units(original_words, filtered_words, tags)
    return { unit.text : unit for unit in units }
924688
function trimLeading(text, prefix) {
        if (text && prefix) {
            if (_.startsWith(text, prefix) || text.indexOf(prefix) === 0) {
                return text.substring(prefix.length);
            }
        }
        return text;
    }
1257710
def trimLeft(self, amount):
    
    if amount == 0:
      return
    self.sequenceData = self.sequenceData[amount:]
    self.sequenceQual = self.sequenceQual[amount:]
706806
def _clean_name(fname, data):
    
    for to_remove in dd.get_batches(data) + [dd.get_sample_name(data), data["sv"]["variantcaller"]]:
        for ext in ("-", "_"):
            if fname.startswith("%s%s" % (to_remove, ext)):
                fname = fname[len(to_remove) + len(ext):]
        if fname.startswith(to_remove):
            fname = fname[len(to_remove):]
    return fname
620646
def trim(self, text):
        
        lines = text.splitlines()
        firstline = lines[0] or lines[1]
        indent = len(firstline) - len(firstline.lstrip())
        return '\n'.join(x[indent:] for x in lines if x.strip())
209883
def trim(sequences, start, end):
    
    logging.info("Trimming from %d to %d", start, end)
    return (sequence[start:end] for sequence in sequences)
535476
def _separate_keyword(line):
    """"""
    try:
        first, rest = line.split(None, 1)
    except ValueError:
        first = line.strip()
        rest = ''
    return first, rest