Mercurial > repos > fcaramia > contra
diff Contra/scripts/count_libsize.py @ 0:7564f3b1e675
Uploaded
author | fcaramia |
---|---|
date | Thu, 13 Sep 2012 02:31:43 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Contra/scripts/count_libsize.py Thu Sep 13 02:31:43 2012 -0400 @@ -0,0 +1,38 @@ +# ----------------------------------------------------------------------# +# Copyright (c) 2011, Richard Lupat & Jason Li. +# +# > Source License < +# This file is part of CONTRA. +# +# CONTRA is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# CONTRA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with CONTRA. If not, see <http://www.gnu.org/licenses/>. +# +# +#-----------------------------------------------------------------------# +# Last Updated : 05 October 2011 16:43PM + +def get_libsize(bedgraph_file): + bedgraph = open(bedgraph_file) + libsize = 0 + for line in bedgraph: + line = line.split() + chr = line[0] + start = int(line[1]) + end = int(line[2]) + cov = float(line[3]) + #cov = int(line[3]) + + libsize += (end-start)*cov + + bedgraph.close() + return int(libsize)