[Bio] / Sprout / ContigDNA.pm Repository:
ViewVC logotype

Annotation of /Sprout/ContigDNA.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download) (as text)

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     package ContigDNA;
4 :    
5 :     use strict;
6 :     use Tracer;
7 :     use FIG;
8 :     use Genome;
9 :    
10 :     =head1 Contig DNA manipulation object
11 :    
12 :     =head2 Introduction
13 :    
14 :     This method creates a pseudo-FIG object for use by the B<FullLocation> object. It
15 :     supports the L</contig_ln> and L</dna_seq> methods.
16 :    
17 :     Note that it keeps all the data structures in memory, so it should not be used except for
18 :     a few genomes with small number of gen
19 :    
20 :     =cut
21 :    
22 :     =head2 Public Methods
23 :    
24 :     =head3 new
25 :    
26 : parrello 1.2 my $cdna = ContigDNA->new($genID1 => $file1, $genID2 => $file, ... $genIDN => $fileN );
27 : parrello 1.1
28 :     Construct a new pseudo-FIG object from a set of FASTA files. The incoming parameters come
29 :     in pairs. The first of each pair is the ID of a genome; the second is the name of a FASTA
30 :     file containing the contig data.
31 :    
32 :     =over 4
33 :    
34 :     =item genID1, genID2, ... genIDN
35 :    
36 :     IDs of the genomes whose contigs are to be read into memory.
37 :    
38 :     =item file1, file2, ... fileN
39 :    
40 :     Names of the FASTA files containing the genome data.
41 :    
42 :     =cut
43 :    
44 :     sub new {
45 :     # Get the parameters.
46 :     my ($class, %files) = @_;
47 :     # Create the object.
48 :     my $retVal = { };
49 :     # Loop through the genomes.
50 :     for my $genID (keys %files) {
51 :     # Get the name of this genome's FASTA file.
52 :     my $file = $files{$genID};
53 :     # Read it in using the Genome object.
54 :     my $genomeData = Genome->new($genID, $file, "");
55 :     # Put it in the hash.
56 :     $retVal->{$genID} = $genomeData;
57 :     }
58 :     # Bless and return it.
59 :     bless $retVal, $class;
60 :     return $retVal;
61 :     }
62 :    
63 :     =head3 dna_seq
64 :    
65 : parrello 1.2 my $sequence = $sfxlate->dna_seq($genomeID, @locations);
66 : parrello 1.1
67 :     Return the sequence represented by a list of locations. The locations
68 :     should be in the standard form I<contigID>C<_>I<begin>I<dir>I<end>.
69 :    
70 :     =over 4
71 :    
72 :     =item genomeID
73 :    
74 :     ID of the relevant genome.
75 :    
76 :     =item location1, location2, ... locationN
77 :    
78 :     List of locations to be included in the DNA sequence.
79 :    
80 :     =item RETURN
81 :    
82 :     Returns a string specifying the DNA nucleotides in the specified locations.
83 :    
84 :     =back
85 :    
86 :     =cut
87 :     #: Return Type $;
88 :     sub dna_seq {
89 :     # Get the parameters.
90 :     my ($self, $genomeID, @locations) = @_;
91 :     # Get the Genome object.
92 :     my $genome = $self->{$genomeID};
93 :     # Start the return string.
94 :     my $retVal = "";
95 :     # Loop through the locations.
96 :     for my $location (@locations) {
97 :     # Get the DNA.
98 :     my $dna = $genome->GetLocation($location);
99 :     # Add it to the return string.
100 :     $retVal .= $dna;
101 :     }
102 :     # Return the result.
103 :     return $retVal;
104 :     }
105 :    
106 :     =head3 contig_ln
107 :    
108 : parrello 1.2 my $length = $sfxlate->contig_ln($genomeID, $contig);
109 : parrello 1.1
110 :     Return the length of the specified contig.
111 :    
112 :     =over 4
113 :    
114 :     =item genomeID
115 :    
116 :     ID of the genome to which the contig belongs.
117 :    
118 :     =item contigID
119 :    
120 :     ID of the contig whose length is desired.
121 :    
122 :     =item RETURN
123 :    
124 :     Returns the length (in base pairs) of the specified contig in the specified
125 :     genome.
126 :    
127 :     =back
128 :    
129 :     =cut
130 :     #: Return Type $;
131 :     sub contig_ln {
132 :     my($self, $genomeID, $contigID) = @_;
133 :     my $genome = $self->{$genomeID};
134 :     return $genome->ContigLen($contigID);
135 :     }
136 :    
137 :     1;
138 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3