~ubuntu-branches/ubuntu/raring/bioperl/raring

« back to all changes in this revision

Viewing changes to bioperl.lisp

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2008-03-18 14:44:57 UTC
  • mfrom: (4 hardy)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080318144457-1jjoztrvqwf0gruk
* debian/control:
  - Removed MIA Matt Hope (dopey) from the Uploaders field.
    Thank you for your work, Matt. I hope you are doing well.
  - Downgraded some recommended package to the 'Suggests' priority,
    according to the following discussion on Upstream's mail list.
    http://bioperl.org/pipermail/bioperl-l/2008-March/027379.html
    (Closes: #448890)
* debian/copyright converted to machine-readable format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
;;
2
 
;; $Id: bioperl.lisp,v 1.28 2003/03/06 03:41:24 lapp Exp $
3
 
;;
4
 
;; Perl mode set up
5
 
 
6
 
(assoc "\\.pl$" auto-mode-alist)
7
 
(setq auto-mode-alist (cons '("\\.pl$" . perl-mode) auto-mode-alist))
8
 
 
9
 
(assoc "\\.pm$" auto-mode-alist)
10
 
(setq auto-mode-alist (cons '("\\.pm$" . perl-mode) auto-mode-alist))
11
 
 
12
 
(defun perl-insert-start ()
13
 
  "Places #!..perl at the start of the script"
14
 
  (interactive)
15
 
  (goto-char (point-min))
16
 
  (insert "#!/usr/local/bin/perl\n"))
17
 
 
18
 
 
19
 
(defun bioperl-object-start (perl-object-name perl-caretaker-name caretaker-email)
20
 
  "Places standard bioperl object notation headers and footers"
21
 
  (interactive "sName of Object: \nsName of caretaker: \nsEmail: ")
22
 
  (insert "# $Id: bioperl.lisp,v 1.28 2003/03/06 03:41:24 lapp Exp $\n#\n# BioPerl module for " perl-object-name "\n#\n# Cared for by " perl-caretaker-name " <" caretaker-email ">\n#\n# Copyright " perl-caretaker-name "\n#\n# You may distribute this module under the same terms as perl itself\n\n")
23
 
  (insert "# POD documentation - main docs before the code\n\n")
24
 
  (insert "=head1 NAME\n\n" perl-object-name " - DESCRIPTION of Object\n\n")
25
 
  (insert "=head1 SYNOPSIS\n\nGive standard usage here\n\n")
26
 
  (insert "=head1 DESCRIPTION\n\nDescribe the object here\n\n")
27
 
  (insert "=head1 FEEDBACK\n\n=head2 Mailing Lists\n\n")
28
 
  (insert "User feedback is an integral part of the evolution of this and other\nBioperl modules. Send your comments and suggestions preferably to\nthe Bioperl mailing list.  Your participation is much appreciated.\n\n")
29
 
  (insert "  bioperl-l@bioperl.org              - General discussion\n  http://bioperl.org/MailList.shtml  - About the mailing lists\n\n")
30
 
  (insert "=head2 Reporting Bugs\n\nReport bugs to the Bioperl bug tracking system to help us keep track\nof the bugs and their resolution. Bug reports can be submitted via\nthe web:\n\n")
31
 
  (insert "  http://bugzilla.bioperl.org/\n\n")
32
 
  (insert "=head1 AUTHOR - " perl-caretaker-name "\n\nEmail " caretaker-email "\n\nDescribe contact details here\n\n")
33
 
  (insert "=head1 CONTRIBUTORS\n\nAdditional contributors names and emails here\n\n")
34
 
  (insert "=head1 APPENDIX\n\nThe rest of the documentation details each of the object methods.\nInternal methods are usually preceded with a _\n\n=cut\n\n")
35
 
  (insert "\n# Let the code begin...\n\n")
36
 
  (insert "\npackage " perl-object-name ";\n")
37
 
  (insert "use vars qw(@ISA);\n")
38
 
  (insert "use strict;\n")
39
 
  (insert "\n# Object preamble - inherits from Bio::Root::Root\n")
40
 
  (insert "\nuse Bio::Root::Root;\n\n")
41
 
  (insert "\n@ISA = qw(Bio::Root::Root );\n\n")
42
 
  (insert "=head2 new\n\n Title   : new\n Usage   : my $obj = new "
43
 
          perl-object-name "();\n Function: Builds a new "
44
 
          perl-object-name " object \n Returns : an instance of "
45
 
          perl-object-name "\n Args    :\n\n\n=cut\n\n")
46
 
  (insert "sub new {\n  my($class,@args) = @_;\n\n  my $self = $class->SUPER::new(@args);\n  return $self;\n}\n")
47
 
  (insert "\n\n1;")
48
 
  )
49
 
 
50
 
(defun bioperl-interface-start (perl-object-name perl-caretaker-name
51
 
                                                 caretaker-email)
52
 
  "Places standard bioperl object notation headers and footers"
53
 
  (interactive "sName of Object: \nsName of caretaker: \nsEmail: ")
54
 
  (insert "# $Id $\n#\n# BioPerl module for " perl-object-name "\n#\n# Cared for by " perl-caretaker-name " <" caretaker-email ">\n#\n# Copyright " perl-caretaker-name "\n#\n# You may distribute this module under the same terms as perl itself\n\n")
55
 
  (insert "# POD documentation - main docs before the code\n\n")
56
 
  (insert "=head1 NAME\n\n" perl-object-name " - DESCRIPTION of Interface\n\n")
57
 
  (insert "=head1 SYNOPSIS\n\nGive standard usage here\n\n")
58
 
  (insert "=head1 DESCRIPTION\n\nDescribe the interface here\n\n")
59
 
  (insert "=head1 FEEDBACK\n\n=head2 Mailing Lists\n\n")
60
 
  (insert "User feedback is an integral part of the evolution of this and other\nBioperl modules. Send your comments and suggestions preferably to\nthe Bioperl mailing list.  Your participation is much appreciated.\n\n")
61
 
  (insert "  bioperl-l@bioperl.org              - General discussion\n  http://bioperl.org/MailList.shtml  - About the mailing lists\n\n")
62
 
  (insert "=head2 Reporting Bugs\n\nReport bugs to the Bioperl bug tracking system to help us keep track\nof the bugs and their resolution. Bug reports can be submitted via\nemail or the web:\n\n")
63
 
  (insert "  http://bugzilla.bioperl.org/\n\n")
64
 
  (insert "=head1 AUTHOR - " perl-caretaker-name "\n\nEmail " caretaker-email "\n\nDescribe contact details here\n\n")
65
 
  (insert "=head1 CONTRIBUTORS\n\nAdditional contributors names and emails here\n\n")
66
 
  (insert "=head1 APPENDIX\n\nThe rest of the documentation details each of the object methods.\nInternal methods are usually preceded with a _\n\n=cut\n\n")
67
 
  (insert "\n# Let the code begin...\n\n")
68
 
  (insert "\npackage " perl-object-name ";\n")
69
 
  (insert "use vars qw(@ISA);\n")
70
 
  (insert "use strict;\n\nuse Bio::Root::RootI;\n\n")
71
 
  (insert "@ISA = qw( Bio::Root::RootI );")
72
 
  (insert "\n\n1;")
73
 
  )
74
 
 
75
 
 
76
 
(defun bioperl-method (method-name)
77
 
  "puts in a bioperl method complete with pod boiler-plate"
78
 
  (interactive "smethod name:")
79
 
  (insert "=head2 " method-name "\n\n Title   : " method-name "\n Usage   :\n Function:\n Example :\n Returns : \n Args    :\n\n\n=cut\n\n")
80
 
  (insert "sub " method-name "{\n   my ($self,@args) = @_;\n")
81
 
  (save-excursion 
82
 
    (insert "\n\n}\n"))
83
 
  )
84
 
 
85
 
 
86
 
(defun bioperl-getset (field-name)
87
 
  "puts in a bioperl method for a get/set method complete with pod boiler-plate"
88
 
  (interactive "sfield name:")
89
 
  (insert "=head2 " field-name "\n\n Title   : " field-name "\n Usage   : $obj->" field-name "($newval)\n Function: \n Example : \n Returns : value of " field-name " (a scalar)\n Args    : on set, new value (a scalar or undef, optional)\n\n\n=cut\n\n")
90
 
  (insert "sub " field-name "{\n    my $self = shift;\n\n    return $self->{'" field-name "'} = shift if @_;\n    return $self->{'" field-name "'};")
91
 
  (insert "\n}\n"))
92
 
 
93
 
(defun bioperl-array-getset (field-name class-name)
94
 
  "puts in a bioperl method for array get/add/remove methods complete with pod boiler-plate"
95
 
  (interactive "sarray base object: \nstype of element: ")
96
 
  (insert "=head2 get_" field-name "s\n\n Title   : get_" field-name "s\n Usage   : @arr = get_" field-name "s()\n Function: Get the list of " field-name "(s) for this object.\n Example :\n Returns : An array of " class-name " objects\n Args    :\n\n\n=cut\n\n")
97
 
  (insert "sub get_" field-name "s{\n    my $self = shift;\n\n    return @{$self->{'_" field-name "s'}} if exists($self->{'_" field-name "s'});\n    return ();\n}\n\n")
98
 
  (insert "=head2 add_" field-name "\n\n Title   : add_" field-name "\n Usage   :\n Function: Add one or more " field-name "(s) to this object.\n Example :\n Returns : \n Args    : One or more " class-name " objects.\n\n\n=cut\n\n")
99
 
  (insert "sub add_" field-name "{\n    my $self = shift;\n\n    $self->{'_" field-name "s'} = [] unless exists($self->{'_" field-name "s'});\n    push(@{$self->{'_" field-name "s'}}, @_);\n}\n\n")
100
 
  (insert "=head2 remove_" field-name "s\n\n Title   : remove_" field-name "s\n Usage   :\n Function: Remove all " field-name "s for this class.\n Example :\n Returns : The list of previous " field-name "s as an array of\n           " class-name " objects.\n Args    :\n\n\n=cut\n\n")
101
 
  (insert "sub remove_" field-name "s{\n    my $self = shift;\n\n    my @arr = $self->get_" field-name "s();\n    $self->{'_" field-name "s'} = [];\n    return @arr;\n}\n\n"))
102
 
 
103
 
 
104
 
(defun bioperl-abstract-method (method-name)
105
 
  "puts in a bioperl abstract method for interface classes"
106
 
  (interactive "smethod-name:")
107
 
  (save-excursion 
108
 
  (insert "=head2 " method-name "\n\n Title   : " method-name "\n Usage   :\n Function:\n Example :\n Returns : \n Args    :\n\n\n=cut\n\n")
109
 
  (insert "sub " method-name "{\n   my ($self) = @_;\n\n    $self->throw(\"Abstract method " method-name " implementing class did not provide method\");\n")
110
 
    (insert "\n\n}\n")
111
 
    )
112
 
  )
113
 
 
114
 
 
115
 
 
116
 
(setq perl-mode-hook 
117
 
      '(lambda ()
118
 
         (define-key perl-mode-map "\C-c\C-h" 'perl-insert-start)
119
 
         (define-key perl-mode-map "\C-c\C-b" 'bioperl-object-start)
120
 
         (define-key perl-mode-map "\C-c\C-i" 'bioperl-interface-start)
121
 
         (define-key perl-mode-map "\C-c\C-v" 'bioperl-getset)
122
 
         (define-key perl-mode-map "\C-c\C-r" 'bioperl-arrray-getset)
123
 
         (define-key perl-mode-map "\C-c\C-b" 'bioperl-method)
124
 
         (define-key perl-mode-map "\C-c\C-a\C-m" 'bioperl-abstract-method)
125
 
         (define-key perl-mode-map "\C-c\C-z" 'compile)
126
 
         (define-key perl-mode-map [menu-bar] (make-sparse-keymap))
127
 
         (define-key perl-mode-map [menu-bar p]
128
 
           (cons "BioPerl" (make-sparse-keymap "BioPerl")))
129
 
         (define-key perl-mode-map [menu-bar p perl-script-start]
130
 
           '("Insert script template" . perl-script-start))
131
 
         (define-key perl-mode-map [menu-bar p bioperl-object-start]
132
 
           '("bioperl object template" . bioperl-object-start))
133
 
         (define-key perl-mode-map [menu-bar p bioperl-interface-start]
134
 
           '("bioperl interface template" . bioperl-interface-start))
135
 
         (define-key perl-mode-map [menu-bar p bioperl-getset]
136
 
           '("bioperl field func" . bioperl-getset))
137
 
         (define-key perl-mode-map [menu-bar p bioperl-array-getset]
138
 
           '("bioperl array get/add/remove" . bioperl-array-getset))
139
 
         (define-key perl-mode-map [menu-bar p bioperl-method]
140
 
           '("bioperl method" . bioperl-method))
141
 
         ))
142