in reply to Find codon usage in domain based on domain's position from a file
open my $IN, '<', 'domain.txt' or die $!; while (<$IN>) { my ($id, $from, $to) = split /[;\s]+/; print "$id; $from $to\n"; for my $pos (0 .. length($hash1{$id})) { print join ' ', $pos, substr($hash1{$id}, $pos, 1), substr($hash2{$id}, $pos * 3, 3), $from <= $pos && $pos <= $to ? 'YES' : 'NOT', "\n"; } }
Update: The output is now almost the same as yours. The problem was caused by wrong formatting of the post - please use code tags for data, too.
Update 2: This is how I populated the hashes. Again, no BioPerl.
#!/usr/bin/perl use warnings; use strict; sub load_fasta { my ($file) = @_; open my $IN, '<', $file or die $!; my ($seq, $id, %hash) = q(); my $store = sub { $hash{$id} = $seq if $id; ($id) = shift =~ /\|(.*)/; $seq = q(); }; while (<$IN>) { chomp; if (/^>/) { $store->($_); } else { $seq .= $_; } } $store->(q()); return %hash } my %hash1 = load_fasta('acids.txt'); my %hash2 = load_fasta('nucleotides.txt');
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Find codon usage in domain based on domain's position from a file
by 345qwerty (Novice) on Aug 17, 2017 at 09:49 UTC |