Sponsored Content
Top Forums Shell Programming and Scripting parse fasta file to tabular file Post 302584570 by yifangt on Friday 23rd of December 2011 04:55:17 PM
Old 12-23-2011
parse fasta file to tabular file

Hello,
A bioperl problem I thought could be done with awk: convert the fasta format (Note: the length of each row is not the same for each entry as they were combined from different files!) to tabular format.
Code:
input.fasta:

>YAL069W-1.334 Putative promoter sequence
CCACACCACACCCACACACCCACACACCACACCACACACC
ACACCACACCCACACACACACATCCTAACACTACCCTAAC
ACAGCCCTAATCTAACCCTGGCCAACCTGTCTCTCAACTT
>YAL068C-7235.2170 Putative promoter sequence
TACGAGAATAATTTCTCATCATCCAGCTTTAACACAAAAT
ACGTAAATGAAGTTTATATATAAATTTCCTTTTTATTGGA
>gi|31044174|gb|AY143560.1| Tintinnopsis fimbriata 18S ribosomal RNA gene, partial sequence
GAAACTGCGAATGGCTCATTAAAACAGTTATAGTTTATTTGGTAATCAAACTTACATGGATAACCGTGG
TAATTCTAGAGCTAATACATGCTGTTGTGCCCGACTCACGAAGGGCGGTATTTATTAGATATCAGCCAATA
AGCATCTGCTATTGTGGTGACTCATAGTAACTTAATCGGATCGCATGGGCTTGTCCCGCGACAAACCATT
>gi|31044185|gb|AY143571.1| Codonellopsis americana 18S ribosomal RNA gene, partial sequence
ATTACCCAATCCTGACTCAGGGAGGTAGTGACAAGAAATAATGGGTCGGGGTTCTGCCCCGGGACTGCA
GGGCACCACCAGGCGTGGAGCTTGCGGCTCAATTTGACTCAACACGGGGAAACTTACCAGGTCCAGACAT

I want to convert it to the tabular format as:
Code:
output.tab:

>YAL069W-1.334 Putative promoter sequence CCACACCACACCCACACACCCACACA......CACAGCCCTAATCTAACCCTGGCCAACCTGTCTCTCAACTT
>YAL068C-7235.2170 Putative promoter sequence TACGAGAATAATTTCTCATCATCCAG......CATTTTCTTATGACGTAAATGAAGTTTATATATAAATTTCCTTTTTATTGGA
>gi|31044174|gb|AY143560.1| Tintinnopsis fimbriata 18S ribosomal RNA gene, partial sequence GAAACTGCGAATGGCTCA......ATTGTGGTGACTCATAGTAACTTAATCGGATCGCATGGGCTTGTCCCGCGACAAACCATT
>gi|31044185|gb|AY143571.1| Codonellopsis americana 18S ribosomal RNA gene, partial sequence ATTACCCAATCCTGACTC......CCAGGCGTGGAGCTTGCGGCTCAATTTGACTCAACACGGGGAAACTTACCAGGTCCAGACAT

i.e. each row has two columns: the first one is the header for the sequence name and description, the second column is the DNA sequence. This is quite common in bioinformatics daily task.
I am aware bioperl is the right tool to do the job, but I am trying to level up my awk when I read the RS variable. Not sure how to handle this situation for the RS and the FS variables.
Thanks a lot!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to change sequence name in along fasta file?

Hi I have an alignment file (.fasta) with ~80 sequences. They look like this- >JV101.contig00066(+):25302-42404|sequence_index=0|block_index=4|species=JV101|JV101_4_0 GAGGTTAATTATCGATAACGTTTAATTAAAGTGTTTAGGTGTCATAATTT TAAATGACGATTTCTCATTACCATACACCTAAATTATCATCAATCTGAAT... (2 Replies)
Discussion started by: baika
2 Replies

2. UNIX for Dummies Questions & Answers

Change sequence names in fasta file

I have fasta files with multiple sequences in each. I need to change the sequence name headers from: >accD:_59176-60699 ATGGAAAAGTGGAGGATTTATTCGTTTCAGAAGGAGTTCGAACGCA >atpA_(reverse_strand):_showing_revcomp_of_10525-12048 ATGGTAACCATTCAAGCCGACGAAATTAGTAATCTTATCCGGGAAC... (2 Replies)
Discussion started by: tyrianthinae
2 Replies

3. Shell Programming and Scripting

Extract sequence from fasta file

Hi, I want to match the sequence id (sub-string of line starting with '>' and extract the information upto next '>' line ). Please help . input > fefrwefrwef X900 AGAGGGAATTGG AGGGGCCTGGAG GGTTCTCTTC > fefrwefrwef X932 AGAGGGAATTGG AGGAGGTGGAG GGTTCTCTTC > fefrwefrwef X937... (2 Replies)
Discussion started by: ritakadm
2 Replies

4. Shell Programming and Scripting

Extract sequences from a FASTA file based on another file

I have two files. File1 is shown below. >153L:B|PDBID|CHAIN|SEQUENCE RTDCYGNVNRIDTTGASCKTAKPEGLSYCGVSASKKIAERDLQAMDRYKTIIKKVGEKLCVEPAVIAGIISRESHAGKVL KNGWGDRGNGFGLMQVDKRSHKPQGTWNGEVHITQGTTILINFIKTIQKKFPSWTKDQQLKGGISAYNAGAGNVRSYARM DIGTTHDDYANDVVARAQYYKQHGY >16VP:A|PDBID|CHAIN|SEQUENCE... (7 Replies)
Discussion started by: nelsonfrans
7 Replies

5. UNIX for Dummies Questions & Answers

Append file name to fasta file headers in Linux

How do we append the file name to fasta file headers in multiple fasta-files in Linux? (10 Replies)
Discussion started by: Mauve
10 Replies

6. Shell Programming and Scripting

Convert text file to HTML tabular format.

Please provide script/commands to convert text file to HTML tabular format. No need of styles and colours, just output and a heading in table is required. Output file will be send via email and will be seen from outlook. (script required without using awk). output file content: (sar... (7 Replies)
Discussion started by: Veera_V
7 Replies

7. UNIX for Dummies Questions & Answers

Select distinct sequences from fasta file and list

Hi How can I extract sequences from a fasta file with respect a certain criteria? The beginning of my file (containing in total more than 1000 sequences) looks like this: >H8V34IS02I59VP SDACNDLTIALLQIAREVRVCNPTFSFRWHPQVKDEVMRECFDCIRQGLG YPSMRNDPILIANCMNWHGHPLEEARQWVHQACMSPCPSTKHGFQPFRMA... (6 Replies)
Discussion started by: Marion MPI
6 Replies

8. UNIX for Dummies Questions & Answers

Round up -FASTA file

I have the following script: awk 'FNR==NR{s+=$3;next;} { print $1 , $2, 100*$3/s }' and the following file: >P39PT-1224 Freq 900 cccctacgacggcattggtaatggctcagctgctccggatcccgcaagccatcttggatatgagggttcgtcggcctcttcagccaagg-cccccagcagaacatccagctgatcg >P39PT-784 Freq 2... (2 Replies)
Discussion started by: Xterra
2 Replies

9. UNIX for Dummies Questions & Answers

Selectively extracting entries from FASTA file

I would like to extract all entries containing the following patterns: ccccta & ccccccccc from the following infile: >P39PT-1224_Freq_900 cccctacgacggcattggtaatggctcccgcaagccatctctcttcagccaagg >P39PT-784_Freq_2 cccctacgacggcattggtaatggcacccgcaagccatctctcttccccccccc >P39PT-678_Freq_5... (4 Replies)
Discussion started by: Xterra
4 Replies

10. Shell Programming and Scripting

Getting unique sequences from multiple fasta file

Hi, I have a fasta file with multiple sequences. How can i get only unique sequences from the file. For example my_file.fasta >seq1 TCTCAAAGAAAGCTGTGCTGCATACTGTACAAAACTTTGTCTGGAGAGATGGAGAATCTCATTGACTTTACAGGTGTGGACGGTCTTCAGAGATGGCTCAAGCTAACATTCCCTGACACACCTATAGGGAAAGAGCTAAC >seq2... (3 Replies)
Discussion started by: Ibk
3 Replies
Bio::Tools::ERPIN(3pm)					User Contributed Perl Documentation				    Bio::Tools::ERPIN(3pm)

NAME
Bio::Tools::ERPIN - a parser for ERPIN output SYNOPSIS
use Bio::Tools::ERPIN; my $parser = Bio::Tools::ERPIN->new( -file => $rna_output, -motiftag => 'protein_bind' -desctag => 'TRAP_binding'); #parse the results while( my $motif = $parser->next_prediction) { # do something here } DESCRIPTION
Parses raw ERPIN output. This module is not currently complete. As is, it will parse raw ERPIN long format output and pack information into Bio::SeqFeature::Generic objects. Several values have also been added in the 'tag' hash. These can be accessed using the following syntax: my ($entry) = $feature->get_Annotations('SecStructure'); Added tags are : tset - training set used for the sequence tsetdesc - training set description line cutoff - cutoff value used database - name of database dbdesc - description of database dbratios - nucleotide ratios of database (used to calculate evalue) descline - entire description line (in case the regex used for sequence ID doesn't adequately catch the name accession - accession number of sequence (if present) logodds - logodds score value sequence - sequence from hit, separated based on training set See t/ERPIN.t for example usage. At some point a more complicated feature object may be used to support this data rather than forcing most of the information into tag/value pairs in a SeqFeature::Generic. This will hopefully allow for more flexible analysis of data (specifically RNA secondary structural data). FEEDBACK
Mailing Lists User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_lists - About the mailing lists Support Please direct usage questions or support issues to the mailing list: bioperl-l@bioperl.org rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. Reporting Bugs Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via the web: https://redmine.open-bio.org/projects/bioperl/ AUTHOR - Chris Fields Email cjfields-at-uiuc-dot-edu APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ new Title : new Usage : my $obj = Bio::Tools::ERPIN->new(); Function: Builds a new Bio::Tools::ERPIN object Returns : an instance of Bio::Tools::ERPIN Args : -fh/-file for input filename -motiftag => primary tag used in gene features (default 'misc_binding') -desctag => tag used for display_name name (default 'erpin') -srctag => source tag used in all features (default 'ERPIN') motif_tag Title : motiftag Usage : $obj->motiftag($newval) Function: Get/Set the value used for 'motif_tag', which is used for setting the primary_tag. Default is 'misc_binding' as set by the global $MotifTag. 'misc_binding' is used here because a conserved RNA motif is capable of binding proteins (regulatory proteins), antisense RNA (siRNA), small molecules (riboswitches), or nothing at all (tRNA, terminators, etc.). It is recommended that this be changed to other tags ('misc_RNA', 'protein_binding', 'tRNA', etc.) where appropriate. For more information, see: http://www.ncbi.nlm.nih.gov/collab/FT/index.html Returns : value of motif_tag (a scalar) Args : on set, new value (a scalar or undef, optional) source_tag Title : source_tag Usage : $obj->source_tag($newval) Function: Get/Set the value used for the 'source_tag'. Default is 'ERPIN' as set by the global $SrcTag Returns : value of source_tag (a scalar) Args : on set, new value (a scalar or undef, optional) desc_tag Title : desc_tag Usage : $obj->desc_tag($newval) Function: Get/Set the value used for the query motif. This will be placed in the tag '-display_name'. Default is 'erpin' as set by the global $DescTag. Use this to manually set the descriptor (motif searched for). Since there is no way for this module to tell what the motif is from the name of the descriptor file or the ERPIN output, this should be set every time an ERPIN object is instantiated for clarity Returns : value of exon_tag (a scalar) Args : on set, new value (a scalar or undef, optional) analysis_method Usage : $obj->analysis_method(); Purpose : Inherited method. Overridden to ensure that the name matches /ERPIN/i. Returns : String Argument : n/a next_feature Title : next_feature Usage : while($gene = $obj->next_feature()) { # do something } Function: Returns the next gene structure prediction of the ERPIN result file. Call this method repeatedly until FALSE is returned. The returned object is actually a SeqFeatureI implementing object. This method is required for classes implementing the SeqAnalysisParserI interface, and is merely an alias for next_prediction() at present. Returns : A Bio::Tools::Prediction::Gene object. Args : None (at present) next_prediction Title : next_prediction Usage : while($gene = $obj->next_prediction()) { # do something } Function: Returns the next gene structure prediction of the ERPIN result file. Call this method repeatedly until FALSE is returned. Returns : A Bio::Tools::Prediction::Gene object. Args : None (at present) perl v5.14.2 2012-03-02 Bio::Tools::ERPIN(3pm)
All times are GMT -4. The time now is 06:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy