comparison lib/CPT/Writer/Fasta.pm @ 1:d724f34e671d draft default tip

planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
author cpt
date Mon, 05 Jun 2023 02:50:07 +0000
parents
children
comparison
equal deleted inserted replaced
0:e4de0a0e90c8 1:d724f34e671d
1 package CPT::Writer::Fasta;
2 use Moose;
3 with 'CPT::Writer';
4 require Bio::SeqIO;
5
6 sub process {
7 my ($self) = @_;
8 $self->processed_data( $self->data );
9 $self->processing_complete(1);
10 return 1;
11 }
12
13 sub write {
14 my ($self) = @_;
15 if ( $self->processing_complete ) {
16 $self->OutputFilesClass->extension( $self->suffix() );
17 my $next_output_file = $self->OutputFilesClass->get_next_file();
18 open( my $filehandle, '>', $next_output_file );
19 # This is probably a good change but will need testing.
20 if ( ref( $self->processed_data ) eq 'Bio::PrimarySeqI') {
21 my $outseq = Bio::SeqIO->new(
22 -fh => $filehandle,
23 -format => 'Fasta',
24 );
25 $outseq->write_seq( $self->processed_data );
26 }
27 elsif ( ref( $self->processed_data ) eq 'ARRAY') {
28 my $outseq = Bio::SeqIO->new(
29 -fh => $filehandle,
30 -format => 'Fasta',
31 );
32 foreach my $seq (@{$self->processed_data()}){
33 $outseq->write_seq( $seq );
34 }
35 }
36 else {
37 print $filehandle $self->processed_data;
38 }
39 close($filehandle);
40 }
41 else {
42 warn "Write called but processing was not marked as complete. Not writing";
43 }
44 }
45
46 sub suffix {
47 return 'fa';
48 }
49 no Moose;
50 1;
51
52 __END__
53
54 =pod
55
56 =encoding UTF-8
57
58 =head1 NAME
59
60 CPT::Writer::Fasta
61
62 =head1 VERSION
63
64 version 1.99.4
65
66 =head1 AUTHOR
67
68 Eric Rasche <rasche.eric@yandex.ru>
69
70 =head1 COPYRIGHT AND LICENSE
71
72 This software is Copyright (c) 2014 by Eric Rasche.
73
74 This is free software, licensed under:
75
76 The GNU General Public License, Version 3, June 2007
77
78 =cut