annotate catchsequence/catchsequence.pl @ 0:37d48392bf22 draft default tip

Uploaded
author dcouvin
date Tue, 21 Sep 2021 16:44:26 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
1 #!/usr/bin/perl
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
2
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
3 use strict;
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
4 use warnings;
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
5
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
6 #INPUTS_
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
7 # my $Result_RES = $ARGV[0];
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
8 my $sequences = $ARGV[0];
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
9
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
10 #OUTPUT_
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
11 #my $output = $ARGV[1];
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
12
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
13 my @list_seq = split(/,/,$sequences);
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
14 #my @list_seq = @ARGV;
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
15
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
16 my $res = 90.00;
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
17 my $plas = 90.00;
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
18 my $vf = 80.00;
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
19
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
20 my $percentage = "ident"; # other possibility is "cov"
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
21 my $columPerc = 10; # other possibility is 9
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
22
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
23
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
24
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
25 #Other parameters
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
26 for (my $i = 0; $i <= $#ARGV; $i++) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
27 if ($ARGV[$i]=~/-percent/i or $ARGV[$i]=~/-perc/i) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
28 $percentage = $ARGV[$i+1];
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
29 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
30 elsif ($ARGV[$i]=~/-res/i) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
31 $res = $ARGV[$i+1];
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
32 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
33 elsif ($ARGV[$i]=~/-plas/i) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
34 $plas = $ARGV[$i+1];
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
35 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
36 elsif ($ARGV[$i]=~/-vf/i) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
37 $vf = $ARGV[$i+1];
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
38 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
39 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
40
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
41 ##########################################################################################
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
42
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
43 if ($percentage eq "ident"){
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
44 $columPerc = 10;
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
45 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
46 elsif ($percentage eq "cov"){
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
47 $columPerc = 9;
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
48 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
49
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
50
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
51 #open (OUT, ">$output");
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
52 print "Sequence\tResistance genes\tPlasmids\tVirulence genes\tST (MLST)\tAlleles (MLST)\n";
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
53
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
54 foreach my $sequence (@list_seq) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
55 my $Result_RES = `abricate --db resfinder $sequence > $sequence.RES.txt`; #appel système de la commande abricate avec la BDD ResFinder
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
56 my $Result_PLA = `abricate --db plasmidfinder $sequence > $sequence.PLA.txt`; #appel système de la commande abricate avec la BDD PlasmidFinder
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
57 my $Result_VIR = `abricate --db vfdb $sequence > $sequence.VIR.txt`;
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
58 my $Result_MLST = `mlst $sequence > $sequence.MLST.txt`;
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
59
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
60 open (RES, "$sequence.RES.txt");
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
61 print "$sequence\t";
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
62
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
63 while (<RES>) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
64
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
65 chomp();
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
66 if ($_ !~ m/^#/) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
67 my @infos = split(/\t/,$_);
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
68 my $geneRes = $infos[5]; # resistance gene name (ancienne valeur $infos[4])
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
69 my $identity = $infos[$columPerc]; # identity % (ancienne valeur $infos[9])
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
70
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
71 if ($identity > $res) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
72 print "$geneRes;";
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
73 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
74 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
75
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
76 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
77
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
78 close (RES);
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
79 print "\t";
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
80
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
81
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
82 open (PLA, "$sequence.PLA.txt") or die "could not open $!";
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
83
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
84 while (<PLA>) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
85 chomp();
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
86 if ($_ !~ m/^#/) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
87 my @infos = split(/\t/,$_);
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
88 my $plasmid = $infos[5]; # plasmid name
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
89 my $identity = $infos[$columPerc]; # identity %
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
90
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
91 if ($identity > $plas) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
92 print"$plasmid;";
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
93 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
94 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
95
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
96 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
97 close (PLA);
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
98 print "\t";
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
99
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
100 open (VIR, "$sequence.VIR.txt") or die "could not open $!";
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
101
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
102 while (<VIR>) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
103 chomp();
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
104
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
105 if ($_ !~ m/^#/) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
106 my @infos = split(/\t/,$_);
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
107 my $geneVir = $infos[5]; # virulence gene name
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
108 my $identity = $infos[$columPerc]; # identity %
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
109
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
110 if ($identity > $vf) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
111 print "$geneVir;";
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
112 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
113 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
114
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
115 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
116 close (VIR);
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
117 print "\t";
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
118
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
119
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
120 open (MLST, "$sequence.MLST.txt") or die "could not open $!";
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
121
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
122 while (<MLST>) {
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
123 chomp();
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
124
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
125 my @infos = split(/\t/,$_);
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
126 my $numMLST = $infos[2];
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
127 print "$numMLST\t";
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
128
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
129 for (my $i=3; $i <= $#infos; $i++){
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
130 print "$infos[$i];";
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
131 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
132
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
133 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
134 close (MLST);
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
135 print "\n";
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
136 }
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
137
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
138 #close (OUT);
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
139
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
140 unlink glob ('*.VIR.txt');
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
141 unlink glob ('*.PLA.txt');
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
142 unlink glob ('*.RES.txt');
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
143 unlink glob ('*.MLST.txt');
37d48392bf22 Uploaded
dcouvin
parents:
diff changeset
144