scripts/support/fasta2rfamseq_old.py
def generate_rfamseq_metadata_from_fasta(fasta_file, taxid, source, filename=None, to_file=True):
    """
    Parses a fasta file and generates rfamseq like matadata using esl-seqstat. The output is in
    rfamseq table format.

    fasta_file: A valid merged genome fasta (UPXXXXXXXXX.fa)
    taxid: A valid genome taxonomy id
    source: The database where the genome was downloaded from
    filename: A filename to be used for the output file. If None, uses fasta_file name
    to_file: A boolean value indicating whether to write output to file or print the entries
    on screen

    returns: void
    """

    mol_type = "genomic DNA"
    previous_acc = ''

    # create an output file pointed
    output_fp = None

    if to_file is True:
        if filename is None:
            filename = os.path.basename(fasta_file).partition('.')[0]
        destination = os.path.split(fasta_file)[0]
        output_fp = open(os.path.join(destination, filename+".rfamseq"), 'w')

    args = [gf.ESL_SEQSTAT, "-a", "--dna", fasta_file]
    # open a process pipe and run esl-seqstat. Stores the result in process
    process = subprocess.Popen(args, stdout=subprocess.PIPE)

    # fetch esl-seqstat results
    result = process.communicate()

    # read in and clean-up sequence stats
    seq_stats = [x[2:] for x in result[0].strip().split('\n') if x[0] == '=']

    # process every sequence header to generate a rfamseq entry
    for sequence in seq_stats:
        seq_elements = [x.strip() for x in sequence.split(' ') if x != '']

        rfamseq_acc = seq_elements[0].split('|')[-1]
        accession = rfamseq_acc.partition('.')[0]
        version = rfamseq_acc.partition('.')[2]
        length = seq_elements[1]
        description = " ".join(seq_elements[2:])

        rfamseq_entry = "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (rfamseq_acc, accession,
                                                      version, taxid,
                                                      mol_type, length,
                                                      description, previous_acc,
                                                      source)
        if to_file is True:
            output_fp.write(rfamseq_entry+'\n')
        else:
            print rfamseq_entry

    if to_file is True:
        output_fp.close()

    Parses a fasta file and generates rfamseq like matadata using esl-seqstat. The output is in
    rfamseq table format.

    fasta_file: A valid merged genome fasta (UPXXXXXXXXX.fa)
    taxid: A valid genome taxonomy id
    source: The database where the genome was downloaded from
    filename: A filename to be used for the output file. If None, uses fasta_file name
    to_file: A boolean value indicating whether to write output to file or print the entries
    on screen

    returns: void
    
Parses a fasta file and generates rfamseq like matadata using esl-seqstat. The output is in
rfamseq table format.

A valid merged genome fasta (UPXXXXXXXXX.fa)
taxid: A valid genome taxonomy id
source: The database where the genome was downloaded from
filename: A filename to be used for the output file. If None, uses fasta_file name
to_file: A boolean value indicating whether to write output to file or print the entries
on screen

void
Parses a fasta file and generates rfamseq like matadata using esl - seqstat . The output is in rfamseq table format . A valid merged genome fasta ( UPXXXXXXXXX . fa ) taxid : A valid genome taxonomy id source : The database where the genome was downloaded from filename : A filename to be used for the output file . If None uses fasta_file name to_file : A boolean value indicating whether to write output to file or print the entries on screen void
def generate_rfamseq_metadata_from_fasta(fasta_file, taxid, source, filename=None, to_file=True):
    mol_type = "genomic DNA"
    previous_acc = ''
    output_fp = None
    if to_file is True:
        if filename is None:
            filename = os.path.basename(fasta_file).partition('.')[0]
        destination = os.path.split(fasta_file)[0]
        output_fp = open(os.path.join(destination, filename+".rfamseq"), 'w')
    args = [gf.ESL_SEQSTAT, "-a", "--dna", fasta_file]
    process = subprocess.Popen(args, stdout=subprocess.PIPE)
    result = process.communicate()
    seq_stats = [x[2:] for x in result[0].strip().split('\n') if x[0] == '=']
    for sequence in seq_stats:
        seq_elements = [x.strip() for x in sequence.split(' ') if x != '']
        rfamseq_acc = seq_elements[0].split('|')[-1]
        accession = rfamseq_acc.partition('.')[0]
        version = rfamseq_acc.partition('.')[2]
        length = seq_elements[1]
        description = " ".join(seq_elements[2:])
        rfamseq_entry = "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (rfamseq_acc, accession,
                                                      version, taxid,
                                                      mol_type, length,
                                                      description, previous_acc,
                                                      source)
        if to_file is True:
            output_fp.write(rfamseq_entry+'\n')
        else:
            print rfamseq_entry
    if to_file is True:
        output_fp.close()
def generate_rfamseq_metadata_from_fasta ( fasta_file , taxid , source , filename = None , to_file = True ) : mol_type = "genomic DNA" previous_acc = '' output_fp = None if to_file is True : if filename is None : filename = os . path . basename ( fasta_file ) . partition ( '.' ) [ 0 ] destination = os . path . split ( fasta_file ) [ 0 ] output_fp = open ( os . path . join ( destination , filename + ".rfamseq" ) , 'w' ) args = [ gf . ESL_SEQSTAT , "-a" , "--dna" , fasta_file ] process = subprocess . Popen ( args , stdout = subprocess . PIPE ) result = process . communicate ( ) seq_stats = [ x [ 2 : ] for x in result [ 0 ] . strip ( ) . split ( '\n' ) if x [ 0 ] == '=' ] for sequence in seq_stats : seq_elements = [ x . strip ( ) for x in sequence . split ( ' ' ) if x != '' ] rfamseq_acc = seq_elements [ 0 ] . split ( '|' ) [ - 1 ] accession = rfamseq_acc . partition ( '.' ) [ 0 ] version = rfamseq_acc . partition ( '.' ) [ 2 ] length = seq_elements [ 1 ] description = " " . join ( seq_elements [ 2 : ] ) rfamseq_entry = "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % ( rfamseq_acc , accession , version , taxid , mol_type , length , description , previous_acc , source ) if to_file is True : output_fp . write ( rfamseq_entry + '\n' ) else : print rfamseq_entry if to_file is True : output_fp . close ( )
Parses a fasta file and generates rfamseq like matadata using esl-seqstat.
Parses a fasta file and generates rfamseq like matadata using esl - seqstat .
"""
    Parses a fasta file and generates rfamseq like matadata using esl-seqstat. The output is in
    rfamseq table format.

    fasta_file: A valid merged genome fasta (UPXXXXXXXXX.fa)
    taxid: A valid genome taxonomy id
    source: The database where the genome was downloaded from
    filename: A filename to be used for the output file. If None, uses fasta_file name
    to_file: A boolean value indicating whether to write output to file or print the entries
    on screen

    returns: void
    """ # create an output file pointed # open a process pipe and run esl-seqstat. Stores the result in process # fetch esl-seqstat results # read in and clean-up sequence stats # process every sequence header to generate a rfamseq entry
fasta_file
taxid
source
filename
to_file