forked from Dfam-consortium/RepeatModeler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SeedAlignment.pm
executable file
·1278 lines (953 loc) · 30 KB
/
SeedAlignment.pm
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/local/bin/perl -w
##---------------------------------------------------------------------------##
## File:
## @(#) SeedAlignment.pm
## Author:
## Robert M. Hubley [email protected]
## Description:
## An for holding a Dfam seed alignment dataset for a single
## family.
##
#******************************************************************************
#* Copyright (C) Institute for Systems Biology 2017 Developed by
#* Robert Hubley.
#*
#* This work is licensed under the Open Source License v2.1. To view a copy
#* of this license, visit http://www.opensource.org/licenses/osl-2.1.php or
#* see the license.txt file contained in this distribution.
#*
#******************************************************************************
# Implementation Details:
#
# bless( {
# 'property' => value,
# ...
# }
# }, 'SeedAlignment' );
#
###############################################################################
# ChangeLog
#
# $Log: SeedAlignment.pm,v $
# Revision 1.2 2017/04/05 00:03:31 rhubley
# Cleanup before a distribution
#
#
###############################################################################
# To Do:
#
=head1 NAME
SeedAlignment
=head1 SYNOPSIS
use SeedAlignment
Usage:
my $familySeed = SeedAlignment->new();
=head1 DESCRIPTION
A class for storing the contents of a Dfam family seed alignment.
=head1 SEE ALSO
=over 4
SeedAlignmentCollection
=back
=head1 COPYRIGHT
Copyright 2017 Institute for Systems Biology
=head1 AUTHOR
Robert Hubley <[email protected]>
=head1 INSTANCE METHODS
=cut
package SeedAlignment;
use strict;
use Data::Dumper;
use Carp;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw();
@EXPORT_OK = qw();
%EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
my $CLASS = "SeedAlignment";
my $DEBUG = 0;
##-------------------------------------------------------------------------##
## Constructor:
##-------------------------------------------------------------------------##
sub new
{
my $class = shift;
my %nameValuePairs = @_;
my $subroutine = ( caller( 0 ) )[ 0 ] . "::" . ( caller( 0 ) )[ 3 ];
# Create ourself as a hash
my $this = {};
# Bless this hash in the name of the father, the son...
bless $this, $class;
# Allow import of values
if ( %nameValuePairs )
{
while ( my ( $name, $value ) = each( %nameValuePairs ) )
{
# RMH: Perl optimisation, the calls to _ucFirst were
# costly.
my $method = "set" . uc( substr( $name, 0, 1 ) ) . substr( $name, 1 );
# RMH: Perl optimisation, the calls to ->can are really expensive
#unless ( $this->can( $method ) ) {
# croak(
# "SeedAlignment::add: Instance variable $name doesn't exist." . "" );
#}
eval { $this->$method( $value ); };
if ( $@ )
{
croak( "$subroutine: Instance variable $name doesn't exist." . "" );
}
}
}
return $this;
}
##-------------------------------------------------------------------------##
=head2 clone()
Use: my $newObj = $obj->clone();
Clone a SeedAlignment *duplicating* all the values of the old
object in the new one.
=cut
##-------------------------------------------------------------------------##
sub clone
{
my $this = shift;
my %newHash = %{$this};
my $newObj = \%newHash;
bless $newObj, ref( $this );
return $newObj;
}
##-------------------------------------------------------------------------##
## Get and Set Methods
##-------------------------------------------------------------------------##
##-------------------------------------------------------------------------##
=head2 get_setId()
Use: my $value = getId();
Use: my $oldValue = setId( $value );
Get/Set the id.
=cut
##-------------------------------------------------------------------------##
sub getId
{
my $obj = shift;
my $value = $obj->{'id'};
return $value;
}
sub setId
{
my $obj = shift;
my $value = shift;
my $oldValue = undef;
$oldValue = $obj->{'id'};
$obj->{'id'} = $value;
return $oldValue;
}
##-------------------------------------------------------------------------##
=head2 get_setComment()
Use: my $value = getComment();
Use: my $oldValue = setComment( $value );
Get/Set the Comment.
=cut
##-------------------------------------------------------------------------##
sub getComment
{
my $obj = shift;
my $value = $obj->{'comment'};
return $value;
}
sub setComment
{
my $obj = shift;
my $value = shift;
my $oldValue = undef;
$oldValue = $obj->{'comment'};
$obj->{'comment'} = $value;
return $oldValue;
}
##-------------------------------------------------------------------------##
=head2 get_setDescription()
Use: my $value = getDescription();
Use: my $oldValue = setDescription( $value );
Get/Set the description.
=cut
##-------------------------------------------------------------------------##
sub getDescription
{
my $obj = shift;
my $value = $obj->{'description'};
return $value;
}
sub setDescription
{
my $obj = shift;
my $value = shift;
my $oldValue = undef;
$oldValue = $obj->{'description'};
$obj->{'description'} = $value;
return $oldValue;
}
##-------------------------------------------------------------------------##
=head2 get_setAlignmentMethod()
Use: my $value = getAlignmentMethod();
Use: my $oldValue = setAlignmentMethod( $value );
Get/Set the alignmentMethod.
=cut
##-------------------------------------------------------------------------##
sub getAlignmentMethod
{
my $obj = shift;
my $value = $obj->{'alignmentMethod'};
return $value;
}
sub setAlignmentMethod
{
my $obj = shift;
my $value = shift;
my $oldValue = undef;
$oldValue = $obj->{'alignmentMethod'};
$obj->{'alignmentMethod'} = $value;
return $oldValue;
}
##-------------------------------------------------------------------------##
=head2 get_setClassification()
Use: my $value = getClassification();
Use: my $oldValue = setClassification( $value );
Get/Set the classification.
=cut
##-------------------------------------------------------------------------##
sub getClassification
{
my $obj = shift;
my $value = $obj->{'classification'};
return $value;
}
sub setClassification
{
my $obj = shift;
my $value = shift;
my $oldValue = undef;
$oldValue = $obj->{'classification'};
$obj->{'classification'} = $value;
return $oldValue;
}
##-------------------------------------------------------------------------##
=head2 get_setSeqCount()
Use: my $value = getSeqCount();
Use: my $oldValue = setSeqCount( $value );
Get/Set the seqCount.
=cut
##-------------------------------------------------------------------------##
sub getSeqCount
{
my $obj = shift;
my $value = $obj->{'seqCount'};
return $value;
}
sub setSeqCount
{
my $obj = shift;
my $value = shift;
my $oldValue = undef;
$oldValue = $obj->{'seqCount'};
$obj->{'seqCount'} = $value;
return $oldValue;
}
##-------------------------------------------------------------------------##
=head2 get_setRfLine()
Use: my $value = getRfLine();
Use: my $oldValue = setRfLine( $value );
Get/Set the rfLine.
=cut
##-------------------------------------------------------------------------##
sub getRfLine
{
my $obj = shift;
my $value = $obj->{'rfLine'};
return $value;
}
sub setRfLine
{
my $obj = shift;
my $value = shift;
my $oldValue = undef;
$oldValue = $obj->{'rfLine'};
$obj->{'rfLine'} = $value;
return $oldValue;
}
##-------------------------------------------------------------------------##
=head2 setCitation()
Use: my ( $oldPmid, $oldTitle, $oldAuthor, $oldJournal ) =
setCitation( $index, $pmid, $title, $author, $journal );
Set the citation at a given position in the list.
=cut
##-------------------------------------------------------------------------##
sub setCitation
{
my $this = shift;
my $index = shift;
my $pmid = shift;
my $title = shift;
my $author = shift;
my $journal = shift;
my $subroutine = ( caller( 0 ) )[ 0 ] . "::" . ( caller( 0 ) )[ 3 ];
croak "$subroutine: index $index is out of bounds."
if ( $index < 0 || $index > $#{ $this->{'citations'} } );
my ( $oldPmid, $oldTitle, $oldAuthor, $oldJournal ) =
$this->getCitation( $index );
$this->{'citations'}->[ $index ]->{'pmid'} = $pmid;
$this->{'citations'}->[ $index ]->{'title'} = $title;
$this->{'citations'}->[ $index ]->{'author'} = $author;
$this->{'citations'}->[ $index ]->{'journal'} = $journal;
return ( $oldPmid, $oldTitle, $oldAuthor, $oldJournal );
}
##-------------------------------------------------------------------------##
=head2 getCitation()
Use: my ( $pmid, $title, $author, $journal ) = getCitation( $index );
Get the citation at a given position in the list.
=cut
##-------------------------------------------------------------------------##
sub getCitation
{
my $this = shift;
my $index = shift;
my $subroutine = ( caller( 0 ) )[ 0 ] . "::" . ( caller( 0 ) )[ 3 ];
croak "$subroutine: index $index is out of bounds."
if ( $index < 0 || $index > $#{ $this->{'citations'} } );
return (
$this->{'citations'}->[ $index ]->{'pmid'},
$this->{'citations'}->[ $index ]->{'title'},
$this->{'citations'}->[ $index ]->{'author'},
$this->{'citations'}->[ $index ]->{'journal'}
);
}
##-------------------------------------------------------------------------##
=head2 citationCount()
Use: my $count = citationCount();
Return a count of the citation list.
=cut
##-------------------------------------------------------------------------##
sub citationCount
{
my $this = shift;
return $#{ $this->{'citations'} } + 1;
}
##-------------------------------------------------------------------------##
=head2 removeCitation()
Use: removeCitation( $index );
Remove the citation at the given index.
=cut
##-------------------------------------------------------------------------##
sub removeCitation
{
my $this = shift;
my $index = shift;
my $subroutine = ( caller( 0 ) )[ 0 ] . "::" . ( caller( 0 ) )[ 3 ];
croak "$subroutine: index $index is out of bounds."
if ( $index < 0 || $index > $#{ $this->{'citations'} } );
splice( @{ $this->{'citations'} }, $index, 1 );
}
##-------------------------------------------------------------------------##
=head2 addCitation()
Use: addCitation( $pmid, $title, $author, $journal );
Add a citation to the end of the list.
=cut
##-------------------------------------------------------------------------##
sub addCitation
{
my $this = shift;
my $pmid = shift;
my $title = shift;
my $author = shift;
my $journal = shift;
push @{ $this->{'citations'} },
{
pmid => $pmid,
title => $title,
author => $author,
journal => $journal
};
}
##-------------------------------------------------------------------------##
=head2 clearCitations()
Use: clearCitations();
Remove all citations from the list.
=cut
##-------------------------------------------------------------------------##
sub clearCitations
{
my $this = shift;
$this->{'citations'} = [];
}
##-------------------------------------------------------------------------##
=head2 setAlignment()
Use: my ( $oldAssemblyName, $oldSequenceName, $oldStart,
$oldEnd, $oldOrient, $oldSequence ) =
setAlignment( $index, $assemblyName, $sequenceName,
$start, $end, $orient, $sequence );
Set the alignment at a given position in the list.
=cut
##-------------------------------------------------------------------------##
sub setAlignment
{
my $this = shift;
my $index = shift;
my $assemblyName = shift;
my $sequenceName = shift;
my $start = shift;
my $end = shift;
my $orient = shift;
my $sequence = shift;
my $subroutine = ( caller( 0 ) )[ 0 ] . "::" . ( caller( 0 ) )[ 3 ];
croak "$subroutine: index $index is out of bounds."
if ( $index < 0 || $index > $#{ $this->{'alignments'} } );
my @oldValues = $this->getAlignment( $index );
$this->{'alignments'}->[ $index ]->{'assemblyName'} = $assemblyName;
$this->{'alignments'}->[ $index ]->{'sequenceName'} = $sequenceName;
$this->{'alignments'}->[ $index ]->{'start'} = $start;
$this->{'alignments'}->[ $index ]->{'end'} = $end;
$this->{'alignments'}->[ $index ]->{'orient'} = $orient;
$this->{'alignments'}->[ $index ]->{'sequence'} = $sequence;
return ( @oldValues );
}
##-------------------------------------------------------------------------##
=head2 getAlignment()
Use: my ( $assemblyName, $sequenceName, $start, $end,
$orient, $sequence ) = getAlignment( $index );
Get the alignment at a given position in the list.
=cut
##-------------------------------------------------------------------------##
sub getAlignment
{
my $this = shift;
my $index = shift;
my $subroutine = ( caller( 0 ) )[ 0 ] . "::" . ( caller( 0 ) )[ 3 ];
croak "$subroutine: index $index is out of bounds."
if ( $index < 0 || $index > $#{ $this->{'alignments'} } );
return (
$this->{'alignments'}->[ $index ]->{'assemblyName'},
$this->{'alignments'}->[ $index ]->{'sequenceName'},
$this->{'alignments'}->[ $index ]->{'start'},
$this->{'alignments'}->[ $index ]->{'end'},
$this->{'alignments'}->[ $index ]->{'orient'},
$this->{'alignments'}->[ $index ]->{'sequence'}
);
}
##-------------------------------------------------------------------------##
=head2 alignmentCount()
Use: my $count = alignmentCount();
Return a count of the alignment list.
=cut
##-------------------------------------------------------------------------##
sub alignmentCount
{
my $this = shift;
return $#{ $this->{'alignments'} } + 1;
}
##-------------------------------------------------------------------------##
=head2 removeAlignment()
Use: removeAlignment( $index );
Remove the alignment at the given index.
=cut
##-------------------------------------------------------------------------##
sub removeAlignment
{
my $this = shift;
my $index = shift;
my $subroutine = ( caller( 0 ) )[ 0 ] . "::" . ( caller( 0 ) )[ 3 ];
croak "$subroutine: index $index is out of bounds."
if ( $index < 0 || $index > $#{ $this->{'alignments'} } );
splice( @{ $this->{'alignments'} }, $index, 1 );
}
##-------------------------------------------------------------------------##
=head2 addAlignment()
Use: addAlignment( $assemblyName, $sequenceName,
$start, $end, $orient, $sequence );
Add a alignment to the end of the list.
=cut
##-------------------------------------------------------------------------##
sub addAlignment
{
my $this = shift;
my $assemblyName = shift;
my $sequenceName = shift;
my $start = shift;
my $end = shift;
my $orient = shift;
my $sequence = shift;
push @{ $this->{'alignments'} },
{
assemblyName => $assemblyName,
sequenceName => $sequenceName,
start => $start,
end => $end,
orient => $orient,
sequence => $sequence
};
}
##-------------------------------------------------------------------------##
=head2 clearAlignments()
Use: clearAlignments();
Remove all alignments from the list.
=cut
##-------------------------------------------------------------------------##
sub clearAlignments
{
my $this = shift;
$this->{'alignments'} = [];
}
##-------------------------------------------------------------------------##
=head2 setClade()
Use: my $oldCladeName = setClade( $index, $cladeName );
Set the clade at a given position in the list.
=cut
##-------------------------------------------------------------------------##
sub setClade
{
my $this = shift;
my $index = shift;
my $cladeName = shift;
my $subroutine = ( caller( 0 ) )[ 0 ] . "::" . ( caller( 0 ) )[ 3 ];
croak "$subroutine: index $index is out of bounds."
if ( $index < 0 || $index > $#{ $this->{'clades'} } );
my $oldValue = $this->getClade( $index );
$this->{'clades'}->[ $index ]->{'cladeName'} = $cladeName;
return ( $oldValue );
}
##-------------------------------------------------------------------------##
=head2 getClade()
Use: my $cladeName = getClade( $index );
Get the clade at a given position in the list.
=cut
##-------------------------------------------------------------------------##
sub getClade
{
my $this = shift;
my $index = shift;
my $subroutine = ( caller( 0 ) )[ 0 ] . "::" . ( caller( 0 ) )[ 3 ];
croak "$subroutine: index $index is out of bounds."
if ( $index < 0 || $index > $#{ $this->{'clades'} } );
return ( $this->{'clades'}->[ $index ]->{'cladeName'} );
}
##-------------------------------------------------------------------------##
=head2 cladeCount()
Use: my $count = cladeCount();
Return a count of the clade list.
=cut
##-------------------------------------------------------------------------##
sub cladeCount
{
my $this = shift;
return $#{ $this->{'clades'} } + 1;
}
##-------------------------------------------------------------------------##
=head2 removeClade()
Use: removeClade( $index );
Remove the clade at the given index.
=cut
##-------------------------------------------------------------------------##
sub removeClade
{
my $this = shift;
my $index = shift;
my $subroutine = ( caller( 0 ) )[ 0 ] . "::" . ( caller( 0 ) )[ 3 ];
croak "$subroutine: index $index is out of bounds."
if ( $index < 0 || $index > $#{ $this->{'clades'} } );
splice( @{ $this->{'clades'} }, $index, 1 );
}
##-------------------------------------------------------------------------##
=head2 addClade()
Use: addClade( $cladeName );
Add a clade to the end of the list.
=cut
##-------------------------------------------------------------------------##
sub addClade
{
my $this = shift;
my $cladeName = shift;
push @{ $this->{'clades'} }, { cladeName => $cladeName };
}
##-------------------------------------------------------------------------##
=head2 clearClades()
Use: clearClades();
Remove all clades from the list.
=cut
##-------------------------------------------------------------------------##
sub clearClades
{
my $this = shift;
$this->{'clades'} = [];
}
##-------------------------------------------------------------------------##
## General Object Methods
##-------------------------------------------------------------------------##
##-------------------------------------------------------------------------##
=head2
Use: $obj->read_stockholm(\*INPUT);
or
$obj->read_stockholm(\@array_ref);
Reads the Dfam dialect of the Stockholm format.
Minimal Example
===============
# STOCKHOLM 1.0
#=GF ID Jumbo1
#=GF DE A very common DNA transposon with two deletion products Jumbo1A
#=GF DE and Jumbo1B.
#=GF SE Predicted; RepeatModeler
#=GF TP Interspersed_Repeat;Unknown
#=GF OC Colius striatus
#=GF SQ 2
#=GC RF xxxx.xxx.x.x...x.x.x
colStr1:KK551537:690782-691123 .GCT.GGGAT.G...CTGCG
colStr1:KK551537:1038-2834 AGCTTGGG.TTGTACC.G.G
//
Complex Example
===============
# STOCKHOLM 1.0
#=GF ID Jumbo1
#=GF DE A very common DNA transposon with two deletion products Jumbo1A
#=GF DE and Jumbo1B.
#=GF SE Predicted; RepeatModeler
#=GF TP Interspersed_Repeat;Transposable_Element;DNA;TIR;hAT;Tip100
#=GF OC Eutheria
#=GF OC Metatheria
#=GF RN [1]
#=GF RM 382832
#=GF RN [2]
#=GF RM 28834
#=GF DR DPTEdb; af31b_dna;
#=GF SQ 2
#=GC RF xxxx.xxx.x.x...x.x.x
hg38:chr12:690782-691123 .GCT.GGGAT.G...CTGCG
hg38:chr2:38282-38399 AGCTTGGG.TTGTACC.G.G
//
Recommended features
====================
#=GF
Compulsory fields:
------------------
ID Identification: One word name for family.
DE Definition: Short description of family.
AU Author: Authors of the entry.
SE Source of seed: The source suggesting the seed members
belong to one family.
TP Type/Classification: Classifcation of family -- Presently we use the
new unified RepeatMasker classification
heirarchy.
OC Clade: Organism (clade, etc.) Multiple OC records are
allowed.
SQ Sequence: Number of sequences in alignment.
Optional fields:
----------------
RN Reference Number: Reference Number.
RM Reference PubMed: Pubmed reference number.
RT Reference Title: Reference Title.
RA Reference Author: Reference Author
RL Reference Location: Journal location.
DR Database Reference: Reference to external database.
#=GC
Optional fields:
----------------
RF Reference annotation Often the consensus DNA is used as a reference
or simple "x" for match columns and "." for
insert columns.
=cut
##-------------------------------------------------------------------------##
sub read_stockholm
{
my $this = shift;
my $in = shift;
my $input;
my $subroutine = ( caller( 0 ) )[ 0 ] . "::" . ( caller( 0 ) )[ 3 ];
if ( ref $in eq "GLOB" )
{
$input = [ <$in> ];
} else
{
$input = $in;
}
my $inCitation = 0;
my $pmid = "";
my $title = "";
my $author = "";
my $journal = "";
my $sequenceLen = 0;
foreach ( @{$input} )
{
# Start of the data
next if ( /^\# STOCKHOLM/ );
# End of the data
last if ( /^\/\// );
# Specific GC line we care about ( RF )
if ( /^\#=GC\s+RF\s+(\S+)/ )
{
$this->setRfLine( $1 );
next;
}
# Save the first identifier line
if ( /^\#=GF\s+ID\s+(\S+)/ && !$this->getId() )
{
# Only keep the first word in the field.
$this->setId( $1 );
next;
}
# Save the description lines
if ( /^\#=GF\s+DE\s+(\S.*)$/ )
{
if ( $this->getDescription() )
{
$this->setDescription( $this->getDescription() . $1 . "\n" );
} else
{
$this->setDescription( $1 . "\n" );
}
next;
}
# Save the classification of the entry
if ( /^\#=GF\s+TP\s+(\S.*)$/ )
{
$this->setClassification( $1 );
next;
}
# Save the clades
if ( /^\#=GF\s+OC\s+(\S.*)$/ )
{
$this->addClade( $1 );