File Coverage

lib/App/SimulateReads/Fastq/PairedEnd.pm
Criterion Covered Total %
statement 20 20 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 27 29 93.1


line stmt bran cond sub pod time code
1             package App::SimulateReads::Fastq::PairedEnd;
2             # ABSTRACT: App::SimulateReads::Fastq subclass for simulate paired-end fastq entries.
3              
4 6     6   4490 use App::SimulateReads::Base 'class';
  6         12  
  6         52  
5 6     6   2216 use App::SimulateReads::Read::PairedEnd;
  6         2215  
  6         2038  
6              
7             extends 'App::SimulateReads::Fastq';
8              
9             our $VERSION = '0.06'; # VERSION
10              
11             has 'fragment_mean' => (
12             is => 'rw',
13             isa => 'My:IntGt0',
14             required => 1
15             );
16              
17             has 'fragment_stdd' => (
18             is => 'rw',
19             isa => 'My:IntGe0',
20             required => 1
21             );
22              
23             has 'sequencing_error' => (
24             is => 'ro',
25             isa => 'My:NumHS',
26             required => 1
27             );
28              
29             has '_read' => (
30             is => 'ro',
31             isa => 'App::SimulateReads::Read::PairedEnd',
32             builder => '_build_read',
33             lazy_build => 1,
34             handles => [qw{ gen_read }]
35             );
36              
37             sub BUILD {
38 25     25 0 65 my $self = shift;
39             ## Just to ensure that the lazy attributes are built before &new returns
40 25         650 $self->_read;
41             }
42              
43             sub _build_read {
44 25     25   45 my $self = shift;
45 25         735 App::SimulateReads::Read::PairedEnd->new(
46             sequencing_error => $self->sequencing_error,
47             read_size => $self->read_size,
48             fragment_mean => $self->fragment_mean,
49             fragment_stdd => $self->fragment_stdd
50             );
51             }
52              
53             sub sprint_fastq {
54 580     580 0 10871 my ($self, $id, $seq_name, $seq_ref, $seq_size, $is_leader) = @_;
55              
56 580         1736 my ($read1_ref, $read2_ref, $fragment_pos, $fragment_size) = $self->gen_read($seq_ref, $seq_size, $is_leader);
57              
58 580         15179 my ($seq_pos1, $seq_pos2) = (
59             "$seq_name:" . ($fragment_pos + 1) . "-" . ($fragment_pos + $self->read_size),
60             "$seq_name:" . ($fragment_pos + $fragment_size) . "-" . ($fragment_pos + $fragment_size - $self->read_size + 1)
61             );
62              
63 580 100       1236 unless ($is_leader) {
64 300         676 ($seq_pos1, $seq_pos2) = ($seq_pos2, $seq_pos1);
65             }
66              
67 580         13893 my $header1 = "$id simulation_read length=" . $self->read_size . " position=$seq_pos1";
68 580         13630 my $header2 = "$id simulation_read length=" . $self->read_size . " position=$seq_pos2";
69              
70 580         1766 my $fastq1_ref = $self->fastq_template(\$header1, $read1_ref);
71 580         1344 my $fastq2_ref = $self->fastq_template(\$header2, $read2_ref);
72              
73 580         2569 return ($fastq1_ref, $fastq2_ref);
74             }
75              
76             __END__
77              
78             =pod
79              
80             =encoding UTF-8
81              
82             =head1 NAME
83              
84             App::SimulateReads::Fastq::PairedEnd - App::SimulateReads::Fastq subclass for simulate paired-end fastq entries.
85              
86             =head1 VERSION
87              
88             version 0.06
89              
90             =head1 AUTHOR
91              
92             Thiago L. A. Miller <tmiller@mochsl.org.br>
93              
94             =head1 COPYRIGHT AND LICENSE
95              
96             This software is Copyright (c) 2017 by Teaching and Research Institute from Sírio-Libanês Hospital.
97              
98             This is free software, licensed under:
99              
100             The GNU General Public License, Version 3, June 2007
101              
102             =cut