Parent Directory
|
Revision Log
Revision 1.3 - (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 : | parrello | 1.3 | =back |
43 : | |||
44 : | parrello | 1.1 | =cut |
45 : | |||
46 : | sub new { | ||
47 : | # Get the parameters. | ||
48 : | my ($class, %files) = @_; | ||
49 : | # Create the object. | ||
50 : | my $retVal = { }; | ||
51 : | # Loop through the genomes. | ||
52 : | for my $genID (keys %files) { | ||
53 : | # Get the name of this genome's FASTA file. | ||
54 : | my $file = $files{$genID}; | ||
55 : | # Read it in using the Genome object. | ||
56 : | my $genomeData = Genome->new($genID, $file, ""); | ||
57 : | # Put it in the hash. | ||
58 : | $retVal->{$genID} = $genomeData; | ||
59 : | } | ||
60 : | # Bless and return it. | ||
61 : | bless $retVal, $class; | ||
62 : | return $retVal; | ||
63 : | } | ||
64 : | |||
65 : | =head3 dna_seq | ||
66 : | |||
67 : | parrello | 1.2 | my $sequence = $sfxlate->dna_seq($genomeID, @locations); |
68 : | parrello | 1.1 | |
69 : | Return the sequence represented by a list of locations. The locations | ||
70 : | should be in the standard form I<contigID>C<_>I<begin>I<dir>I<end>. | ||
71 : | |||
72 : | =over 4 | ||
73 : | |||
74 : | =item genomeID | ||
75 : | |||
76 : | ID of the relevant genome. | ||
77 : | |||
78 : | =item location1, location2, ... locationN | ||
79 : | |||
80 : | List of locations to be included in the DNA sequence. | ||
81 : | |||
82 : | =item RETURN | ||
83 : | |||
84 : | Returns a string specifying the DNA nucleotides in the specified locations. | ||
85 : | |||
86 : | =back | ||
87 : | |||
88 : | =cut | ||
89 : | #: Return Type $; | ||
90 : | sub dna_seq { | ||
91 : | # Get the parameters. | ||
92 : | my ($self, $genomeID, @locations) = @_; | ||
93 : | # Get the Genome object. | ||
94 : | my $genome = $self->{$genomeID}; | ||
95 : | # Start the return string. | ||
96 : | my $retVal = ""; | ||
97 : | # Loop through the locations. | ||
98 : | for my $location (@locations) { | ||
99 : | # Get the DNA. | ||
100 : | my $dna = $genome->GetLocation($location); | ||
101 : | # Add it to the return string. | ||
102 : | $retVal .= $dna; | ||
103 : | } | ||
104 : | # Return the result. | ||
105 : | return $retVal; | ||
106 : | } | ||
107 : | |||
108 : | =head3 contig_ln | ||
109 : | |||
110 : | parrello | 1.2 | my $length = $sfxlate->contig_ln($genomeID, $contig); |
111 : | parrello | 1.1 | |
112 : | Return the length of the specified contig. | ||
113 : | |||
114 : | =over 4 | ||
115 : | |||
116 : | =item genomeID | ||
117 : | |||
118 : | ID of the genome to which the contig belongs. | ||
119 : | |||
120 : | =item contigID | ||
121 : | |||
122 : | ID of the contig whose length is desired. | ||
123 : | |||
124 : | =item RETURN | ||
125 : | |||
126 : | Returns the length (in base pairs) of the specified contig in the specified | ||
127 : | genome. | ||
128 : | |||
129 : | =back | ||
130 : | |||
131 : | =cut | ||
132 : | #: Return Type $; | ||
133 : | sub contig_ln { | ||
134 : | my($self, $genomeID, $contigID) = @_; | ||
135 : | my $genome = $self->{$genomeID}; | ||
136 : | return $genome->ContigLen($contigID); | ||
137 : | } | ||
138 : | |||
139 : | 1; | ||
140 : |
MCS Webmaster | ViewVC Help |
Powered by ViewVC 1.0.3 |