-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathgetMyContigs
More file actions
executable file
·65 lines (50 loc) · 1.75 KB
/
Copy pathgetMyContigs
File metadata and controls
executable file
·65 lines (50 loc) · 1.75 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#! /usr/bin/perl
# Copyright 2013, 2015, 2019 Regents of The University of Michigan.
# This file is part of geo-omics-scripts.
# Geo-omics-scripts is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# Geo-omics-scripts is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License along
# with Geo-omics-scripts. If not, see <https://www.gnu.org/licenses/>.
# USAGE: perl getMyContigs.pl <CoverageOutputFromReadCoverage Script> <Your Contig Shortlist file> <OUTPUT.list>
use strict;
my $readCov=$ARGV[0];
my $list=$ARGV[1];
my $OUT=$ARGV[2];
die "Incorrect number of files input\nUSAGE: perl getMyContigs.pl <CoverageOutputFromReadCoverage Script> <Your Contig Shortlist file> <OUTPUT.list>" if (scalar(@ARGV) != 3);
open(LIST, $list)|| $!;
my %LIST;
while(my $line=<LIST>){
chomp;
next unless $line;
next if $line=~ /^#/;
# NODE_14_length_2679_cov_8.406121
my @headerParts=split(/\_/, $line);
$LIST{$headerParts[1]}++;
}
close LIST;
my %READS;
open(READ, $readCov)|| $!;
while(my $line=<READ>){
next if $line=~ /^#/;
chomp $line;
next unless $line;
my ($contigName, $size, @reads)=split(/\t/, $line);
next unless $LIST{$contigName};
foreach my $r(@reads){
$READS{$r}++;
}
}
close READ;
undef %LIST;
print "Total # Reads Mapped to this bin:".keys(%READS)."\n";
open(OUT, ">".$OUT)|| die $!;
foreach my $r(keys %READS){
print OUT $r."\n";
}
close OUT;