Skip to content

Instantly share code, notes, and snippets.

@soh-i
Created July 4, 2012 17:53
Show Gist options
  • Save soh-i/3048587 to your computer and use it in GitHub Desktop.
Save soh-i/3048587 to your computer and use it in GitHub Desktop.
リン酸化部位とかUniProtのフラットファイルからとる
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
open my $fh, '<', $ARGV[0] or die;
local $/ = undef;
my $data = <$fh>;
my @flat = split( m{//\n}, $data );
my $uni = {};
for my $line (@flat) {
#Parse ID line
$line =~ m/ID\s+(.+\_YEAST)\s+Reviewed\;\s+\d+\w+/;
my $ac = $1 if defined $line;
THREONINE:
while ( $line =~ /FT\s+MOD_RES\s+(\d+)\s+\d+\s+(Phosphothreonine)/g ) {
my $pos = $1;
my $mod_res = $2;
unless ( !$pos && !$mod_res ) {
push @{ $uni->{$ac}->{THREONINE} }, $pos;
#Parse DE line
$line =~ m/DE\s+(.+)/;
$uni->{$ac}->{DE} = $1 if defined $1;
}
else {
next THREONINE;
}
}
TYROSINE:
while ( $line =~ /FT\s+MOD_RES\s+(\d+)\s+\d+\s+(Phosphotyrosine)/g ) {
my $pos = $1;
my $mod_res = $2;
unless ( !$pos && !$mod_res ) {
push @{ $uni->{$ac}->{TYROSINE} }, $pos;
}
else {
next TYROSINE;
}
}
SERINE:
while ( $line =~ /FT\s+MOD_RES\s+(\d+)\s+\d+\s+(Phosphoserine)/g ) {
my $pos = $1;
my $mod_res = $2;
unless ( !$pos && !$mod_res ) {
push @{ $uni->{$ac}->{SERINE} }, $pos;
}
else {
next SERINE;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment