Core iTOps Tube

Wednesday, 9 May 2012

filtering files

Hi guys, I need your help.

I have a big file with names and numbers in columns like this:


Code:


        Albumin1A713G  1  1  3  3  1  3  1  3  1     

Albumin1TC1894  1  1  1  1  1  1  1  1  1

      Albumin5G186T  1  1  1  1  1  1  1  1  1

      AY388580_a  0  0  1  2  1  2  1  2  1

      AY388582_a  3  3  1  3  1  3  1  3  1     

AY388585_a  1  1  1  3  1  3  1  1  1     

AY388587_a  1  1  1  1  1  1  1  3  1     

AY388588_a  1  3  1  1  1  1  1  1  1

      AY388589_a  1  1  1  1  1  1  1  1  1     

AY388591_a  1  1  1  2  1  2  2  2  1


there are 5000 of this markers with correspond to an specific chromosome. So I want to separate this markers into the specific chromosome including the values.



So far I've been using this




Code:


#!/usr/bin/perl



use strict;



open(D,$ARGV[0]) || die "Unfiltered\: $!\n";

open(E,$ARGV[1]) || die "Names\: $!\n";



my %names=();



while(<D>)

{

        chomp($_);

        my ($name, $val) = $_=~/^(\S+)\s+(\S+)/;

    $names{$name} = $val;

}

close(D);



while(<E>)

{

    chomp($_);

    $_=~s/^\s+//;

    $_=~s/\s+$//;



    print $_,"\t",$names{$_},"\n";

}

close(E);




This way separates the names but only the first value in the spreadsheet (and now I need all of them).. and I have to do it one by one, having the a file for the markers on each chromosome like this: perl filter-name-new.pl genotypes.txt c01.txt > c01filtered.txt



In summary I'd appreciate if you can help me find an easier way to separate this values.

Thanks







Moderator's Comments:









Code tags for code, please.





No comments:

Post a Comment