File: vcfInfoOnePerLine.pl

package info (click to toggle)
snpeff 5.4.b%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 757,496 kB
  • sloc: java: 62,572; perl: 2,279; sh: 1,185; python: 744; xml: 507; makefile: 50
file content (30 lines) | stat: -rwxr-xr-x 621 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl

# Split VCF into several lines
# Show one info field per line
#

while( $l = <STDIN> ) {
	chomp $l;
	if( $l !~ /^#/ ) {
		($chrom, $pos, $id, $ref, $alt, $qual, $filter, $info) = split /\t/, $l;
		print "$chrom\t$pos\t$id\t$ref\t$alt\t$qual\t$filter\n";

		foreach $in ( split /;/, $info ) {
			if( $in =~ /^(.*?)=(.*)/ ) {
				$key = $1;
				$values = $2;

				@vals = split /,/, $values;

				if( $#vals > 0 ) {
					foreach $val ( @vals ) { print "\t\t\t\t\t\t\t$key\t$val\n"; }
				} else {
					print "\t\t\t\t\t\t\t$key\t$values\n";
				}
			} else {
				print "\t\t\t\t\t\t\t$in\n";
			}
		}
	}
}