Skip to content

Instantly share code, notes, and snippets.

Created April 18, 2018 15:35
What would you like to do?
Perl script to combine multiple columns from the protraits table to a single categorical traitType for FENNEC
# USAGE: perl <ProTraits_binaryIntegrated_File> <columns ...>
# EXAMPLE: perl 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);
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