Sponsored Content
Full Discussion: Remove empty records
Top Forums Shell Programming and Scripting Remove empty records Post 302639131 by birei on Friday 11th of May 2012 08:48:01 AM
Old 05-11-2012
Hi yifangt,

One more way using perl:
Code:
$ cat infile
>head1
ACGATAGCTCTAGCTAGCTA
>header2
GGCGCTATGGCGACTGATCAGC
CCGAAAGATGCT
>other header name
>some thing maybe long but single line for sure
GCTAGCTAGCA
>something 
>strange header 2
AGCTAGCTGAGGGAGGAGGGA
>some description  
>other description  2
CGTAGCTAGGTAGATTTA
>something not good for me
$ cat script.pl
use warnings;
use strict;

my ($prev_line, $is_prev_header);

while ( <> ) {
        chomp;

        if ( $. == 1 ) {
                $prev_line = $_;
                $is_prev_header = is_header( $_ );
                next unless eof;
        }

        if ( ! $is_prev_header || ! is_header( $_ ) ) {
                printf qq[%s\n], $prev_line;
        }

        if ( eof && ! is_header( $_ ) ) {
                printf qq[%s\n], $_;
                exit 0;
        }

        $prev_line = $_;
        $is_prev_header = is_header( $_ );
}

sub is_header {
        return substr( $_[0], 0, 1 ) eq q[>] ? 1 : 0;
}

$ perl script.pl infile
>head1
ACGATAGCTCTAGCTAGCTA
>header2
GGCGCTATGGCGACTGATCAGC
CCGAAAGATGCT
>some thing maybe long but single line for sure
GCTAGCTAGCA
>strange header 2
AGCTAGCTGAGGGAGGAGGGA
>other description  2
CGTAGCTAGGTAGATTTA

This User Gave Thanks to birei For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

Remove non empty dirctory

Hi, Any command or means to delete a director which is not empty rmdir or similar iam using Sun Solaries 2.6 :confused: I have many full directories with subdirectories and I can not go on emptying them all (5 Replies)
Discussion started by: adol3
5 Replies

2. Shell Programming and Scripting

remove empty directory

Hi, I need to delete an empty directory in a temp directory except "dir5" (keep everything that is not empty). Plese advise. Here is an example of my directory. /dir/temp/ dir1 - delete if this is empty dir2 - delete if this is empty dir3 - delete if this is empty dir4 - delete if this... (7 Replies)
Discussion started by: sirrtuan
7 Replies

3. UNIX for Dummies Questions & Answers

Remove only Empty Directories

I know this one was answered before in forum below - https://www.unix.com/unix-dummies-questions-answers/58210-removing-empty-folders-using-find-command.html But that one is closed & I have a question so here it goes. I want to delete all 2006 files. Now if along with the files, if the... (2 Replies)
Discussion started by: kedar.mehta
2 Replies

4. Shell Programming and Scripting

using vi -c to remove empty lines

Hello: I searched here for "vi -c" but found no hits. How can I use vi -c to remove ALL empty lines, regardless of how many? I tried <code> vi -c ":g/^$/d | wq" filename </code> but I have to run it several times. This is NOT homework. :) Thanks for your time. (3 Replies)
Discussion started by: Habitual
3 Replies

5. UNIX for Dummies Questions & Answers

Grep specific records from a file of records that are separated by an empty line

Hi everyone. I am a newbie to Linux stuff. I have this kind of problem which couldn't solve alone. I have a text file with records separated by empty lines like this: ID: 20 Name: X Age: 19 ID: 21 Name: Z ID: 22 Email: xxx@yahoo.com Name: Y Age: 19 I want to grep records that... (4 Replies)
Discussion started by: Atrisa
4 Replies

6. Shell Programming and Scripting

Remove empty line and the next one

Hi all, I'm trying to remove when this condition is met: an empty and the next one I'm using this command: sed '/^$/N; s/&//' file Which searches for an empty line, N attaches it to the next line, and substituing the combination with nothing.... but it is not working. What I'm missing... (1 Reply)
Discussion started by: meuser
1 Replies

7. UNIX for Dummies Questions & Answers

remove empty field

Hi all ! I'm sure it is a basic question but I didn't find any threads that fit my need. How to remove empty fields with awk? Or in other words, how to shift all the fields after an empty field on the left? input: 1|2||3|4|5||6 wanted: 1|2|3|4|5|6 I tried: awk '{for(i=1; i<=NF;... (7 Replies)
Discussion started by: lucasvs
7 Replies

8. Shell Programming and Scripting

Remove CR only on empty lines

Dear community, I have two output files that contains some CR # cat first.out 1234567890 598679857648566 9 1234567234 365837465873465 4 2342343243 289374982374894 4 # cat second.out 2342342342 ... (2 Replies)
Discussion started by: Lord Spectre
2 Replies

9. Shell Programming and Scripting

How to remove empty line.?

Hi gurus, I have a script which works fine. https://www.unix.com/shell-programming-and-scripting/239347-how-pass-string-into-sql-query.html while read p do && para="'${p}'" || para="${para},'${p}'" done < filePlease use code tags as required by forum rules! a few days... (6 Replies)
Discussion started by: ken6503
6 Replies

10. Shell Programming and Scripting

Remove empty files in home directory

how to remove empty files tried below command its remove only zero bytes not empty file which is greater then zero byte. for x in * do if then rm $x fi done (8 Replies)
Discussion started by: Kalia
8 Replies
PRODA(1)																  PRODA(1)

NAME
proda - multiple alignment of protein sequences with repeats and rearrangements SYNOPSIS
proda [option] [mfafile] [> output] DESCRIPTION
This manual page documents briefly the proda command. proda (Protein Domain Aligner) is public domain software for generating multiple alignments of protein sequences with repeats and rearrangements, e.g. proteins with multiple domains. Given a set of protein sequences as input, ProDA first finds local pairwise alignments between all pairs of sequences, then forms blocks of alignable sequence fragments, and finally generates multiple alignments of the blocks. ProDA relies on many techniques used in probcons (<http://probcons.stanford.edu>), a recent multiple aligner that shows high accuracy in a number of popular benchmarks. INPUT FORMAT
Proda accepts input files in the MFA format. The MFA format is specified below: o the MFA format consists of multiple sequences; o each sequence in the MFA format begins with a single-line description, followed by lines of sequence data; o the description line is distinguished from the sequence data by a greater-than (">") symbol in the first column. OUTPUT FORMAT
For a set of input sequences, Proda usually outputs several blocks in turn, each consists of alignable sequence fragments. Each block is followed by its multiple alignment. A block is specified by listing its sequence fragments. Each fragment is output as sequence_name(start-end), where sequence_name is the name of the original sequence and start and end are positions at which the fragment begins and ends respectively. Proda produces block alignments in the ClustalW (ALN) format described below: o the ClustalW format consists of a single header line followed by sequence data in blocks of 50 alignment positions; o each block consists of: o one line of data for each of the sequences in the alignment - in particular, the name of the sequence; o 50 characters of the alignment; o one annotation line indicating fully conserved (*), strongly-conserved (:), or weakly-conserved columns (.); o the description line is distinguished from the sequence data by a greater-than (">") symbol in the first column. FASTA format for output If the -fasta option is specified, then, in addition to regular output, ProDA produces a file containing block alignments in the FASTA format. The output file has the same name as the first input file and extension ".fasta". Two consecutive block alignments are separated by a line containing character '#'. The FASTA format is described below: o the FASTA format consists of all the sequences given in the input files; o each sequence in the FASTA format begins with a single-line description, followed by lines of sequence data; o the description line is distinguished from the sequence data by a greater-than (">") symbol in the first column; o aligned residues are in upper case, unaligned residues are in lower case. Since a final alignment contains each sequence only once, this option should be used only if input sequences do not contain repeats. OPTIONS
-L [min_length] Set minimal alignment length equal to [min_length]. ProDA finds alignments of length greater than or equal to a threshold L. By default, L = 30. This option sets the threshold to [min_length]. -posterior Use posterior decoding when computing local pairwise alignments. ProDA computes local pairwise alignments between two sequences using a pair-HMM and either Viterbi decoding or posterior decoding. The default option is using Viterbi decoding which is faster than posterior decoding but may be less accurate. Turning on this option instructs the aligner to use posterior decoding instead. In the example above, the output was generated with -posterior option turned on. -silent Do not report progress while aligning. Turning on this option instructs the aligner not to report the progress while aligning. By default, ProDA reports the progress on all pairwise alignments, block generation, and on block alignment. Since some stages of the algorithm, especially pairwise alignment, may take long time, reporting progress makes the program look alive while running. -tran Use transitivity when forming blocks of alignable sequence fragments. Two sequence fragments are directly alignable if they are parts of a local pairwise alignment. By default, two fragments are considered alignable if and only if they are directly alignable. Turning on this option instructs the aligner to consider two fragments alignable when they are directly alignable or when both of them are directly alignable to a third fragment. -fasta Use FASTA output format in addition to the ClustalW format. When this option is turned on, the aligner generates output in the FASTA format and stores in a file with the same name as the first input file and extension ".fasta", in addition to the normal output to stdout. This option should be used only if input sequences do not contain repeats. SEE ALSO
probcons(1) AUTHOR
This manual page was written by David Paleino <d.paleino@gmail.com> for the Debian(TM) system (but may be used by others). This man page is released under the same conditions as the software, that is Public Domain. This software has been released in Public Domain by Phuong T.M., Do C.B., Edgar R.C. and Batzoglou S. in "Multiple alignment of protein sequences with repeats and rearrangements", Nucleic Acids Research 2006 - 34(20), 5932-5942 COPYRIGHT
Copyright (C) 2007 David Paleino april 25, 2007 PRODA(1)
All times are GMT -4. The time now is 02:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy