-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangeInsertionCode.pl
More file actions
executable file
·109 lines (90 loc) · 2.93 KB
/
changeInsertionCode.pl
File metadata and controls
executable file
·109 lines (90 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/perl -w
# Author: Abdullah Kahraman
# Date: 28.01.2013
use strict;
use warnings;
use Getopt::Long;
##############################################################################
### Changes the insertion code of a PDB file ###
##############################################################################
my(
$ain,
$aout,
$help,
);
&GetOptions(
"help!" => \$help, # print this help
"i:s" => \$ain, # insertion code to be changed. If not defined, all insertion codes will be changed.
"o=s" => \$aout, # into insertion code
) or die "\nTry \"$0 -h\" for a complete list of options\n\n";
# help
if ($help) {printHelp(); exit}
##############################################################################
##############################################################################
### SUBROUTINES
##############################################################################
##############################################################################
###############################################################################
sub printHelp {
###############################################################################
# prints a help about the using and parameters of this scripts
# (execute if user types commandline parameter -h)
# param: no paramaters
# return: no return value
my (
$usage,
$sourceCode,
@rows,
$row,
$option,
$scriptInfo,
$example,
);
$usage = "cat xxx.pdb | $0 -o B\n";
print "\nUsage: " . $usage . "\n";
print "Valid options are:\n\n";
open(MYSELF, "$0") or
die "Cannot read source code file $0: $!\n";
$sourceCode .= join "", <MYSELF>;
close MYSELF;
$sourceCode =~ s/^.+?\&GetOptions\(\n//s;
$sourceCode =~ s/\n\).+$//s;
@rows = split /\n/, $sourceCode;
foreach $row (@rows){
$option = $row;
$option =~ s/\s+\"//g;
$option =~ s/\"\s.+\#/\t\#/g;
$option =~ s/=./\t<value> [required]/;
$option =~ s/:./\t<value> [optional]/;
$option =~ s/!/\t<non value> [optional]/;
$row =~ s/^.*//;
print "\t";
printf("%-1s%-30s%-30s\n", "-",$option,$row);
} # end of foreach $row (@rows)
print "\n";
print "Options may be abreviated, e.g. -h for --help\n\n";
$example = "$0";
}
##############################################################################
##############################################################################
### MAIN
##############################################################################
##############################################################################
if(!defined $aout){
die "Please specify \"-o\" or use -help.\n";
}
$ain = " " if(defined $ain and $ain eq "_");
$aout = " " if($aout eq "_");
while(<>){
if(/^ATOM/ or /^HETATM/){
my $altLoc = substr($_, 26, 1);
if(defined $ain){
if($altLoc eq $ain){
substr($_, 26, 1, $aout);
}
} else {
substr($_, 26, 1, $aout);
}
}
print $_;
}