FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
NewPythonPrograms/compareDoc.py at master · marcsze/NewPythonPrograms · GitHub
marcsze
/
NewPythonPrograms
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
NewPythonPrograms
/
compareDoc.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
59 lines (48 loc) · 1.63 KB
Breadcrumbs
NewPythonPrograms
/
compareDoc.py
Copy path
File metadata and controls
59 lines (48 loc) · 1.63 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#! python
# New program to compare two different files and output a number of columns on the
# data infromation of samples that are the same
# Uses the certain convertToList.py programs to edit the existing text file to make
# it more amenable for downstream use
# Read in necessary programs and functions
import
sys
from
convertToList
import
readData
,
identifySamples
# Read in a Command arguments for the program
# Input other instructions from here
def
commandLine
():
commands
=
sys
.
argv
textToConvert
=
commands
[
1
]
pattern
=
commands
[
2
]
mappingFile
=
commands
[
3
]
return
textToConvert
,
pattern
,
mappingFile
# Read in test data as a dictionary to modify file as needed
def
readTestFile
(
mappingFile
,
pattern
):
data
=
open
(
mappingFile
,
'r'
)
testDict
=
{}
x
=
0
for
line
in
data
:
if
x
!=
0
:
sampleID
,
barcode
,
linker
,
group
=
line
.
split
(
"
\t
"
)
if
pattern
in
group
:
testDict
[
group
.
strip
(
'
\n
'
)]
=
sampleID
x
=
x
+
1
return
testDict
# Make the comparison between the data and test data
def
compareData
(
dataList
,
testDict
):
noMatchList
=
[]
YESMatchDict
=
{}
for
i
,
group
in
enumerate
(
dataList
):
try
:
sample
=
testDict
[
group
]
YESMatchDict
[
group
]
=
sample
except
KeyError
:
noMatchList
.
append
(
group
)
return
YESMatchDict
,
noMatchList
def
main
():
# Need to change this so that existing commandLine is what is read.
textToConvert
,
pattern
,
mappingFile
=
commandLine
()
dataList
=
readData
(
textToConvert
)
goodData
=
identifySamples
(
dataList
,
pattern
)
testDict
=
readTestFile
(
mappingFile
,
pattern
)
YESMatchDict
,
noMatchList
=
compareData
(
dataList
,
testDict
)
print
(
YESMatchDict
)
if
__name__
==
'__main__'
:
main
()
Back
|
FazBrowse Home
|
New Git URL