-
Notifications
You must be signed in to change notification settings - Fork 8
Corley_Sampathkumar_Mitchell Submission #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mcorley1
wants to merge
9
commits into
lyy005:master
Choose a base branch
from
mcorley1:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
981e447
halfway complete code for part1 and the output file
mcorley1 772d6eb
finished second objective of part 1
mcorley1 751f544
code and outfile for 2nd half of part 1
bsampath17 fcffc43
Merge branch 'master' of https://github.com/mcorley1/Intro_Biocom_ND_…
bsampath17 9442907
updated part 1 script
mcorley1 ee9fdd5
Merge branch 'master' of https://github.com/mcorley1/Intro_Biocom_ND_…
mcorley1 ce84ac0
added comments and cleaned up the prev code - balaji
bsampath17 a29d0ef
Merge branch 'master' of https://github.com/mcorley1/Intro_Biocom_ND_…
bsampath17 1dc4947
Beginning of Exercise 8, Challenge 2
twhmitchell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # Import packages: | ||
|
|
||
| import numpy | ||
| import os | ||
| import pandas | ||
| import re | ||
| from plotnine import * | ||
|
|
||
| # Navigation to directory: | ||
|
|
||
| os.listdir('.') | ||
| os.chdir('/Users/winghomitchell/Intro_Biocom_ND_319_Tutorial8') | ||
|
|
||
| # Open files to read and write: | ||
|
|
||
| IDtxt = open("indivIDs.txt","r") | ||
| seqFastq = open("seqFastq.fq","r") | ||
|
|
||
| IDseqFasta = open("seqFastq.fq","w") | ||
|
|
||
| # Initialize empty dictionary and lists: | ||
|
|
||
| dictionary = {} | ||
|
|
||
| for line in seqFastq: | ||
| line = line.strip() | ||
| cols = line.split() | ||
|
|
||
| if cols[0] in dictionary: | ||
| print("Duplicate: " + cols[1]) | ||
| break | ||
| else: | ||
| dictionary[cols[0]] = cols[1] | ||
|
|
||
| # Make dictionary of IDs: | ||
|
|
||
| # Close ID file: | ||
| IDtxt.close() | ||
|
|
||
| # Assign RegEx to variable name, or compile to variable name: | ||
|
|
||
| # RegEx = (AATTC) | ||
|
|
||
| # While loop to process fastq lines: | ||
|
|
||
| while line != "": | ||
| if: line = | ||
| if: | ||
| if: | ||
|
|
||
| else: | ||
| else: | ||
| print("Error") | ||
| break | ||
|
|
||
| # Graph histograms of good and bad start positions: | ||
|
|
||
|
|
||
| # Close other file: | ||
| seqFastq.close() | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import numpy | ||
| import os | ||
| import re | ||
| from plotnine import * | ||
| os.listdir('.') | ||
| os.chdir('/Users/sampathkumarbalaji/EX_8/Intro_Biocom_ND_319_Tutorial8') | ||
| import pandas | ||
|
|
||
| pattern = '[0-9],[0-9]' | ||
| regex = re.compile(pattern) | ||
| #file1 = open("Cflorida.vcf", 'r') | ||
| dictionary = {} | ||
| #for lines in file1: | ||
| #data_txt = pandas.read_csv("Cflorida.vcf") | ||
| with open("Cflorida.vcf", "r") as infile, open("CfloridaCounts_2ndhalf.txt", "w") as outfile: | ||
| for line in infile: | ||
| # outfile.write(line) | ||
| line = line.strip() | ||
| cols = line.split() | ||
| for index in range(4,len(cols)): | ||
| #match = re.search(pattern, cols[index]).group() | ||
| match = re.findall(pattern, cols[index]) | ||
| #match = re.search(pattern, cols[index],flags=0) | ||
| # print (match.group(0)) | ||
| if (match): | ||
| cols[index] = match[0] | ||
| else: | ||
| cols[index] = 'NA' | ||
| line_new = '\t'.join(cols) | ||
| outfile.write(line_new + '\n') | ||
| print (match) | ||
| outfile.close() | ||
| infile.close() | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import numpy | ||
| import os | ||
| import re | ||
| from plotnine import * | ||
| os.listdir('.') | ||
| os.chdir('/Users/sampathkumarbalaji/EX_8/Intro_Biocom_ND_319_Tutorial8') | ||
| import pandas | ||
|
|
||
| pattern = '[0-9],[0-9]' | ||
| # setting up the regex format and compiling it | ||
| regex = re.compile(pattern) | ||
| # parsing input file Cflorida.vcf and writing onto the outfile CfloridaCounts_2ndhalf using for loop | ||
| with open("Cflorida.vcf", "r") as infile, open("CfloridaCounts_2ndhalf.txt", "w") as outfile: | ||
| for line in infile: | ||
| # splitting up lines and columns to process further | ||
| line = line.strip() | ||
| cols = line.split() | ||
| for index in range(4,len(cols)): | ||
| # find all the matching pattern based off pattern str variable | ||
| match = re.findall(pattern, cols[index]) | ||
| # if match is found then replace with the 1st match | ||
| if (match): | ||
| cols[index] = match[0] | ||
| # else '.' gets replaced with NA | ||
| else: | ||
| cols[index] = 'NA' | ||
| line_new = '\t'.join(cols) | ||
| # new lines are written onto the output file | ||
| outfile.write(line_new + '\n') | ||
| outfile.close() | ||
| infile.close() | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #Exercise 8, Question 1 | ||
| #10/13/17 | ||
| import re | ||
|
|
||
| #Open files to read and write | ||
| vcffile = open("Cflorida.vcf","r") | ||
| outfile = open("CfloridaCounts.txt","w") | ||
|
|
||
| #regex variables | ||
| TXsamples = "([Cc][Ff](\d{2})?\.[Aa]\d?)" | ||
| FLsamples = "([Cc][Ff]\.[Gg](2|AI|ai))" | ||
| allelect = r"\d/\d:(\d,\d):\d:\d+:\d+,\d+,\d+" | ||
| missing = "\./\.:\.:\.:\.:\." | ||
|
|
||
| for Line in vcffile: | ||
| Line=Line.strip() | ||
| if '##' in Line: | ||
| #print('found first line') | ||
| outfile.write(Line + "\n") #write unchanged header line to file | ||
| elif '#' in Line: #how can you tell if this is the line with the column headings? | ||
| #print('found second line') | ||
| TXreplaced = re.sub(TXsamples,"Cf.Sfa",Line) | ||
| FLreplaced = re.sub(FLsamples,"Cf.Gai",TXreplaced) #standardize (replace) sample names with TX and FL regexes | ||
| outfile.write(FLreplaced + "\n") #write new version of line to file | ||
| else: #now you're in the data | ||
| selAllele = re.sub(allelect, r"\1", Line) #replace full SNP info with allele counts only | ||
| #print(selAllele) | ||
| missingData = re.sub(missing, "N/A", selAllele) #replace missing data with NA | ||
| #print(missingData) | ||
| outfile.write(missingData +"\n") #write new version of line to new file | ||
|
|
||
| vcffile.close() | ||
| outfile.close() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job