Пример #1
0
    def onNotes(self):
        notes_program = pw.Config.SCIPION_NOTES_PROGRAM
        notes_args = pw.Config.SCIPION_NOTES_ARGS
        args = []
        notes_file = self.project.getPath('Logs', pw.Config.SCIPION_NOTES_FILE)

        # If notesFile does not exist, it is created and an explanation/documentation comment is added at the top.
        if not os.path.exists(notes_file):
            f = open(notes_file, 'a')
            f.write(pw.genNotesHeading())
            f.close()

        # Then, it will be opened as specified in the conf
        if notes_program:
            args.append(notes_program)
            # Custom arguments
            if notes_args:
                args.append(notes_args)
            args.append(notes_file)
            subprocess.Popen(args)  # nonblocking
        else:
            # if no program has been selected
            # xdg-open will try to guess but
            # if the file does not exist it
            # will return an error so If the file does
            # not exist I will create an empty one
            # 'a' will avoid accidental truncation
            openTextFileEditor(notes_file)
Пример #2
0
    def visualize(self, obj, **kwargs):
        # The sequence object is visualized in a tmp file;
        # To build this tmp file we use a method (saveFile) from the class
        # SequenceHandler that requires a Biopython sequence (Bio.Seq.Seq
        # object);

        # Step 1: transformation of the sequence of our Scipion Sequence
        # object (obj.getSequence()) in a Biopython Sequence:
        # Let keep the SequenceHandler import here to avoid a default BioPython
        # import
        seqHandler = emconv.SequenceHandler(obj.getSequence(),
                                            isAminoacid=obj.getIsAminoacids())
        seqBio = seqHandler._sequence  # Bio.Seq.Seq object
        # Step 2: retrieving of the other args needed in the saveFile method
        seqID = obj.getId()
        seqName = obj.getSeqName()
        seqDescription = obj.getDescription()
        seqFileName = os.path.abspath(
            self.protocol._getExtraPath(seqName + ".fasta"))
        # Step 3: Sequence saved in the extra file
        seqHandler.saveFile(seqFileName,
                            seqID,
                            sequence=seqBio,
                            name=seqName,
                            seqDescription=seqDescription,
                            type="fasta")
        # Step 4: Visualization of extra file
        openTextFileEditor(seqFileName)
Пример #3
0
    def onExportTreeGraph(self):
        runsGraph = self.project.getRunsGraph(refresh=True)
        useId = not pwutils.envVarOn('SCIPION_TREE_NAME')
        dotStr = runsGraph.printDot(useId=useId)
        with tempfile.NamedTemporaryFile(suffix='.gv', mode="w") as dotFile:
            dotFile.write(dotStr)
            dotFile.flush()
            openTextFileEditor(dotFile.name)

        if useId:
            print("\nexport SCIPION_TREE_NAME=1 # to use names instead of ids")
        else:
            print("\nexport SCIPION_TREE_NAME=0 # to use ids instead of names")
Пример #4
0
    def onExportTreeGraph(self):
        runsGraph = self.project.getRunsGraph(refresh=True)
        useId = not pwutils.envVarOn('SCIPION_TREE_NAME')
        dotStr = runsGraph.printDot(useId=useId)
        with tempfile.NamedTemporaryFile(suffix='.gv') as dotFile:
            dotFile.write(dotStr)
            dotFile.flush()
            openTextFileEditor(dotFile.name)

        if useId:
            print "\nexport SCIPION_TREE_NAME=1 # to use names instead of ids"
        else:
            print "\nexport SCIPION_TREE_NAME=0 # to use ids instead of names"
Пример #5
0
    def onNotes(self):
        if not all(var in os.environ for var in ['SCIPION_NOTES_PROGRAM',
                                                 'SCIPION_NOTES_FILE',
                                                 'SCIPION_NOTES_ARGS']):
            return self.showError("Missing variables SCIPION_NOTES_* under\n"
                                  "[VARIABLES] section in the configuration file\n"
                                  "~/.config/scipion/scipion.conf")
        args = []
        # Program name
        program = os.environ.get('SCIPION_NOTES_PROGRAM', None)
        notesFile = self.project.getPath('Logs', os.environ['SCIPION_NOTES_FILE'])

        if program:
            args.append(program)
            # Custom arguments
            if os.environ.get('SCIPION_NOTES_ARGS', None):
                args.append(os.environ['SCIPION_NOTES_ARGS'])
            args.append(notesFile)
            subprocess.Popen(args)  #nonblocking
        else:
            openTextFileEditor(notesFile)
Пример #6
0
    def onNotes(self):
        if not all(var in os.environ for var in [
                'SCIPION_NOTES_PROGRAM', 'SCIPION_NOTES_FILE',
                'SCIPION_NOTES_ARGS'
        ]):
            return self.showError(
                "Missing variables SCIPION_NOTES_* under\n"
                "[VARIABLES] section in the configuration file\n"
                "~/.config/scipion/scipion.conf")
        args = []
        # Program name
        program = os.environ.get('SCIPION_NOTES_PROGRAM', None)
        notesFile = self.project.getPath('Logs',
                                         os.environ['SCIPION_NOTES_FILE'])

        if program:
            args.append(program)
            # Custom arguments
            if os.environ.get('SCIPION_NOTES_ARGS', None):
                args.append(os.environ['SCIPION_NOTES_ARGS'])
            args.append(notesFile)
            subprocess.Popen(args)  #nonblocking
        else:
            openTextFileEditor(notesFile)
Пример #7
0
 def visualize(self, obj, **kwargs):
     prot = obj
     fnPlot = prot._getPath('plot.png')
     if os.path.exists(fnPlot):
         openTextFileEditor(fnPlot)
Пример #8
0
    def visualize(self, obj, **kwargs):
        fnStatistics = self.protocol._getPath("statistics.txt")

        if exists(fnStatistics):
            openTextFileEditor(fnStatistics)
Пример #9
0
    def visualize(self, obj, **kwargs):
        fnAnalysis = obj.fnAnalysis.get()

        if exists(fnAnalysis):
            openTextFileEditor(fnAnalysis)
Пример #10
0
    def visualize(self, obj, **kwargs):
        fnCSV = self.protocol.getFilenameOut()

        if exists(fnCSV):
            openTextFileEditor(fnCSV)
Пример #11
0
    def visualize(self, obj, **kwargs):
        fnStatistics = self.protocol._getPath("statistics.txt")

        if exists(fnStatistics):
            openTextFileEditor(fnStatistics)
Пример #12
0
    def visualize(self, obj, **kwargs):
        fnAnalysis = obj.fnAnalysis.get()

        if exists(fnAnalysis):
            openTextFileEditor(fnAnalysis)
Пример #13
0
    def visualize(self, obj, **kwargs):
        fnCSV = self.protocol.getFilenameOut()

        if exists(fnCSV):
            openTextFileEditor(fnCSV)