7 agp_to_fasta.pl - assemble an AGP file into fasta
11 agp_to_fasta.pl foo.agp source.fasta > result.fasta
17 Column width of fasta output, with 0 being unlimited (no additional
18 newlines). Default 80.
26 use Bio
::Index
::Fasta
;
28 use CXGN
::BioTools
::AGP qw
/ agp_to_seqs /;
31 getopts
( 'w', \
%opts );
32 $opts{w
} = 80 unless defined $opts{w
};
33 pod2usage
() unless @ARGV;
35 @ARGV == 2 or die "must pass exactly 2 file names as arguments\n";
38 -r
or die "cannot read file '$_'"
40 my ( $agp_file, $source_seqs ) = @ARGV;
42 my $index = make_seqs_index
( $source_seqs );
44 my @seqs = agp_to_seqs
(
46 fetch_default
=> sub {
47 my $s = $index->fetch( $_[0] )
53 my $o = Bio
::SeqIO
->new(
56 ( $opts{w
} ?
(-width
=> 80) : () ),
59 # the while/shift cuts down a bit on disk space usage
61 $o->write_seq( shift @seqs );
66 ################# SUBS ###########3
71 $temp = File
::Temp
->new;
74 # index of source sequences, for random access
75 my $inx = Bio
::Index
::Fasta
->new(
78 $inx->make_index( $source_seqs );