File: nextProt_filter.pl

package info (click to toggle)
snpeff 5.2.f%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 701,384 kB
  • sloc: java: 62,547; perl: 2,279; sh: 1,185; python: 744; xml: 507; makefile: 50
file content (89 lines) | stat: -rwxr-xr-x 2,172 bytes parent folder | download | duplicates (2)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/perl

#-------------------------------------------------------------------------------
#
# Find variants having either:
#
#	1) EFF impact HIGH
#
#	2) EFF impact MODERATE and NEXT_PROT impact HIGH 
#
#
#																Pablo Cingolani
#-------------------------------------------------------------------------------

# Debug mode?
$debug=0;

# Effect impact coded as number
$MODERATE = 1;
$HIGH = 2;

#-------------------------------------------------------------------------------
# Funciton max
#-------------------------------------------------------------------------------
sub max($$) {
	my($a,$b) = @_;
	if( $a >= $b )	{ return $a; }
	return $b;
}

#-------------------------------------------------------------------------------
# Main
#-------------------------------------------------------------------------------

# Read STDIN
while( $l = <STDIN> ) {

	# Always show VCF headers
	if( $l =~ /^#/ ) {
		print $l;
	} else {
		# Split VCF entry
		@t = split /\t/, $l;

		# Get INFO field
		$info = $t[7];
		print "INFO: $info\n" if $debug;

		# Parse INFO field: Get EFF tag
		$eff = '';
		@infos = split /;/, $info;
		foreach $info ( @infos ) {
			if( $info =~ /^EFF=(.*)/ ) { $eff = $1; }
		}

		# Parse EFF tag
		if( $eff ne '' ) {
			@effs = split /,/, $eff;

			# Try to find : ( EFF HIGH ) or ( EFF MODERATE + one NEXT_PROT HIGH )
			$effBest = 0;
			$nextprotBest = '';
			foreach $f ( @effs ) {
				# Nextprot effect?
				if( $f =~/^NEXT_PROT/ ) {	
					if( $f =~ /\(HIGH/ ) {	# We only care about high impact nextprot effects
						print "NEXT_PROT: $f\n" if $debug;
						$nextprotBest = $f;
					}
				} else {					
					# Effect (not nextprot)
					if( $f =~ /\(HIGH/ ) { 
						$effBest = max($effBest, $HIGH); 
						print "EFF : $effBest\t$f\n" if $debug;
					} elsif( $f =~ /\(MODERATE/ ) { 
						$effBest = max($effBest, $MODERATE); 
						print "EFF : $effBest\t$f\n" if $debug;
					}
				} 
			}

			# Do we have at least one Moderate EFFect AND one High NEXT_PROT?
			if( ($effBest == $HIGH) || (($effBest == $MODERATE) && ($nextprotBest ne '')) ) {
				print "$effBest\t$nextprotBest\t" if $debug; 
				print "$l"; 
			} 
		}
	}
}