Skip to content

Commit

Permalink
script adds random weights to a .maf; used in demo weight example
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamDS committed Sep 30, 2017
1 parent ac6e330 commit a65f29a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions scripts/addRandomWeight.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/perl
#25 September 2017 - Adam D Scott -

use strict;
use warnings;

use IO::File;
use FileHandle;

my $usage = 'perl addRandomWeight.pl <maf> <output>
';

die $usage , unless @ARGV == 2;
my ( $maf , $output ) = @ARGV;

my $IN1 = FileHandle->new( $maf , "r" );
if ( not defined $IN1 ) { die "ADSERROR: Could not open/read ".$maf."\n"; }

my $IN2 = FileHandle->new( $output , "w" );
if ( not defined $IN2 ) { die "ADSERROR: Could not open/write ".$output."\n"; }

while ( my $line = <$IN1> ) {
chomp( $line );
$IN2->print( $line."\t" );
if ( $line =~ /Hugo/ ) {
$IN2->print( "RandomWeight" );
} else {
my $r = int( rand( 40 ) );
$r -= 20;
$IN2->print( $r )
}
$IN2->print( "\n" );
}
$IN1->close();
$IN2->close();

0 comments on commit a65f29a

Please sign in to comment.