Sparky2mars.pl, create MARS pseudoresidue table from Sparky assignment table

From NMR Wiki

Jump to: navigation, search

Purpose

Create MARS assignment table input from sparky list of chemical shifts.

Usage

  • in sparky "assign" peaks to arbitrarily named pseudoresidues, e.g. P1, P2, etc.
  • use atom names CA CA-1 CB CB-1 CO CO-1 HN N.
  • save assignment table
  • create file sparky2mars.pl with the content shown in "code" section below.
  • run:
sparky2mars.pl <   sparky.shifts   >  mars_shifts.inp

Code

#!/usr/bin/perl
 
use strict;
 
my @lines = <>;
 
shift  @lines;
shift  @lines;
 
my %at;
foreach my $l (@lines) {
    chomp $l;
    my @bits = split ' ', $l;
    my $resname = $bits[0];
    my $atom = $bits[1];
    my $shift = $bits[3];
    my $count = $bits[5];
    next if $count == 0;
    $at{$resname}{$atom} = $shift;
}
 
my @atom_list = qw (CA    CA-1      CB    CB-1      CO    CO-1       HN       N);
 
print "\t", join("\t",@atom_list), "\n";
 
for my $resname (keys %at) {
    my $rec = $at{$resname};
    print $resname, "\t";
 
    for my $catom (@atom_list) {
        if (exists $rec->{$catom}) {
            print $rec->{$catom};
        }
        else {
            print '-';
        }
        print "\t";
    }
    print "\n";
 
}
Personal tools