-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_contig_lengths.pl
50 lines (33 loc) · 1.02 KB
/
get_contig_lengths.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/perl -w
use strict;
#contig_length_fasta.pl
my $largest = 0;
my $contig = '';
if (@ARGV != 1) {
print "contig_length_fastq fasta\n\n" ;
exit ;
}
my $filenameA = $ARGV[0];
open (IN, "$filenameA") or die "oops!\n" ;
my $read_name = '' ;
my $read_seq = '' ;
print "##gff-version 3\n" ;
while (<IN>) {
if (/^>(\S+)/) {
$read_name = $1 ;
$read_seq = "" ;
while (<IN>) {
if (/^>(\S+)/) {
print "##sequence-region " . "$read_name " . "1 " . length($read_seq) . "\n" ;
$read_name = $1 ;
$read_seq = "" ;
}
else {
chomp ;
$read_seq .= $_ ;
}
}
}
}
close(IN) ;
print "##sequence-region " . "$read_name " . "1 " . length($read_seq) . "\n" ;