<commit_before>#! /usr/bin/env python

"""
PBstat.py reads protein blocks (PBs) sequence files in fasta format
and compute statisiques (count and Neq).

2012 - <NAME>, <NAME> 
"""


#===============================================================================
# load modules
#===============================================================================
from optparse import OptionParser
import os
import sys
import numpy 
import math

#===============================================================================
# data
#===============================================================================
# 16 PBs
PB_DIC = {"a":0, "b":1, "c":2, "d":3, "e":4, "f":5, "g":6, "h":7, "i":8,
"j":9, "k":10, "l":11, "m":12, "n":13, "o":14, "p":15}
PB_DIC_SIZE = len(PB_DIC)


#===============================================================================
# functions
#===============================================================================
def read_fasta(name):
    """read fasta file and output sequences in a list"""
    seqLst = []
    seq = ""
    f_in = open(name, "r")
    for line in f_in:
        data = line.strip()
        if data and ">" not in data:
            seq += data
        if seq and data and ">" == data[0]:
            seqLst.append(seq)
            seq = ""
    f_in.close()
    # save last sequence
    if seq:
        seqLst.append(seq)
    # outputs
    print "read %d sequences in %s" % (len(seqLst), name)
    return seqLst
#===============================================================================
# MAIN - program starts here
#===============================================================================

#-------------------------------------------------------------------------------
# get options
#-------------------------------------------------------------------------------
parser = OptionParser(usage="%prog -f PB_1.PB.fasta [-f PB_2.PB.fasta] -o output_root_name")
parser.add_option("-f", action="append", type="string", 
help="name(s) of the PB file (in fasta format)")
parser.add_option("-o", action="store", type="string", 
help="root name for results")

(options, args) = parser.parse_args()<commit_msg>PBstat.py - improved usage message<commit_after>#! /usr/bin/env python

"""
PBstat.py reads protein blocks (PBs) sequence files in fasta format
and compute statisiques (count and Neq).

2012 - <NAME>, <NAME> 
"""


#===============================================================================
# load modules
#===============================================================================
from optparse import OptionParser
import os
import sys
import numpy 
import math

#===============================================================================
# data
#===============================================================================
# 16 PBs
PB_DIC = {"a":0, "b":1, "c":2, "d":3, "e":4, "f":5, "g":6, "h":7, "i":8,
"j":9, "k":10, "l":11, "m":12, "n":13, "o":14, "p":15}
PB_DIC_SIZE = len(PB_DIC)


#===============================================================================
# functions
#===============================================================================
def read_fasta(name):
    """read fasta file and output sequences in a list"""
    seqLst = []
    seq = ""
    f_in = open(name, "r")
    for line in f_in:
        data = line.strip()
        if data and ">" not in data:
            seq += data
        if seq and data and ">" == data[0]:
            seqLst.append(seq)
            seq = ""
    f_in.close()
    # save last sequence
    if seq:
        seqLst.append(seq)
    # outputs
    print "read %d sequences in %s" % (len(seqLst), name)
    return seqLst
#===============================================================================
# MAIN - program starts here
#===============================================================================

#-------------------------------------------------------------------------------
# get options
#-------------------------------------------------------------------------------
parser = OptionParser(usage="%prog -f file_1.PB.fasta [-f file_2.PB.fasta] -o output_root_name")
parser.add_option("-f", action="append", type="string", 
help="name(s) of the PB file (in fasta format)")
parser.add_option("-o", action="store", type="string", 
help="root name for results")

(options, args) = parser.parse_args()
{'fraction_non_alphanumeric': 0.4734787600459242, 'fraction_numerical': 0.01423650975889782, 'mean_word_length': 3.377889447236181, 'pattern_counts': {'":': 32, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4163055', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1091, 'n_words': 302}