App-lapidary

 view release on metacpan or  search on metacpan

script/lapidary  view on Meta::CPAN

	    if($position_depth == 0) {
		push @position_match_array, $match;
		push @position_cover_array, $cover;
		push @position_depth_array, $depth;
		push @position_start_array, ($alignment_start + 1);
		push @position_end_array, $alignment_end;
		push @consensus_chunks, join("", @consensus_positions);
		    
		$match = 0;
		$cover = 0;
		$depth = 0;
		
		@consensus_positions=();
		
		$alignment_start = 1000000000000000000;
	    } elsif($consensus_positions[-1] eq "*") {
		push @position_match_array, $match;
		push @position_cover_array, $cover;
		push @position_depth_array, $depth;
		push @position_start_array, ($alignment_start + 1);
		push @position_end_array, $alignment_end;
		push @consensus_chunks, join("", @consensus_positions);
		    
		$match = 0;
		$cover = 0;
		$depth = 0;
		
		@consensus_positions=();
		
		$alignment_start = 1000000000000000000;
	    } elsif($consensus_positions[-1] eq "X") {
		push @position_match_array, $match;
		push @position_cover_array, $cover;
		push @position_depth_array, $depth;
		push @position_start_array, ($alignment_start + 1);
		push @position_end_array, $alignment_end;
		push @consensus_chunks, join("", @consensus_positions);
		    
		$match = 0;
		$cover = 0;
		$depth = 0;
		
		@consensus_positions=();
		
		$alignment_start = 1000000000000000000;
	    } else {
		$cover++;
		if($k < $alignment_start) {
		    $alignment_start = $k;
		}
	    }
	}

	push @position_match_array, $match;
	push @position_cover_array, $cover;
	push @position_depth_array, $depth;
	push @position_start_array, $alignment_start;
	push @position_end_array, ($alignment_end - 1);
	push @consensus_chunks, join("", @consensus_positions);

	#Sort position arrrays from largest to smallest fragment
	@index_sorted_size = sort { $position_cover_array[$b] <=> $position_cover_array[$a] } 0 .. $#position_cover_array;

	@position_cover_array = @position_cover_array[@index_sorted_size];
	@position_match_array = @position_match_array[@index_sorted_size];
	@position_depth_array = @position_depth_array[@index_sorted_size];
	@position_start_array = @position_start_array[@index_sorted_size];
	@position_end_array = @position_end_array[@index_sorted_size];
	@consensus_chunks = @consensus_chunks[@index_sorted_size];

	#Calcular coverage, identity and mean read depth from largest fragment
	if($position_cover_array[0] == 0) {
	    $identity_proportion = 0;
	} else {
	    $identity_proportion = $position_match_array[0] / $position_cover_array[0];
	}

	$coverage_proportion = $position_cover_array[0] / scalar(@protein_split);
	$mean_read_depth = $position_depth_array[0] / scalar(@protein_split);
	
	if($coverage_proportion > 0){
	    print OUT "$unique_proteins[$j]\t$coverage_proportion\t$identity_proportion\t$mean_read_depth\t$position_start_array[0]\t$position_end_array[0]\t$consensus_chunks[0]\n";
	}
    }
	
    close OUT;
} else {
    die "Please provide reads in fastq format\n";
}

=head1 NAME

lapidary - Determine the read coverage and identity to a protein database using diamond

=head1 DESCRIPTION

Determine the read coverage and identity of reads from fastq files to a protein database using diamond and reports the output to a file

=head1 SYNOPSIS

  $ lapidary -read_1 Examples/Reads/Paired_reads_1.fq.gz -read_2 Examples/Reads/Paired_reads_2.fq.gz -read_type paired -db Examples/Amino_acid_database.fasta
...
Total time = 5.668s
Reported 613 pairwise alignments, 613 HSPs.
613 queries aligned.

=head1 AUTHOR

Samuel Bloomfield

=head1 LICENSE

GPL_3

=head1 INSTALLATION

Using C<cpan>:

    $ cpan App::lapidary

Manual install:

    $ perl Makefile.PL
    $ make
    $ make install

=cut



( run in 3.397 seconds using v1.01-cache-2.11-cpan-b16cb0d3907 )