Mercurial > repos > yating-l > hubarchivecreator
diff Bed.py @ 2:4ced8f116509 draft
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 23b12dd763c0235674988ebdf6a258afd1ad629a-dirty
author | yating-l |
---|---|
date | Tue, 22 Nov 2016 17:13:18 -0500 |
parents | 3e0c61b52a06 |
children |
line wrap: on
line diff
--- a/Bed.py Tue Nov 22 17:07:47 2016 -0500 +++ b/Bed.py Tue Nov 22 17:13:18 2016 -0500 @@ -26,13 +26,10 @@ self.track_color = self.data_bed_generic["track_color"] # TODO: Think about how to avoid repetition of the group_name everywhere self.group_name = self.data_bed_generic["group_name"] - - modified = self._checkAndFixBed() + + # Sort processing subtools.sort(self.inputBedGeneric, self.sortedBedFile.name) - - - # bedToBigBed processing # TODO: Change the name of the bb, to tool + genome + possible adding if multiple + .bb @@ -42,10 +39,8 @@ with open(myBigBedFilePath, 'w') as self.bigBedFile: subtools.bedToBigBed(self.sortedBedFile.name, self.chromSizesFile.name, - self.bigBedFile.name, - typeOption='bed12+1', - tab=True) - + self.bigBedFile.name) + # Create the Track Object self.createTrack(file_path=trackName, track_name=trackName, @@ -53,8 +48,7 @@ priority=self.priority, track_file=myBigBedFilePath, track_color=self.track_color, - group_name=self.group_name, - ) + group_name=self.group_name) # dataURL = "tracks/%s" % trackName # @@ -76,35 +70,4 @@ # ) print("- Bed %s created" % self.name_bed_generic) - if (len(modified) != 0): - print("The lines that were removed: " + str(len(modified))) #print("- %s created in %s" % (trackName, myBigBedFilePath)) - - # TODO: bed verifier, check if there are invalid strands: "." - def _checkAndFixBed(self): - """ - Call _checkAndFixBed, check the integrity of bed file, - if the strand is not "+" or "-" truncate that line and report to users - create column and move the score column to - """ - # Store the lines that have been removed - removedLines = [] - # Remove the lines with invalid strand - temp_bed = tempfile.NamedTemporaryFile(bufsize=0, suffix=".bed", delete=False) - with open(temp_bed.name, 'w') as tmp: - with open(self.inputBedGeneric, 'r') as f: - lines = f.readlines() - for line in lines: - fields = line.split() - strand = fields[5] - score = fields[4] - fields[4] = '1000' - fields.append(score) - if (strand == '+' or strand == '-'): - tmp.write('\t'.join(map(str, fields))) - tmp.write("\n") - else: - removedLines.append(line) - self.inputBedGeneric = temp_bed.name - - return removedLines \ No newline at end of file