Created
April 18, 2018 15:35
-
-
Save iimog/0424de0b4efbfe73ef2e9092f8969c06 to your computer and use it in GitHub Desktop.
Perl script to combine multiple columns from the protraits table to a single categorical traitType for FENNEC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# USAGE: perl extract_traits.pl <ProTraits_binaryIntegrated_File> <columns ...> | |
# EXAMPLE: perl extract_traits.pl ProTraits_binaryIntegratedPr0.90.txt 275 276 277 292 >oxygenreq.tsv | |
use strict; | |
use warnings; | |
my $file = shift(@ARGV); | |
my @columns = @ARGV; | |
open IN, "<$file" or die "$!"; | |
my $header = <IN>; | |
chomp $header; | |
my @header = split(/\t/, $header); | |
while(<IN>){ | |
chomp; | |
my @row = split(/\t/, $_); | |
foreach my $col (@columns){ | |
print "$row[1]\t$header[$col-1]\t\t\t\n" if($row[$col-1] eq "1"); | |
} | |
} | |
close IN or die "$!"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment