| 1 |
#!/usr/local/bin/perl |
| 2 |
# $Id: fmap2_4,v 1.5 1995/09/04 21:49:01 rd Exp $ |
| 3 |
# |
| 4 |
# Richard Durbin 950312 |
| 5 |
# |
| 6 |
# Script to convert Sanger ace files containing Sequence/DNA |
| 7 |
# objects to ACEDB4 models. |
| 8 |
# May assume sometimes layout of .ace file dumped from acedb. |
| 9 |
|
| 10 |
%month2fig = ( |
| 11 |
"JAN", "01", |
| 12 |
"FEB", "02", |
| 13 |
"MAR", "03", |
| 14 |
"APR", "04", |
| 15 |
"MAY", "05", |
| 16 |
"JUN", "06", |
| 17 |
"JUL", "07", |
| 18 |
"AUG", "08", |
| 19 |
"SEP", "09", |
| 20 |
"OCT", "10", |
| 21 |
"NOV", "11", |
| 22 |
"DEC", "12" ) ; |
| 23 |
|
| 24 |
while (<>) { |
| 25 |
reparse: |
| 26 |
if (/JZJ/) { # catch St Louis Text bug in B0303.8 |
| 27 |
warn "JZJ bad line $.\n" ; |
| 28 |
next ; |
| 29 |
} |
| 30 |
|
| 31 |
undef $isD ; |
| 32 |
s/^-D // && ($isD = 1) ; |
| 33 |
# non-DNA Sequences change class |
| 34 |
if ( /^Sequence/ ) { |
| 35 |
s/Sequence :/Sequence/ ; s/\"//g ; |
| 36 |
/Sequence\s+(\S+)/ ; |
| 37 |
if ($1 =~ /^WP:/ || |
| 38 |
$1 =~ /^SP:/ || |
| 39 |
$1 =~ /^SW:/ || |
| 40 |
$1 =~ /^PIR:/) { |
| 41 |
s/^Sequence/Protein/ ; |
| 42 |
} |
| 43 |
elsif ($1 =~ /^PS:/ || |
| 44 |
$1 =~ /^REP-/) { |
| 45 |
s/^Sequence/Motif/ ; |
| 46 |
} |
| 47 |
} |
| 48 |
# split Homols by sequence class and type |
| 49 |
if ( /^Homol/ ) { |
| 50 |
s/\"//g ; /Homol\s+(\S+)/ ; |
| 51 |
if ($1 =~ /^WP:/ || |
| 52 |
$1 =~ /^SP:/ || |
| 53 |
$1 =~ /^SW:/ || |
| 54 |
$1 =~ /^PIR:/) { |
| 55 |
s/^Homol/Pep_homol/ ; |
| 56 |
s/BlastX/BLASTX/ ; |
| 57 |
} |
| 58 |
elsif ($1 =~ /^PS:/ || |
| 59 |
$1 =~ /^REP-/) { |
| 60 |
s/^Homol/Motif_homol/ ; |
| 61 |
s/Prosite/PSsearch/ ; |
| 62 |
} |
| 63 |
else { |
| 64 |
if ($1 =~ /^yk/ || $1 =~ /^cm/ || $1 =~ /^CE/) { |
| 65 |
s/BlastN/BLASTN_EST_elegans/ ; |
| 66 |
} |
| 67 |
else { |
| 68 |
s/BlastN/BLASTN/ ; |
| 69 |
} |
| 70 |
s/^Homol/DNA_homol/ ; |
| 71 |
s/TBlastX/TBLASTX_EST/ ; |
| 72 |
s/BlastX/BLASTX/ ; |
| 73 |
} |
| 74 |
} |
| 75 |
# Dates must conform to DateType |
| 76 |
if ((/^Date\s/ || /^Received/ || /^Library_construction/ || |
| 77 |
/^Shotgun/ || /^Shotgun_complete/ || /^Contiguous/ || |
| 78 |
/^Finished/ || /^Submitted/ || /^Archived/) && |
| 79 |
(($tag, $date, $rest) = /(\S+)\s+(\S+)\s+(.*)/) && |
| 80 |
$date !~ /\d\d-\d\d-\d\d/) { |
| 81 |
$date =~ tr/a-z/A-Z/ ; |
| 82 |
$isQuote = 0 ; |
| 83 |
($date =~ s/^\"//) && ($isQuote = 1) ; |
| 84 |
if ((($day, $month, $year) = |
| 85 |
$date =~ /(\d\d)-([A-Z][A-Z][A-Z])-(\d\d\d\d)/) && |
| 86 |
$year > 1970 && ($month = $month2fig{$month})) { |
| 87 |
$year -= 1900 ; |
| 88 |
$date = $year . $month . $day ; |
| 89 |
} |
| 90 |
if ($date !~ /(\d\d)(\d\d)(\d\d)/) { |
| 91 |
warn "bad Date $_ line $. translates to $date\n" ; |
| 92 |
next ; |
| 93 |
} |
| 94 |
$_ = "$tag $1-$2-$3" ; |
| 95 |
if ($rest) { |
| 96 |
$_ .= " " ; |
| 97 |
if ($isQuote) { $_ .= "\"" ; } |
| 98 |
$_ .= $rest ; |
| 99 |
} |
| 100 |
$_ .= "\n" ; |
| 101 |
} |
| 102 |
# delete Length |
| 103 |
/^Length/ && next ; |
| 104 |
# TSL -> Feature |
| 105 |
if ( /^TSL/ ) { |
| 106 |
s/TSL/Feature TSL/ ; |
| 107 |
s/"SL/0 "SL/ ; # need dummy score |
| 108 |
} |
| 109 |
# Inverted repeat -> Features |
| 110 |
# specific to Sanger script-generated data |
| 111 |
if ( /^Repeats\s+Inverted/ ) { |
| 112 |
($s1, $s2, $perc) = /(\d+) (\d+) Percent_Identity (\d+)/ ; |
| 113 |
($_ = <>) || die "End of file line $. during a repeat\n" ; |
| 114 |
s/\"//g ; ($score) = /Score \+3-4-12 (\d+)/ ; |
| 115 |
($_ = <>) || die "End of file line $. during a repeat\n" ; |
| 116 |
($ngaps) = /N_gaps (\d+)/ ; |
| 117 |
($_ = <>) || die "End of file line $. during a repeat\n" ; |
| 118 |
($loop) = /Loop (\d+)/ ; |
| 119 |
($_ = <>) || die "End of file line $. during a repeat\n" ; |
| 120 |
($unit) = /$s1 $s2 Unit_Length (\d+)/ ; |
| 121 |
if (!defined($s1) || !defined($s2) || |
| 122 |
!defined($perc) || !defined($score) || !defined($ngaps) || |
| 123 |
!defined(!loop) || !defined($unit)) { |
| 124 |
# warn "s1,s2,perc,score,unit are $s1,$s2,$perc,$score,$unit\n" ; |
| 125 |
warn "Non-standard Inverted repeat around line $.\n" ; |
| 126 |
next ; |
| 127 |
} |
| 128 |
$text = "loop $loop" ; |
| 129 |
if ($ngaps == 1) { $text .= ", 1 gap" ; } |
| 130 |
if ($ngaps > 1) { $text .= ", $ngaps gaps" ; } |
| 131 |
$x = $s1 + $unit - 1 ; |
| 132 |
print "-D " if $isD ; |
| 133 |
print "Feature inverted $s1 $x $perc \"$text\"\n" ; |
| 134 |
$x += $loop + 1 ; |
| 135 |
print "-D " if $isD ; |
| 136 |
print "Feature inverted $s2 $x $perc \"$text\"\n" ; |
| 137 |
next ; |
| 138 |
} |
| 139 |
# Tandem repeat -> Feature |
| 140 |
# specific to Sanger script-generated data |
| 141 |
if ( /^Repeats\s+Tandem/ ) { |
| 142 |
($s1, $s2, $perc) = /(\d+) (\d+) Percent_Identity (\d+)/ ; |
| 143 |
($_ = <>) || die "End of file line $. during a repeat\n" ; |
| 144 |
s/\"//g ; ($score) = /Score \+1-1 (\d+)/ ; |
| 145 |
if (!defined($s1) || !defined($s2) || |
| 146 |
!defined($perc) || !defined($score)) { |
| 147 |
warn "Non-standard Tandem repeat around line $.\n" ; |
| 148 |
next ; |
| 149 |
} |
| 150 |
($_ = <>) || die "End of file line $. during a repeat\n" ; |
| 151 |
($unit) = /$s1 $s2 Unit_Length (\d+)/ ; |
| 152 |
if (defined($unit)) { |
| 153 |
$text = sprintf ("%d copies %dmer", ($s2-$s1+1)/$unit, $unit) ; |
| 154 |
print "-D " if $isD ; |
| 155 |
print "Feature tandem $s1 $s2 $perc \"$text\"\n" ; |
| 156 |
next ; |
| 157 |
} |
| 158 |
else { |
| 159 |
print "-D " if $isD ; |
| 160 |
print "Feature tandem $s1 $s2 $perc\n" ; |
| 161 |
goto reparse ; |
| 162 |
} |
| 163 |
} |
| 164 |
# Library -> Database |
| 165 |
s/^Library/Database/ ; |
| 166 |
s/^From_Library/From_Database/ ; |
| 167 |
# delete Repeat_consensus |
| 168 |
/^Repeat_consensus/ && next ; |
| 169 |
# delete General |
| 170 |
/^General/ && next ; |
| 171 |
# Genomic_canonical - delete number |
| 172 |
/^Genomic_Canonical/ && ($_ = "Genomic_Canonical\n") ; |
| 173 |
# Related_Sequence -> Related_DNA |
| 174 |
s/^Related_Sequence/Related_DNA/ ; |
| 175 |
# fix endcoding screwup |
| 176 |
s/endcoding/encoding/ ; |
| 177 |
# peptide -> protein |
| 178 |
s/^Corresponding_peptide/Corresponding_protein/ ; |
| 179 |
# Possible_exon -> a feature |
| 180 |
/^Possible_exon\s+(\d+)\s+(\d+)/ && |
| 181 |
($_ = "Feature Possible_exon $1 $2\n") ; |
| 182 |
|
| 183 |
print "-D " if $isD ; |
| 184 |
print ; |
| 185 |
if (eof) { last ; } |
| 186 |
} |
| 187 |
|
| 188 |
############ end of file ############ |
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|