#!/usr/bin/perl -w # Fri Nov 25 16:58:43 PST 2005 Kevin Karplus # extract-guide < foo.a2m > guide.a2m # # reads the first sequence from the input a2m file and copies it to output. =pod =head1 NAME extract-guide -- extracts the first sequence from an a2m file =head1 SYNOPSIS extract-guide < foo.a2m > guide.a2m Options: -help brief help -man detailed help =head1 OPTIONS =over 4 =item B<-help> Print a brief help message and exits. =item B<-man> Prints the manual page and exits. =back =head1 DESCRIPTION extract-guide is a very simple script that simply copies the first sequence out of an a2m or fasta formatted input on STDIN. =cut use strict; use FileHandle; STDERR->autoflush(1); use English; use Getopt::Long; use Pod::Usage; # function prototypes #main { GetOptions( "help|?" => sub {pod2usage("verbose"=>1);} , "man" => sub {pod2usage("verbose"=>2);} ) or pod2usage("verbose"=>0); my $id_line_seen=0; while() { if (/^>/) { exit (0) if ($id_line_seen); # copied first sequence $id_line_seen=1; } tr/\r//d; print $_ if ($id_line_seen); } print "\n"; # make sure there is a new-line at the end exit ($id_line_seen? 0: -1); }