示例#1
0
 def test_file_format_error(self):
     # given
     expected = FileFormatError
     file_path = 'wrongformat.txt'
     config_path = 'config.txt'
     # when
     rf = ReadFile()
     # then
     config = rf.get_config(config_path)
     self.assertRaises(expected, rf.seq_path, file_path, config)
示例#2
0
    def getCourseComment(self):
        courseCommentInfo = {}
        readFile = ReadFile()

        fileNamePaths = readFile.getFileName(self.fileDir)
        for fileNamePath in fileNamePaths:
            fileName = os.path.basename(fileNamePath).split(".")[0]
            comList = readFile.readFile(fileNamePath)
            courseCommentInfo.setdefault(fileName, comList)
        return courseCommentInfo
示例#3
0
 def test_too_long_sequence(self):
     # given
     expected = SequenceTooLongException
     file_path = 'longsequence.txt'
     config_path = 'config.txt'
     # when
     rf = ReadFile()
     config = rf.get_config(config_path)
     # then
     self.assertRaises(expected, rf.seq_path, file_path, config)
示例#4
0
 def test_read_sequence(self):
     # given
     config_path = 'config.txt'
     seq_path = 'a.txt'
     expected = 'GATTACA'
     # when
     rf = ReadFile()
     config = rf.get_config(config_path)
     seq = rf.seq_path(seq_path, config)
     # then
     self.assertEqual(seq, expected)
示例#5
0
    def getUserName(self):
        userInfo = {}
        filePath = ""

        readFile = ReadFile()
        nameList = readFile.readFile(filePath)

        db = DBconnect()
        dbc = db.dbConn()
        imageList = db.search(dbc)
        db.dbClose(dbc)

        for i in range(0, len(nameList)):
            userInfo.setdefault(nameList[0], imageList[0])

        return userInfo
示例#6
0
 def test_read_config(self):
     # given
     config_path = 'config.txt'
     same = 5
     diff = -5
     gap_penalty = -2
     max_seq_length = 100
     max_number_path = 20
     # when
     rf = ReadFile()
     config = rf.get_config(config_path)
     c = Config(same, diff, gap_penalty, max_seq_length, max_number_path)
     # then
     self.assertEqual(config.SAME, c.SAME)
     self.assertEqual(config.DIFF, c.DIFF)
     self.assertEqual(config.GAP_PENALTY, c.GAP_PENALTY)
     self.assertEqual(config.MAX_SEQ_LENGTH, c.MAX_SEQ_LENGTH)
     self.assertEqual(config.MAX_NUMBER_PATH, c.MAX_NUMBER_PATH)
示例#7
0
    def getCourseName(self):
        courseInfo = {}

        readFile = ReadFile()
        db = DBconnect()

        fileNamePaths = readFile.getFileName(self.fileDir)

        for fileNamePath in fileNamePaths:
            fileName = os.path.basename(fileNamePath).split(".")[0]

            sql = "select course_id from jh_course where title = '" + fileName + "'"

            dbc = db.dbConn()
            idList = db.search(dbc, sql)
            db.dbClose(dbc)

            courseInfo.setdefault(fileName, idList[0])
        return courseInfo
示例#8
0
 def test_wrong_config_error(self):
     # given
     expected = WrongConfigInput
     file_path1 = 'wrongconfig1.txt'
     file_path2 = 'wrongconfig2.txt'
     file_path3 = 'wrongconfig3.txt'
     # when
     rf = ReadFile()
     # then
     self.assertRaises(expected, rf.get_config, file_path1)
     self.assertRaises(expected, rf.get_config, file_path2)
     self.assertRaises(expected, rf.get_config, file_path3)
示例#9
0
    def on_button_clicked(self):
        self.filename = InputLoadFile().filename
        self.data = ReadFile(self.filename).data

        # Second line : Text fields with X and Y
        hboxCoord = QHBoxLayout()
        label_min_x = QLabel("Min X : ")
        label_max_x = QLabel("Max X : ")
        self.textbox_min_x = QLineEdit()
        self.textbox_max_x = QLineEdit()
        hboxCoord.addWidget(label_min_x)
        hboxCoord.addWidget(self.textbox_min_x)
        hboxCoord.addWidget(label_max_x)
        hboxCoord.addWidget(self.textbox_max_x)
        hboxCoord.addStretch(1)

        # Forth line : Button Plot
        hbox_plot = QHBoxLayout()
        button_plot = QPushButton('Plot')
        button_plot.clicked.connect(self.launch_plot_window)
        hbox_plot.addStretch(1)
        hbox_plot.addWidget(button_plot)
        hbox_plot.addStretch(1)

        hbox_label_table = QHBoxLayout()
        label_table = QLabel("Values : ")
        hbox_label_table.addWidget(label_table)

        hbox_table = QHBoxLayout()
        tableWidget = QTableWidget()
        tableWidget.setRowCount(2)
        tableWidget.setColumnCount(len(self.data[0]))
        hbox_table.addWidget(tableWidget)
        for i in range(len(self.data[0])):
            tableWidget.setItem(0, i, QTableWidgetItem(str(self.data[0][i])))
            tableWidget.setItem(1, i, QTableWidgetItem(str(self.data[1][i])))

        self.vbox.addLayout(hboxCoord)
        self.vbox.addLayout(hbox_label_table)
        self.vbox.addLayout(hbox_table)
        self.vbox.addLayout(hbox_plot)

        self.textbox_min_x.setText(str(min(self.data[0])))
        self.textbox_max_x.setText(str(max(self.data[0])))
        self.label.setText(self.filename)
示例#10
0
                        help='Path to the b sequence',
                        required=True,
                        dest='seq_b')
    parser.add_argument('-c',
                        type=str,
                        help='Path to the config file',
                        required=True,
                        dest='config_path')
    parser.add_argument('-o',
                        type=str,
                        help='Path to the output file',
                        required=True,
                        dest='output_path')
    args = parser.parse_args()

    rf = ReadFile()
    config = rf.get_config(args.config_path)
    nw = NeedlemanWunsh()
    mat, directmat = nw.calculate_matrix(rf.seq_path(args.seq_a, config),
                                         rf.seq_path(args.seq_b, config),
                                         config)
    score, alignments = nw.calculate_result(mat, directmat,
                                            rf.seq_path(args.seq_a, config),
                                            rf.seq_path(args.seq_b, config),
                                            config)
    # write results to file
    f = open(args.output_path, 'w')
    f.write('SCORE=' + str(score) + '\n')
    f.write('\n')
    for i in range(len(alignments)):
        f.write(alignments[i].res_a + '\n')