TempAcolyte has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w # Open Tab-delimited file, extract and display HOX gene info #FILE HANDLING open INPUT,"<MOUSE_TF1.txt"; open OUTPUT,">HOX_GENE_TF.txt"; # # MAIN print OUTPUT "MOUSE TRANSCRIPTION FACTORS IN THE HOX GENE FAMILY\n\n\n +"; print OUTPUT "ENSEMBL GENE ID \tSYMBOL \tCHR\tSTART\t\tEND\t\tSTRAND\n +"; while (<INPUT>){ $line = $_; chop($line); # split line by tab character @Gene_Info = split("\t",$line); # Defines fields as scalars $Ensembl_Gene_ID = $Gene_Info[0]; $Chromosome_Name = $Gene_Info[1]; $Gene_Start = $Gene_Info[2]; $Gene_End = $Gene_Info[3]; $Chr_Strand = $Gene_Info[4]; $Gene_Symbol = $Gene_Info[5]; # Create hashes to store table values and associate with key $chrs{$Ensembl_Gene_ID} = $Chromosome_Name; $starts{$Ensembl_Gene_ID} = $Gene_Start; $ends{$Ensembl_Gene_ID} = $Gene_End; $symbols{$Ensembl_Gene_ID} = $Gene_Symbol; $strands{$Ensembl_Gene_ID} = $Chr_Strand; } close INPUT; # select Gene Symbols belonging to "Hox" family and print foreach $key (keys %symbols) { if ($Gene_Symbol =~ /Hox/) { print OUTPUT $key,"\t"; print OUTPUT $symbols{$key},"\t"; print OUTPUT $chrs{$key},"\t"; print OUTPUT $starts{$key},"\t"; print OUTPUT $ends{$key},"\t"; print OUTPUT $strands{$key},"\n"; } } close INPUT; close OUTPUT; #end
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: If Statements and Regular Expressions
by Animator (Hermit) on Sep 30, 2008 at 22:42 UTC | |
|
Re: If Statements and Regular Expressions
by GrandFather (Saint) on Sep 30, 2008 at 23:16 UTC | |
by JavaFan (Canon) on Oct 01, 2008 at 00:12 UTC | |
by GrandFather (Saint) on Oct 01, 2008 at 00:27 UTC | |
by JavaFan (Canon) on Oct 01, 2008 at 00:56 UTC | |
|
Re: If Statements and Regular Expressions
by pjotrik (Friar) on Sep 30, 2008 at 22:50 UTC | |
|
Re: If Statements and Regular Expressions
by toolic (Bishop) on Sep 30, 2008 at 23:33 UTC | |
|
Re: If Statements and Regular Expressions
by JadeNB (Chaplain) on Sep 30, 2008 at 23:12 UTC | |
|
Re: If Statements and Regular Expressions
by TempAcolyte (Initiate) on Oct 01, 2008 at 01:59 UTC | |
|
Re: If Statements and Regular Expressions
by JavaFan (Canon) on Sep 30, 2008 at 23:48 UTC |